Пример #1
0
	def eat(self, food_item = None):
		item_props = food_item.item_props
		mutations = self.get_mutations()
		statuses = self.getStatusEffects()

		# Find out if the item is perishable
		if item_props.get('perishable') != None:
			perishable_status = item_props.get('perishable')
			if perishable_status == 'true' or perishable_status == '1':
				item_is_non_perishable = False
			else:
				item_is_non_perishable = True
		else:
			item_is_non_perishable = False
			
		user_has_spoiled_appetite = ewcfg.mutation_id_spoiledappetite in mutations
		item_has_expired = float(getattr(food_item, "time_expir", 0)) < time.time()
		if item_has_expired and not (user_has_spoiled_appetite or item_is_non_perishable):
			response = "You realize that the food you were trying to eat is already spoiled. In disgust, you throw it away."
			ewitem.item_drop(food_item.id_item)
		else:
			hunger_restored = int(item_props['recover_hunger'])
			if self.id_user in ewutils.food_multiplier and ewutils.food_multiplier.get(self.id_user) > 0:
				if ewcfg.mutation_id_bingeeater in mutations:
					hunger_restored *= ewutils.food_multiplier.get(self.id_user)
				ewutils.food_multiplier[self.id_user] += 1
			else:
				ewutils.food_multiplier[self.id_user] = 1

			if ewcfg.status_high_id in statuses:
				hunger_restored *= 0.5			
	
			hunger_restored = round(hunger_restored)

			self.hunger -= hunger_restored
			if self.hunger < 0:
				self.hunger = 0
			self.inebriation += int(item_props['inebriation'])
			if self.inebriation > 20:
				self.inebriation = 20
						
			try:
				if item_props['id_food'] in ["coleslaw","bloodcabbagecoleslaw"]:
					self.clear_status(id_status = ewcfg.status_ghostbust_id)
					self.applyStatus(id_status = ewcfg.status_ghostbust_id)
					#Bust player if they're a ghost
					if self.life_state == ewcfg.life_state_corpse:
						self.die(cause = ewcfg.cause_busted)
				if item_props['id_food'] == ewcfg.item_id_seaweedjoint:
					self.applyStatus(id_status = ewcfg.status_high_id)

			except:
				# An exception will occur if there's no id_food prop in the database. We don't care.
				pass

			response = item_props['str_eat'] + ("\n\nYou're stuffed!" if self.hunger <= 0 else "")

			ewitem.item_delete(food_item.id_item)

		return response
Пример #2
0
    def eat(self, food_item=None):
        item_props = food_item.item_props
        mutations = self.get_mutations()
        statuses = self.getStatusEffects()

        if ewcfg.mutation_id_spoiledappetite not in mutations and float(
                food_item.time_expir if food_item.time_expir is not None else 0
        ) < time.time():
            response = "You realize that the food you were trying to eat is already spoiled. In disgust, you throw it away."
            ewitem.item_drop(food_item.id_item)
        else:
            hunger_restored = int(item_props['recover_hunger'])
            if self.id_user in ewutils.food_multiplier and ewutils.food_multiplier.get(
                    self.id_user) > 0:
                if ewcfg.mutation_id_bingeeater in mutations:
                    hunger_restored *= ewutils.food_multiplier.get(
                        self.id_user)
                ewutils.food_multiplier[self.id_user] += 1
            else:
                ewutils.food_multiplier[self.id_user] = 1

            if ewcfg.status_high_id in statuses:
                hunger_restored *= 0.5

            hunger_restored = round(hunger_restored)

            #SLIMERNALIA
            old_hunger = self.hunger

            self.hunger -= hunger_restored
            if self.hunger < 0:
                self.hunger = 0
            self.inebriation += int(item_props['inebriation'])
            if self.inebriation > 20:
                self.inebriation = 20

            self.festivity += old_hunger - self.hunger

            try:
                if item_props['id_food'] in [
                        "coleslaw", "bloodcabbagecoleslaw"
                ]:
                    self.applyStatus(id_status=ewcfg.status_ghostbust_id)
                    #Bust player if they're a ghost
                    if self.life_state == ewcfg.life_state_corpse:
                        self.die(cause=ewcfg.cause_busted)
                if item_props['id_food'] == ewcfg.item_id_seaweedjoint:
                    self.applyStatus(id_status=ewcfg.status_high_id)

            except:
                # An exception will occur if there's no id_food prop in the database. We don't care.
                pass

            response = item_props['str_eat'] + ("\n\nYou're stuffed!"
                                                if self.hunger <= 0 else "")

            ewitem.item_delete(food_item.id_item)

        return response