def test_should_be_able_to_attack_and_draw(self, pusher):
app.post('/api/create', params={'board': json.dumps(FIXTURES.SETUP)})
game = models.Game.query().get()
app.post('/api/join', params={
'board': json.dumps(FIXTURES.SETUP),
'join_hash': game.join_hash
})
app.post('/api/move', params={
'player_hash': game.red_hash,
'side': 0,
'from': json.dumps({'x': 5, 'y': 6}),
'to': json.dumps({'x': 5, 'y': 5})
})
app.post('/api/move', params={
'player_hash': game.blue_hash,
'side': 1,
'from': json.dumps({'x': 4, 'y': 6}),
'to': json.dumps({'x': 4, 'y': 5})
})
app.post('/api/move', params={
'player_hash': game.red_hash,
'side': 0,
'from': json.dumps({'x': 5, 'y': 5}),
'to': json.dumps({'x': 5, 'y': 4})
})
game = models.Game.query().get()
current_state_of_game = copy.deepcopy(FIXTURES.DEFAULT_GAME)
# These pieces should have been destroyed
current_state_of_game[3][5] = 0
current_state_of_game[6][5] = 0
self.assertEqual(game.get_board(), current_state_of_game)
self.assertEqual(game.get_last_move(), {
'type': 'draw',
'from': {
'piece': {'side': 0, 'rank': '4'},
'position': {'x': 5, 'y': 5}
},
'to': {
'piece': {'side': 1, 'rank': '4'},
'position': {'x': 5, 'y': 4}
}
})
# Blue's turn
self.assertEqual(game.turn, 1)
评论列表
文章目录