1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| Type
TPlayerType = (ptHuman, ptComputer);
TCellStatus = (csUndefined, csPlayer1, csPlayer2);
TBoard = Array of TCellStatus;//Array[0..cMaxBoardSize-1] of TCellStatus;
TMills = Array of Array of Byte;
TBoardGame = class
private
FMaxBoardSize : Byte;
FMaxVoisin : Byte;
FBoardName : String;
FBoardWidth, FBoardHeight : Byte;
FBoard : TBoard;
FMaxMills : Byte;
FMaxMillTokens : Byte;
FMills : TMills
// Exemple FMills avec FMaxMills = 16 FMaxMillToken = 3
// Moulins horizontaux
{ (0, 1, 2), (3, 4, 5),
(6, 7, 8), (9, 10, 11),
(12, 13, 14), (15, 16, 17),
(18, 19, 20), (21, 22, 23),
// Moulins Verticaux
(0, 9, 21), (3, 10, 18),
(6, 11, 15), (1, 4, 7),
(16, 19, 22), (8, 12, 17),
(5, 13, 20), (2,14,23) }
protected
public
Constructor Create;
Destructor Destroy;
function getBoard : TBoard;
property MaxBoardSize : Byte read FMaxBoardSize;
property MaxVoisin : Byte read MaxVoisin;
property BoardName : String read FBoardName;
property FBoardWidth : Byte read FBoardWidth;
property BoardHeight : Byte read FBoardHeight;
property MaxMills : Byte read FMaxMills;
property MaxMillTokens : Byte read FMaxMillTokens;
property Mill[MillIndex : Integer; TokenIndex : Integer] : Integer read getMillToken;
property Cell[Index : Integer] : TCellStatus read getCell write setCell
end;
TPlayer = Class
private
FBoard : TBoardGame;
FPlayerType : TPlayerType;
function CanMove(OldPos, NewPos : Integer) : Boolean;
public
Constructor Create(ABoard : TBoardGame);
procedure SetMove(NewPos : Integer):
procedure UpdateMove(OldPos, NewPos : Integer):
function CheckIfWin : Boolean;
property PlayerType : TPlayerType read FPlayerType write FPlayerType;
end; |
Partager