Changeset 213 for trunk/UGameProtocol.pas
- Timestamp:
- May 24, 2018, 9:25:17 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGameProtocol.pas
r203 r213 6 6 7 7 uses 8 Classes, SysUtils, UGame, UVarBlockSerializer, UCommPin, SpecializedList; 8 Classes, SysUtils, UGame, UVarBlockSerializer, UCommPin, SpecializedList, 9 UCommFrame; 9 10 10 11 type 11 TCommand = (cmdTextMessage, cmdTurnStart, cmdTurnEnd, cmdGameStart, cmdGameEnd); 12 TCommand = (cmdTextMessage, cmdTurnStart, cmdTurnEnd, cmdGameStart, cmdGameEnd, 13 cmdSurrender, cmdNextPlayer); 12 14 TCommandEvent = procedure (Command: TCommand; DataIn, DataOut: TStream); 13 15 … … 22 24 FOnGameEnd: TNotifyEvent; 23 25 FOnGameStart: TNotifyEvent; 26 FOnNextPlayer: TNotifyEvent; 24 27 FOnTurnStart: TNotifyEvent; 25 28 procedure Receive(Sender: TCommPin; Stream: TListByte); … … 28 31 Pin: TCommPin; 29 32 procedure TurnEnd; 33 procedure Surrender; 30 34 procedure SendMessage(Text: string); 31 35 constructor Create; 32 36 destructor Destroy; override; 33 property OnGameStart: TNotifyEvent read FOnGameStart 34 write FOnGameStart; 35 property OnGameEnd: TNotifyEvent read FOnGameEnd 36 write FOnGameEnd; 37 property OnTurnStart: TNotifyEvent read FOnTurnStart 38 write FOnTurnStart; 37 property OnGameStart: TNotifyEvent read FOnGameStart write FOnGameStart; 38 property OnGameEnd: TNotifyEvent read FOnGameEnd write FOnGameEnd; 39 property OnTurnStart: TNotifyEvent read FOnTurnStart write FOnTurnStart; 40 property OnNextPlayer: TNotifyEvent read FOnNextPlayer write FOnNextPlayer; 39 41 end; 40 42 … … 46 48 private 47 49 FOnSendMessage: TSendMessageEvent; 50 FOnSurrender: TNotifyEvent; 48 51 FOnTurnEnd: TNotifyEvent; 52 CommFrame: TCommFrame; 49 53 procedure Receive(Sender: TCommPin; Stream: TListByte); 50 54 procedure SendCmd(Command: TCommand); … … 56 60 procedure GameEnd; 57 61 procedure TurnStart; 62 procedure NextPlayer; 58 63 property OnSendMessage: TSendMessageEvent read FOnSendMessage 59 64 write FOnSendMessage; 60 property OnTurnEnd: TNotifyEvent read FOnTurnEnd 61 write FOnTurnEnd;65 property OnTurnEnd: TNotifyEvent read FOnTurnEnd write FOnTurnEnd; 66 property OnSurrender: TNotifyEvent read FOnSurrender write FOnSurrender; 62 67 end; 63 68 … … 82 87 if Command = Integer(cmdTurnEnd) then begin 83 88 if Assigned(FOnTurnEnd) then FOnTurnEnd(Self); 89 end else 90 if Command = Integer(cmdSurrender) then begin 91 if Assigned(FOnSurrender) then FOnSurrender(Self); 84 92 end; 85 93 finally … … 133 141 end; 134 142 143 procedure TGameProtocolServer.NextPlayer; 144 begin 145 SendCmd(cmdNextPlayer); 146 end; 147 135 148 { TGameProtocol } 136 149 … … 153 166 if Command = Integer(cmdTurnStart) then begin 154 167 if Assigned(FOnTurnStart) then FOnTurnStart(Self); 168 end else 169 if Command = Integer(cmdNextPlayer) then begin 170 if Assigned(FOnNextPlayer) then FOnNextPlayer(Self); 155 171 end; 156 172 finally … … 180 196 begin 181 197 SendCmd(cmdTurnEnd); 198 end; 199 200 procedure TGameProtocolClient.Surrender; 201 begin 202 SendCmd(cmdSurrender); 182 203 end; 183 204
Note:
See TracChangeset
for help on using the changeset viewer.