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,
27 :game_extensions, :notation
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 @notation = SAN.new(piece, size)
42 @serializer = Factory.new(Serializer) {|rep|
43 Serializer.new(rep, validator, move, piece, notation) }
46 @game_writer = PGN.new(serializer.new(:compact), state)
47 @game_extensions = %w(pgn)
49 action :promote_to_queen,
50 :text => 'Promote to &Queen' do |policy|
51 policy.promotion = :queen
53 action :promote_to_rook,
54 :text => 'Promote to &Rook' do |policy|
55 policy.promotion = :rook
57 action :promote_to_bishop,
58 :text => 'Promote to &Bishop' do |policy|
59 policy.promotion = :bishop
61 action :promote_to_knight,
62 :text => 'Promote to &Knight' do |policy|
63 policy.promotion = :knight
71 def actions(parent, collection, policy)
73 group = Qt::ActionGroup.new(parent)
74 group.exclusive = true
77 act.action_group = group
79 acts.first.checked = true
88 class Game < Chess::Game
89 plugin :name => 'Chess 5x5',
92 :keywords => %w(chess)
96 @size = Point.new(5, 5)