1 # Copyright (c) 2009 Paolo Capriotti <p.capriotti@gmail.com>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
10 attr_reader :color, :type
11 SYMBOLS = { :knight => 'N' }
12 TYPES = { 'P' => :pawn,
19 def initialize(color, type)
25 @color == other.color and @type == other.type
33 s = self.class.symbol(type)
34 s = s.downcase if color == :black
38 def same_color_of?(other)
39 other and other.color == color
47 other.instance_of?(self.class) and self == other
55 SYMBOLS[type] || type.to_s[0, 1].upcase
58 def self.type_from_symbol(sym)