Changeset 222 for trunk/UGame.pas
- Timestamp:
- Jul 13, 2018, 11:13:12 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGame.pas
r220 r222 38 38 private 39 39 FArea: TMapArea; 40 FId: Integer; 40 41 FMap: TMap; 41 42 FPower: Integer; 42 43 procedure SetArea(AValue: TMapArea); 44 procedure SetId(AValue: Integer); 43 45 procedure SetPower(AValue: Integer); 44 46 public 45 Id: Integer;46 47 PosPx: TPoint; 47 48 Polygon: TPolygon; … … 58 59 Links: TCellLinks; 59 60 Extra: TExtraType; 61 property Id: Integer read FId write SetId; 60 62 procedure ConnectTo(Cell: TCell); 61 63 procedure DisconnectFrom(Cell: TCell); … … 226 228 procedure CreateLinks; 227 229 procedure Clear; 230 procedure CheckCells; 228 231 constructor Create; virtual; 229 232 destructor Destroy; override; … … 1688 1691 end; 1689 1692 1693 procedure TMap.CheckCells; 1694 var 1695 I: Integer; 1696 J: Integer; 1697 begin 1698 for I := 0 to Cells.Count - 1 do begin 1699 for J := I + 1 to Cells.Count - 1 do begin 1700 if (Cells[I].Id = Cells[J].Id) then 1701 raise Exception.Create('Duplicate cells ID ' + IntToStr(I) + ' ' + IntToStr(J)); 1702 if (Cells[I].PosPx = Cells[J].PosPx) then 1703 raise Exception.Create('Duplicate cells position ' + IntToStr(I) + ' ' + IntToStr(J)); 1704 end; 1705 end; 1706 end; 1707 1690 1708 constructor TMap.Create; 1691 1709 begin … … 1889 1907 FArea := AValue; 1890 1908 if Assigned(FArea) then FArea.Cells.Add(Self); 1909 end; 1910 1911 procedure TCell.SetId(AValue: Integer); 1912 begin 1913 if FId = AValue then Exit; 1914 FId := AValue; 1891 1915 end; 1892 1916 … … 2037 2061 constructor TCell.Create; 2038 2062 begin 2063 FId := -1; 2039 2064 Player := nil; 2040 2065 Neighbors := TCells.Create; … … 2451 2476 Confirm: Boolean; 2452 2477 begin 2478 if CellFrom.Player <> Self then 2479 raise Exception.Create('Can''t set move of other player.'); 2453 2480 Confirm := True; 2454 2481 Result := Moves.SearchByFromTo(CellFrom, CellTo); … … 2749 2776 I: Integer; 2750 2777 begin 2778 if AttackCount < 0 then raise Exception.Create('Attack power needs to be possitive' + IntToStr(AttackCount)); 2751 2779 if AttackCount = 0 then begin 2752 2780 Result := 0; 2753 2781 Exit; 2754 2782 end; 2783 if DefendCount < 0 then raise Exception.Create('Defend power needs to be possitive but is ' + IntToStr(DefendCount)); 2755 2784 if DefendCount = 0 then begin 2756 2785 Result := 1; … … 3187 3216 NewPlayerIndex: Integer; 3188 3217 begin 3218 {$IFDEF DEBUG} 3219 Map.CheckCells; 3220 {$ENDIF} 3221 3189 3222 // Finalize current player 3190 3223 CurrentPlayer.MoveAll;
Note:
See TracChangeset
for help on using the changeset viewer.