def test_messages_get_tick_game_data(): game = Game() game.time_left = 42 game.npcs = [object(), object()] assert messages.get_tick_game_data(game) == dict( status='game', action='info', ticks_left=42, npcs_left=2, )
async def test_do_it_after_ticks(): game = Game() game.time_left = 250 logic = TickLogicPart(game) with patch.multiple(logic, unset_player_actions=DEFAULT, send_info=DEFAULT, do_sth_with_npcs=DEFAULT) as patch_values: await logic.do_it_after_ticks() patch_values['unset_player_actions'].assert_called_once_with() patch_values['do_sth_with_npcs'].assert_called_once_with() patch_values['send_info'].assert_called_once_with() assert game.time_left == 249
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]), ]