Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit UnitGame;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, StdCtrls, Vcl.Imaging.jpeg, Vcl.ExtCtrls,
- System.ImageList, Vcl.ImgList, UnitListOfPlayers, Vcl.Menus, UnitGameHelp;
- type
- TArrayHand = array [1..10] of Integer;
- TPerson = (Player, Dealer, Nobody);
- TFormGame = class(TForm)
- btStand: TButton;
- btHit: TButton;
- btSetBet: TButton;
- btRepeatBet: TButton;
- btDoubleBet: TButton;
- Label1: TLabel;
- Label2: TLabel;
- lBalance: TLabel;
- lBet: TLabel;
- rb5: TRadioButton;
- rb10: TRadioButton;
- gbForBet: TGroupBox;
- rb25: TRadioButton;
- rb100: TRadioButton;
- rb250: TRadioButton;
- rb500: TRadioButton;
- rb1000: TRadioButton;
- rb1: TRadioButton;
- pbPlayerHand: TPaintBox;
- pbDealerHand: TPaintBox;
- btResetBet: TButton;
- PlayerScore: TLabel;
- DealerScore: TLabel;
- TimerNewGame: TTimer;
- gbBalanceAndBet: TGroupBox;
- btFold: TButton;
- mmGameForm: TMainMenu;
- ItefGameHelp: TMenuItem;
- ItemBackToMenu: TMenuItem;
- procedure FormCreate(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- procedure btSetBetClick(Sender: TObject);
- procedure rb5Click(Sender: TObject);
- procedure rb10Click(Sender: TObject);
- procedure rb25Click(Sender: TObject);
- procedure rb100Click(Sender: TObject);
- procedure rb250Click(Sender: TObject);
- procedure rb500Click(Sender: TObject);
- procedure rb1000Click(Sender: TObject);
- procedure rb1Click(Sender: TObject);
- procedure btResetBetClick(Sender: TObject);
- function GetCard: Integer;
- function GetScore(const SomebodyHand: TArrayHand): Integer;
- function GetCardValue(Number: Integer): Integer;
- procedure ShowGameInterface(Visibility: Boolean);
- procedure btHitClick(Sender: TObject);
- procedure PrintScore(const SomebodyHand: TArrayHand; var PersonScore: TLabel);
- procedure btStandClick(Sender: TObject);
- procedure DealerGame;
- procedure CheckGameResult;
- procedure ShowResult(Winner: TPerson; Blackjack: Boolean);
- procedure TimerNewGameTimer(Sender: TObject);
- function CheckBust(var SomeBodyHand: TArrayHand; Person: TPerson): Boolean;
- procedure btSplitClick(Sender: TObject);
- procedure btDoubleBetClick(Sender: TObject);
- procedure btRepeatBetClick(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure FormPaint(Sender: TObject);
- procedure pbPlayerHandPaint(Sender: TObject);
- procedure pbDealerHandPaint(Sender: TObject);
- procedure btFoldClick(Sender: TObject);
- procedure ItemBackToMenuClick(Sender: TObject);
- procedure ItefGameHelpClick(Sender: TObject);
- private
- Wdth:integer;
- Hght:integer;
- procedure ClearHands;
- public
- end;
- var
- FormGame: TFormGame;
- lGameResult: TLabel;
- ArrPlayerHand : TArrayHand;
- ArrDealerHand : TArrayHand;
- LastBet : Integer;
- function cdtDraw(DC: HDC; X, Y, Card, Typ: Integer; Color: TColor):Integer; StdCall; external 'cards.dll';
- function cdtDrawExt(DC: HDC; X, Y, CardWidth, CardHeight, Card, Typ:Integer; Color:TColor):integer; StdCall; external 'cards.dll';
- function cdtInit(var Width, Height: Integer): Integer; StdCall; external 'cards.dll';
- function cdtTerm: Integer; StdCall; external 'cards.dll';
- implementation
- {$R *.dfm}
- uses UnitMainMenu;
- procedure DrawDeck;
- const
- X = 550;
- Y = 60;
- Diff = 2;
- var
- i : Integer;
- begin
- for i := 1 to 20 do
- begin
- cdtDrawExt(FormGame.Canvas.Handle, X + i * Diff, Y - i * Diff, 80, 100, 59, 1, clGray);
- end;
- end;
- procedure DrawHand(var HandPaintBox: TPaintBox; SomebodyHand: TArrayHand);
- const
- CardWidth = 80;
- CardHeght = 100;
- Border = 15;
- StartPositionY = 0;
- var
- ClearWidth, ClearHeight, StartPositionX, i, Count : Integer;
- Fon: TBitMap;
- begin
- ClearWidth := HandPaintBox.Width;
- ClearHeight := HandPaintBox.Height;
- Fon := TBitmap.Create;
- Fon.LoadFromFile('../../Картинки/FonGame.bmp');
- HandPaintBox.Canvas.Draw(0 - HandPaintBox.Left, 0 - HandPaintBox.Top, Fon);
- Fon.Free;
- Count := 0;
- for i := 1 to 10 do
- if SomebodyHand[i] <> 0 then
- Inc(Count);
- StartPositionX := (ClearWidth - Count * (CardWidth + 2 * Border - Count * 10)) div 2;
- for i := 1 to Count do
- begin
- if (HandPaintBox = FormGame.pbDealerHand) and (Count = 2) and (i = 2) then
- cdtDrawExt(HandPaintBox.Canvas.Handle, StartPositionX + (i - 1) * (CardWidth + 2 * Border - Count * 10),
- StartPositionY, CardWidth, CardHeght, 59, 1, clWhite)
- else
- cdtDrawExt(HandPaintBox.Canvas.Handle, StartPositionX + (i - 1) * (CardWidth + 2 * Border - Count * 10),
- StartPositionY, CardWidth, CardHeght, SomebodyHand[i], 0, clWhite);
- end;
- end;
- procedure TFormGame.ClearHands;
- var
- i : Integer;
- Fon: TBitmap;
- begin
- for i := 1 to 10 do
- begin
- ArrPlayerHand[i] := 0;
- ArrDealerHand[i] := 0;
- end;
- Fon := TBItmap.Create;
- Fon.LoadFromFile('../../Картинки/FonGame.bmp');
- pbPlayerHand.Canvas.Draw(0 - pbPlayerHand.Left, 0 - pbPlayerHand.Top, Fon);
- pbDealerHand.Canvas.Draw(0 - pbDealerHand.Left, 0 - pbDealerHand.Top, Fon);
- Fon.Free;
- end;
- procedure TFormGame.ShowGameInterface(Visibility: Boolean);
- begin
- btStand.Visible := Visibility;
- btHit.Visible := Visibility;
- btDoubleBet.Visible := Visibility;
- btFold.Visible := Visibility;
- if Visibility then
- begin
- btSetBet.Visible := not Visibility;
- btRepeatBet.Visible := not Visibility;
- btResetBet.Visible := not Visibility;
- gbForBet.Visible := not Visibility;
- end;
- end;
- procedure TFormGame.ShowResult(Winner: TPerson; Blackjack: Boolean);
- const
- TextHeight = 50;
- TextWidth = 400;
- begin
- lGameResult := TLabel.Create(FormGame);
- lGameResult.Parent := FormGame;
- lGameResult.AutoSize := False;
- lGameResult.Left := 0;
- lGameResult.Top := DealerScore.Top + DealerScore.Height;
- lGameResult.Height := PlayerScore.Top - (DealerScore.Top + DealerScore.Height);
- lGameResult.Width := FormGame.ClientWidth;
- lGameResult.Alignment := taCenter;
- lGameResult.Font.Size := 25;
- lGameResult.Font.Name := 'Vineta BT';
- if Winner = Player then
- if Blackjack then
- lGameResult.Caption := '$Blackjack$' + #13#10 + 'Победил ' + PlayerName +
- #13#10 + ' +' + IntToStr(StrToInt(lBet.Caption) * 5 div 2) + '$'
- else
- lGameResult.Caption := 'Победил ' + PlayerName + #13#10 +
- '+' + IntToStr(StrToInt(lBet.Caption) * 2) + '$'
- else
- if Winner = Dealer then
- if Blackjack then
- lGameResult.Caption := '$Blackjack$' + #13#10 + 'Победил дилер' +
- #13#10 + '-' + lBet.Caption + '$'
- else
- lGameResult.Caption := 'Победил дилер' +
- #13#10 + '-' + lBet.Caption + '$'
- else
- lGameResult.Caption := 'Ничья'
- end;
- procedure TFormGame.btSetBetClick(Sender: TObject);
- begin
- if StrToInt(lBet.Caption) >= MinBet then
- begin
- DrawDeck;
- LastBet := StrToInt(lBet.Caption);
- ArrPlayerHand[1] := GetCard;
- ArrDealerHand[1] := GetCard;
- ArrPlayerHand[2] := GetCard;
- ArrDealerHand[2] := GetCard;
- DrawHand(pbPlayerHand, ArrPlayerHand);
- PrintScore(ArrPlayerHand, PlayerScore);
- PrintScore(ArrDealerHand, DealerScore);
- DrawHand(pbDealerHand, ArrDealerHand);
- ShowGameInterface(True);
- end
- else
- MessageBox(Handle, PChar('Минимальная ставка ' + IntToStr(MinBet) + '$'), PChar(''), MB_ICONINFORMATION + MB_OK);
- end;
- procedure TFormGame.btSplitClick(Sender: TObject);
- begin
- MessageBox(Handle, 'На стадии разработки!', 'Не доступно', MB_ICONSTOP + MB_OK);
- end;
- procedure TFormGame.btHitClick(Sender: TObject);
- var
- Index : Integer;
- begin
- btDoubleBet.Visible := False;
- Index := 3;
- while ArrPlayerHand[Index] <> 0 do
- Inc(Index);
- ArrPlayerHand[Index] := GetCard;
- DrawHand(pbPlayerHand, ArrPlayerHand);
- PrintScore(ArrPlayerHand, PlayerScore);
- if GetScore(ArrPlayerHand) = 21 then
- DealerGame;
- if CheckBust(ArrPlayerHand, Player) then
- CheckGameResult;
- end;
- procedure TFormGame.btDoubleBetClick(Sender: TObject);
- begin
- ArrPlayerHand[3] := GetCard;
- DrawHand(pbPlayerHand, ArrPlayerHand);
- PrintScore(ArrPlayerHand, PlayerScore);
- if CheckBust(ArrPlayerHand, Player) then
- CheckGameResult
- else
- btStandClick(Sender);
- end;
- procedure TFormGame.btStandClick(Sender: TObject);
- begin
- ShowGameInterface(False);
- DealerGame;
- end;
- procedure TFormGame.btFoldClick(Sender: TObject);
- const
- MessageFold = 'Вы уверены, что хотите сдаться?' + #13#10 +
- 'Вам вернется лишь 50% от вашей ставки.';
- var
- CurPlayer: PPlayer;
- begin
- if MessageBox(Handle, MessageFold, '', MB_ICONINFORMATION + MB_YESNO) = mrYes then
- begin
- ShowGameInterface(False);
- lBalance.Caption := IntToStr(StrToInt(lBalance.Caption) +
- StrToInt(lBet.Caption) div 2);
- if FindPlayer(FirstPl, PlayerName, CurPlayer) then
- CurPlayer^.DataPl.Balance := lBalance.Caption;
- lBet.Caption := '0';
- TimerNewGame.Enabled := True;
- end;
- end;
- procedure TFormGame.TimerNewGameTimer(Sender: TObject);
- const
- MessageBankrot = 'На вышем счету недостаточно денег для продолжения игры.' +
- #13#10 + 'Вы будете перенапрвлены в главное меню!';
- begin
- ClearHands;
- btSetBet.Visible := True;
- btRepeatBet.Visible := True;
- btResetBet.Visible := True;
- gbForBet.Visible := True;
- PlayerScore.Caption := '';
- DealerScore.Caption := '';
- FreeAndNil(lGameResult);
- TimerNewGame.Enabled := False;
- if (StrToInt(lBalance.Caption) < MinBet) then
- begin
- if MessageBox(Handle, MessageBankrot, 'Вы банкрот!', MB_ICONINFORMATION + MB_OK) = mrOk then
- ItemBackToMenu.Click;
- end;
- end;
- procedure TFormGame.CheckGameResult;
- const
- BlackJack: Boolean = True;
- var
- CurPlayer: PPlayer;
- begin
- if (GetScore(ArrDealerHand) > 21) then
- begin
- ShowResult(Player, not Blackjack);
- ShowGameInterface(False);
- lBalance.Caption := IntToStr(StrToInt(lBalance.Caption) + StrToInt(lBet.Caption) * 2);
- if FindPlayer(FirstPl, PlayerName, CurPlayer) then
- begin
- CurPlayer^.DataPl.Balance := lBalance.Caption;
- if CurPlayer^.DataPl.Balance > CurPlayer^.DataPl.MaxBalance then
- begin
- CurPlayer^.DataPl.MaxBalance := CurPlayer^.DataPl.Balance;
- RatingSort(FirstPl, LastPl);
- end;
- end;
- lBet.Caption := '0';
- TimerNewGame.Enabled := True;
- end
- else
- begin
- if (GetScore(ArrPlayerHand) > 21) then
- begin
- ShowResult(Dealer, not Blackjack);
- DealerScore.Caption := IntToStr(GetScore(ArrDealerHand));
- ShowGameInterface(False);
- lBet.Caption := '0';
- TimerNewGame.Enabled := True;
- end
- else
- begin
- if (GetScore(ArrPlayerHand) > GetScore(ArrDealerHand)) then
- begin
- ShowResult(Player, not Blackjack);
- ShowGameInterface(False);
- lBalance.Caption := IntToStr(StrToInt(lBalance.Caption) + StrToInt(lBet.Caption) * 2);
- if FindPlayer(FirstPl, PlayerName, CurPlayer) then
- begin
- CurPlayer^.DataPl.Balance := lBalance.Caption;
- if CurPlayer^.DataPl.Balance > CurPlayer^.DataPl.MaxBalance then
- begin
- CurPlayer^.DataPl.MaxBalance := CurPlayer^.DataPl.Balance;
- RatingSort(FirstPl, LastPl);
- end;
- end;
- lBet.Caption := '0';
- TimerNewGame.Enabled := True;
- end;
- if (GetScore(ArrDealerHand) > GetScore(ArrPlayerHand)) then
- begin
- ShowResult(Dealer, not Blackjack);
- ShowGameInterface(False);
- lBet.Caption := '0';
- TimerNewGame.Enabled := True;
- end;
- if GetScore(ArrPlayerHand) = GetScore(ArrDealerHand) then
- begin
- ShowResult(Nobody, not BlackJack);
- ShowGameInterface(False);
- lBalance.Caption := IntToStr(StrToInt(lBalance.Caption) + StrToInt(lBet.Caption));
- lBet.Caption := '0';
- TimerNewGame.Enabled := True;
- end;
- end;
- end;
- end;
- procedure TFormGame.DealerGame;
- const
- CardWidth = 80;
- CardHeght = 100;
- Border = 15;
- StartPositionY = 0;
- var
- Index, StartPositionX : Integer;
- begin
- Index := 2;
- DealerScore.Caption:= IntToStr(GetScore(ArrDealerHand));
- while StrToInt(DealerScore.Caption) < 17 do
- begin
- Inc(Index);
- ArrDealerHand[Index] := GetCard;
- DrawHand(pbDealerHand, ArrDealerHand);
- PrintScore(ArrDealerHand, DealerScore);
- end;
- if Index = 2 then
- begin
- StartPositionX := (pbDealerHand.Width - Index * (CardWidth + 2 * Border - Index * 10)) div 2;
- cdtDrawExt(pbDealerHand.Canvas.Handle, StartPositionX + (CardWidth + 2 * Border - Index * 10),
- StartPositionY, CardWidth, CardHeght, ArrDealerHand[Index], 0, clWhite)
- end;
- CheckGameResult;
- end;
- procedure TFormGame.btRepeatBetClick(Sender: TObject);
- const
- MsgNoLastBet = 'Еще не было ставок в данном сеансе.' + #13#10 + 'Сделайте ставку вручную!';
- MsgSmallBalance = 'Текущий баланс не позволяет поставить ставку такого размера!';
- begin
- if LastBet <> 0 then
- begin
- if StrToInt(lBalance.Caption) > LastBet then
- if StrToInt(lBet.Caption) = 0 then
- begin
- lBalance.Caption := IntToStr(StrToInt(lBalance.Caption) - LastBet);
- lBet.Caption := IntToStr(LastBet);
- end
- else
- begin
- btResetBet.Click;
- lBalance.Caption := IntToStr(StrToInt(lBalance.Caption) - LastBet);
- lBet.Caption := IntToStr(LastBet);
- end
- else
- MessageBox(Handle, MsgSmallBalance, 'Внимание!', MB_ICONINFORMATION + MB_OK);
- end
- else
- MessageBox(Handle, MsgNoLastBet, 'Внимание', MB_ICONINFORMATION + MB_OK);
- end;
- procedure TFormGame.btResetBetClick(Sender: TObject);
- begin
- lBalance.Caption := IntToStr(StrToint(lBalance.Caption) + StrToInt(lBet.Caption));
- lBet.Caption := '0';
- end;
- function TFormGame.CheckBust(var SomeBodyHand: TArrayHand; Person: TPerson): Boolean;
- var
- IsBust : Boolean;
- begin
- if GetScore(SomeBodyHand) > 21 then
- IsBust := True
- else
- IsBust := False;
- CheckBust := IsBust;
- end;
- procedure TFormGame.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- Action := TCloseAction.caNone;
- ItemBackToMenu.Click;
- end;
- procedure TFormGame.FormCreate(Sender: TObject);
- begin
- cdtInit(Wdth,Hght); // Инициализируем DLL
- end;
- procedure TFormGame.FormDestroy(Sender: TObject);
- begin
- cdtTerm; // Освобождаем ресурсы
- end;
- procedure TFormGame.FormPaint(Sender: TObject);
- var
- Fon: TBitMap;
- begin
- Fon := TBitmap.Create;
- Fon.LoadFromFile('../../Картинки/FonGame.bmp');
- FormGame.Canvas.Draw(0, 0, Fon);
- Fon.Free;
- DrawDeck;
- end;
- procedure TFormGame.FormShow(Sender: TObject);
- begin
- DrawDeck;
- gbBalanceAndBet.Visible := True;
- ShowGameInterface(False);
- lBalance.Caption := Balance;
- lBet.Caption := '0';
- LastBet := 0;
- PlayerScore.Caption := '';
- DealerScore.Caption := '';
- gbForBet.Visible := True;
- btSetBet.Visible := True;
- btResetBet.Visible := True;
- btRepeatBet.Visible := True;
- end;
- function TFormGame.GetCard: Integer;
- var
- CardValue : Integer;
- IsUsed, IsFind : Boolean;
- I: Integer;
- begin
- IsFind := False;
- while not IsFind do
- begin
- CardValue := Random(51);
- IsUsed := False;
- for I := 1 to Length(ArrPlayerHand) do
- begin
- if (ArrPlayerHand[i] = CardValue) or (ArrDealerHand[i] = CardValue) then
- IsUsed := True;
- end;
- IsFind := not IsUsed;
- end;
- GetCard := CardValue;
- end;
- function TFormGame.GetCardValue(Number: Integer): Integer;
- var
- Value : Integer;
- begin
- Number := Number div 4;
- case Number of
- 0:
- Value := 11;
- 1..9:
- Value := Number + 1;
- 10..12:
- Value := 10;
- end;
- Result := Value;
- end;
- function TFormGame.GetScore(const SomebodyHand: TArrayHand): Integer;
- var
- Score, i, Count, AceAsElevenCount : Integer;
- begin
- Count := 0;
- Score := 0;
- for i := 1 to 10 do
- if SomebodyHand[i] <> 0 then
- Inc(Count);
- AceAsElevenCount := 0;
- for i := 1 to Count do
- begin
- if GetCardValue(SomebodyHand[i]) = 11 then
- begin
- if (Score + 11) <= 21 then
- begin
- Inc(AceAsElevenCount);
- Score := Score + 11;
- end
- else
- Score := Score + 1;
- end
- else
- begin
- if (Score + GetCardValue(SomebodyHand[i])) > 21 then
- begin
- Score := Score + GetCardValue(SomebodyHand[i]);
- while (Score > 21) and (AceAsElevenCount > 0) do
- begin
- Score := Score - 10;
- Dec(AceAsElevenCount);
- end;
- end
- else
- Score := Score + GetCardValue(SomebodyHand[i]);
- end;
- end;
- Result := Score;
- end;
- procedure TFormGame.ItefGameHelpClick(Sender: TObject);
- begin
- FormGameHelp.Show;
- end;
- procedure TFormGame.ItemBackToMenuClick(Sender: TObject);
- const
- UnfinishedGame = 'Партия еще не закончилась!' + #13#10
- + 'Если нажмете "Да" - вернется 50% от вашей ставки.' + #13#10
- + 'Нажмете "Нет" - партия будет продолжена';
- var
- CurPlayer: PPlayer;
- begin
- if lBet.Caption <> '0' then
- begin
- if btSetBet.Visible then
- begin
- btResetBet.Click;
- Balance := lBalance.Caption;
- if FindPlayer(FirstPl, PlayerName, CurPlayer) then
- begin
- CurPlayer^.DataPl.Balance := Balance;
- if StrToInt(CurPlayer^.DataPl.MaxBalance) < StrToInt(Balance) then
- begin
- CurPlayer^.DataPl.MaxBalance := Balance;
- RatingSort(FirstPl, LastPl);
- end;
- end;
- ClearHands;
- FormGame.Hide;
- FormMainMenu.Show;
- end
- else
- begin
- if MessageBox(Handle, UnfinishedGame, 'Выйти в главное меню?', MB_ICONSTOP + MB_YESNO) = mrYes then
- begin
- lBalance.Caption := IntToStr(StrToInt(lBalance.Caption) + StrToInt(lBet.Caption) div 2);
- Balance := lBalance.Caption;
- if FindPlayer(FirstPl, PlayerName, CurPlayer) then
- begin
- CurPlayer^.DataPl.Balance := Balance;
- if StrToInt(CurPlayer^.DataPl.MaxBalance) < StrToInt(Balance) then
- begin
- CurPlayer^.DataPl.MaxBalance := Balance;
- RatingSort(FirstPl, LastPl);
- end;
- end;
- ClearHands;
- FormGame.Hide;
- FormMainMenu.Show;
- end;
- end;
- end
- else
- begin
- Balance := lBalance.Caption;
- if FindPlayer(FirstPl, PlayerName, CurPlayer) then
- begin
- CurPlayer^.DataPl.Balance := Balance;
- if StrToInt(CurPlayer^.DataPl.MaxBalance) < StrToInt(Balance) then
- begin
- CurPlayer^.DataPl.MaxBalance := Balance;
- RatingSort(FirstPl, LastPl);
- end;
- end;
- FormGame.Hide;
- FormMainMenu.Show;
- end;
- end;
- procedure TFormGame.pbDealerHandPaint(Sender: TObject);
- begin
- DrawHand(pbDealerHand, ArrDealerHand);
- end;
- procedure TFormGame.pbPlayerHandPaint(Sender: TObject);
- begin
- DrawHand(pbPlayerHand, ArrPlayerHand);
- end;
- procedure TFormGame.PrintScore(const SomebodyHand: TArrayHand; var PersonScore: TLabel);
- var
- i, Count : Integer;
- begin
- if PersonScore = DealerScore then
- begin
- Count := 0;
- for i := 1 to 10 do
- if SomebodyHand[i] <> 0 then
- Inc(Count);
- if Count = 2 then
- PersonScore.Caption := '?'
- else
- PersonScore.Caption := IntToStr(GetScore(SomebodyHand));
- end
- else
- begin
- PersonScore.Caption := IntToStr(GetScore(SomebodyHand));
- end;
- end;
- ////////////////////////////////////////////////////////////////////////////////
- {Раздел ставок}
- procedure TFormGame.rb1000Click(Sender: TObject);
- const
- AddBet = 1000;
- begin
- if StrToInt(lBalance.Caption) >= AddBet then
- begin
- lBet.Caption := IntToStr(StrToInt(lBet.Caption) + AddBet);
- lBalance.Caption := IntToStr(StrToInt(lBalance.Caption) - AddBet);
- end;
- rb1000.Checked := False;
- end;
- procedure TFormGame.rb100Click(Sender: TObject);
- const
- AddBet = 100;
- begin
- if StrToInt(lBalance.Caption) >= AddBet then
- begin
- lBet.Caption := IntToStr(StrToInt(lBet.Caption) + AddBet);
- lBalance.Caption := IntToStr(StrToInt(lBalance.Caption) - AddBet);
- end;
- rb100.Checked := False;
- end;
- procedure TFormGame.rb10Click(Sender: TObject);
- const
- AddBet = 10;
- begin
- if StrToInt(lBalance.Caption) >= AddBet then
- begin
- lBet.Caption := IntToStr(StrToInt(lBet.Caption) + AddBet);
- lBalance.Caption := IntToStr(StrToInt(lBalance.Caption) - AddBet);
- end;
- rb10.Checked := False;
- end;
- procedure TFormGame.rb1Click(Sender: TObject);
- const
- AddBet = 1;
- begin
- if StrToInt(lBalance.Caption) >= AddBet then
- begin
- lBet.Caption := IntToStr(StrToInt(lBet.Caption) + AddBet);
- lBalance.Caption := IntToStr(StrToInt(lBalance.Caption) - AddBet);
- end;
- rb1.Checked := False;
- end;
- procedure TFormGame.rb250Click(Sender: TObject);
- const
- AddBet = 250;
- begin
- if StrToInt(lBalance.Caption) >= AddBet then
- begin
- lBet.Caption := IntToStr(StrToInt(lBet.Caption) + AddBet);
- lBalance.Caption := IntToStr(StrToInt(lBalance.Caption) - AddBet);
- end;
- rb250.Checked := False;
- end;
- procedure TFormGame.rb25Click(Sender: TObject);
- const
- AddBet = 25;
- begin
- if StrToInt(lBalance.Caption) >= AddBet then
- begin
- lBet.Caption := IntToStr(StrToInt(lBet.Caption) + AddBet);
- lBalance.Caption := IntToStr(StrToInt(lBalance.Caption) - AddBet);
- end;
- rb25.Checked := False;
- end;
- procedure TFormGame.rb500Click(Sender: TObject);
- const
- AddBet = 500;
- begin
- if StrToInt(lBalance.Caption) >= AddBet then
- begin
- lBet.Caption := IntToStr(StrToInt(lBet.Caption) + AddBet);
- lBalance.Caption := IntToStr(StrToInt(lBalance.Caption) - AddBet);
- end;
- rb500.Checked := False;
- end;
- procedure TFormGame.rb5Click(Sender: TObject);
- const
- AddBet = 5;
- begin
- if StrToInt(lBalance.Caption) >= AddBet then
- begin
- lBet.Caption := IntToStr(StrToInt(lBet.Caption) + AddBet);
- lBalance.Caption := IntToStr(StrToInt(lBalance.Caption) - AddBet);
- end;
- rb5.Checked := False;
- end;
- ////////////////////////////////////////////////////////////////////////////////
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement