本文整理汇总了Python中horizons.messaging.SettlerUpdate.broadcast方法的典型用法代码示例。如果您正苦于以下问题:Python SettlerUpdate.broadcast方法的具体用法?Python SettlerUpdate.broadcast怎么用?Python SettlerUpdate.broadcast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类horizons.messaging.SettlerUpdate
的用法示例。
在下文中一共展示了SettlerUpdate.broadcast方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: level_down
# 需要导入模块: from horizons.messaging import SettlerUpdate [as 别名]
# 或者: from horizons.messaging.SettlerUpdate import broadcast [as 别名]
def level_down(self):
if self.level == 0: # can't level down any more
# replace this building with a ruin
command = Build(BUILDINGS.SETTLER_RUIN, self.position.origin.x, \
self.position.origin.y, island=self.island, settlement=self.settlement)
Scheduler().add_new_object(
Callback.ChainedCallbacks(self.remove, Callback(command, self.owner)), # remove, then build new
self, run_in=0)
self.log.debug("%s: Destroyed by lack of happiness", self)
if self.owner.is_local_player:
# check_duplicate: only trigger once for different settlers of a neighborhood
self.session.ingame_gui.message_widget.add(self.position.center().x, self.position.center().y, \
'SETTLERS_MOVED_OUT', check_duplicate=True)
else:
self.level -= 1
self._update_level_data()
# reset happiness value for new level
self.get_component(StorageComponent).inventory.alter(RES.HAPPINESS, self.__get_data("happiness_init_value") - self.happiness)
self.log.debug("%s: Level down to %s", self, self.level)
self._changed()
# Notify the world about the level down
SettlerUpdate.broadcast(self, self.level, -1)
示例2: level_down
# 需要导入模块: from horizons.messaging import SettlerUpdate [as 别名]
# 或者: from horizons.messaging.SettlerUpdate import broadcast [as 别名]
def level_down(self):
if self.level == TIER.LOWEST:
# Can't level down any more.
self.make_ruin()
self.log.debug("%s: Destroyed by lack of happiness", self)
if self.owner.is_local_player:
# check_duplicate: only trigger once for different settlers of a neighborhood
self.session.ingame_gui.message_widget.add(point=self.position.center,
string_id='SETTLERS_MOVED_OUT', check_duplicate=True)
else:
self.level -= 1
self._update_level_data()
# reset happiness value for new level
new_happiness = self.__get_data("happiness_init_value") - self.happiness
self.get_component(StorageComponent).inventory.alter(RES.HAPPINESS, new_happiness)
self.log.debug("%s: Level down to %s", self, self.level)
self._changed()
# update the level of our inhabitants so graphics can change
if self.has_component(CollectingComponent):
for collector in self.get_component(CollectingComponent).get_local_collectors():
collector.level_upgrade(self.level)
# Notify the world about the level down
SettlerUpdate.broadcast(self, self.level, -1)
示例3: load
# 需要导入模块: from horizons.messaging import SettlerUpdate [as 别名]
# 或者: from horizons.messaging.SettlerUpdate import broadcast [as 别名]
def load(self, db, worldid):
super(Settler, self).load(db, worldid)
self.inhabitants, last_tax_payed = \
db("SELECT inhabitants, last_tax_payed FROM settler WHERE rowid=?", worldid)[0]
remaining_ticks = \
db("SELECT ticks FROM remaining_ticks_of_month WHERE rowid=?", worldid)[0][0]
self.__init(loading=True, last_tax_payed=last_tax_payed)
self._load_upgrade_data(db)
SettlerUpdate.broadcast(self, self.level, self.level)
self.run(remaining_ticks)
示例4: _do_level_up
# 需要导入模块: from horizons.messaging import SettlerUpdate [as 别名]
# 或者: from horizons.messaging.SettlerUpdate import broadcast [as 别名]
def _do_level_up():
self.level += 1
self.log.debug("%s: Levelling up to %s", self, self.level)
self._update_level_data()
# Notify the world about the level up
SettlerUpdate.broadcast(self, self.level, 1)
# reset happiness value for new level
self.get_component(StorageComponent).inventory.alter(RES.HAPPINESS, self.__get_data("happiness_init_value") - self.happiness)
self._changed()
示例5: _do_level_up
# 需要导入模块: from horizons.messaging import SettlerUpdate [as 别名]
# 或者: from horizons.messaging.SettlerUpdate import broadcast [as 别名]
def _do_level_up():
# NOTE: production is unused, but gets passed by the production code
self.level += 1
self.log.debug("%s: Levelling up to %s", self, self.level)
self._update_level_data()
# Notify the world about the level up
SettlerUpdate.broadcast(self, self.level)
# reset happiness value for new level
self.get_component(StorageComponent).inventory.alter(RES.HAPPINESS_ID, self.__get_data("happiness_init_value") - self.happiness)
self._changed()
示例6: _do_level_up
# 需要导入模块: from horizons.messaging import SettlerUpdate [as 别名]
# 或者: from horizons.messaging.SettlerUpdate import broadcast [as 别名]
def _do_level_up():
self.level += 1
self.log.debug("%s: Levelling up to %s", self, self.level)
self._update_level_data()
# update the level of our inhabitants so graphics can change
if self.has_component(CollectingComponent):
for collector in self.get_component(CollectingComponent).get_local_collectors():
collector.level_upgrade(self.level)
# Notify the world about the level up
SettlerUpdate.broadcast(self, self.level, 1)
# reset happiness value for new level
new_happiness = self.__get_data("happiness_init_value") - self.happiness
self.get_component(StorageComponent).inventory.alter(RES.HAPPINESS, new_happiness)
self._changed()
示例7: level_down
# 需要导入模块: from horizons.messaging import SettlerUpdate [as 别名]
# 或者: from horizons.messaging.SettlerUpdate import broadcast [as 别名]
def level_down(self):
if self.level == 0: # can't level down any more
self.make_ruin()
self.log.debug("%s: Destroyed by lack of happiness", self)
if self.owner.is_local_player:
# check_duplicate: only trigger once for different settlers of a neighborhood
self.session.ingame_gui.message_widget.add(
point=self.position.center(), string_id="SETTLERS_MOVED_OUT", check_duplicate=True
)
else:
self.level -= 1
self._update_level_data()
# reset happiness value for new level
self.get_component(StorageComponent).inventory.alter(
RES.HAPPINESS, self.__get_data("happiness_init_value") - self.happiness
)
self.log.debug("%s: Level down to %s", self, self.level)
self._changed()
# Notify the world about the level down
SettlerUpdate.broadcast(self, self.level, -1)
示例8: change_tier
# 需要导入模块: from horizons.messaging import SettlerUpdate [as 别名]
# 或者: from horizons.messaging.SettlerUpdate import broadcast [as 别名]
def change_tier(session, tier):
""" Changes the tier of the settlements. """
for settlement in session.world.settlements:
if settlement.owner == session.world.player:
# Settler levels are zero-based!
SettlerUpdate.broadcast(settlement.warehouse, tier - 1, tier - 1)
示例9: change_increment
# 需要导入模块: from horizons.messaging import SettlerUpdate [as 别名]
# 或者: from horizons.messaging.SettlerUpdate import broadcast [as 别名]
def change_increment(session, increment):
""" Changes the increment of the settlements. """
for settlement in session.world.settlements:
if settlement.owner == session.world.player:
# Settler levels are zero-based!
SettlerUpdate.broadcast(settlement.warehouse, increment - 1, increment - 1)