コード例 #1
0
ファイル: prototypes.py プロジェクト: Tiendil/the-tale
    def _fight(self, action):
        from the_tale.game.actions.prototypes import ActionBattlePvE1x1Prototype

        if action.mob is not None:
            mob = mobs_storage[self.knowledge_base[action.mob].externals["id"]].create_mob(self.hero, is_boss=True)
        else:
            mob = mobs_storage.get_random_mob(self.hero, mercenary=action.mercenary, is_boss=True)

            if mob is None:
                mobs_storage.get_random_mob(self.hero, is_boss=True)

        ActionBattlePvE1x1Prototype.create(hero=self.hero, mob=mob)
コード例 #2
0
ファイル: test_storage.py プロジェクト: Jazzis18/the-tale
    def test_get_random_mob__action_type(self):
        account = self.accounts_factory.create_account()
        hero = heroes_logic.load_hero(account_id=account.id)

        action_type = actions_relations.ACTION_TYPE.random()

        with mock.patch("the_tale.game.actions.prototypes.ActionBase.ui_type", action_type):
            mob = mobs_storage.get_random_mob(hero)

        self.assertEqual(mob.action_type, action_type)
コード例 #3
0
ファイル: test_storage.py プロジェクト: alexudracul/the-tale
    def test_get_random_mob__action_type(self):
        result, account_id, bundle_id = register_user('test_user_1', '*****@*****.**', '111111')
        hero = HeroPrototype.get_by_account_id(account_id)

        action_type = actions_relations.ACTION_TYPE.random()

        with mock.patch('the_tale.game.actions.prototypes.ActionBase.ui_type', action_type):
            mob = mobs_storage.get_random_mob(hero)

        self.assertEqual(mob.action_type, action_type)
コード例 #4
0
ファイル: test_storage.py プロジェクト: alexudracul/the-tale
    def test_get_random_mob__terrain(self):
        result, account_id, bundle_id = register_user('test_user_1', '*****@*****.**', '111111')
        hero = HeroPrototype.get_by_account_id(account_id)

        terrain = map_relations.TERRAIN.random()

        with mock.patch('the_tale.game.heroes.prototypes.HeroPositionPrototype.get_terrain', lambda h: terrain):
            mob = mobs_storage.get_random_mob(hero)

        self.assertEqual(mob.terrain, terrain)
コード例 #5
0
ファイル: test_storage.py プロジェクト: Jazzis18/the-tale
    def test_get_random_mob__terrain(self):
        account = self.accounts_factory.create_account()
        hero = heroes_logic.load_hero(account_id=account.id)

        terrain = map_relations.TERRAIN.random()

        with mock.patch("the_tale.game.heroes.position.Position.get_terrain", lambda h: terrain):
            mob = mobs_storage.get_random_mob(hero)

        self.assertEqual(mob.terrain, terrain)
コード例 #6
0
ファイル: test_storage.py プロジェクト: Jazzis18/the-tale
    def test_choose_mob__when_actions(self):
        account = self.accounts_factory.create_account()
        hero = heroes_logic.load_hero(account_id=account.id)

        MobRecordPrototype.create_random("action_1", global_action_probability=0.25)
        MobRecordPrototype.create_random("action_2", global_action_probability=0.10)

        counter = collections.Counter([mobs_storage.get_random_mob(hero).id for i in xrange(1000)])

        non_actions_count = sum(count for uuid, count in counter.iteritems() if uuid not in ("action_1", "action_2"))

        self.assertTrue(counter["action_2"] < counter["action_1"] < non_actions_count)
コード例 #7
0
ファイル: test_storage.py プロジェクト: Alkalit/the-tale
    def test_choose_mob__when_actions__total_actions(self):
        result, account_id, bundle_id = register_user('test_user_1', '*****@*****.**', '111111')
        hero = HeroPrototype.get_by_account_id(account_id)

        MobRecordPrototype.create_random('action_1', global_action_probability=0.66)
        MobRecordPrototype.create_random('action_2', global_action_probability=0.66)

        counter = collections.Counter([mobs_storage.get_random_mob(hero).id for i in xrange(10000)])

        self.assertEqual(sum([count for uuid, count in counter.iteritems() if uuid not in ('action_1', 'action_2')], 0), 0)

        self.assertTrue(abs(counter['action_2'] - counter['action_1']) < 0.2 * counter['action_2'])
コード例 #8
0
    def test_choose_mob__when_actions__total_actions(self):
        account = self.accounts_factory.create_account()
        hero = heroes_logic.load_hero(account_id=account.id)

        MobRecordPrototype.create_random('action_1', global_action_probability=0.66)
        MobRecordPrototype.create_random('action_2', global_action_probability=0.66)

        counter = collections.Counter([mobs_storage.get_random_mob(hero).id for i in range(10000)])

        self.assertEqual(sum([count for uuid, count in counter.items() if uuid not in ('action_1', 'action_2')], 0), 0)

        self.assertTrue(abs(counter['action_2'] - counter['action_1']) < 0.2 * counter['action_2'])
コード例 #9
0
ファイル: test_storage.py プロジェクト: Jazzis18/the-tale
    def test_get_random_mob__boss(self):
        account = self.accounts_factory.create_account()
        hero = heroes_logic.load_hero(account_id=account.id)

        boss = mobs_storage.get_random_mob(hero, is_boss=True)

        self.assertTrue(boss.is_boss)

        normal_mob = boss.record.create_mob(hero)

        self.assertFalse(normal_mob.is_boss)

        self.assertTrue(boss.max_health > normal_mob.max_health)
コード例 #10
0
ファイル: test_storage.py プロジェクト: Alkalit/the-tale
    def test_get_random_mob__boss(self):
        result, account_id, bundle_id = register_user('test_user_1', '*****@*****.**', '111111')
        hero = HeroPrototype.get_by_account_id(account_id)

        boss = mobs_storage.get_random_mob(hero, is_boss=True)

        self.assertTrue(boss.is_boss)

        normal_mob = boss.record.create_mob(hero)

        self.assertFalse(normal_mob.is_boss)

        self.assertTrue(boss.max_health > normal_mob.max_health)
コード例 #11
0
ファイル: test_storage.py プロジェクト: pavetok/the-tale
    def test_get_random_mob__boss(self):
        result, account_id, bundle_id = register_user('test_user_1',
                                                      '*****@*****.**',
                                                      '111111')
        hero = HeroPrototype.get_by_account_id(account_id)

        boss = mobs_storage.get_random_mob(hero, is_boss=True)

        self.assertTrue(boss.is_boss)

        normal_mob = boss.record.create_mob(hero)

        self.assertFalse(normal_mob.is_boss)

        self.assertTrue(boss.max_health > normal_mob.max_health)
コード例 #12
0
    def test_choose_mob__when_actions(self):
        account = self.accounts_factory.create_account()
        hero = heroes_logic.load_hero(account_id=account.id)

        MobRecordPrototype.create_random('action_1',
                                         global_action_probability=0.25)
        MobRecordPrototype.create_random('action_2',
                                         global_action_probability=0.10)

        counter = collections.Counter(
            [mobs_storage.get_random_mob(hero).id for i in xrange(1000)])

        non_actions_count = sum(count for uuid, count in counter.iteritems()
                                if uuid not in ('action_1', 'action_2'))

        self.assertTrue(
            counter['action_2'] < counter['action_1'] < non_actions_count)
コード例 #13
0
ファイル: test_storage.py プロジェクト: pavetok/the-tale
    def test_choose_mob__when_actions(self):
        result, account_id, bundle_id = register_user('test_user_1',
                                                      '*****@*****.**',
                                                      '111111')
        hero = HeroPrototype.get_by_account_id(account_id)

        MobRecordPrototype.create_random('action_1',
                                         global_action_probability=0.25)
        MobRecordPrototype.create_random('action_2',
                                         global_action_probability=0.10)

        counter = collections.Counter(
            [mobs_storage.get_random_mob(hero).id for i in xrange(1000)])

        non_actions_count = sum(count for uuid, count in counter.iteritems()
                                if uuid not in ('action_1', 'action_2'))

        self.assertTrue(
            counter['action_2'] < counter['action_1'] < non_actions_count)
コード例 #14
0
ファイル: test_battle.py プロジェクト: AtnesNess/the-tale
    def test_mob_actor(self):
        mob = mobs_storage.get_random_mob(self.hero)
        mob.health = 10
        mob.abilities.add(RUN_UP_PUSH.get_id())

        actor = battle.Actor(mob, BattleContext())

        self.assertEqual(mob.initiative, actor.initiative)
        self.assertEqual(mob.name, actor.name)
        self.assertEqual(mob.utg_name, actor.utg_name)
        self.assertEqual(mob.basic_damage, actor.basic_damage)
        self.assertEqual(mob.health, actor.health)
        self.assertEqual(mob.max_health, actor.max_health)

        self.assertEqual(actor.change_health(-5), -5)
        self.assertEqual(actor.health, 5)

        self.assertEqual(actor.change_health(-50), -5)
        self.assertEqual(actor.health, 0)

        self.assertEqual(actor.change_health(actor.max_health + 50),
                         actor.max_health)
        self.assertEqual(actor.health, actor.max_health)

        hit_selected = False
        run_up_push_selected = False
        vampire_strike_selected = False
        for i in range(100):
            ability = actor.choose_ability()

            if ability.get_id() == HIT.get_id():
                hit_selected = True
            elif ability.get_id() == RUN_UP_PUSH.get_id():
                run_up_push_selected = True
            elif ability.get_id() == VAMPIRE_STRIKE.get_id():
                vampire_strike_selected = True

        self.assertTrue(hit_selected)
        self.assertTrue(run_up_push_selected)
        self.assertTrue(vampire_strike_selected)

        self.storage._test_save()
コード例 #15
0
ファイル: test_battle.py プロジェクト: ruckysolis/the-tale
    def test_mob_actor(self):
        mob = mobs_storage.get_random_mob(self.hero)
        mob.health = 10
        mob.abilities.add(RUN_UP_PUSH.get_id())

        actor = battle.Actor(mob, BattleContext())

        self.assertEqual(mob.initiative, actor.initiative)
        self.assertEqual(mob.name, actor.name)
        self.assertEqual(mob.utg_name, actor.utg_name)
        self.assertEqual(mob.basic_damage, actor.basic_damage)
        self.assertEqual(mob.health, actor.health)
        self.assertEqual(mob.max_health, actor.max_health)

        self.assertEqual(actor.change_health(-5), -5)
        self.assertEqual(actor.health, 5)

        self.assertEqual(actor.change_health(-50), -5)
        self.assertEqual(actor.health, 0)

        self.assertEqual(actor.change_health(actor.max_health+50), actor.max_health)
        self.assertEqual(actor.health, actor.max_health)

        hit_selected = False
        run_up_push_selected = False
        vampire_strike_selected = False
        for i in xrange(100):
            ability = actor.choose_ability()

            if ability.get_id() == HIT.get_id():
               hit_selected = True
            elif ability.get_id() == RUN_UP_PUSH.get_id():
                run_up_push_selected = True
            elif ability.get_id() == VAMPIRE_STRIKE.get_id():
                vampire_strike_selected = True

        self.assertTrue(hit_selected)
        self.assertTrue(run_up_push_selected)
        self.assertTrue(vampire_strike_selected)

        self.storage._test_save()
コード例 #16
0
ファイル: test_storage.py プロジェクト: he1mdallr/the-tale
    def test_get_random_mob__no_mob(self):
        account = self.accounts_factory.create_account()
        hero = heroes_logic.load_hero(account_id=account.id)

        self.assertEqual(mobs_storage.get_random_mob(hero), None)
コード例 #17
0
ファイル: test_storage.py プロジェクト: Alkalit/the-tale
    def test_get_random_mob__no_mob(self):
        result, account_id, bundle_id = register_user('test_user_1', '*****@*****.**', '111111')
        hero = HeroPrototype.get_by_account_id(account_id)

        self.assertEqual(mobs_storage.get_random_mob(hero), None)
コード例 #18
0
ファイル: test_battle.py プロジェクト: angru/the-tale
    def get_actors(self):
        mob = mobs_storage.get_random_mob(self.hero)
        actor_1 = battle.Actor(self.hero, BattleContext())
        actor_2 = battle.Actor(mob, BattleContext())

        return actor_1, actor_2
コード例 #19
0
ファイル: test_storage.py プロジェクト: Jazzis18/the-tale
    def test_get_random_mob__no_mob(self):
        account = self.accounts_factory.create_account()
        hero = heroes_logic.load_hero(account_id=account.id)

        self.assertEqual(mobs_storage.get_random_mob(hero), None)