unit Spel4;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, jpeg, ExtCtrls;

type
  TTorrie = class(TForm)
    Image1: TImage;
    Image2: TImage;
    Image3: TImage;
    Image4: TImage;
    Image5: TImage;
    Image6: TImage;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Memo1: TMemo;
    Button4: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Torrie: TTorrie;

implementation
var
  scorecomp: integer;
  scoreplayer: integer;
  card: integer;
  win: boolean;
  loss: boolean;
{$R *.dfm}

procedure TTorrie.FormCreate(Sender: TObject);
begin
Image2.Visible := true;
Image3.Visible := false;
Image4.Visible := false;
Image5.Visible := false;
Image6.Visible := false;
scoreplayer := 0;
end;

procedure TTorrie.Button3Click(Sender: TObject);
begin
loss := false;
win := false;
if (Image6.Visible = true) then begin
Application.MessageBox('You have finished the game, enjoy the view or reset the game', 'Game is finished', mb_OK);
end
else if (scoreplayer = 0) then begin
Memo1.Lines.Clear;
Randomize;
    scorecomp:= Random(7);
    scorecomp:= scorecomp + 14;
    card:= Random(10);
    card:= card + 1;
    scoreplayer:= card;
    card:= Random(10);
    card:= card + 1;
    scoreplayer:= scoreplayer + card;
Memo1.Lines.Add('Your starting hand is ' + IntToStr(scoreplayer) + ', would you like take another card or stop?');
end
else begin
Application.MessageBox('Dont cheat, play with the cards you are dealt', 'Cheater', mb_OK);
end;
end;

procedure TTorrie.Button1Click(Sender: TObject);
begin
if (Image6.Visible = true) then begin
Application.MessageBox('You have finished the game, enjoy the view or reset the game', 'Game is finished', mb_OK);
end
else if (scoreplayer = 0) then begin
Application.MessageBox('Please hit "Deal" first', 'Error',mb_OK);
end
else begin
loss := false;
win := false;
Randomize;
  card := random (10);
  card := card + 1;
  scoreplayer := scoreplayer + card;
Memo1.Lines.Add('Your current hand is ' + IntToStr(scoreplayer) + ', would you like to take another card or stop?');
if (scoreplayer > 21) then begin
if (Image2.Visible = true) then begin
Application.MessageBox('You went over 21, and therefore, you lose, Since Torrie was already fully clothed, nothing will happen','Loss', mb_OK);
Memo1.Lines.Add('Torries score was '+IntToStr(scorecomp));
end
else begin
Application.MessageBox('You went over 21, and therefore, you lose, Torrie will put some clothes on', 'Loss', mb_OK);
Memo1.Lines.Add('Torries score was '+IntToStr(scorecomp));
end;
loss := true;
scoreplayer := 0;
end;
if ((Image3.Visible = true) and (loss = true)) then begin
Image2.Visible := true;
Image3.Visible := false;
end
else if ((Image4.Visible =true) and (loss = true)) then begin
Image3.Visible := true;
Image4.Visible := false;
end
else if ((Image5.Visible = true) and (loss = true)) then begin
Image4.Visible := true;
Image5.Visible := false;
end;
end;
end;

procedure TTorrie.Button2Click(Sender: TObject);
begin
if (Image6.Visible = true) then begin
Application.MessageBox('You have finished the game, enjoy the view or reset the game', 'Game is finished', mb_OK);
end
else if (scoreplayer = 0) then begin
Application.MessageBox('Please hit "Deal" first', 'Error', mb_OK);
end
else begin
loss:= false;
win := false;
if (scoreplayer > scorecomp) then begin
Application.MessageBox('Congratulations, you beat Torrie, lets get ready to strip', 'WIn', mb_ok);
Memo1.Lines.Add('Torries score was ' + IntToStr(scorecomp));
win := true;
end
else if (scoreplayer < scorecomp) then begin
if (Image2.Visible = true) then begin
Application.MessageBox('Too bad, Torrie had a higher score, since she was already fully clothed, nothing will happen', 'Loss', mb_OK);
Memo1.Lines.Add('Torries score was '+IntToStr(scorecomp));
end
else begin
Application.MessageBox('Too bad, Torrie had a higher score than you, she will put some more clothes on', 'Loss', mb_ok);
Memo1.Lines.Add('Torries score was '+IntToStr(scorecomp));
loss := true;
end;
end
else if (scoreplayer = scorecomp) then begin
Application.messagebox('You and Torrie had a draw, nothing happens', 'Draw', mb_OK);
Memo1.Lines.Add('Torries score was ' +IntToStr(scorecomp));
end;
if ((Image2.Visible = true) and (win = true)) then begin
Image3.Visible:= true;
Image2.Visible:= false;
end
else if ((Image3.Visible = true) and (win = true)) then begin
Image4.Visible := true;
Image3.Visible := false;
end
else if ((Image3.Visible = true) and (loss = true)) then begin
Image2.Visible := true;
Image3.Visible := false;
end
else if ((Image4.Visible = true) and (win = true)) then begin
Image5.Visible := true;
Image4.Visible := false;
end
else if ((Image4.Visible = true) and (loss = true)) then begin
Image3.Visible := true;
Image4.Visible := false;
end
else if ((Image5.Visible = true) and (win = true)) then begin
Application.MessageBox('You have unlocked the last level of Torrie Wilson, the game is finished', 'You is winner', mb_OK);
Image6.Visible := true;
Image5.Visible := false;
end
else if ((Image5.Visible = true) and (loss = true)) then begin
Image4.Visible := true;
Image5.Visible := false;
end;
end;
scoreplayer := 0;
end;
procedure TTorrie.Button4Click(Sender: TObject);
begin
if Application.MessageBox('Do you want to reset the game?', 'Reset', mb_YesNo) = IDYes then
  if Application.MessageBox('This means Torrie will put all her clothes back on. Are you really, really sure you want to reset?' , 'Really?', mb_YesNo) = IDYes then
    begin
    Image2.Visible:= true;
    Image3.Visible:= false;
    Image4.Visible:= false;
    Image5.Visible:= false;
    Image6.Visible:= false;
    scoreplayer := 0;
    end
   else begin
   end
else begin
end;
end;

end.
