unit Unit4;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm4 =
class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Button9: TButton;
Button10: TButton;
Button11: TButton;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
procedure FormPaint(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure Button11Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form4: TForm4;
Spieleein :
Array[1..4]
of Boolean;
PCcheck,SPcheck: boolean;
//PC oder SPieler dran
Buttonwahl: integer;
// Pc wählt im Random ein Button aus
implementation
uses unit1, unit2, unit3;
{$R *.DFM}
procedure Auswertung;
var Win: Integer;
begin
If (Form4.Label6.Caption = Form4.Label7.Caption)
and (Form4.Label7.Caption = Form4.Label8.Caption)
or
(Form4.Label9.Caption = Form4.Label10.Caption)
and (Form4.Label10.Caption = Form4.Label11.Caption)
or
(Form4.Label12.Caption = Form4.Label13.Caption)
and (Form4.Label13.caption = Form4.Label4.Caption)
or
(Form4.Label6.Caption = Form4.Label9.Caption)
and (Form4.Label9.Caption = Form4.Label12.caption)
or
(Form4.Label7.Caption = Form4.Label10.Caption)
and (Form4.Label10.Caption = Form4.Label13.Caption)
or
(Form4.Label8.Caption = Form4.Label11.Caption)
and (Form4.Label11.Caption = Form4.Label14.Caption)
or
(Form4.Label6.Caption = Form4.Label10.Caption)
and (Form4.Label10.Caption = Form4.Label14.Caption)
or
(Form4.Label8.Caption = Form4.Label11.Caption)
and (Form4.Label11.Caption = Form4.Label12.Caption)
then begin
Win := Application.MessageBox('
Du hast Gewonnen', '
Gewonnen', 0+64);
if Win = IDOK
then ;
Form4.button3.Visible := false;
Form4.button4.Visible := false;
Form4.button5.Visible := false;
Form4.button6.Visible := false;
Form4.button7.Visible := false;
Form4.button8.Visible := false;
Form4.button9.Visible := false;
Form4.button10.Visible := false;
Form4.button11.Visible := false;
end;
end;
procedure Spieleinstellung;
// Wichtig für Form3
begin
if (Pczug = true)
and (X = true)
then // Im Klartext, es gibt 4 Möglichkeiten, erst PC dran, und Spieler 1 hat X, dann PC und SP1 hat O usw...
Spieleein[1] := true;
if (Pczug = true)
and (O = true)
then
Spieleein[2] := true;
if (SP1 = true)
and (X = true)
then
Spieleein[3] := true;
If (SP1 = true)
and (O = true)
then
Spieleein[4] := true;
end;
procedure ComputerZug;
// Die Technik^^
begin
if (Spieleein[1] = true)
and (PCcheck = false)
then
begin
repeat
ButtonWahl:= Random (9) + 1;
// Random für ButtonWahl
case ButtonWahl
of
1:
if Form4.Button3.visible = true
then
begin
Form4.button3.visible := false;
Form4.label6.caption := '
O';
SPcheck := false;
PCcheck := true;
end;
2:
if Form4.Button4.visible = true
then
begin
Form4.button4.visible := false;
Form4.label7.caption := '
O';
SPcheck := false;
PCcheck := true;
end;
3:
if Form4.Button5.visible = true
then
begin
Form4.button5.visible := false;
Form4.label8.caption := '
O';
SPcheck := false;
PCcheck := true;
end;
4:
if Form4.Button6.visible = true
then
begin
Form4.button6.visible := false;
Form4.label9.caption := '
O';
SPcheck := false;
PCcheck := true;
end;
5:
if Form4.Button7.visible = true
then
begin
Form4.button7.visible := false;
Form4.label10.caption := '
O';
SPcheck := false;
PCcheck := true;
end;
6:
if Form4.Button8.visible = true
then
begin
Form4.button8.visible := false;
Form4.label11.caption := '
O';
SPcheck := false;
PCcheck := true;
end;
7:
if Form4.Button9.visible = true
then
begin
Form4.button9.visible := false;
Form4.label12.caption := '
O';
SPcheck := false;
PCcheck := true;
end;
8:
if Form4.Button10.visible = true
then
begin
Form4.button10.visible := false;
Form4.label13.caption := '
O';
SPcheck := false;
PCcheck := true;
end;
9:
if Form4.Button11.visible = true
then
begin
Form4.button11.visible := false;
Form4.label14.caption := '
O';
SPcheck := false;
PCcheck := true;
end;
end;
until
PCcheck = true;
end;
if (Spieleein[2] = true)
and (PCcheck = false)
then
begin
repeat
ButtonWahl:= Random (9) + 1;
// Random für ButtonWahl
case ButtonWahl
of
1:
if Form4.Button3.visible = true
then
begin
Form4.button3.visible := false;
Form4.label6.caption := '
X';
SPcheck := false;
PCcheck := true;
end;
2:
if Form4.Button4.visible = true
then
begin
Form4.button4.visible := false;
Form4.label7.caption := '
X';
SPcheck := false;
PCcheck := true;
end;
3:
if Form4.Button5.visible = true
then
begin
Form4.button5.visible := false;
Form4.label8.caption := '
X';
SPcheck := false;
PCcheck := true;
end;
4:
if Form4.Button6.visible = true
then
begin
Form4.button6.visible := false;
Form4.label9.caption := '
X';
SPcheck := false;
PCcheck := true;
end;
5:
if Form4.Button7.visible = true
then
begin
Form4.button7.visible := false;
Form4.label10.caption := '
X';
SPcheck := false;
PCcheck := true;
end;
6:
if Form4.Button8.visible = true
then
begin
Form4.button8.visible := false;
Form4.label11.caption := '
X';
SPcheck := false;
PCcheck := true;
end;
7:
if Form4.Button9.visible = true
then
begin
Form4.button9.visible := false;
Form4.label12.caption := '
X';
SPcheck := false;
PCcheck := true;
end;
8:
if Form4.Button10.visible = true
then
begin
Form4.button10.visible := false;
Form4.label13.caption := '
X';
SPcheck := false;
PCcheck := true;
end;
9:
if Form4.Button11.visible = true
then
begin
Form4.button11.visible := false;
Form4.label14.caption := '
X';
SPcheck := false;
PCcheck := true;
end;
end;
until
PCcheck = true;
end;
if (Spieleein[3]= true)
and (SPcheck =true)
then
begin
repeat
ButtonWahl:= Random (9) + 1;
// Random für ButtonWahl
case ButtonWahl
of
1:
if Form4.Button3.visible = true
then
begin
Form4.Button3.visible := false;
Form4.label6.caption := '
O';
SPcheck := false;
PCcheck := true;
end;
2:
if Form4.Button4.visible = true
then
begin
Form4.Button4.visible := false;
Form4.label7.caption := '
O';
SPcheck := false;
PCcheck := true;
end;
3:
if Form4.Button5.visible = true
then
begin
Form4.Button5.visible := false;
Form4.label8.caption := '
O';
SPcheck := false;
PCcheck := true;
end;
4:
if Form4.Button6.visible = true
then
begin
Form4.Button6.visible := false;
Form4.label9.caption := '
O';
SPcheck := false;
PCcheck := true;
end;
5:
if Form4.Button7.visible = true
then
begin
Form4.Button7.visible := false;
Form4.label10.caption := '
O';
SPcheck := false;
PCcheck := true;
end;
6:
if Form4.Button8.visible = true
then
begin
Form4.Button8.visible := false;
Form4.label11.caption := '
O';
SPcheck := false;
PCcheck := true;
end;
7:
if Form4.Button9.visible = true
then
begin
Form4.Button9.visible := false;
Form4.label12.caption := '
O';
SPcheck := false;
PCcheck := true;
end;
8:
if Form4.Button10.visible = true
then
begin
Form4.Button10.visible := false;
Form4.label13.caption := '
O';
SPcheck := false;
PCcheck := true;
end;
9:
if Form4.Button11.visible = true
then
begin
Form4.Button11.visible := false;
Form4.label14.caption := '
O';
SPcheck := false;
PCcheck := true;
end;
end;
until
PCcheck = true;
end;
if (Spieleein[4]= true)
and (SPcheck =true)
then
begin
repeat
ButtonWahl:= Random (9) + 1;
// Random für ButtonWahl
case ButtonWahl
of
1:
if Form4.Button3.visible = true
then
begin
Form4.Button3.visible := false;
Form4.label6.caption := '
X';
SPcheck := false;
PCcheck := true;
end;
2:
if Form4.Button4.visible = true
then
begin
Form4.Button4.visible := false;
Form4.label7.caption := '
X';
SPcheck := false;
PCcheck := true;
end;
3:
if Form4.Button5.visible = true
then
begin
Form4.Button5.visible := false;
Form4.label8.caption := '
X';
SPcheck := false;
PCcheck := true;
end;
4:
if Form4.Button6.visible = true
then
begin
Form4.Button6.visible := false;
Form4.label9.caption := '
X';
SPcheck := false;
PCcheck := true;
end;
5:
if Form4.Button7.visible = true
then
begin
Form4.Button7.visible := false;
Form4.label10.caption := '
X';
SPcheck := false;
PCcheck := true;
end;
6:
if Form4.Button8.visible = true
then
begin
Form4.Button8.visible := false;
Form4.label11.caption := '
X';
SPcheck := false;
PCcheck := true;
end;
7:
if Form4.Button9.visible = true
then
begin
Form4.Button9.visible := false;
Form4.label12.caption := '
X';
SPcheck := false;
PCcheck := true;
end;
8:
if Form4.Button10.visible = true
then
begin
Form4.Button10.visible := false;
Form4.label13.caption := '
X';
SPcheck := false;
PCcheck := true;
end;
9:
if Form4.Button11.visible = true
then
begin
Form4.Button11.visible := false;
Form4.label14.caption := '
X';
SPcheck := false;
PCcheck := true;
end;
end;
until
PCcheck = true;
end;
end;
procedure TForm4.FormPaint(Sender: TObject);
begin
//waagerechte
canvas.MoveTo (50, 132);
Canvas.LineTo (232, 132);
canvas.MoveTo (50, 188);
Canvas.LineTo (232, 188);
// Senkrecht
canvas.MoveTo (108, 80);
canvas.LineTo (108, 240);
canvas.MoveTo (172, 80);
canvas.LineTo (172, 240);
label1.caption := '
Spieler 1: ';
label2.caption := Spieler1name ;
label3.caption := '
Spieler 2:';
label4.caption := '
Computer';
Spieleinstellung;
ComputerZug;
end;
procedure TForm4.FormCreate(Sender: TObject);
var Nrrr: Integer;
begin
for Nrrr := 1
to 4
do Spieleein[Nrrr] := false;
PCcheck := false;
SPcheck := false;
end;
procedure TForm4.Button2Click(Sender: TObject);
var Knopf: Integer;
begin
Knopf := Application.MessageBox ('
Sind Sie sicher?','
Beenden', 1+32);
if Knopf = IDOK
then close;
if Knopf <> IDCANCEL
then ;
end;
procedure TForm4.Button1Click(Sender: TObject);
begin
refresh
end;
procedure TForm4.Button3Click(Sender: TObject);
begin
if Spieleein[1]= true
then
begin
form4.button3.visible := false;
form4.label6.caption := '
X';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[2]= true
then
begin
form4.button3.visible := false;
form4.label6.caption := '
O';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[3]= true
then
begin
form4.button3.visible := false;
form4.label6.caption := '
X';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[4]= true
then
begin
form4.button3.visible := false;
form4.label6.caption := '
O';
SPCheck:= true;
PCcheck := false;
end;
end;
procedure TForm4.Button4Click(Sender: TObject);
begin
if Spieleein[1]= true
then
begin
form4.button4.visible := false;
form4.label7.caption := '
X';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[2]= true
then
begin
form4.button4.visible := false;
form4.label7.caption := '
O';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[3]= true
then
begin
form4.button4.visible := false;
form4.label7.caption := '
X';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[4]= true
then
begin
form4.button4.visible := false;
form4.label7.caption := '
O';
SPCheck:= true;
PCcheck := false;
end;
end;
procedure TForm4.Button5Click(Sender: TObject);
begin
if Spieleein[1]= true
then
begin
form4.button5.visible := false;
form4.label8.caption := '
X';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[2]= true
then
begin
form4.button5.visible := false;
form4.label8.caption := '
O';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[3]= true
then
begin
form4.button5.visible := false;
form4.label8.caption := '
X';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[4]= true
then
begin
form4.button5.visible := false;
form4.label8.caption := '
O';
SPCheck:= true;
PCcheck := false;
end;
end;
procedure TForm4.Button6Click(Sender: TObject);
begin
if Spieleein[1]= true
then
begin
form4.button6.visible := false;
form4.label9.caption := '
X';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[2]= true
then
begin
form4.button6.visible := false;
form4.label9.caption := '
O';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[3]= true
then
begin
form4.button6.visible := false;
form4.label9.caption := '
X';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[4]= true
then
begin
form4.button6.visible := false;
form4.label9.caption := '
O';
SPCheck:= true;
PCcheck := false;
end;
end;
procedure TForm4.Button7Click(Sender: TObject);
begin
if Spieleein[1]= true
then
begin
form4.button7.visible := false;
form4.label10.caption := '
X';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[2]= true
then
begin
form4.button7.visible := false;
form4.label10.caption := '
O';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[3]= true
then
begin
form4.button7.visible := false;
form4.label10.caption := '
X';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[4]= true
then
begin
form4.button7.visible := false;
form4.label10.caption := '
O';
SPCheck:= true;
PCcheck := false;
end;
end;
procedure TForm4.Button8Click(Sender: TObject);
begin
if Spieleein[1]= true
then
begin
form4.button8.visible := false;
form4.label11.caption := '
X';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[2]= true
then
begin
form4.button8.visible := false;
form4.label11.caption := '
O';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[3]= true
then
begin
form4.button8.visible := false;
form4.label11.caption := '
X';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[4]= true
then
begin
form4.button8.visible := false;
form4.label11.caption := '
O';
SPCheck:= true;
PCcheck := false;
end;
end;
procedure TForm4.Button9Click(Sender: TObject);
begin
if Spieleein[1]= true
then
begin
form4.button9.visible := false;
form4.label12.caption := '
X';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[2]= true
then
begin
form4.button9.visible := false;
form4.label12.caption := '
O';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[3]= true
then
begin
form4.button9.visible := false;
form4.label12.caption := '
X';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[4]= true
then
begin
form4.button9.visible := false;
form4.label12.caption := '
O';
SPCheck:= true;
PCcheck := false;
end;
end;
procedure TForm4.Button10Click(Sender: TObject);
begin
if Spieleein[1]= true
then
begin
form4.button10.visible := false;
form4.label13.caption := '
X';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[2]= true
then
begin
form4.button10.visible := false;
form4.label13.caption := '
O';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[3]= true
then
begin
form4.button10.visible := false;
form4.label3.caption := '
X';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[4]= true
then
begin
form4.button10.visible := false;
form4.label3.caption := '
O';
SPCheck:= true;
PCcheck := false;
end;
end;
procedure TForm4.Button11Click(Sender: TObject);
begin
if Spieleein[1]= true
then
begin
form4.button11.visible := false;
form4.label14.caption := '
X';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[2]= true
then
begin
form4.button11.visible := false;
form4.label14.caption := '
O';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[3]= true
then
begin
form4.button11.visible := false;
form4.label14.caption := '
X';
SPCheck:= true;
PCcheck := false;
end;
if Spieleein[4]= true
then
begin
form4.button11.visible := false;
form4.label14.caption := '
O';
SPCheck:= true;
PCcheck := false;
end;
end;
end.