Changeset 199 for trunk/UGame.pas
- Timestamp:
- May 16, 2018, 2:48:57 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGame.pas
r198 r199 329 329 Moves: TUnitMoves; 330 330 Computer: TComputer; 331 procedure Reset; 331 332 function IsAlive: Boolean; 332 333 procedure Clear; … … 442 443 procedure CalculatePlayersDistance; 443 444 procedure PropagatePlayerDistance(List: TCells); 444 procedure InitDefaultPlayers Setting;445 procedure InitDefaultPlayers; 445 446 procedure WinObjectiveMapPrepare; 446 447 public 447 448 DevelMode: Boolean; 448 449 Players: TPlayers; 449 PlayersSetting: TPlayers;450 450 Map: TMap; 451 451 MapImageFileName: string; … … 467 467 BridgeEnabled: Boolean; 468 468 MaxPower: Integer; 469 procedure Assign(Source: TGame); 469 470 function AttackProbability(AttackCount, DefendCount: Integer): Double; 470 471 procedure LoadConfig(Config: TXmlConfig; Path: string); … … 2809 2810 end; 2810 2811 2812 procedure TPlayer.Reset; 2813 begin 2814 Moves.Clear; 2815 PlayerMap.Cells.Clear; 2816 TotalUnits := 0; 2817 TotalCells := 0; 2818 TotalCities := 0; 2819 TotalDiscovered := 0; 2820 TurnStats.Clear; 2821 StartCell := nil; 2822 end; 2823 2811 2824 function TPlayer.IsAlive: Boolean; 2812 2825 begin … … 3199 3212 end; 3200 3213 3201 procedure TGame.InitDefaultPlayers Setting;3202 begin 3203 Players Setting.Clear;3204 Players Setting.New(SPlayer + ' 1', clBlue, pmHuman);3205 Players Setting.New(SPlayer + ' 2', clRed, pmComputer);3214 procedure TGame.InitDefaultPlayers; 3215 begin 3216 Players.Clear; 3217 Players.New(SPlayer + ' 1', clBlue, pmHuman); 3218 Players.New(SPlayer + ' 2', clRed, pmComputer); 3206 3219 end; 3207 3220 … … 3226 3239 Cells.Free; 3227 3240 end; 3241 end; 3242 3243 procedure TGame.Assign(Source: TGame); 3244 begin 3245 DevelMode := Source.DevelMode; 3246 Players.Assign(Source.Players); 3247 MapType := Source.MapType; 3248 Map.Assign(Source.Map); 3249 MapImageFileName := Source.MapImageFileName; 3250 VoidEnabled := Source.VoidEnabled; 3251 VoidPercentage := Source.VoidPercentage; 3252 SymetricMap := Source.SymetricMap; 3253 GrowCells := Source.GrowCells; 3254 GrowAmount := Source.GrowAmount; 3255 CityEnabled := Source.CityEnabled; 3256 CityPercentage := Source.CityPercentage; 3257 TurnCounter := Source.TurnCounter; 3258 WinObjective := Source.WinObjective; 3259 SpecialCaptureCellCount := Source.SpecialCaptureCellCount; 3260 StayAliveForDefinedTurns := Source.StayAliveForDefinedTurns; 3261 MaxNeutralUnits := Source.MaxNeutralUnits; 3262 FileName := Source.FileName; 3263 FogOfWar := Source.FogOfWar; 3264 BridgeEnabled := Source.BridgeEnabled; 3265 MaxPower := Source.MaxPower; 3228 3266 end; 3229 3267 … … 3248 3286 SetValue(DOMString(Path + '/StayAliveForDefinedTurns'), StayAliveForDefinedTurns); 3249 3287 SetValue(DOMString(Path + '/SpecialCaptureCellCount'), SpecialCaptureCellCount); 3250 Players Setting.SaveConfig(Config, Path + '/Players');3288 Players.SaveConfig(Config, Path + '/Players'); 3251 3289 end; 3252 3290 end; … … 3282 3320 StayAliveForDefinedTurns := GetValue(DOMString(Path + '/StayAliveForDefinedTurns'), 20); 3283 3321 SpecialCaptureCellCount := GetValue(DOMString(Path + '/SpecialCaptureCellCount'), 1); 3284 Players Setting.LoadConfig(Config, Path + '/Players');3322 Players.LoadConfig(Config, Path + '/Players'); 3285 3323 end; 3286 3324 end; … … 3499 3537 Players := TPlayers.Create; 3500 3538 Players.Game := Self; 3501 PlayersSetting := TPlayers.Create;3502 PlayersSetting.Game := Self;3503 3539 3504 3540 MapImageFileName := 'Images/Maps/WorldMap.png'; 3505 3541 Randomize; 3506 InitDefaultPlayers Setting;3542 InitDefaultPlayers; 3507 3543 3508 3544 VoidEnabled := True; … … 3517 3553 destructor TGame.Destroy; 3518 3554 begin 3519 FreeAndNil(PlayersSetting);3520 3555 FreeAndNil(Players); 3521 3556 FreeAndNil(Map); … … 3524 3559 3525 3560 procedure TGame.Clear; 3526 begin 3527 Players.Clear; 3561 var 3562 I: Integer; 3563 begin 3564 for I := 0 to Players.Count - 1 do Players[I].Clear; 3528 3565 Map.Clear; 3529 3566 end; … … 3551 3588 end; 3552 3589 3553 Players.Assign(PlayersSetting);3554 3590 for Player in Players do Player.StartCell := nil; 3555 3591 I := 0;
Note:
See TracChangeset
for help on using the changeset viewer.