Changeset 197 for trunk/UCore.pas


Ignore:
Timestamp:
May 16, 2018, 11:03:48 AM (6 years ago)
Author:
chronos
Message:
  • Added: Evaluate win objection to stay alive for defined number of turns. Multiple players can win.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r196 r197  
    116116resourcestring
    117117  SPlayerWins = 'Player %s wins';
     118  SPlayersWins = 'Players %s win';
    118119  SEndGame = 'End game?';
    119120  SEndGameQuestion = 'Do you want to end current game?';
     
    127128
    128129procedure TCore.DoOnWin(Player: TPlayer);
     130var
     131  PlayerNames: string;
     132  AlivePlayers: TPlayerArray;
     133  I: Integer;
    129134begin
    130135  RedrawClients;
    131   ShowMessage(Format(SPlayerWins, [Player.Name]));
     136  if Assigned(Player) then
     137    ShowMessage(Format(SPlayerWins, [Player.Name]))
     138  else begin
     139    AlivePlayers := Game.Players.GetAlivePlayers;
     140    PlayerNames := '';
     141    for I := 0 to Length(AlivePlayers) - 1 do begin
     142      if I > 0 then PlayerNames := PlayerNames + ', ';
     143      PlayerNames := PlayerNames + AlivePlayers[I].Name;
     144    end;
     145    ShowMessage(Format(SPlayersWins, [PlayerNames]))
     146  end;
    132147end;
    133148
     
    407422  FreeAndNil(StoredDimension);
    408423  FreeAndNil(Server);
     424  FreeAndNil(Clients);
    409425  FreeAndNil(Game);
    410   FreeAndNil(Clients);
    411426end;
    412427
Note: See TracChangeset for help on using the changeset viewer.