1 require 'games/chess/piece'
5 class Piece < Chess::Piece
6 TYPES = { 'P' => :pawn,
14 SYMBOLS = TYPES.invert
16 def self.type_from_symbol(sym)
17 promoted = sym[0,1] == '+'
18 sym = sym[1..-1] if promoted
19 type = TYPES[sym.upcase]
20 type = ('promoted_' + type.to_s).to_sym if promoted
25 promoted = type.to_s =~ /^promoted_/
26 base_type = if promoted
27 type.to_s.gsub(/^promoted_/, '').to_sym
31 result = SYMBOLS[base_type] || '?'
32 result = '+' + result if promoted