def setUp(self): super(QuestsTestBase, self).setUp() self.p1, self.p2, self.p3 = create_test_map() # add more persons, to lower conflicts places_logic.add_person_to_place(self.p1) places_logic.add_person_to_place(self.p1) places_logic.add_person_to_place(self.p2) places_logic.add_person_to_place(self.p2) places_logic.add_person_to_place(self.p3) places_logic.add_person_to_place(self.p3) account = self.accounts_factory.create_account(is_fast=True) self.storage = LogicStorage() self.storage.load_account_data(account) self.hero = self.storage.accounts_to_heroes[account.id] self.action_idl = self.hero.actions.current_action self.hero.money += 1 self.hero.preferences.set(heroes_relations.PREFERENCE_TYPE.MOB, mobs_storage.mobs.all()[0]) self.hero.preferences.set(heroes_relations.PREFERENCE_TYPE.PLACE, self.p1) self.hero.preferences.set(heroes_relations.PREFERENCE_TYPE.FRIEND, self.p1.persons[0]) self.hero.preferences.set(heroes_relations.PREFERENCE_TYPE.ENEMY, self.p2.persons[0]) self.hero.preferences.set(heroes_relations.PREFERENCE_TYPE.EQUIPMENT_SLOT, heroes_relations.EQUIPMENT_SLOT.PLATE) self.hero.position.set_place(self.p3) heroes_logic.save_hero(self.hero) self.p2.set_modifier(places_modifiers.CITY_MODIFIERS.HOLY_CITY) places_logic.save_place(self.p2) self.p1.persons[0].type = PERSON_TYPE.BLACKSMITH persons_logic.save_person(self.p1.persons[0])
def use(self, task, storage, highlevel=None, **kwargs): # pylint: disable=R0911,W0613 card = objects.Card.deserialize(uuid.UUID(task.data['card']['id']), task.data['card']['data']) delta = card.data['direction'] * self.modificator person_id = task.data.get('value') if person_id not in persons_storage.persons: return task.logic_result( next_step=postponed_tasks.UseCardTask.STEP.ERROR, message='Мастер не найден.') person = persons_storage.persons[person_id] if task.step.is_LOGIC: return task.logic_result( next_step=postponed_tasks.UseCardTask.STEP.HIGHLEVEL) elif task.step.is_HIGHLEVEL: person.politic_power.change_power(person=person, hero_id=task.hero_id, has_in_preferences=True, power=delta) persons_logic.save_person(person) persons_storage.persons.update_version() return task.logic_result(message='Влияние Мастера изменено')
def setUp(self): super(QuestsTestBase, self).setUp() self.p1, self.p2, self.p3 = create_test_map() # add more persons, to lower conflicts places_logic.add_person_to_place(self.p1) places_logic.add_person_to_place(self.p1) places_logic.add_person_to_place(self.p2) places_logic.add_person_to_place(self.p2) places_logic.add_person_to_place(self.p3) places_logic.add_person_to_place(self.p3) persons_logic.sync_social_connections() result, account_id, bundle_id = register_user('test_user') self.storage = LogicStorage() self.storage.load_account_data(AccountPrototype.get_by_id(account_id)) self.hero = self.storage.accounts_to_heroes[account_id] self.action_idl = self.hero.actions.current_action self.hero.money += 1 self.hero.preferences.set_mob(mobs_storage.all()[0]) self.hero.preferences.set_place(self.p1) self.hero.preferences.set_friend(self.p1.persons[0]) self.hero.preferences.set_enemy(self.p2.persons[0]) self.hero.preferences.set_equipment_slot(EQUIPMENT_SLOT.PLATE) self.hero.position.set_place(self.p3) heroes_logic.save_hero(self.hero) self.p2.set_modifier(places_modifiers.CITY_MODIFIERS.HOLY_CITY) places_logic.save_place(self.p2) self.p1.persons[0].type = PERSON_TYPE.BLACKSMITH persons_logic.save_person(self.p1.persons[0])
def setUp(self): super(QuestsTestBase, self).setUp() self.p1, self.p2, self.p3 = create_test_map() # add more persons, to lower conflicts places_logic.add_person_to_place(self.p1) places_logic.add_person_to_place(self.p1) places_logic.add_person_to_place(self.p2) places_logic.add_person_to_place(self.p2) places_logic.add_person_to_place(self.p3) places_logic.add_person_to_place(self.p3) account = self.accounts_factory.create_account(is_fast=True) self.storage = LogicStorage() self.storage.load_account_data(account) self.hero = self.storage.accounts_to_heroes[account.id] self.action_idl = self.hero.actions.current_action self.hero.money += 1 self.hero.preferences.set_mob(mobs_storage.all()[0]) self.hero.preferences.set_place(self.p1) self.hero.preferences.set_friend(self.p1.persons[0]) self.hero.preferences.set_enemy(self.p2.persons[0]) self.hero.preferences.set_equipment_slot(EQUIPMENT_SLOT.PLATE) self.hero.position.set_place(self.p3) heroes_logic.save_hero(self.hero) self.p2.set_modifier(places_modifiers.CITY_MODIFIERS.HOLY_CITY) places_logic.save_place(self.p2) self.p1.persons[0].type = PERSON_TYPE.BLACKSMITH persons_logic.save_person(self.p1.persons[0])
def use(self, task, storage, highlevel=None, **kwargs): # pylint: disable=R0911,W0613 person_id = task.data.get("person_id") if person_id not in persons_storage.persons: return task.logic_result(next_step=UseCardTask.STEP.ERROR, message=u"Мастер не найден.") person = persons_storage.persons[person_id] if task.step.is_LOGIC: return task.logic_result(next_step=UseCardTask.STEP.HIGHLEVEL) elif task.step.is_HIGHLEVEL: person.politic_power.change_power( person=person, hero_id=task.hero_id, has_in_preferences=True, power=self.BONUS ) persons_logic.save_person(person) persons_storage.persons.update_version() return task.logic_result()
def use(self, task, storage, highlevel=None, **kwargs): # pylint: disable=R0911,W0613 person_id = task.data.get('person_id') if person_id not in persons_storage.persons: return task.logic_result(next_step=UseCardTask.STEP.ERROR, message='Мастер не найден.') person = persons_storage.persons[person_id] if task.step.is_LOGIC: return task.logic_result(next_step=UseCardTask.STEP.HIGHLEVEL) elif task.step.is_HIGHLEVEL: person.politic_power.change_power(person=person, hero_id=task.hero_id, has_in_preferences=True, power=self.BONUS) persons_logic.save_person(person) persons_storage.persons.update_version() return task.logic_result()