#!/home/hsmyers/rakudo741/bin/perl6 # board.p6 - Beginnings of a PGN toolset. And place to start learning # Perl 6/Raku. use v6d; #!_____________________________________________________________________________ constant $size = 4; class Piece { my Str @namesOfPieces[$size] = < white-rook white-knight white-bishop white-queen >; my Str @abrevsOfPieces[$size] = < R N B Q K B N R >; my Str @symbolsOfPieces[$size] = < ♖ ♘ ♗ ♕ ♔ ♗ ♘ ♖ >; my Str @codeptsOfPieces[$size] = ( "\x2656", "\x2658", "\x2657", "\x2655", ); has Str $.name; has Str $.abrev; has Str $.symbol; has Uni $.codept; submethod BUILD( :$i ) { $!name = @namesOfPieces[$i]; $!abrev = @abrevsOfPieces[$i]; $!symbol = @symbolsOfPieces[$i]; $!codept = @codeptsOfPieces[$i].NFC; } } class Square { my Int @colors[$size] = < 1 0 1 0 1 0 1 0 >; my Str @names[$size] = < a1 b1 c1 d1 e1 f1 g1 h1 >; has Int $.color; has Int $.index; has Str $.name; has Piece $.piece; submethod BUILD( :$i ) { $!color = @colors[$i]; $!index = $i; $!name = @names[$i]; $!piece = Piece.new(:i($i)); } } class Board is Array { } my $p = Piece.new(:i(0)); $p.say; my $s = Square.new(:i(0)); $s.say; #!_____________________________________________________________________________ my @b := Board.new( Square.new(:i(0)), Square.new(:i(1)), Square.new(:i(2)) ); say @b; say @b.WHAT;