Example #1
0
def create_wally(maze, pos):
    char = maze.wall_at(pos)
    if char == '#':
        wall = create_peep('wall', 'FIGHTER', 'Wally', pos=pos)
    elif char == '%':
        wall = create_peep('permanent wall', 'FIGHTER', '*WALLY*', pos=pos)
    else:
        raise ValueError(f'no wall located at {pos}')

    maze.walls.replace_region(pos[0], pos[1], ['.'])
    maze.peeps.append(wall)
    return wall
Example #2
0
def test_balrog_whip():
    random.seed = 1
    game = dungeons.create_game({
        'walls': [
            '%%%%%%',
            '%....%',
            '%%%%%%',
        ],
        'peeps': [
            create_peep('human', name='Super Dad', pos=(1,1)),
            create_peep('balrog', name='Gark', pos=(3,1))
        ]
    })
    assert_game(game, ['.', '.', '.', Key.CTRL_Q], paint=False)
Example #3
0
def test_shoot_monster_blocked():
    random.seed = 1
    game =  dungeons.create_game({
        'walls': [
            '%%%%%%',
            '%..%.%',
            '%%%%%%',
        ],
        'peeps': [
            create_peep('human', name='Super Dad', pos=(1,1)),
            create_peep('goblin', name='Gark', pos=(4,1))
        ]
    })
    assert_game(game, ['a', '*', 't', '.', Key.CTRL_Q], paint=False)
Example #4
0
def test_shoot_thru_monster():
    random.seed = 1
    game =  dungeons.create_game({
        'walls': [
            '%%%%%%',
            '%....%',
            '%%%%%%',
        ],
        'peeps': [
            create_peep('human', name='Super Dad', pos=(1,1)),
            create_peep('dodger', name='Dummy', pos=(4,1))
        ]
    })
    assert_game(game, ['a', 'l', '.', '.', '.', '.', Key.CTRL_Q], paint=False)
Example #5
0
    def create_projectile(self, src, ptype, targetpath, attacks):
        shot = create_peep(ptype,
                           pos=targetpath[0],
                           attacks=attacks,
                           shooter=src)
        shot.pos_path = targetpath
        shot.pos_i = 0

        self.peeps.append(shot)
        self.log(f'{src.name} shoots {shot.name}')
        return shot
Example #6
0
def test_shoot_wall():
    random.seed = 1
    game =  dungeons.create_game({
        'walls': [
            '%%%%',
            '%..%',
            '%%%%',
        ],
        'peeps': [
            create_peep('human', name='Super Dad', pos=(1,1)),
        ]
    })
    assert_game(game, ['a', 'l', '.', '.', Key.CTRL_Q])
Example #7
0
def test_shield_block():
    random.seed = 1
    game = dungeons.create_game({
        'walls': [
            '%%%%',
            '%..%',
            '%%%%',
        ],
        'peeps': [
            create_peep('human', name='Super Dad', pos=(1,1)),
            create_peep('big bird', name='birdy!', pos=(2,1)),
        ]
    })

    class shield:
        type: str = 'rect'
        height: int = 2
        width: int = 2

    p = game.maze_model.peeps[0]
    game.maze_model.peeps[0].inventory.hand1 = shield()
    print(p)
    assert_game(game, ['a', 'l', '.', '.',  '.', '.', '.', '.', '.', Key.CTRL_Q], paint=False)
Example #8
0
def cb(scr):
    root_layout = RootLayout(dim=Dim(w, h),
                             border=0,
                             logger=Logger(__file__),
                             scr=scr,
                             curses=curses)
    game = GameModel(create_peep('human', name='Super Dad'))
    game.player.body.wear(clothes.cloak(size=Size(1.1, 1.1, 1.1), thick=1.0))
    game.player.body.wear(armor.helm(size=Size(1.15, 1.1, 1.1), thick=1.0))
    # game.player.body.wear(armor.shield(size=Size(1.4, 1.1, 1.0), thick=1.1))
    game.player.body.wear(weapons.sword(size=Size(1.0, 1.0, 1.0)))

    game.goto_level(1, placement='<')

    main(root_layout, game)
Example #9
0
def test_draw_target():
    data = (
        (0, -4),
        (1, -4),
        (2, -4),
        (3, -4),
        (4, -4),
        (4, -3),
        (4, -2),
        (4, -1),
        (4, 0),
        (4, 1),
        (4, 2),
        (4, 3),
        (4, 4),
        (3, 4),
        (2, 4),
        (1, 4),
        (0, 4),
        (-1, 4),
        (-2, 4),
        (-3, 4),
        (-4, 4),
        (-4, 3),
        (-4, 2),
        (-4, 1),
        (-4, 0),
        (-4, -1),
        (-4, -2),
        (-4, -3),
        (-4, -4),
        (-3, -4),
        (-2, -4),
        (-1, -4),
        (0, -4),
    )
    random.seed = 1
    game = dungeons.create_game({
        'walls': [
            '%%%%%%%%%',
            '%.......%',
            '%.......%',
            '%.......%',
            '%.......%',
            '%.......%',
            '%.......%',
            '%.......%',
            '%%%%%%%%%',
        ],
        'peeps': [
            create_peep('human', name='Super Dad', pos=(4, 4)),
        ]
    })
    root_layout = dummy_root(dim=Dim(11, 11), logger=Logger('dbg.py'))
    control = PrpgControl(root_layout, game)
    for comp in root_layout.info.comp_by_name.values():
        if not comp.children and comp.name != 'maze':
            comp.con = Con(0, 0, 1, 1)
    root_layout.do_layout()
    player = game.maze_model.peeps[0]
    for target in data:
        tp = (player.pos[0] + target[0], player.pos[1] + target[1])
        game.maze_model.target_path = tuple(line_points(player.pos, tp))
        control.root_layout.window.paint()
Example #10
0
from lib.peep_types import create_peep
import yaml

MONSTERS = [
    # GOBLINS
    create_peep('goblin', name='Thark'),
    create_peep('giant rat'),
    create_peep('big bird'),
    create_peep('red dragon', name='Spark'),
    create_peep('black dragon', name='Brog'),
    create_peep('multi-hued dragon', name='Crystal')
]

MONSTERS_BY_NAME = {m.name: m for m in MONSTERS}


def monster_by_name(name, pos=(0, 0), maxhp=0):
    ret = MONSTERS_BY_NAME[name]
    if maxhp > 0:
        ret.hp = maxhp
    ret.hp = ret.maxhp
    ret.pos = pos
    return ret


def color_rep(dumper, data):
    return dumper.represent_scalar('!color', data.name)


if __name__ == '__main__':
    for m in MONSTERS:
Example #11
0
from lib.peep_types import create_peep

_PEEPS = [
    create_peep('dog', name='Bo Bo the Destroyer'),
    create_peep('human',
                name='Super Dad',
                height=1.3,
                weight=1.5,
                body2head=8.0),
]

_PEEPS_BY_NAME = {m.name: m for m in _PEEPS}


def player_by_name(name, pos=(0, 0), maxhp=0):
    ret = _PEEPS_BY_NAME[name]
    if maxhp > 0:
        ret.maxhp = maxhp
    ret.hp = ret.maxhp
    ret.pos = pos
    return ret
Example #12
0
         '%#########.........##########%###....####%',
         '%#####..................#####%#........##%',
         '%####...................................#%',
         '%####....................####%#........##%',
         '%#####..................#####%###....####%',
         '%#########.........##########%#####.#####%',
         '%#############.##############%%%%%%%%%%%%%',
         '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%',
     ],
     'peeps': [
         player_by_name('Super Dad', pos=(1, 2), maxhp=40),
         monster_by_name('Thark', pos=(2, 2), maxhp=10),
         monster_by_name('Spark', pos=(24, 7), maxhp=50),
         monster_by_name('Brog', pos=(14, 20), maxhp=200),
         monster_by_name('Crystal', pos=(36, 17), maxhp=500),
         create_peep('big bird', name='Beaky', pos=(18, 4)),
         create_peep('giant rat', name='Scriggle', pos=(19, 4)),
     ],
     'items': [clothes.belt(pos=(1, 1))]
 },
 'level_0': {
     'walls': [
         '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%',
         '%.........................>........................%',
         '%......#####...#####.............#####...#####.....%',
         '%.....######...######...........######...######....%',
         '%.....######...#####2...........5#####...######....%',
         '%.....######...######...........######...######....%',
         '%......##1##...#####.............#####...#####.....%',
         '%..................................................%',
         '%..................................................%',