Changeset 364 for trunk/NoTerm.pas


Ignore:
Timestamp:
Apr 12, 2021, 11:55:20 PM (4 years ago)
Author:
chronos
Message:
  • Added: Partial network game play implementation.
  • Modified: Code cleanup.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NoTerm.pas

    r352 r364  
    99
    1010type
     11  TRunMode = (rmStop, rmStopped, rmRunning, rmQuit);
     12
    1113  TNoTermDlg = class(TDrawDlg)
    1214    QuitBtn: TButtonB;
     
    2022    procedure Client(Command, Player: integer; var Data);
    2123  private
    22     me, Active, ToldAlive, Round: integer;
    23     LastShowYearTime, LastShowTurnChange, LastNewTurn: TDateTime;
    24     TurnTime, TotalStatTime: extended;
     24    Me: Integer;
     25    Active: Integer;
     26    ToldAlive: Integer;
     27    Round: Integer;
     28    LastShowYearTime: TDateTime;
     29    LastShowTurnChange: TDateTime;
     30    LastNewTurn: TDateTime;
     31    TurnTime: Extended;
     32    TotalStatTime: Extended;
    2533    G: TNewGameData;
    2634    Server: TServerCall;
    2735    Shade: TBitmap;
    2836    State: TBitmap;
    29     WinStat, ExtStat, AloneStat: array [0 .. nPl - 1] of integer;
    30     DisallowShowActive: array [0 .. nPl - 1] of boolean;
    31     TimeStat: array [0 .. nPl - 1] of extended;
    32     Mode: (Stop, Stopped, Running, Quit);
     37    WinStat: array [0 .. nPl - 1] of Integer;
     38    ExtStat: array [0 .. nPl - 1] of Integer;
     39    AloneStat: array [0 .. nPl - 1] of Integer;
     40    DisallowShowActive: array [0 .. nPl - 1] of Boolean;
     41    TimeStat: array [0 .. nPl - 1] of Extended;
     42    Mode: TRunMode;
    3343    procedure NewStat;
    3444    procedure EndPlaying;
     
    92102  FillChar(TimeStat, SizeOf(TimeStat), 0);
    93103  TotalStatTime := 0;
    94   Mode := Stop;
     104  Mode := rmStop;
    95105end;
    96106
     
    109119        EndCommand := sResign
    110120      else
    111         EndCommand := sBreak
     121        EndCommand := sBreak;
    112122    end
    113123  else
     
    171181      begin
    172182        inc(Round);
    173         if Mode = Running then
     183        if Mode = rmRunning then
    174184        begin
    175185          Invalidate;
    176           Update
     186          Update;
    177187        end
    178188        else
     
    192202      begin
    193203        LogDlg.List.Clear;
    194         if Mode <> Running then
     204        if Mode <> rmRunning then
    195205        begin
    196206          if LogDlg.Visible then
    197207            LogDlg.Close;
    198208          Close;
    199         end
     209        end;
    200210      end;
    201211
     
    206216        begin
    207217          ShowActive(Active, false);
    208           Active := -1
     218          Active := -1;
    209219        end; // should not happen
    210220
     
    229239        end;
    230240        Application.ProcessMessages;
    231         if Mode = Quit then
     241        if Mode = rmQuit then
    232242          EndPlaying
    233243        else if G.RO[me].Happened and phGameEnd <> 0 then
     
    248258                  inc(WinStat[p]);
    249259              end;
    250           if Mode = Running then
    251             Server(sNextRound, me, 0, nil^)
     260          if Mode = rmRunning then
     261            Server(sNextRound, me, 0, nil^);
    252262        end
    253         else if Mode = Running then
     263        else if Mode = rmRunning then
    254264          Server(sTurn, me, 0, nil^);
    255         if Mode = Stop then
     265        if Mode = rmStop then
    256266        begin
    257267          GoBtn.ButtonIndex := 22;
    258           Mode := Stopped;
     268          Mode := rmStopped;
    259269        end;
    260270      end;
     
    284294procedure TNoTermDlg.GoBtnClick(Sender: TObject);
    285295begin
    286   if Mode = Running then
    287     Mode := Stop
    288   else if Mode = Stopped then
     296  if Mode = rmRunning then
     297    Mode := rmStop
     298  else if Mode = rmStopped then
    289299  begin
    290     Mode := Running;
     300    Mode := rmRunning;
    291301    GoBtn.ButtonIndex := 23;
    292302    GoBtn.Update;
     
    297307procedure TNoTermDlg.QuitBtnClick(Sender: TObject);
    298308begin
    299   if Mode = Stopped then
    300     EndPlaying
    301   else
    302     Mode := Quit;
     309  if Mode = rmStopped then EndPlaying
     310    else Mode := rmQuit;
    303311end;
    304312
     
    362370end;
    363371
    364 procedure Client;
     372procedure Client(Command, Player: integer; var Data);
    365373begin
    366374  if not FormsCreated then
     
    384392initialization
    385393
    386 FormsCreated := false;
     394FormsCreated := False;
    387395
    388396end.
Note: See TracChangeset for help on using the changeset viewer.