Pieces are demoted when captured.
[kaya.git] / test / games / shogi / test_shogi_perform_moves.rb
blob3c2201554359e50a3103955455d68402ec211c44
1 require 'test/unit'
2 require 'games/games'
3 require 'games/all'
4 require 'helpers/validation_helper'
6 class TestShogiPerformMoves < Test::Unit::TestCase
7   include ValidationHelper
8   
9   def setup
10     @game = Game.get(:shogi)
11     @state = @game.state.new
12     @validate = @game.validator.new(@state)
13     @board = @state.board
14     
15     @state.setup
16   end
17   
18   def test_pawn_push
19     execute 2, 6, 2, 5
20     
21     assert_piece :black, :pawn, 2, 5
22     assert_no_piece 2, 6
23     assert_equal :white, @state.turn
24   end
25   
26   def test_pawn_capture
27     execute 2, 6, 2, 5
28     execute 2, 2, 2, 3
29     execute 2, 5, 2, 4
30     execute 2, 3, 2, 4
31     
32     assert_piece :white, :pawn, 2, 4
33     assert_no_piece 2, 3
34     assert_no_piece 2, 2
35     assert_no_piece 2, 5
36     assert_no_piece 2, 6
37     
38     assert_pool :white, :pawn, 1
39     assert_equal 1, @state.pool(:white).size
40     assert @state.pool(:black).empty?
41   end
42   
43   def test_promoted_capture
44     @board[Point.new(2, 5)] = @state.promoted(@game.piece.new(:white, :rook))
45     
46     execute 2, 6, 2, 5
47     
48     assert_pool :black, :rook, 1
49   end
50 end