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 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, extctrls, Menus, StdCtrls;
type
TForm1 = class(TForm)
DrawGrid1: TDrawGrid;
MainMenu1: TMainMenu;
Menu1: TMenuItem;
Nouvellepartie1: TMenuItem;
N1: TMenuItem;
Quitter1: TMenuItem;
Rglesdujeu1: TMenuItem;
procedure DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure Quitter1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Nouvellepartie1Click(Sender: TObject);
procedure Rglesdujeu1Click(Sender: TObject);
procedure DrawGrid1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Déclarations privées }
public
procedure VerifierJoueur;
procedure VerifierCasesPossibles;
procedure VerifierSiCaseNoir;
procedure ChangementsCouleur;
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
var ColSelect, RowSelect, x1, y1, x2, y2, NbTours : Integer;
premierClic, blanc: Boolean;
tabDamier : array [0..9,0..9] of integer;
// Le damier en (colonne, ligne).
// Les indices vont de 0 à 9 pour correspondre au DrawGrid.
// Les valeurs possibles dans le tableau sont
// 0 : case vide
// 1 : case noire
// 2 : pion blanc
// 3 : pion noir
{$R *.dfm}
function Joueur : boolean ;
var Resultat : boolean;
begin
if (NbTours mod 2)=0 then Resultat:=True
else Resultat:=False;
Joueur:=Resultat;
end;
//-----------------------------------------------------------------------------
procedure TForm1.DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
...
//-----------------------------------------------------------------------------
procedure TForm1.VerifierJoueur;
begin
//Ne fais rien comme c'est au deuxième joueur de jouer.
if Joueur=false then
begin
if (tabDamier[x1,y1] = 3) then
Abort;
end
//Ne fais rien comme c'est au premier joueur de jouer.
else
begin
if (tabDamier[x1,y1] = 2) then
Abort;
end;
end; |
Partager