Beispiel #1
0
def test_render_label(pygame):
    drawer = Drawer(Game())
    drawer.font.render = Mock(return_value='IMAGE')

    drawer._render_label(id='test',
                         label='test',
                         cords=(1, 2),
                         color=(0, 1, 2))

    drawer.screen.blit.assert_called_once_with(
        'IMAGE', (drawer.OFFSET_LABELS_X + 1, drawer.OFFSET_LABELS_Y + 2))
    drawer.font.render.assert_called_once_with('test', 1, (0, 1, 2))
Beispiel #2
0
def test_render_text(pygame):
    game = Game()
    game.npcs = [NPC(0, 0), NPC(1, 1)]
    game.players = [Player(0, 32, 32), Player(1, 64, 32)]
    game.players[0].set_nick('1234')
    game.players[0].score = 100
    game.time_left = 125
    game.npcs_left = 3
    drawer = Drawer(game)
    drawer._render_label = Mock(spec=drawer._render_label)

    drawer._render_text()

    assert drawer._render_label.call_args_list == [
        call('title', 'BATTLE CITY AI', (0, 00)),
        call('npc_left', 'NPCs left:    003', (0, 40)),
        call('npc', 'NPCs in area: 002', (0, 80)),
        call('time', 'Time left:    125', (0, 120)),
        call('not-ready', 'NOT READY', (0, 180)),
        call('p-1', '1234       000100', (0, 240), drawer.PLAYER_COLORS[0]),
        call('p-info-1', 'WAIT', (0, 260), drawer.PLAYER_COLORS[0]),
        call('p-2', 'P1         000000', (0, 280), drawer.PLAYER_COLORS[1]),
        call('p-info-2', 'WAIT', (0, 300), drawer.PLAYER_COLORS[1]),
    ]