Exemplo n.º 1
0
	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)
Exemplo n.º 2
0
	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)
Exemplo n.º 3
0
	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)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
	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)
Exemplo n.º 6
0
		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()
Exemplo n.º 7
0
		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()
Exemplo n.º 8
0
		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
			new_happiness = self.__get_data("happiness_init_value") - self.happiness
			self.get_component(StorageComponent).inventory.alter(RES.HAPPINESS, new_happiness)
			self._changed()
Exemplo n.º 9
0
		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()
Exemplo n.º 10
0
		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()
Exemplo n.º 11
0
    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)
Exemplo n.º 12
0
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)
Exemplo n.º 13
0
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)
Exemplo n.º 14
0
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)