def dress_new_hero(hero): hero.equipment.equip( EQUIPMENT_SLOT.PANTS, artifacts_storage.get_by_uuid( DEFAULT_HERO_EQUIPMENT.PANTS).create_artifact(level=1, power=Power(1, 1))) hero.equipment.equip( EQUIPMENT_SLOT.BOOTS, artifacts_storage.get_by_uuid( DEFAULT_HERO_EQUIPMENT.BOOTS).create_artifact(level=1, power=Power(1, 1))) hero.equipment.equip( EQUIPMENT_SLOT.PLATE, artifacts_storage.get_by_uuid( DEFAULT_HERO_EQUIPMENT.PLATE).create_artifact(level=1, power=Power(1, 1))) hero.equipment.equip( EQUIPMENT_SLOT.GLOVES, artifacts_storage.get_by_uuid( DEFAULT_HERO_EQUIPMENT.GLOVES).create_artifact(level=1, power=Power(1, 1))) hero.equipment.equip( EQUIPMENT_SLOT.HAND_PRIMARY, artifacts_storage.get_by_uuid( DEFAULT_HERO_EQUIPMENT.WEAPON).create_artifact(level=1, power=Power(1, 1)))
def test_change_uuid(self): loot = ArtifactRecordPrototype.create_random('some_loot', type_=relations.ARTIFACT_TYPE.USELESS, state=relations.ARTIFACT_RECORD_STATE.DISABLED) form = ModerateArtifactRecordForm(self.get_form_data(loot)) self.assertTrue(form.is_valid()) self.assertEqual(loot.uuid, artifacts_storage.get_by_uuid(loot.uuid).uuid) loot.update_by_moderator(form) self.assertEqual(loot.uuid, artifacts_storage.get_by_uuid(loot.uuid).uuid)
def test_disable_default_equipment(self): artifact_uid = random.choice(heroes_relations.EQUIPMENT_SLOT.default_uids()) data = self.get_form_data(artifacts_storage.get_by_uuid(artifact_uid)) data['approved'] = False form = ModerateArtifactRecordForm(data) self.assertTrue(form.is_valid()) default_artifact = artifacts_storage.get_by_uuid(artifact_uid) self.assertRaises(exceptions.DisableDefaultEquipmentError, default_artifact.update_by_moderator, form)
def test_disable_default_equipment(self): artifact_uid = random.choice(DEFAULT_HERO_EQUIPMENT._ALL) data = self.get_form_data(artifacts_storage.get_by_uuid(artifact_uid)) data['approved'] = False form = ModerateArtifactRecordForm(data) self.assertTrue(form.is_valid()) default_artifact = artifacts_storage.get_by_uuid(artifact_uid) self.assertRaises(exceptions.DisableDefaultEquipmentError, default_artifact.update_by_moderator, form)
def test_change_uuid(self): loot = ArtifactRecordPrototype.create_random( 'some_loot', type_=relations.ARTIFACT_TYPE.USELESS, state=relations.ARTIFACT_RECORD_STATE.DISABLED) form = ModerateArtifactRecordForm(self.get_form_data(loot)) self.assertTrue(form.is_valid()) self.assertEqual(loot.uuid, artifacts_storage.get_by_uuid(loot.uuid).uuid) loot.update_by_moderator(form) self.assertEqual(loot.uuid, artifacts_storage.get_by_uuid(loot.uuid).uuid)
def dress_new_hero(hero): for equipment_slot in relations.EQUIPMENT_SLOT.records: if equipment_slot.default: hero.equipment.equip( equipment_slot, artifacts_storage.get_by_uuid( equipment_slot.default).create_artifact(level=1, power=power.Power( 1, 1)))
def test_artifacts_attributes(self): ArtifactRecordPrototype.create(uuid='bandit_loot', level=1, utg_name=names.generator().get_test_name('artifact'), description='bandit loot description', type_=relations.ARTIFACT_TYPE.HELMET, power_type=relations.ARTIFACT_POWER_TYPE.NEUTRAL) loot = ArtifactPrototype(record_id=artifacts_storage.get_by_uuid('bandit_loot').id, level=1) self.assertFalse(loot.is_useless)
def test_artifacts_attributes(self): ArtifactRecordPrototype.create( uuid='bandit_loot', level=1, utg_name=names.generator.get_test_name('artifact'), description='bandit loot description', type_=relations.ARTIFACT_TYPE.HELMET, power_type=relations.ARTIFACT_POWER_TYPE.NEUTRAL) loot = ArtifactPrototype( record_id=artifacts_storage.get_by_uuid('bandit_loot').id, level=1) self.assertFalse(loot.is_useless)
def deserialize(cls, data): # if artifact record is desabled or deleted, get another random record from the_tale.game.artifacts.storage import artifacts_storage record = artifacts_storage.get_by_uuid(data['id']) if record is None or record.state.is_DISABLED: record = random.choice(artifacts_storage.artifacts) integrity = data.get('integrity', [c.ARTIFACT_MAX_INTEGRITY, c.ARTIFACT_MAX_INTEGRITY]) return cls(record_id=record.id, power=Power.deserialize(data['power']), bag_uuid=data['bag_uuid'], integrity=integrity[0], max_integrity=integrity[1], rarity=relations.RARITY.index_value[data.get('rarity', relations.RARITY.NORMAL.value)], level=data.get('level', 1))
def deserialize(cls, data): # if artifact record is desabled or deleted, get another random record from the_tale.game.artifacts.storage import artifacts_storage record = artifacts_storage.get_by_uuid(data['id']) if record is None or record.state.is_DISABLED: record = random.choice(artifacts_storage.artifacts) integrity = data.get( 'integrity', [c.ARTIFACT_MAX_INTEGRITY, c.ARTIFACT_MAX_INTEGRITY]) return cls(record_id=record.id, power=Power.deserialize(data['power']), bag_uuid=data['bag_uuid'], integrity=integrity[0], max_integrity=integrity[1], rarity=relations.RARITY.index_value[data.get( 'rarity', relations.RARITY.NORMAL.value)], level=data.get('level', 1))
def dress_new_hero(hero): hero.equipment.equip(EQUIPMENT_SLOT.PANTS, artifacts_storage.get_by_uuid(DEFAULT_HERO_EQUIPMENT.PANTS).create_artifact(level=1, power=Power(1, 1))) hero.equipment.equip(EQUIPMENT_SLOT.BOOTS, artifacts_storage.get_by_uuid(DEFAULT_HERO_EQUIPMENT.BOOTS).create_artifact(level=1, power=Power(1, 1))) hero.equipment.equip(EQUIPMENT_SLOT.PLATE, artifacts_storage.get_by_uuid(DEFAULT_HERO_EQUIPMENT.PLATE).create_artifact(level=1, power=Power(1, 1))) hero.equipment.equip(EQUIPMENT_SLOT.GLOVES, artifacts_storage.get_by_uuid(DEFAULT_HERO_EQUIPMENT.GLOVES).create_artifact(level=1, power=Power(1, 1))) hero.equipment.equip(EQUIPMENT_SLOT.HAND_PRIMARY, artifacts_storage.get_by_uuid(DEFAULT_HERO_EQUIPMENT.WEAPON).create_artifact(level=1, power=Power(1, 1)))
def dress_new_hero(hero): for equipment_slot in relations.EQUIPMENT_SLOT.records: if equipment_slot.default: hero.equipment.equip(equipment_slot, artifacts_storage.get_by_uuid(equipment_slot.default).create_artifact(level=1, power=power.Power(1, 1)))