Changeset 447 for trunk/NoTerm.pas
- Timestamp:
- May 19, 2022, 10:39:34 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NoTerm.pas
r442 r447 18 18 procedure FormPaint(Sender: TObject); 19 19 procedure FormCreate(Sender: TObject); 20 procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);20 procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 21 21 public 22 procedure Client(Command, Player: integer; var Data);22 procedure Client(Command, Player: Integer; var Data); 23 23 private 24 24 Me: Integer; … … 43 43 procedure NewStat; 44 44 procedure EndPlaying; 45 procedure ShowActive( p: integer; Active: boolean);45 procedure ShowActive(P: Integer; Active: Boolean); 46 46 procedure ShowYear; 47 47 end; … … 50 50 NoTermDlg: TNoTermDlg; 51 51 52 procedure Client(Command, Player: integer; var Data); stdcall;52 procedure Client(Command, Player: Integer; var Data); stdcall; 53 53 54 54 … … 69 69 dxBrain = 128; 70 70 dyBrain = 128; 71 xBrain: array [0 .. nPlOffered - 1] of integer = (x0Brain, x0Brain,71 xBrain: array [0 .. nPlOffered - 1] of Integer = (x0Brain, x0Brain, 72 72 x0Brain + dxBrain, x0Brain + dxBrain, x0Brain + dxBrain, x0Brain, 73 73 x0Brain - dxBrain, x0Brain - dxBrain, x0Brain - dxBrain); 74 yBrain: array [0 .. nPlOffered - 1] of integer = (y0Brain, y0Brain - dyBrain,74 yBrain: array [0 .. nPlOffered - 1] of Integer = (y0Brain, y0Brain - dyBrain, 75 75 y0Brain - dyBrain, y0Brain, y0Brain + dyBrain, y0Brain + dyBrain, 76 76 y0Brain + dyBrain, y0Brain, y0Brain - dyBrain); 77 xActive: array [0 .. nPlOffered - 1] of integer = (0, 0, 36, 51, 36, 0,77 xActive: array [0 .. nPlOffered - 1] of Integer = (0, 0, 36, 51, 36, 0, 78 78 -36, -51, -36); 79 yActive: array [0 .. nPlOffered - 1] of integer = (0, -51, -36, 0, 36, 51,79 yActive: array [0 .. nPlOffered - 1] of Integer = (0, -51, -36, 0, 36, 51, 80 80 36, 0, -36); 81 81 82 82 var 83 FormsCreated: boolean;83 FormsCreated: Boolean; 84 84 85 85 procedure TNoTermDlg.FormCreate(Sender: TObject); … … 108 108 procedure TNoTermDlg.EndPlaying; 109 109 var 110 EndCommand: integer;110 EndCommand: Integer; 111 111 begin 112 112 NewStat; 113 if G.RO[ me].Turn > 0 then113 if G.RO[Me].Turn > 0 then 114 114 with MessgDlg do 115 115 begin … … 127 127 end; 128 128 129 procedure TNoTermDlg.ShowActive( p: integer; Active: boolean);130 begin 131 if p< nPlOffered then132 Sprite(Canvas, HGrSystem, x0Brain + 28 + xActive[ p],133 y0Brain + 28 + yActive[ p], 8, 8, 81 + 9 * Byte(Active), 16);129 procedure TNoTermDlg.ShowActive(P: Integer; Active: Boolean); 130 begin 131 if P < nPlOffered then 132 Sprite(Canvas, HGrSystem, x0Brain + 28 + xActive[P], 133 y0Brain + 28 + yActive[P], 8, 8, 81 + 9 * Byte(Active), 16); 134 134 end; 135 135 … … 138 138 Fill(State.Canvas, 0, 0, 192, 20, 64, 287 + 138); 139 139 RisedTextOut(State.Canvas, 0, 0, Format(Phrases.Lookup('AIT_ROUND'), [Round]) 140 + ' ' + TurnToString(G.RO[ me].Turn));140 + ' ' + TurnToString(G.RO[Me].Turn)); 141 141 BitBltCanvas(Canvas, 64, 287 + 138, 192, 20, State.Canvas, 0, 0); 142 142 end; 143 143 144 procedure TNoTermDlg.Client(Command, Player: integer; var Data);145 var 146 i, x, y, p: integer;147 ActiveDuration: extended;148 ShipComplete: boolean;149 r: TRect;144 procedure TNoTermDlg.Client(Command, Player: Integer; var Data); 145 var 146 I, X, Y, P: Integer; 147 ActiveDuration: Extended; 148 ShipComplete: Boolean; 149 R: TRect; 150 150 nowt: TDateTime; 151 151 begin 152 152 case Command of 153 153 cDebugMessage: 154 LogDlg.Add(Player, G.RO[0].Turn, pchar(@Data));154 LogDlg.Add(Player, G.RO[0].Turn, PChar(@Data)); 155 155 156 156 cInitModule: … … 160 160 Shade := TBitmap.Create; 161 161 Shade.SetSize(64, 64); 162 for x:= 0 to 63 do163 for y:= 0 to 63 do164 if Odd( x + y) then165 Shade.Canvas.Pixels[ x, y] := $FFFFFF162 for X := 0 to 63 do 163 for Y := 0 to 63 do 164 if Odd(X + Y) then 165 Shade.Canvas.Pixels[X, Y] := $FFFFFF 166 166 else 167 Shade.Canvas.Pixels[ x, y] := $000000;167 Shade.Canvas.Pixels[X, Y] := $000000; 168 168 State := TBitmap.Create; 169 169 State.SetSize(192, 20); … … 181 181 cNewGame, cLoadGame: 182 182 begin 183 inc(Round);183 Inc(Round); 184 184 if Mode = rmRunning then 185 185 begin … … 190 190 Show; 191 191 G := TNewGameData(Data); 192 LogDlg.mSlot.Visible := false;192 LogDlg.mSlot.Visible := False; 193 193 LogDlg.Host := nil; 194 ToldAlive := G.RO[ me].Alive;194 ToldAlive := G.RO[Me].Alive; 195 195 Active := -1; 196 196 FillChar(DisallowShowActive, SizeOf(DisallowShowActive), 0); // false … … 213 213 cTurn, cResume, cContinue: 214 214 begin 215 me := Player;215 Me := Player; 216 216 if Active >= 0 then 217 217 begin 218 ShowActive(Active, false);218 ShowActive(Active, False); 219 219 Active := -1; 220 220 end; // should not happen … … 228 228 TurnTime := SecondOf(nowt - LastNewTurn); 229 229 LastNewTurn := nowt; 230 if (G.RO[ me].Alive <> ToldAlive) then231 begin 232 for p:= 1 to nPlOffered - 1 do233 if 1 shl p and (G.RO[me].Alive xor ToldAlive) <> 0 then230 if (G.RO[Me].Alive <> ToldAlive) then 231 begin 232 for P := 1 to nPlOffered - 1 do 233 if 1 shl P and (G.RO[Me].Alive xor ToldAlive) <> 0 then 234 234 begin 235 r := Rect(xBrain[p], yBrain[p] - 16, xBrain[p] + 64,236 yBrain[ p] - 16 + 64);237 InvalidateRect(Handle, @ r, false);235 R := Rect(xBrain[P], yBrain[P] - 16, xBrain[P] + 64, 236 yBrain[P] - 16 + 64); 237 InvalidateRect(Handle, @R, False); 238 238 end; 239 ToldAlive := G.RO[ me].Alive;239 ToldAlive := G.RO[Me].Alive; 240 240 end; 241 241 Application.ProcessMessages; 242 242 if Mode = rmQuit then 243 243 EndPlaying 244 else if G.RO[ me].Happened and phGameEnd <> 0 then244 else if G.RO[Me].Happened and phGameEnd <> 0 then 245 245 begin // game ended, update statistics 246 for p:= 1 to nPlOffered - 1 do247 if Assigned(PlayersBrain[ p]) then248 if 1 shl p and G.RO[me].Alive = 0 then249 inc(ExtStat[p]) // extinct250 else if G.RO[ me].Alive = 1 shl pthen251 inc(AloneStat[p]) // only player alive246 for P := 1 to nPlOffered - 1 do 247 if Assigned(PlayersBrain[P]) then 248 if 1 shl P and G.RO[Me].Alive = 0 then 249 Inc(ExtStat[P]) // extinct 250 else if G.RO[Me].Alive = 1 shl P then 251 Inc(AloneStat[P]) // only player alive 252 252 else 253 253 begin // alive but not alone -- check colony ship 254 ShipComplete := true;255 for i:= 0 to nShipPart - 1 do256 if G.RO[ me].Ship[p].Parts[i] < ShipNeed[i] then257 ShipComplete := false;254 ShipComplete := True; 255 for I := 0 to nShipPart - 1 do 256 if G.RO[Me].Ship[P].Parts[I] < ShipNeed[I] then 257 ShipComplete := False; 258 258 if ShipComplete then 259 inc(WinStat[p]);259 Inc(WinStat[P]); 260 260 end; 261 261 if Mode = rmRunning then 262 Server(sNextRound, me, 0, nil^);262 Server(sNextRound, Me, 0, nil^); 263 263 end 264 264 else if Mode = rmRunning then 265 Server(sTurn, me, 0, nil^);265 Server(sTurn, Me, 0, nil^); 266 266 if Mode = rmStop then 267 267 begin … … 280 280 TotalStatTime := TotalStatTime + ActiveDuration; 281 281 if not DisallowShowActive[Active] then 282 ShowActive(Active, false);282 ShowActive(Active, False); 283 283 DisallowShowActive[Active] := (ActiveDuration < TurnTime * 0.25) and 284 284 (ActiveDuration < ShowActiveThreshold); … … 286 286 LastShowTurnChange := nowt; 287 287 288 Active := integer(Data);288 Active := Integer(Data); 289 289 if (Active >= 0) and not DisallowShowActive[Active] then 290 ShowActive(Active, true);290 ShowActive(Active, True); 291 291 end; 292 292 end; … … 302 302 GoBtn.ButtonIndex := 23; 303 303 GoBtn.Update; 304 Server(sTurn, me, 0, nil^);304 Server(sTurn, Me, 0, nil^); 305 305 end; 306 306 end; … … 314 314 procedure TNoTermDlg.FormPaint(Sender: TObject); 315 315 var 316 i, TimeShare: integer;316 I, TimeShare: Integer; 317 317 begin 318 318 Fill(Canvas, 3, 3, ClientWidth - 6, ClientHeight - 6, 0, 0); … … 330 330 7, Caption); 331 331 Canvas.Font.Assign(UniFont[ftSmall]); 332 for i:= 1 to nPlOffered - 1 do333 if Assigned(PlayersBrain[ i]) then332 for I := 1 to nPlOffered - 1 do 333 if Assigned(PlayersBrain[I]) then 334 334 begin 335 Frame(Canvas, xBrain[ i] - 24, yBrain[i] - 8 - 16, xBrain[i] - 24 + 111,336 yBrain[ i] - 8 - 16 + 111, MainTexture.ColorBevelShade,335 Frame(Canvas, xBrain[I] - 24, yBrain[I] - 8 - 16, xBrain[I] - 24 + 111, 336 yBrain[I] - 8 - 16 + 111, MainTexture.ColorBevelShade, 337 337 MainTexture.ColorBevelShade); 338 FrameImage(Canvas, PlayersBrain[ i].Picture, xBrain[i],339 yBrain[ i] - 16, 64, 64, 0, 0);340 if 1 shl i and G.RO[me].Alive = 0 then341 BitBltCanvas(Canvas, xBrain[ i], yBrain[i] - 16, 64, 64,338 FrameImage(Canvas, PlayersBrain[I].Picture, xBrain[I], 339 yBrain[I] - 16, 64, 64, 0, 0); 340 if 1 shl I and G.RO[Me].Alive = 0 then 341 BitBltCanvas(Canvas, xBrain[I], yBrain[I] - 16, 64, 64, 342 342 Shade.Canvas, 0, 0, SRCAND); 343 Sprite(Canvas, HGrSystem, xBrain[ i] + 30 - 14, yBrain[i] + 53, 14,343 Sprite(Canvas, HGrSystem, xBrain[I] + 30 - 14, yBrain[I] + 53, 14, 344 344 14, 1, 316); 345 RisedTextOut(Canvas, xBrain[ i] + 30 - 16 - BiColorTextWidth(Canvas,346 IntToStr(WinStat[ i])), yBrain[i] + 51, IntToStr(WinStat[i]));347 Sprite(Canvas, HGrSystem, xBrain[ i] + 34, yBrain[i] + 53, 14, 14,345 RisedTextOut(Canvas, xBrain[I] + 30 - 16 - BiColorTextWidth(Canvas, 346 IntToStr(WinStat[I])), yBrain[I] + 51, IntToStr(WinStat[I])); 347 Sprite(Canvas, HGrSystem, xBrain[I] + 34, yBrain[I] + 53, 14, 14, 348 348 1 + 15, 316); 349 RisedTextOut(Canvas, xBrain[ i] + 34 + 16, yBrain[i] + 51,350 IntToStr(AloneStat[ i]));351 Sprite(Canvas, HGrSystem, xBrain[ i] + 30 - 14, yBrain[i] + 53 + 16, 14,349 RisedTextOut(Canvas, xBrain[I] + 34 + 16, yBrain[I] + 51, 350 IntToStr(AloneStat[I])); 351 Sprite(Canvas, HGrSystem, xBrain[I] + 30 - 14, yBrain[I] + 53 + 16, 14, 352 352 14, 1 + 30, 316); 353 RisedTextOut(Canvas, xBrain[ i] + 30 - 16 - BiColorTextWidth(Canvas,354 IntToStr(ExtStat[ i])), yBrain[i] + 51 + 16, IntToStr(ExtStat[i]));355 Sprite(Canvas, HGrSystem, xBrain[ i] + 34, yBrain[i] + 53 + 16, 14, 14,353 RisedTextOut(Canvas, xBrain[I] + 30 - 16 - BiColorTextWidth(Canvas, 354 IntToStr(ExtStat[I])), yBrain[I] + 51 + 16, IntToStr(ExtStat[I])); 355 Sprite(Canvas, HGrSystem, xBrain[I] + 34, yBrain[I] + 53 + 16, 14, 14, 356 356 1 + 45, 316); 357 357 if TotalStatTime > 0 then 358 358 begin 359 TimeShare := trunc(TimeStat[ i] / TotalStatTime * 100 + 0.5);360 RisedTextOut(Canvas, xBrain[ i] + 34 + 16, yBrain[i] + 51 + 16,359 TimeShare := trunc(TimeStat[I] / TotalStatTime * 100 + 0.5); 360 RisedTextOut(Canvas, xBrain[I] + 34 + 16, yBrain[I] + 51 + 16, 361 361 IntToStr(TimeShare) + '%'); 362 362 end; 363 ShowActive( i, i= Active);363 ShowActive(I, I = Active); 364 364 end; 365 365 Sprite(Canvas, HGrSystem2, x0Brain + 32 - 20, y0Brain + 32 - 20, 40, … … 381 381 end; 382 382 383 procedure TNoTermDlg.FormKeyDown(Sender: TObject; var Key: word;383 procedure TNoTermDlg.FormKeyDown(Sender: TObject; var Key: Word; 384 384 Shift: TShiftState); 385 385 begin
Note:
See TracChangeset
for help on using the changeset viewer.