本文整理汇总了Python中the_tale.game.logic_storage.LogicStorage类的典型用法代码示例。如果您正苦于以下问题:Python LogicStorage类的具体用法?Python LogicStorage怎么用?Python LogicStorage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LogicStorage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_load_account_data_with_meta_action
def test_load_account_data_with_meta_action(self):
bundle_id = 666
meta_action_battle = meta_actions.ArenaPvP1x1.create(self.storage, self.hero_1, self.hero_2)
proxy_action_1 = actions_prototypes.ActionMetaProxyPrototype.create(hero=self.hero_1, _bundle_id=bundle_id, meta_action=meta_action_battle)
proxy_action_2 = actions_prototypes.ActionMetaProxyPrototype.create(hero=self.hero_2, _bundle_id=bundle_id, meta_action=meta_action_battle)
self.assertEqual(len(self.storage.meta_actions), 1)
self.assertEqual(len(self.storage.meta_actions_to_actions), 1)
self.assertEqual(self.storage.meta_actions_to_actions[meta_action_battle.uid], set([LogicStorage.get_action_uid(proxy_action_1),
LogicStorage.get_action_uid(proxy_action_2)]))
self.storage.save_changed_data()
self.assertIs(self.hero_1.actions.current_action.meta_action, self.hero_2.actions.current_action.meta_action)
self.assertIs(self.hero_1.actions.current_action.saved_meta_action, self.hero_2.actions.current_action.saved_meta_action)
storage = LogicStorage()
storage.load_account_data(AccountPrototype.get_by_id(self.account_1.id))
storage.load_account_data(AccountPrototype.get_by_id(self.account_2.id))
self.assertEqual(len(storage.meta_actions), 1)
self.assertEqual(len(storage.meta_actions_to_actions), 1)
self.assertEqual(storage.meta_actions_to_actions[meta_action_battle.uid], set([LogicStorage.get_action_uid(proxy_action_1),
LogicStorage.get_action_uid(proxy_action_2)]))
self.assertEqual(storage.bundles_to_accounts, {self.hero_1.actions.current_action.bundle_id: set([self.account_1.id, self.account_2.id])})
hero_1 = storage.accounts_to_heroes[self.account_1.id]
hero_2 = storage.accounts_to_heroes[self.account_2.id]
self.assertIs(hero_1.actions.current_action.meta_action, hero_2.actions.current_action.meta_action)
self.assertIsNot(hero_1.actions.current_action.saved_meta_action, hero_2.actions.current_action.saved_meta_action)
self.assertEqual(hero_1.actions.current_action.saved_meta_action.serialize(), hero_2.actions.current_action.saved_meta_action.serialize())
开发者ID:alexudracul,项目名称:the-tale,代码行数:35,代码来源:test_logic_storage.py
示例2: HelpPlaceMixin
class HelpPlaceMixin(CardsTestMixin):
CARD = None
def setUp(self):
super(HelpPlaceMixin, self).setUp()
self.place_1, self.place_2, self.place_3 = create_test_map()
result, account_1_id, bundle_id = register_user('test_user', '[email protected]', '111111')
self.account_1 = AccountPrototype.get_by_id(account_1_id)
self.storage = LogicStorage()
self.storage.load_account_data(self.account_1)
self.hero = self.storage.accounts_to_heroes[self.account_1.id]
self.card = self.CARD()
def test_use(self):
with self.check_delta(lambda: self.hero.places_history._get_places_statisitcs().get(self.place_1.id, 0), self.CARD.HELPS):
result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero, place_id=self.place_1.id))
self.assertEqual((result, step, postsave_actions), (ComplexChangeTask.RESULT.SUCCESSED, ComplexChangeTask.STEP.SUCCESS, ()))
def test_wrong_place(self):
with self.check_not_changed(lambda: self.hero.places_history._get_places_statisitcs().get(self.place_1.id, 0)):
result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero, place_id=666))
self.assertEqual((result, step, postsave_actions), (ComplexChangeTask.RESULT.FAILED, ComplexChangeTask.STEP.ERROR, ()))
开发者ID:Alkalit,项目名称:the-tale,代码行数:29,代码来源:test_help_place.py
示例3: test_initialize_bots__second_create
def test_initialize_bots__second_create(self):
account_1 = self.accounts_factory.create_account()
account_2 = self.accounts_factory.create_account(is_bot=True)
storage = LogicStorage()
storage.load_account_data(account_1)
storage.load_account_data(account_2)
hero_1 = storage.accounts_to_heroes[account_1.id]
hero_2 = storage.accounts_to_heroes[account_2.id]
hero_1.level = 50
self.assertEqual(hero_2.level, 1)
self.pvp_create_battle(account_1, account_2, BATTLE_1X1_STATE.PROCESSING)
self.pvp_create_battle(account_2, account_1, BATTLE_1X1_STATE.PROCESSING)
meta_action = meta_actions.ArenaPvP1x1.create(storage, hero_1, hero_2)
meta_action.process_battle_ending()
meta_actions.ArenaPvP1x1.create(storage, hero_1, hero_2)
self.assertEqual(hero_2.level, 50)
self.assertTrue(len(hero_2.abilities.all) > 1)
self.assertEqual(hero_2.health, hero_2.max_health)
开发者ID:Jazzis18,项目名称:the-tale,代码行数:25,代码来源:test_meta_action_arena_pvp_1x1.py
示例4: test_process_bot__flame_ability_not_used
def test_process_bot__flame_ability_not_used(self):
result, account_1_id, bundle_id = register_user("bot", "[email protected]", "111111", is_bot=True)
result, account_2_id, bundle_id = register_user("test_user_3")
account_1 = AccountPrototype.get_by_id(account_1_id)
account_2 = AccountPrototype.get_by_id(account_2_id)
storage = LogicStorage()
storage.load_account_data(account_1)
storage.load_account_data(account_2)
hero_1 = storage.accounts_to_heroes[account_1.id]
hero_2 = storage.accounts_to_heroes[account_2.id]
MetaActionArenaPvP1x1Prototype.create(storage, hero_1, hero_2, bundle_id=self.bundle_id + 1)
self.assertEqual(hero_2.pvp.energy_speed, 1)
with mock.patch(
"the_tale.game.actions.meta_actions.MetaActionArenaPvP1x1Prototype.get_bot_pvp_properties",
lambda a: {"priorities": {Flame.TYPE: 1}, "ability_chance": 1},
):
with mock.patch("the_tale.game.pvp.abilities.Flame.use") as use:
for i in xrange(100):
self.meta_action_battle.process_bot(hero_1, hero_2)
self.assertEqual(use.call_count, 0)
开发者ID:nbadp,项目名称:the-tale,代码行数:27,代码来源:test_meta_action_arena_pvp_1x1.py
示例5: AddGoldTestMixin
class AddGoldTestMixin(CardsTestMixin):
CARD = None
def setUp(self):
super(AddGoldTestMixin, self).setUp()
create_test_map()
result, account_1_id, bundle_id = register_user('test_user', '[email protected]', '111111')
self.account_1 = AccountPrototype.get_by_id(account_1_id)
self.storage = LogicStorage()
self.storage.load_account_data(self.account_1)
self.hero = self.storage.accounts_to_heroes[self.account_1.id]
self.card = self.CARD()
def test_use(self):
with self.check_delta(lambda: self.hero.money, self.CARD.GOLD):
with self.check_delta(lambda: self.hero.statistics.money_earned_from_help, self.CARD.GOLD):
with self.check_delta(lambda: self.hero.statistics.money_earned, self.CARD.GOLD):
result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero))
self.assertEqual((result, step, postsave_actions), (ComplexChangeTask.RESULT.SUCCESSED, ComplexChangeTask.STEP.SUCCESS, ()))
开发者ID:Alkalit,项目名称:the-tale,代码行数:26,代码来源:test_add_gold.py
示例6: ChooseRequestsTests
class ChooseRequestsTests(testcase.TestCase, QuestTestsMixin):
def setUp(self):
super(ChooseRequestsTests, self).setUp()
create_test_map()
register_user('test_user', '[email protected]', '111111')
account = AccountPrototype.get_by_email('[email protected]')
self.storage = LogicStorage()
self.storage.load_account_data(AccountPrototype.get_by_id(account.id))
self.hero =self.storage.accounts_to_heroes[account.id]
self.choice_uid = '[ns-0]choice_1'
self.option_uid = '#option<[ns-0]choice_1, [ns-0]choice_2>'
@mock.patch('questgen.quests.quests_base.QuestsBase._available_quests', lambda *argv, **kwargs: [QuestWith2ChoicePoints])
def test_choose_no_account(self):
self.turn_to_quest(self.storage, self.hero.id)
response = self.client.post(url('game:quests:api-choose', option_uid=self.option_uid, api_version='1.0', api_client=project_settings.API_CLIENT))
self.check_ajax_error(response, 'common.login_required')
@mock.patch('questgen.quests.quests_base.QuestsBase._available_quests', lambda *argv, **kwargs: [QuestWith2ChoicePoints])
def test_choose_processing(self):
self.turn_to_quest(self.storage, self.hero.id)
self.request_login('[email protected]')
response = self.client.post(url('game:quests:api-choose', option_uid=self.option_uid, api_version='1.0', api_client=project_settings.API_CLIENT))
task = PostponedTaskPrototype._db_get_object(0)
self.check_ajax_processing(response, task.status_url)
self.assertEqual(PostponedTask.objects.all().count(), 1)
开发者ID:Alkalit,项目名称:the-tale,代码行数:33,代码来源:test_requests.py
示例7: LevelUpTest
class LevelUpTest(testcase.TestCase, CardsTestMixin):
CARD = LevelUp
def setUp(self):
super(LevelUpTest, self).setUp()
create_test_map()
result, account_1_id, bundle_id = register_user('test_user', '[email protected]', '111111')
self.account_1 = AccountPrototype.get_by_id(account_1_id)
self.storage = LogicStorage()
self.storage.load_account_data(self.account_1)
self.hero = self.storage.accounts_to_heroes[self.account_1.id]
self.card = self.CARD()
def test_use(self):
self.hero.add_experience(self.hero.experience_to_next_level / 2)
self.assertTrue(self.hero.experience > 0)
self.assertEqual(self.hero.level, 1)
with self.check_not_changed(lambda: self.hero.experience):
with self.check_delta(lambda: self.hero.level, 1):
result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero))
self.assertEqual((result, step, postsave_actions), (ComplexChangeTask.RESULT.SUCCESSED, ComplexChangeTask.STEP.SUCCESS, ()))
开发者ID:Alkalit,项目名称:the-tale,代码行数:31,代码来源:test_level_up.py
示例8: test_initialize_bots__second_create
def test_initialize_bots__second_create(self):
result, account_1_id, bundle_id = register_user("test_user_3")
result, account_2_id, bundle_id = register_user("bot", "[email protected]", "111111", is_bot=True)
account_1 = AccountPrototype.get_by_id(account_1_id)
account_2 = AccountPrototype.get_by_id(account_2_id)
storage = LogicStorage()
storage.load_account_data(account_1)
storage.load_account_data(account_2)
hero_1 = storage.accounts_to_heroes[account_1.id]
hero_2 = storage.accounts_to_heroes[account_2.id]
hero_1._model.level = 50
self.assertEqual(hero_2.level, 1)
self.pvp_create_battle(account_1, account_2, BATTLE_1X1_STATE.PROCESSING)
self.pvp_create_battle(account_2, account_1, BATTLE_1X1_STATE.PROCESSING)
meta_action = MetaActionArenaPvP1x1Prototype.create(storage, hero_1, hero_2, bundle_id=self.bundle_id + 1)
meta_action.process_battle_ending()
MetaActionArenaPvP1x1Prototype.create(storage, hero_1, hero_2, bundle_id=self.bundle_id + 2)
self.assertEqual(hero_2.level, 50)
self.assertTrue(len(hero_2.abilities.all) > 1)
self.assertEqual(hero_2.health, hero_2.max_health)
开发者ID:nbadp,项目名称:the-tale,代码行数:28,代码来源:test_meta_action_arena_pvp_1x1.py
示例9: BuyRandomPremiumChestTask__EpicArtifact_Tests
class BuyRandomPremiumChestTask__EpicArtifact_Tests(base_buy_task._BaseBuyHeroMethodPosponedTaskTests):
def setUp(self):
super(BuyRandomPremiumChestTask__EpicArtifact_Tests, self).setUp()
self.task = BuyRandomPremiumChest(account_id=self.account.id,
transaction=self.transaction)
self.storage = LogicStorage()
self.storage.load_account_data(self.account)
self.cmd_update_with_account_data__call_count = 0
self.accounts_manages_worker = False
self.supervisor_worker = True
self.hero = self.storage.accounts_to_heroes[self.account.id]
self.assertEqual(self.hero.bag.occupation, 0)
def _get_expected_arguments(self):
return {}
def _check_not_used(self):
self.assertEqual(self.hero.bag.occupation, 0)
self.assertEqual(RandomPremiumRequestPrototype._db_count(), 0)
def _check_used(self):
self.assertEqual(self.hero.bag.occupation, 1)
self.assertTrue(self.hero.bag.values()[0].rarity.is_EPIC)
self.assertEqual(RandomPremiumRequestPrototype._db_count(), 1)
开发者ID:Alkalit,项目名称:the-tale,代码行数:30,代码来源:test_buy_random_premium_chest.py
示例10: BuyRandomPremiumChestTask__Energy_Tests
class BuyRandomPremiumChestTask__Energy_Tests(base_buy_task._BaseBuyHeroMethodPosponedTaskTests):
def setUp(self):
super(BuyRandomPremiumChestTask__Energy_Tests, self).setUp()
self.task = BuyRandomPremiumChest(account_id=self.account.id,
transaction=self.transaction)
self.storage = LogicStorage()
self.storage.load_account_data(self.account)
self.cmd_update_with_account_data__call_count = 0
self.accounts_manages_worker = False
self.supervisor_worker = True
self.hero = self.storage.accounts_to_heroes[self.account.id]
self.hero.energy_bonus = 0
def _get_expected_arguments(self):
return {}
def _check_not_used(self):
self.assertEqual(self.hero.energy_bonus, 0)
self.assertEqual(RandomPremiumRequestPrototype._db_count(), 0)
def _check_used(self):
self.assertEqual(self.hero.energy_bonus, relations.RANDOM_PREMIUM_CHEST_REWARD.ENERGY.arguments['energy'])
self.assertEqual(RandomPremiumRequestPrototype._db_count(), 1)
开发者ID:Alkalit,项目名称:the-tale,代码行数:29,代码来源:test_buy_random_premium_chest.py
示例11: ResetPreferenceAllTests
class ResetPreferenceAllTests(CardsTestMixin, testcase.TestCase):
CARD = effects.PreferencesCooldownsResetAll
def setUp(self):
super(ResetPreferenceAllTests, self).setUp()
create_test_map()
result, account_1_id, bundle_id = register_user("test_user", "[email protected]", "111111")
self.account_1 = AccountPrototype.get_by_id(account_1_id)
self.storage = LogicStorage()
self.storage.load_account_data(self.account_1)
self.hero = self.storage.accounts_to_heroes[self.account_1.id]
for preference in PREFERENCE_TYPE.records:
self.hero.preferences._set(preference, self.hero.preferences._get(preference))
self.card = self.CARD()
def test_use(self):
for preference in PREFERENCE_TYPE.records:
self.assertFalse(self.hero.preferences.can_update(preference, datetime.datetime.now()))
result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero))
self.assertEqual(
(result, step, postsave_actions), (ComplexChangeTask.RESULT.SUCCESSED, ComplexChangeTask.STEP.SUCCESS, ())
)
for preference in PREFERENCE_TYPE.records:
self.assertTrue(self.hero.preferences.can_update(preference, datetime.datetime.now()))
开发者ID:lshestov,项目名称:the-tale,代码行数:33,代码来源:test_reset_preferences.py
示例12: ArenaPvP1x1AcceptBaseTests
class ArenaPvP1x1AcceptBaseTests(UseAbilityTaskMixin, testcase.TestCase):
def setUp(self):
super(ArenaPvP1x1AcceptBaseTests, self).setUp()
self.p1, self.p2, self.p3 = create_test_map()
result, account_1_id, bundle_id = register_user('test_user', '[email protected]', '111111')
result, account_2_id, bundle_id = register_user('test_user_2', '[email protected]', '111111')
self.account_1 = AccountPrototype.get_by_id(account_1_id)
self.account_2 = AccountPrototype.get_by_id(account_2_id)
self.storage = LogicStorage()
self.storage.load_account_data(self.account_1)
self.storage.load_account_data(self.account_2)
self.hero_1 = self.storage.accounts_to_heroes[self.account_1.id]
self.hero_2 = self.storage.accounts_to_heroes[self.account_2.id]
environment.deinitialize()
environment.initialize()
self.pvp_balancer = environment.workers.pvp_balancer
self.pvp_balancer.process_initialize('pvp_balancer')
self.battle = self.pvp_balancer.add_to_arena_queue(self.hero_1.id)
开发者ID:Alkalit,项目名称:the-tale,代码行数:27,代码来源:test_ability_arena_pvp_1x1_accept.py
示例13: LongTeleportTests
class LongTeleportTests(CardsTestMixin, testcase.TestCase):
CARD = effects.LongTeleport
def setUp(self):
super(LongTeleportTests, self).setUp()
self.place_1, self.place_2, self.place_3 = create_test_map()
result, account_1_id, bundle_id = register_user("test_user", "[email protected]", "111111")
self.account_1 = AccountPrototype.get_by_id(account_1_id)
self.storage = LogicStorage()
self.storage.load_account_data(self.account_1)
self.hero = self.storage.accounts_to_heroes[self.account_1.id]
self.hero.position.set_place(self.place_1)
self.card = self.CARD()
@mock.patch("the_tale.game.heroes.objects.Hero.is_battle_start_needed", lambda self: False)
def test_moving(self):
self.assertFalse(self.hero.actions.current_action.TYPE.is_MOVE_TO)
result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero))
self.assertEqual(
(result, step, postsave_actions), (ComplexChangeTask.RESULT.FAILED, ComplexChangeTask.STEP.ERROR, ())
)
@mock.patch("the_tale.game.heroes.objects.Hero.is_battle_start_needed", lambda self: False)
def test_use(self):
actions_prototypes.ActionMoveToPrototype.create(hero=self.hero, destination=self.place_3)
self.storage.process_turn(continue_steps_if_needed=False)
self.assertTrue(self.hero.actions.current_action.state == actions_prototypes.ActionMoveToPrototype.STATE.MOVING)
self.assertTrue(self.hero.position.percents < 1)
result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero))
self.assertEqual(
(result, step, postsave_actions), (ComplexChangeTask.RESULT.SUCCESSED, ComplexChangeTask.STEP.SUCCESS, ())
)
self.assertTrue(self.hero.position.place.id, self.place_3.id)
@mock.patch("the_tale.game.heroes.objects.Hero.is_battle_start_needed", lambda self: False)
def test_use__wrong_state(self):
actions_prototypes.ActionMoveToPrototype.create(hero=self.hero, destination=self.place_3)
self.assertTrue(self.hero.actions.current_action.state != actions_prototypes.ActionMoveToPrototype.STATE.MOVING)
with self.check_not_changed(lambda: self.hero.actions.current_action.percents):
result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero))
self.assertEqual(
(result, step, postsave_actions), (ComplexChangeTask.RESULT.FAILED, ComplexChangeTask.STEP.ERROR, ())
)
self.assertTrue(self.hero.position.place.id, self.place_1.id)
开发者ID:Jazzis18,项目名称:the-tale,代码行数:57,代码来源:test_teleports.py
示例14: test_merge_bundles
def test_merge_bundles(self):
storage = LogicStorage()
storage.bundles_to_accounts[555] = set([1, 2])
storage.bundles_to_accounts[666] = set([3])
storage.merge_bundles([555, 666], 777)
self.assertEqual(storage.bundles_to_accounts, {777: set([1, 2, 3])})
开发者ID:alexudracul,项目名称:the-tale,代码行数:10,代码来源:test_logic_storage.py
示例15: InPlaceActionCompanionDrinkArtifactTests
class InPlaceActionCompanionDrinkArtifactTests(testcase.TestCase):
def setUp(self):
super(InPlaceActionCompanionDrinkArtifactTests, self).setUp()
self.place_1, self.place_2, self.place_3 = create_test_map()
self.account = self.accounts_factory.create_account()
self.storage = LogicStorage()
self.storage.load_account_data(self.account)
self.hero = self.storage.accounts_to_heroes[self.account.id]
self.action_idl = self.hero.actions.current_action
self.companion_record = companions_logic.create_random_companion_record('thief', state=companions_relations.STATE.ENABLED)
self.hero.set_companion(companions_logic.create_companion(self.companion_record))
self.hero.money = f.expected_gold_in_day(self.hero.level)
self.hero.position.set_place(self.place_1)
self.hero.position.update_previous_place()
self.hero.position.set_place(self.place_2)
self.artifact = artifacts_storage.generate_artifact_from_list(artifacts_storage.loot, 1, rarity=RARITY.NORMAL)
self.hero.put_loot(self.artifact)
self.assertEqual(self.hero.bag.occupation, 1)
self.hero.position.move_out_place()
@mock.patch('the_tale.game.heroes.objects.Hero.can_companion_drink_artifact', lambda hero: True)
def test_dring_artifact(self):
with self.check_decreased(lambda: self.hero.bag.occupation):
prototypes.ActionInPlacePrototype.create(hero=self.hero)
self.assertTrue(self.hero.journal.messages[-1].key.is_ACTION_INPLACE_COMPANION_DRINK_ARTIFACT)
def check_not_used(self):
with self.check_not_changed(lambda: self.hero.bag.occupation):
prototypes.ActionInPlacePrototype.create(hero=self.hero)
@mock.patch('the_tale.game.heroes.objects.Hero.can_companion_drink_artifact', lambda hero: True)
def test_previouse_place_is_equal(self):
self.hero.position.update_previous_place()
self.check_not_used()
@mock.patch('the_tale.game.heroes.objects.Hero.can_companion_drink_artifact', lambda hero: True)
def test_no_items(self):
self.hero.pop_loot(self.artifact)
self.check_not_used()
@mock.patch('the_tale.game.heroes.objects.Hero.can_companion_drink_artifact', lambda hero: False)
def test_companion_does_not_eat(self):
self.check_not_used()
开发者ID:Jazzis18,项目名称:the-tale,代码行数:55,代码来源:test_action_inplace.py
示例16: ChangeHeroTest
class ChangeHeroTest(TestCase):
def setUp(self):
super(ChangeHeroTest, self).setUp()
place_1, place_2, place_3 = create_test_map()
result, account_id, bundle_id = register_user("test_user", "[email protected]", "111111")
self.account = AccountPrototype.get_by_id(account_id)
self.storage = LogicStorage()
self.storage.load_account_data(self.account)
self.hero = self.storage.accounts_to_heroes[account_id]
self.hero.utg_name.properties = self.hero.utg_name.properties.clone(self.hero.gender.utg_id)
self.noun = names.generator.get_test_name(name="test_name", gender=GENDER.NEUTER)
self.race = RACE.ELF if RACE.ELF != self.hero.race else RACE.HUMAN
self.gender = GENDER.NEUTER if not self.hero.gender.is_NEUTER else GENDER.FEMININE
def tearDown(self):
pass
def test_create(self):
task = ChangeHeroTask(self.hero.id, name=self.noun, race=self.race, gender=self.gender)
self.assertEqual(task.state, CHANGE_HERO_TASK_STATE.UNPROCESSED)
self.assertEqual(self.hero.preferences.place, None)
self.assertEqual(task.name, self.noun)
self.assertEqual(task.race, self.race)
self.assertEqual(task.gender, self.gender)
def test_serialization(self):
task = ChangeHeroTask(self.hero.id, name=self.noun, race=self.race, gender=self.gender)
self.assertEqual(task.serialize(), ChangeHeroTask.deserialize(task.serialize()).serialize())
def test_check_change(self):
task = ChangeHeroTask(self.hero.id, name=self.noun, race=self.race, gender=self.gender)
self.assertNotEqual(self.hero.utg_name, self.noun)
self.assertNotEqual(self.hero.gender, self.gender)
self.assertNotEqual(self.hero.race, self.race)
self.assertFalse(self.hero.settings_approved)
with mock.patch("the_tale.game.heroes.objects.Hero.reset_accessors_cache") as reset_accessors_cache:
self.assertEqual(
task.process(FakePostpondTaskPrototype(), self.storage), POSTPONED_TASK_LOGIC_RESULT.SUCCESS
)
self.assertEqual(reset_accessors_cache.call_count, 1)
self.assertEqual(task.state, CHANGE_HERO_TASK_STATE.PROCESSED)
self.assertEqual(self.hero.utg_name.forms, self.noun.forms)
self.assertEqual(self.hero.utg_name.properties.get(utg_relations.GENDER), self.gender.utg_id)
self.assertEqual(self.hero.name, self.noun.normal_form())
self.assertEqual(self.hero.race, self.race)
self.assertEqual(self.hero.gender, self.gender)
self.assertTrue(self.hero.settings_approved)
开发者ID:Jazzis18,项目名称:the-tale,代码行数:55,代码来源:test_change_hero.py
示例17: PersonPowerBonusMixin
class PersonPowerBonusMixin(CardsTestMixin):
CARD = None
def setUp(self):
super(PersonPowerBonusMixin, self).setUp()
self.place_1, self.place_2, self.place_3 = create_test_map()
result, account_1_id, bundle_id = register_user('test_user', '[email protected]', '111111')
result, account_2_id, bundle_id = register_user('test_user_2')
self.account_1 = AccountPrototype.get_by_id(account_1_id)
self.account_2 = AccountPrototype.get_by_id(account_2_id)
self.storage = LogicStorage()
self.storage.load_account_data(self.account_1)
self.storage.load_account_data(self.account_2)
self.hero = self.storage.accounts_to_heroes[self.account_1.id]
self.card = self.CARD()
environment.deinitialize()
environment.initialize()
self.highlevel = environment.workers.highlevel
self.highlevel.process_initialize(0, 'highlevel')
def test_use(self):
person = self.place_1.persons[0]
result, step, postsave_actions = self.card.use(**self.use_attributes(hero=self.hero, storage=self.storage, person_id=person.id))
self.assertEqual((result, step), (ComplexChangeTask.RESULT.CONTINUE, ComplexChangeTask.STEP.HIGHLEVEL))
self.assertEqual(len(postsave_actions), 1)
with mock.patch('the_tale.game.workers.highlevel.Worker.cmd_logic_task') as highlevel_logic_task_counter:
postsave_actions[0]()
self.assertEqual(highlevel_logic_task_counter.call_count, 1)
with self.check_delta(lambda: person.power_positive, self.CARD.BONUS):
result, step, postsave_actions = self.card.use(**self.use_attributes(hero=self.hero,
step=step,
highlevel=self.highlevel,
person_id=person.id))
self.assertEqual((result, step, postsave_actions), (ComplexChangeTask.RESULT.SUCCESSED, ComplexChangeTask.STEP.SUCCESS, ()))
def test_no_person(self):
self.assertEqual(self.card.use(**self.use_attributes(hero=self.hero, person_id=666, storage=self.storage)),
(ComplexChangeTask.RESULT.FAILED, ComplexChangeTask.STEP.ERROR, ()))
开发者ID:Alkalit,项目名称:the-tale,代码行数:54,代码来源:test_person_power_bonus.py
示例18: HeroLogicAccessorsTestBase
class HeroLogicAccessorsTestBase(testcase.TestCase):
def setUp(self):
super(HeroLogicAccessorsTestBase, self).setUp()
self.place_1, self.place_2, self.place_3 = create_test_map()
result, account_id, bundle_id = register_user('test_user', '[email protected]', '111111')
self.storage = LogicStorage()
self.storage.load_account_data(AccountPrototype.get_by_id(account_id))
self.hero = self.storage.accounts_to_heroes[account_id]
开发者ID:Jazzis18,项目名称:the-tale,代码行数:11,代码来源:test_logic_accessors.py
示例19: RepairRandomArtifactTests
class RepairRandomArtifactTests(RepairArtifacsTestMixin, testcase.TestCase):
CARD = effects.RepairRandomArtifact
def setUp(self):
super(RepairRandomArtifactTests, self).setUp()
create_test_map()
result, account_1_id, bundle_id = register_user("test_user", "[email protected]", "111111")
self.account_1 = AccountPrototype.get_by_id(account_1_id)
self.storage = LogicStorage()
self.storage.load_account_data(self.account_1)
self.hero = self.storage.accounts_to_heroes[self.account_1.id]
self.card = self.CARD()
def test_all_repaired(self):
self.check_all_equipment_repaired(True)
result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero))
self.assertEqual(
(result, step, postsave_actions), (ComplexChangeTask.RESULT.FAILED, ComplexChangeTask.STEP.ERROR, ())
)
self.check_all_equipment_repaired(True)
def test_use(self):
self.check_all_equipment_repaired(True)
items = [item for item in self.hero.equipment.values() if item]
random.shuffle(items)
items[0].integrity = 0
items[1].integrity = 0
self.check_all_equipment_repaired(False)
result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero))
self.assertEqual(
(result, step, postsave_actions), (ComplexChangeTask.RESULT.SUCCESSED, ComplexChangeTask.STEP.SUCCESS, ())
)
self.check_all_equipment_repaired(False)
result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero))
self.assertEqual(
(result, step, postsave_actions), (ComplexChangeTask.RESULT.SUCCESSED, ComplexChangeTask.STEP.SUCCESS, ())
)
self.check_all_equipment_repaired(True)
开发者ID:lshestov,项目名称:the-tale,代码行数:52,代码来源:test_repair_artifacts.py
示例20: ChangeHeroSpendingsMixin
class ChangeHeroSpendingsMixin(CardsTestMixin):
CARD = None
def setUp(self):
super(ChangeHeroSpendingsMixin, self).setUp()
create_test_map()
result, account_1_id, bundle_id = register_user('test_user', '[email protected]', '111111')
self.account_1 = AccountPrototype.get_by_id(account_1_id)
self.storage = LogicStorage()
self.storage.load_account_data(self.account_1)
self.hero = self.storage.accounts_to_heroes[self.account_1.id]
self.card = self.CARD()
old_companion_record = random.choice(companions_storage.companions.all())
self.hero.set_companion(companions_logic.create_companion(old_companion_record))
def test_use(self):
# sure that quests will be loaded and not cal mark_updated
self.hero.quests.mark_updated()
for item in ITEMS_OF_EXPENDITURE.records:
if item == self.CARD.ITEM:
continue
self.hero.next_spending = item
with mock.patch('the_tale.game.quests.container.QuestsContainer.mark_updated') as mark_updated:
result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero))
self.assertEqual(mark_updated.call_count, 1)
self.assertEqual(self.hero.next_spending, self.CARD.ITEM)
self.assertEqual((result, step, postsave_actions), (ComplexChangeTask.RESULT.SUCCESSED, ComplexChangeTask.STEP.SUCCESS, ()))
def test_equal(self):
self.hero.next_spending = self.CARD.ITEM
with mock.patch('the_tale.game.quests.container.QuestsContainer.mark_updated') as mark_updated:
result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero))
self.assertEqual(mark_updated.call_count, 0)
self.assertEqual((result, step, postsave_actions), (ComplexChangeTask.RESULT.FAILED, ComplexChangeTask.STEP.ERROR, ()))
开发者ID:Alkalit,项目名称:the-tale,代码行数:52,代码来源:test_change_hero_spendings.py
注:本文中的the_tale.game.logic_storage.LogicStorage类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论