def create_item(self, item_specification): """ Create new item based on specification :param item_specification: specification of item :type item_specification: ItemConfiguration :return: new item :rtype: Item """ item = Item(EffectsCollection()) item.name = item_specification.name item.icon = random.choice(item_specification.icons) item.cost = item_specification.cost item.weight = item_specification.weight item.rarity = item_specification.rarity item.tags = item_specification.types if not item_specification.weapon_configration is None: weapon_spec = item_specification.weapon_configration item.weapon_data = WeaponData( damage = weapon_spec.damage, critical_range = weapon_spec.critical_range, critical_damage = weapon_spec.critical_damage, damage_type = weapon_spec.damage_types, weapon_type = weapon_spec.weapon_class) for spec in item_specification.effect_handles: new_handle = EffectHandle(trigger = spec.trigger, effect = spec.effect, parameters = spec.parameters, charges = spec.charges) item.add_effect_handle(new_handle) return item
def build(self): """ Build item Returns: Item """ item = Item(effects_collection = EffectsCollection()) item.name = self.name item.appearance = self.appearance item.location = self.location item.icon = self.icon if self.weapon_data != None: item.weapon_data = self.weapon_data for handle in self.effect_handles: item.add_effect_handle(handle) item.tags = self.tags return item
def create_item(self, item_specification): """ Create new item based on specification :param item_specification: specification of item :type item_specification: ItemConfiguration :return: new item :rtype: Item """ item = Item(EffectsCollection()) item.name = item_specification.name item.description = item_specification.description item.icon = random.choice(item_specification.icons) item.cost = item_specification.cost item.weight = item_specification.weight item.rarity = item_specification.rarity item.tags = item_specification.types if not item_specification.weapon_configration is None: weapon_spec = item_specification.weapon_configration damage = [] damage.extend(weapon_spec.damage) item.weapon_data = WeaponData( damage=(damage), critical_range=weapon_spec.critical_range, critical_damage=weapon_spec.critical_damage, weapon_type=weapon_spec.weapon_class, ammunition_type=weapon_spec.ammunition_type, speed=weapon_spec.speed) if item_specification.armour_configuration is not None: armour_spec = item_specification.armour_configuration item.armour_data = ArmourData( damage_reduction=armour_spec.damage_reduction, speed_modifier=armour_spec.speed_modifier) if item_specification.ammunition_configuration is not None: ammo_spec = item_specification.ammunition_configuration item.ammunition_data = AmmunitionData( damage=ammo_spec.damage, critical_range=ammo_spec.critical_range, critical_damage=ammo_spec.critical_damage, ammunition_type=ammo_spec.ammunition_type, count=ammo_spec.count) if item_specification.trap_configuration is not None: trap_spec = item_specification.trap_configuration item.trap_data = TrapData( trap_name = trap_spec.name, count = trap_spec.count) if item_specification.boots_configuration is not None: boots_spec = item_specification.boots_configuration item.boots_data = BootsData( damage_reduction = boots_spec.damage_reduction, speed_modifier = boots_spec.speed_modifier) for spec in item_specification.effect_handles: new_handle = EffectHandle(trigger=spec.trigger, effect=spec.effect, parameters=spec.parameters, charges=spec.charges) item.add_effect_handle(new_handle) for effect in item_specification.effects: item.add_effect(effect) # TODO: do not use same instance return item
def build(self): """ Build item Returns: Item """ item = Item(effects_collection=EffectsCollection()) item.name = self.name item.appearance = self.appearance item.location = self.location item.icon = self.icon item.tags = self.tags if self.weapon_data is not None: item.weapon_data = self.weapon_data item.tags.append('weapon') if self.armour_data is not None: item.armour_data = self.armour_data item.tags.append('armour') if self.ammunition_data is not None: item.ammunition_data = self.ammunition_data item.tags.append('ammunition') if self.trap_data is not None: item.trap_data = self.trap_data item.tags.append('trap bag') if self.boots_data is not None: item.boots_data = self.boots_data item.tags.append('boots') for handle in self.effect_handles: item.add_effect_handle(handle) for effect in self.effects: item.add_effect(effect) return item