Changeset 213 for trunk/UGameServer.pas
- Timestamp:
- May 24, 2018, 9:25:17 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGameServer.pas
r211 r213 6 6 7 7 uses 8 Classes, SysUtils, UGame, DOM, XMLConf, fgl, UGameProtocol ;8 Classes, SysUtils, UGame, DOM, XMLConf, fgl, UGameProtocol, UCommFrame; 9 9 10 10 type … … 15 15 TServerClient = class 16 16 private 17 FOnReceiveCmd: TCommandEvent;18 procedure ReceiveCmd(Command: TCommand; DataOut, DataIn: TStream);19 17 procedure DoTurnEnd(Sender: TObject); 18 procedure DoSurrender(Sender: TObject); 20 19 public 21 20 Game: TGame; 22 21 Protocol: TGameProtocolServer; 23 22 Player: TPlayer; 23 CommFrame: TCommFrame; 24 24 procedure DoChange; 25 procedure SendCmd(Command: TCommand; DataOut, DataIn: TStream);26 25 procedure TurnStart; 27 26 procedure GameEnd; 28 property OnReceiveCmd: TCommandEvent read FOnReceiveCmd write 29 FOnReceiveCmd; 27 procedure NextPlayer; 30 28 constructor Create; 31 29 destructor Destroy; override; … … 62 60 procedure InitClients; 63 61 procedure GameEnd; 62 procedure NextPlayer; 64 63 procedure Clear; 65 64 constructor Create; … … 94 93 end; 95 94 96 procedure TServerClient.SendCmd(Command: TCommand; DataOut, DataIn: TStream);97 begin98 99 end;100 101 95 procedure TServerClient.TurnStart; 102 96 begin … … 109 103 end; 110 104 105 procedure TServerClient.NextPlayer; 106 begin 107 Protocol.NextPlayer; 108 end; 109 111 110 constructor TServerClient.Create; 112 111 begin 112 CommFrame := TCommFrame.Create(nil); 113 113 Protocol := TGameProtocolServer.Create; 114 114 Protocol.OnTurnEnd := DoTurnEnd; 115 Protocol.OnSurrender := DoSurrender; 116 Protocol.Pin.Connect(CommFrame.FrameDataPin); 115 117 end; 116 118 … … 118 120 begin 119 121 Protocol.Free; 122 CommFrame.Free; 120 123 inherited Destroy; 121 124 end; 122 125 123 procedure TServerClient.ReceiveCmd(Command: TCommand; DataOut, DataIn: TStream);124 begin125 if Assigned(FOnReceiveCmd) then126 FOnReceiveCmd(Command, DataOut, DataIn);127 end;128 129 126 procedure TServerClient.DoTurnEnd(Sender: TObject); 130 127 begin 128 if Game.Running then Game.NextPlayer; 129 end; 130 131 procedure TServerClient.DoSurrender(Sender: TObject); 132 begin 133 Player.Surrender; 131 134 if Game.Running then Game.NextPlayer; 132 135 end; … … 249 252 end; 250 253 254 procedure TServer.NextPlayer; 255 var 256 I: Integer; 257 begin 258 for I := 0 to Clients.Count - 1 do 259 Clients[I].NextPlayer; 260 end; 261 251 262 procedure TServer.Clear; 252 263 begin
Note:
See TracChangeset
for help on using the changeset viewer.