Beispiel #1
0
    def test_any_members_active(self):
        actors = []
        actors.append(actor.Actor(max_hp=10, pc_type='pc'))
        actors.append(actor.Actor(max_hp=0, pc_type='pc'))
        actors.append(actor.Actor(max_hp=0, pc_type='npc'))

        assert helpers.any_members_active(actors, 'pc') is True
Beispiel #2
0
    def test_fire_bolt(self, mock_rand, mock_md):
        source_actor = actor.Actor(level=10, max_wil=5)
        target_actor = actor.Actor(level=10, max_wil=6)

        dmg = action.fire_bolt(source_actor, target_actor)
        assert dmg[0]['element'] == "fire"
        assert dmg[0]['damage'] == 11
Beispiel #3
0
    def test_calc_magic_defense(self):
        source_actor = actor.Actor(level=10, max_wil=5)
        target_actor = actor.Actor(level=10, max_wil=8)

        md = helpers.calc_magic_defense(source_actor, target_actor)

        assert md == -3
Beispiel #4
0
    def test_get_max_stat_from_actor_list(self):
        actors = []
        actors.append(actor.Actor(name='foo', level=1, max_dex=10))
        actors.append(actor.Actor(name='bar', level=2, max_dex=5))
        actors.append(actor.Actor(name='baz', level=1, max_dex=15))

        max_val = helpers.get_max_stat_from_actor_list(actors, 'cur_dex')
        assert max_val == 15
Beispiel #5
0
    def test_get_actor_list_by_stat(self):
        actors = []
        actors.append(actor.Actor(name='foo', level=1, max_dex=10))
        actors.append(actor.Actor(name='bar', level=2, max_dex=5))
        actors.append(actor.Actor(name='baz', level=3, max_dex=15))
        actors.append(actor.Actor(name='ham', level=1, max_dex=15))

        sorted_actors = helpers.get_actor_list_by_stat(actors, 'cur_dex',
                                                       'level')

        assert sorted_actors[0].name == 'baz'
Beispiel #6
0
 def get_multiple_actors(self):
     actors = []
     actors.append(
         actor.Actor(actor_id=0,
                     name='spam',
                     pc_type='pc',
                     level=1,
                     max_hp=10,
                     max_str=10,
                     max_dex=10,
                     max_sta=10))
     actors.append(
         actor.Actor(actor_id=1,
                     name='eggs',
                     pc_type='pc',
                     affiliation='friendly',
                     level=1,
                     max_hp=5,
                     max_str=5,
                     max_dex=5,
                     max_sta=5))
     actors.append(
         actor.Actor(actor_id=2,
                     name='foo',
                     pc_type='npc',
                     level=1,
                     max_hp=6,
                     max_str=6,
                     max_dex=6,
                     max_sta=6))
     actors.append(
         actor.Actor(actor_id=3,
                     name='bar',
                     pc_type='npc',
                     affiliation='unfriendly',
                     level=1,
                     max_hp=6,
                     max_str=6,
                     max_dex=6,
                     max_sta=6))
     actors.append(
         actor.Actor(actor_id=4,
                     name='baz',
                     pc_type='npc',
                     affiliation='unfriendly',
                     level=1,
                     max_hp=2,
                     max_str=2,
                     max_dex=2,
                     max_sta=2))
     return actors
Beispiel #7
0
 def get_single_actor(self):
     return actor.Actor(name='ham',
                        pc_type='pc',
                        affiliation='unfriendly',
                        level=1,
                        max_hp=10,
                        max_str=10,
                        max_dex=10,
                        max_sta=10)
Beispiel #8
0
 def combat_setup(self):
     raise NotImplementedError
     actors = []
     actors.append(sm_npc.get_goblin("Fooblin"))
     char1 = sm_actor.Actor(pc_type="pc",
                            name="Bar",
                            level=1,
                            max_hp=20,
                            max_str=10,
                            max_dex=10,
                            max_sta=10,
                            max_wil=5)
     actors.append(char1)
     # print("{}({}) fights {}({})".format(actors[0].name, actors[0].pc_type, actors[1].name, actors[1].pc_type))
     Combat(actors)
Beispiel #9
0
def combat_menu():
    get_default_style()

    choices = [{
        'name': 'Big Goblin',
        'value': 'goblin'
    }, {
        'name': 'Return',
        'value': 'return'
    }]

    questions = [{
        'type': 'list',
        'name': 'selection',
        'message': 'Choose an opponent',
        'choices': choices
    }]

    answers = prompt(questions)

    if 'not implemented' in answers['selection']:
        print("Feature not implemented")
        sys.exit()
    elif answers['selection'] == 'return':
        go_to_menu('main')
    else:
        if answers['selection'] == 'goblin':
            # TODO: Put in battle_setup()
            actors = []
            actors.append(
                sm_actor.Actor(actor_id=len(actors),
                               name='ham',
                               pc_type='pc',
                               level=1,
                               max_hp=10,
                               max_str=10,
                               max_dex=10,
                               max_sta=10))
            actors.append(sm_npc.get_big_goblin(actor_id=len(actors)))
            cur_battle = sm_combat.Combat(actors)
            # TODO: write function to let player know what is going on
            print_battle_header(cur_battle)
            cur_battle.battle()
Beispiel #10
0
 def test_fight(self, mock_atk, mock_def):
     source_actor = actor.Actor()
     target_actor = actor.Actor(max_hp=20)
     action.fight(source_actor, target_actor)
     assert target_actor.cur_hp == 11