Changeset 346 for trunk/Player.pas
- Timestamp:
- Dec 25, 2024, 11:04:56 AM (27 hours ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Player.pas
r344 r346 137 137 public 138 138 Game: TObject; //TGame; 139 procedure Assign(Source: TItemList<TPlayer>); override; 139 140 procedure New(Name: string; Color: TColor; Mode: TPlayerMode); 140 141 function CreateItem(Name: string = ''): TPlayer; override; … … 160 161 CountOnce: Integer; 161 162 CountRepeat: Integer; 163 procedure Assign(Source: TUnitMove); 162 164 procedure LoadFromNode(Node: TDOMNode); 163 165 procedure SaveToNode(Node: TDOMNode); … … 173 175 Game: TObject; //TGame; 174 176 Player: TPlayer; 177 procedure Assign(Source: TUnitMoves); 175 178 function SearchByFromTo(CellFrom, CellTo: TPlayerCell): TUnitMove; 176 179 procedure LoadFromNode(Node: TDOMNode); … … 416 419 begin 417 420 for I := 0 to Cells.Count - 1 do 418 with TPlayerCell(Cells[I])do begin421 with Cells[I] do begin 419 422 for J := Neighbors.Count - 1 downto 0 do 420 423 DisconnectFrom(Neighbors[J]); … … 440 443 with TPlayerCell(Cells[I]) do begin 441 444 for J := 0 to MapCell.Neighbors.Count - 1 do 442 ConnectTo(TPlayerCell( TCell(MapCell.Neighbors[J]).PlayerCell));445 ConnectTo(TPlayerCell(MapCell.Neighbors[J].PlayerCell)); 443 446 end; 444 447 end; … … 499 502 end; 500 503 504 procedure TPlayers.Assign(Source: TItemList<TPlayer>); 505 var 506 I: Integer; 507 begin 508 inherited; 509 for I := 0 to Count - 1 do 510 Items[I].Game := Game; 511 end; 512 501 513 procedure TPlayers.New(Name: string; Color: TColor; Mode: TPlayerMode); 502 begin 503 AddItem(Name); 504 Last.Color := Color; 505 Last.Mode := Mode; 514 var 515 NewPlayer: TPlayer; 516 begin 517 NewPlayer := AddItem(Name); 518 NewPlayer.Color := Color; 519 NewPlayer.Mode := Mode; 506 520 if Mode = pmComputer then 507 Last.Agressivity := caMedium;521 NewPlayer.Agressivity := caMedium; 508 522 end; 509 523 … … 583 597 { TUnitMoves } 584 598 599 procedure TUnitMoves.Assign(Source: TUnitMoves); 600 var 601 I: Integer; 602 begin 603 while Count > Source.Count do 604 Delete(Count - 1); 605 while Count < Source.Count do 606 Add(TUnitMove.Create); 607 for I := 0 to Count - 1 do begin 608 Items[I].Assign(Source.Items[I]); 609 end; 610 end; 611 585 612 function TUnitMoves.SearchByFromTo(CellFrom, CellTo: TPlayerCell): TUnitMove; 586 613 var … … 663 690 else raise Exception.Create('Unit move already exists'); 664 691 end else 692 end; 693 694 procedure TUnitMove.Assign(Source: TUnitMove); 695 begin 696 CountOnce := Source.CountOnce; 697 CountRepeat := Source.CountRepeat; 698 CellFrom.MapCell.Id := Source.CellFrom.MapCell.Id; 699 CellTo.MapCell.Id := Source.CellTo.MapCell.Id; 665 700 end; 666 701 … … 801 836 begin 802 837 inherited; 803 //Game := TPlayer(Source).Game;804 838 TotalCells := TPlayer(Source).TotalCells; 805 839 TotalUnits := TPlayer(Source).TotalUnits; … … 809 843 StartCell := TPlayer(Source).StartCell; 810 844 Color := TPlayer(Source).Color; 811 //Units.Assign(TPlayer(Source).Units); 845 Units.Assign(TPlayer(Source).Units); 846 Moves.Assign(TPlayer(Source).Moves); 812 847 Nation := TPlayer(Source).Nation; 813 848 end;
Note:
See TracChangeset
for help on using the changeset viewer.