2 require 'games/chess/state'
3 require 'games/chess/move'
4 require 'games/chess/board'
5 require 'games/chess/policy'
6 require 'games/chess/animator'
7 require 'games/chess/validator'
8 require 'games/chess/serializer'
9 require 'games/chess/pgn'
10 require 'plugins/plugin'
11 require 'games/game_actions'
19 plugin :name => 'Chess',
22 :keywords => %w(chess)
24 attr_reader :size, :policy, :state, :board, :move,
25 :animator, :validator, :piece, :players,
26 :types, :serializer, :game_writer,
30 @size = Point.new(8, 8)
31 @state_component = State
32 @state = Factory.new(State) { State.new(board.new, move, piece) }
33 @board = Factory.new(Board) { Board.new(size) }
36 @validator = Validator
38 @policy = Factory.new { Policy.new(Move) }
39 @players = [:white, :black]
40 @types = [:pawn, :knight,:bishop, :rook, :queen, :king]
41 @serializer = Factory.new(Serializer) {|rep|
42 Serializer.new(rep, validator, move, piece) }
45 @game_writer = PGN.new(serializer.new(:compact), state)
46 @game_extensions = %w(pgn)
48 action :promote_to_queen,
49 :text => 'Promote to Queen' do |policy|
50 policy.promotion = :queen
52 action :promote_to_rook,
53 :text => 'Promote to Rook' do |policy|
54 policy.promotion = :rook
56 action :promote_to_bishop,
57 :text => 'Promote to Bishop' do |policy|
58 policy.promotion = :bishop
60 action :promote_to_knight,
61 :text => 'Promote to Knight' do |policy|
62 policy.promotion = :knight
70 def actions(parent, collection, policy)
72 group = Qt::ActionGroup.new(parent)
73 group.exclusive = true
76 act.action_group = group
78 acts.first.checked = true
87 class Game < Chess::Game
88 plugin :name => 'Chess 5x5',
91 :keywords => %w(chess)
95 @size = Point.new(5, 5)