unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
TForm3 =
class(TForm)
StringGrid1: TStringGrid;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Label1: TLabel;
Button8: TButton;
Button9: TButton;
procedure Button8Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form3: TForm3;
Spieler, y, x :integer;
implementation
{$R *.dfm}
procedure Kontrolle(
const Target: TStringgrid);
var a, b, r, richtig :integer;
gefunden :boolean;
begin
y:=-1;
begin
For r := 1
to 6
do
begin
For a := 1
to 4
do
begin
richtig:=0;
For b := 1
to 4
do
begin
y:=a+b;
gefunden:=Target.cells[r,y]=IntToStr(Spieler);
if
gefunden
then
richtig:=richtig+1
end;
if
richtig=4
then
break;
end;
if
richtig=4
then
break;
end;
if
richtig=4
then
break;
end;
if
richtig=4
then
showmessage('
Spieler' +IntToStr(Spieler) +'
hat gewonnen!');
end;
procedure Spielstein(
const Target: TStringgrid);
begin
If
Spieler=2
then
Spieler:=0;
Spieler:=Spieler+1;
If
(Target.cells[y,1] ='
1')
or (Target.Cells[y,1] ='
2')
then
showmessage('
Hier passt kein Spielstein mehr rein wählen sie eine andere Reihe!')
else
begin
If
(target.cells[y,2] ='
1')
or (target.Cells[y,2] ='
2')
then
target.cells[y,1]:=IntToStr(Spieler)
else
begin
If
(target.cells[y,3] ='
1')
or (target.Cells[y,3] ='
2')
then
target.cells[y,2]:=IntToStr(Spieler)
else
begin
If
(target.cells[y,4] ='
1')
or (target.Cells[y,4] ='
2')
then
target.cells[y,3]:=IntToStr(Spieler)
else
begin
If
(target.cells[y,5] ='
1')
or (target.Cells[y,5] ='
2')
then
target.cells[y,4]:=IntToStr(Spieler)
else
begin
If
(target.cells[y,6] ='
1')
or (target.Cells[y,6] ='
2')
then
target.cells[y,5]:=IntToStr(Spieler)
else
target.cells[y,6]:=IntToStr(Spieler)
end;
end;
end;
end;
end;
end;
procedure TForm3.Button1Click(Sender: TObject);
begin
y:=1;
Spielstein(Stringgrid1);
Kontrolle(Stringgrid1)
end;
procedure TForm3.Button2Click(Sender: TObject);
begin
y:=2;
Spielstein(Stringgrid1);
Kontrolle(Stringgrid1)
end;
procedure TForm3.Button3Click(Sender: TObject);
begin
y:=3;
Spielstein(Stringgrid1);
Kontrolle(Stringgrid1)
end;
procedure TForm3.Button4Click(Sender: TObject);
begin
y:=4;
Spielstein(Stringgrid1);
Kontrolle(Stringgrid1)
end;
procedure TForm3.Button5Click(Sender: TObject);
begin
y:=5;
Spielstein(Stringgrid1);
Kontrolle(Stringgrid1)
end;
procedure TForm3.Button6Click(Sender: TObject);
begin
y:=6;
Spielstein(Stringgrid1);
Kontrolle(Stringgrid1)
end;
procedure TForm3.Button7Click(Sender: TObject);
begin
y:=7;
Spielstein(Stringgrid1);
Kontrolle(Stringgrid1)
end;
procedure TForm3.Button8Click(Sender: TObject);
begin
For y:= 1
to 7
do
begin
For x:= 1
to 6
do
begin
Stringgrid1.Cells[y,x]:='
';
end;
end;
end;
procedure TForm3.Button9Click(Sender: TObject);
begin
close;
end;
end.