diff --git a/units/game_actors.pas b/units/game_actors.pas index 19e7e80..ec5a2d0 100644 --- a/units/game_actors.pas +++ b/units/game_actors.pas @@ -56,7 +56,7 @@ type ID, Nicname, Login, - Password : UTF8string; + Password : string; Status : TGamePlayerStatus; Data : TStringList; Choice : TPlayerChoice; @@ -78,10 +78,10 @@ type TConsequence = class(TComponent) private - FAppendicePlural: UTF8String; - FAppendiceSingular: UTF8String; - FLastPresentedMessage: UTF8string; - FNicname: UTF8String; + FAppendicePlural: string; + FAppendiceSingular: string; + FLastPresentedMessage: string; + FNicname: string; FStyle : TConsequenceStyle; FP : TGamePoint; FMessage : TPopupNotifier; @@ -91,18 +91,18 @@ type procedure StopTimer(Sender:TObject;var ACloseAction:TCloseAction); procedure TimerTimer(Sender:TOBject);virtual; public - constructor Create(AOwner:TComponent; AP:TGamePoint; AStyle:TConsequenceStyle; AAppendiceSingular,AAppendicePlural:UTF8String);overload; - constructor Create(AOwner:TComponent; AP:integer; AStyle: TConsequenceStyle; AMessage:array of UTF8string);overload; - constructor Create(AOwner:TComponent; AConsequenceString: UTF8String);virtual;overload; + constructor Create(AOwner:TComponent; AP:TGamePoint; AStyle:TConsequenceStyle; AAppendiceSingular,AAppendicePlural:string);overload; + constructor Create(AOwner:TComponent; AP:integer; AStyle: TConsequenceStyle; AMessage:array of string);overload; + constructor Create(AOwner:TComponent; AConsequenceString: string);virtual;overload; destructor Destroy;override; - function AsString(AID :UTF8String): UTF8String; - function PointMessage(ForGroup: Boolean):UTF8String; + function AsString(AID :string): string; + function PointMessage(ForGroup: Boolean):string; procedure Present(ForGroup: Boolean); property ShouldPublishMessage : Boolean read GetShouldPublishMessage; - property LastPresentedMessage : UTF8string read FLastPresentedMessage; - property PlayerNicname : UTF8String read FNicname write FNicname; - property AppendiceSingular : UTF8String read FAppendiceSingular; - property AppendicePlural : UTF8String read FAppendicePlural; + property LastPresentedMessage : string read FLastPresentedMessage; + property PlayerNicname : string read FNicname write FNicname; + property AppendiceSingular : string read FAppendiceSingular; + property AppendicePlural : string read FAppendicePlural; property ConsequenseByPlayerID : TStringList read FConsequenceByPlayerID; end; @@ -119,7 +119,7 @@ type procedure CriteriaEvent; public constructor Create(AOwner:TComponent;AConsequence:TConsequence;ACriteria:TCriteria;IsMeta:Boolean);overload; - function CriteriaString : UTF8String; + function CriteriaString : string; function ResponseMeetsCriteriaI(R : TGameRow; C : TGameColor):Boolean; // Does response meets operant criteria? function ResponseMeetsCriteriaG(Players : TPlayers):Boolean; property OnCriteria : TNotifyEvent read FOnCriteria write FOncriteria; @@ -137,19 +137,19 @@ type TPrompt = class(TConsequence) private - FResponses : array of UTF8String; - FResult : UTF8String; + FResponses : array of string; + FResult : string; FPromptTargets : TContingencies; // need to test this FPromptStyle : TPromptStyle; - FPromptMessage : UTF8String; + FPromptMessage : string; procedure ClearResponses; public - constructor Create(AOwner:TComponent; APStyle:TPromptStyle; APTarget : TContingencies; AMessage:UTF8string);reintroduce; + constructor Create(AOwner:TComponent; APStyle:TPromptStyle; APTarget : TContingencies; AMessage:string);reintroduce; function ResponsesCount : integer; - procedure AppendResponse(AID,R:UTF8String); + procedure AppendResponse(AID,R:string); function AsString: TStringList; overload; - property Question: UTF8String read FPromptMessage; - property PromptResult:UTF8String read FResult; + property Question: string read FPromptMessage; + property PromptResult:string read FResult; end; @@ -229,7 +229,7 @@ begin FFired := False; end; -function TContingency.CriteriaString: UTF8String; +function TContingency.CriteriaString: string; var R : TGameRow; C : TGameColor; begin @@ -398,7 +398,7 @@ begin end; constructor TPrompt.Create(AOwner: TComponent; APStyle: TPromptStyle; - APTarget: TContingencies; AMessage: UTF8string); + APTarget: TContingencies; AMessage: string); begin inherited Create(AOwner); FPromptStyle := APStyle; @@ -411,7 +411,7 @@ begin Result := Length(FResponses); end; -procedure TPrompt.AppendResponse(AID, R: UTF8String); +procedure TPrompt.AppendResponse(AID, R: string); begin SetLength(FResponses,Length(FResponses)+1); FResponses[High(FResponses)] := AID+'|'+R+'|'; @@ -420,7 +420,7 @@ end; function TPrompt.AsString: TStringList; var j,i : integer; - LID,LConsequence : UTF8string; + LID,LConsequence : string; LCsqStyle : TConsequenceStyle; Pts : integer; @@ -437,7 +437,7 @@ var procedure ApplyPointsConditions(IsMeta:Boolean); var - S : UTF8string; + S : string; begin Pts := StrToInt(ExtractDelimited(1,LConsequence, ['|'])); if gsRevertPoints in FPromptStyle then @@ -493,7 +493,7 @@ end; { TConsequence } constructor TConsequence.Create(AOwner: TComponent; AP: TGamePoint; - AStyle: TConsequenceStyle; AAppendiceSingular, AAppendicePlural: UTF8String); + AStyle: TConsequenceStyle; AAppendiceSingular, AAppendicePlural: string); begin inherited Create(AOwner); FStyle:=AStyle; @@ -506,7 +506,7 @@ begin end; constructor TConsequence.Create(AOwner: TComponent; AP: integer; - AStyle:TConsequenceStyle; AMessage: array of UTF8string); + AStyle:TConsequenceStyle; AMessage: array of string); begin inherited Create(AOwner); FStyle:=AStyle; @@ -519,7 +519,7 @@ begin end; constructor TConsequence.Create(AOwner: TComponent; - AConsequenceString: UTF8String); + AConsequenceString: string); begin inherited Create(AOwner); FP := TGamePoint.Create(AOwner,ExtractDelimited(1,AConsequenceString,['|'])); @@ -537,7 +537,7 @@ begin inherited Destroy; end; -function TConsequence.AsString(AID: UTF8String): UTF8String; +function TConsequence.AsString(AID: string): string; begin Result := IntToStr(FP.ValueWithVariation) + '|'; Result += GetConsequenceStylesString(FStyle)+'|'; @@ -547,7 +547,7 @@ begin FConsequenceByPlayerID.Values[AID]:=Result; end; -function TConsequence.PointMessage(ForGroup: Boolean): UTF8String; +function TConsequence.PointMessage(ForGroup: Boolean): string; begin Result := FP.PointMessage(FNicname,FAppendicePlural, FAppendiceSingular,ForGroup); diff --git a/units/game_actors_point.pas b/units/game_actors_point.pas index 64ef302..4ddfb79 100644 --- a/units/game_actors_point.pas +++ b/units/game_actors_point.pas @@ -23,7 +23,7 @@ type //Cycles : integer; // specify when present points regarding condition cycles constructor Create(AOwner:TComponent;AValue : integer);overload; constructor Create(AOwner:TComponent;AValue : array of integer); overload; - constructor Create(AOwner:TComponent;AResult : UTF8String); overload; + constructor Create(AOwner:TComponent;AResult : string); overload; function PointMessage(APrepend, AAppendicePlural, AAppendiceSingular: string; IsGroupPoint: Boolean) : string; property ValueWithVariation : integer read GetValue write FValue; property Variation : integer read FVariation write FVariation; @@ -81,7 +81,7 @@ begin FVariation := AValue[1]; end; -constructor TGamePoint.Create(AOwner: TComponent; AResult: utf8string); +constructor TGamePoint.Create(AOwner: TComponent; AResult: string); begin FValue := 0;//does not matter here, this creation method is called by a player, admin sent a result FVariation := 0; @@ -99,7 +99,7 @@ begin if (AAppendiceSingular = '') or (AAppendicePlural = '') then begin - case FValue of + case FResult of -MaxInt..-2: Result += ' produziram a perda de '+Self.AsString+ ' pontos para o grupo'; -1 : Result += ' produziram a perda de 1 ponto para o grupo'; 0 : Result += ' pontos do grupo não foram produzidos nem perdidos'; @@ -109,7 +109,7 @@ begin end else begin - case FValue of + case FResult of -MaxInt..-2: Result += ' produziram a perda de '+Self.AsString+ ' ' + AAppendicePlural; -1 : Result += ' produziram a perda de 1'+ ' ' + AAppendiceSingular; 0 : Result += ' não produziram ' + AAppendicePlural; @@ -127,7 +127,7 @@ begin if (AAppendiceSingular = '') or (AAppendicePlural = '') then begin - case FValue of + case FResult of -MaxInt..-2: Result += ' perdeu '+Self.AsString+ ' pontos'; -1 : Result += ' perdeu 1 ponto'; 0 : Result += ' não perdeu nem ganhou pontos'; @@ -137,7 +137,7 @@ begin end else begin - case FValue of + case FResult of -MaxInt..-2: Result += ' perdeu '+Self.AsString+ ' ' + AAppendicePlural; -1 : Result += ' ponto 1 ' + AAppendiceSingular; 0 : Result += ' não perdeu nem ganhou ' + AAppendicePlural; diff --git a/units/game_control.pas b/units/game_control.pas index 1fc1568..4230cb6 100644 --- a/units/game_control.pas +++ b/units/game_control.pas @@ -21,18 +21,18 @@ type TGameControl = class(TComponent) private - FID: string; + FID: UTF8string; FMustDrawDots: Boolean; FMustDrawDotsClear: Boolean; FRowBase : integer; FActor : TGameActor; FZMQActor : TZMQActor; FExperiment : TExperiment; - function GetPlayerBox(AID:string) : TPlayerBox; - function GetActorNicname(AID:string) : string; + function GetPlayerBox(AID:UTF8string) : TPlayerBox; + function GetActorNicname(AID:UTF8string) : UTF8string; function GetSelectedColorF(AStringGrid : TStringGrid) : UTF8string; function GetSelectedRowF(AStringGrid : TStringGrid) : UTF8string; - function MessageHas(const A_CONST : string; AMessage : TStringList; I:ShortInt=0): Boolean; + function MessageHas(const A_CONST : UTF8string; AMessage : TStringList; I:ShortInt=0): Boolean; procedure CreatePlayerBox(P:TPlayer; Me:Boolean); procedure SetMatrixType(AStringGrid : TStringGrid; AMatrixType:TGameMatrixType; var ARowBase:integer; var ADrawDots, ADrawClear : Boolean); @@ -43,11 +43,11 @@ type procedure SetMustDrawDotsClear(AValue: Boolean); procedure SetRowBase(AValue: integer); private - function AskQuestion(AQuestion:UTF8string):UTF8String; - procedure ShowPopUp(AText:UTF8String); + function AskQuestion(AQuestion:string):UTF8string; + procedure ShowPopUp(AText:string); procedure DisableConfirmationButton; procedure CleanMatrix(AEnabled : Boolean); - procedure EnablePlayerMatrix(AID:UTF8String; ATurn:integer; AEnabled:Boolean); + procedure EnablePlayerMatrix(AID:UTF8string; ATurn:integer; AEnabled:Boolean); private function ShouldStartCycle : Boolean; function ShouldAskQuestion : Boolean; @@ -71,7 +71,7 @@ type procedure Pause; procedure Resume; property Experiment : TExperiment read FExperiment write FExperiment; - property ID : string read FID; + property ID : UTF8string read FID; property RowBase : integer read FRowBase write SetRowBase; property MustDrawDots: Boolean read FMustDrawDots write SetMustDrawDots; property MustDrawDotsClear:Boolean read FMustDrawDotsClear write SetMustDrawDotsClear; @@ -103,7 +103,7 @@ const implementation -uses ButtonPanel,Controls,ExtCtrls, +uses ButtonPanel,Controls,ExtCtrls,StdCtrls, LazUTF8, Forms, strutils, zhelpers, form_matrixgame, form_chooseactor, game_resources, string_methods ; @@ -232,7 +232,7 @@ begin end; -function TGameControl.GetPlayerBox(AID: string): TPlayerBox; +function TGameControl.GetPlayerBox(AID: UTF8string): TPlayerBox; var i : integer; begin for i := 0 to FormMatrixGame.GBLastChoice.ComponentCount-1 do @@ -243,7 +243,7 @@ begin end; end; -function TGameControl.GetActorNicname(AID: string): string; +function TGameControl.GetActorNicname(AID: UTF8string): UTF8string; begin case FActor of gaPlayer: begin @@ -256,7 +256,7 @@ begin end; end; -function TGameControl.MessageHas(const A_CONST: string; AMessage: TStringList; +function TGameControl.MessageHas(const A_CONST: UTF8string; AMessage: TStringList; I: ShortInt): Boolean; begin Result:= False; @@ -364,11 +364,11 @@ begin FRowBase:=AValue; end; -function TGameControl.AskQuestion(AQuestion: UTF8string): UTF8String; +function TGameControl.AskQuestion(AQuestion: string): UTF8string; var Prompt: TForm; ButtonPanel: TButtonPanel; - QuestionPanel: TPanel; + LabelQuestion: TLabel; mr: TModalResult; begin Prompt:=TForm.CreateNew(nil); @@ -386,10 +386,14 @@ begin ShowGlyphs:=[]; Parent:=Prompt; end; - QuestionPanel:=TPanel.Create(Prompt); - with QuestionPanel do begin + LabelQuestion:=TLabel.Create(Prompt); + with LabelQuestion do begin Align:=alClient; Caption:= AQuestion; + Alignment := taCenter; + Anchors := [akLeft,akRight]; + Layout := tlCenter; + WordWrap := True; Parent:=Prompt; end; @@ -403,7 +407,7 @@ begin end; end; -procedure TGameControl.ShowPopUp(AText: UTF8String); +procedure TGameControl.ShowPopUp(AText: string); var PopUpPos : TPoint; begin PopUpPos.X := FormMatrixGame.GBIndividualAB.Left; @@ -432,7 +436,7 @@ begin FormMatrixGame.btnConfirmRow.Visible := False; end; -procedure TGameControl.EnablePlayerMatrix(AID:UTF8String; ATurn:integer; AEnabled:Boolean); +procedure TGameControl.EnablePlayerMatrix(AID:UTF8string; ATurn:integer; AEnabled:Boolean); begin if FExperiment.PlayerFromID[AID].Turn = ATurn then CleanMatrix(AEnabled); @@ -463,12 +467,11 @@ begin FExperiment.State:=xsWaiting; FExperiment.OnEndTurn := @NextTurn; FExperiment.OnEndCycle := @NextCycle; + FExperiment.OnEndCondition:= @NextCondition; FExperiment.OnEndGeneration:=@NextLineage; + FExperiment.OnEndExperiment:= @EndExperiment; FExperiment.OnInterlocking:=@Interlocking; FExperiment.OnConsequence:=@Consequence; - FExperiment.OnEndCondition:= @NextCondition; - FExperiment.OnEndExperiment:= @EndExperiment; - FExperiment.OnInterlocking := @Interlocking; NextTurn(Self); NextCycle(Self); @@ -492,9 +495,9 @@ end; procedure TGameControl.SendRequest(ARequest: UTF8string); var - M : array of UTF8String; + M : array of UTF8string; - procedure SetM(A : array of UTF8String); + procedure SetM(A : array of UTF8string); var i : integer; begin SetLength(M,Length(A)); @@ -534,9 +537,9 @@ end; // called from outside procedure TGameControl.SendMessage(AMessage: UTF8string); var - M : array of UTF8String; + M : array of UTF8string; - procedure SetM(A : array of UTF8String); + procedure SetM(A : array of UTF8string); var i : integer; begin SetLength(M,Length(A)); @@ -582,7 +585,7 @@ end; // Here FActor is garanted to be a TZMQPlayer procedure TGameControl.ReceiveMessage(AMessage: TStringList); - function MHas(const C : string) : Boolean; + function MHas(const C : UTF8string) : Boolean; begin Result := MessageHas(C,AMessage); end; @@ -731,43 +734,43 @@ procedure TGameControl.ReceiveMessage(AMessage: TStringList); // end; - procedure QuestionMessages; - var - LConsequence : TConsequence; - i : integer; - MID : UTF8String; - begin - case FActor of - // AMessage[i] := - // S + '+' + - // IntToStr(Pts) +'|'+ - // GetConsequenceStylesString(LCsqStyle) +'|'+ - // ExtractDelimited(3,LConsequence, ['|']) +'|'+ - // ExtractDelimited(4,LConsequence, ['|']) +'|'+ - // ExtractDelimited(5,LConsequence, ['|']); - gaPlayer:begin - if AMessage.Count > 1 then - begin - for i := 1 to AMessage.Count -1 do - begin - MID := ExtractDelimited(1,AMessage[i],['+']); - if (MID = 'M') or (MID = Self.ID) then - begin - LConsequence := TConsequence.Create(FormMatrixGame,ExtractDelimited(2,AMessage[i],['+'])); - //LConsequence.PlayerNicname := P.Nicname; - ShowPopUp(LConsequence.PointMessage(MID = 'M')); - while FormMatrixGame.PopupNotifier.Visible do - Application.ProcessMessages; - - {$IFDEF DEBUG} - WriteLn('A consequence should have shown.'); - {$ENDIF} - end; - end; - end; - end; - end; - end; + //procedure QuestionMessages; + //var + // LConsequence : TConsequence; + // i : integer; + // MID : string; + //begin + // case FActor of + // // AMessage[i] := + // // S + '+' + + // // IntToStr(Pts) +'|'+ + // // GetConsequenceStylesString(LCsqStyle) +'|'+ + // // ExtractDelimited(3,LConsequence, ['|']) +'|'+ + // // ExtractDelimited(4,LConsequence, ['|']) +'|'+ + // // ExtractDelimited(5,LConsequence, ['|']); + // gaPlayer:begin + // if AMessage.Count > 1 then + // begin + // for i := 1 to AMessage.Count -1 do + // begin + // MID := ExtractDelimited(1,AMessage[i],['+']); + // if (MID = 'M') or (MID = Self.ID) then + // begin + // LConsequence := TConsequence.Create(FormMatrixGame,ExtractDelimited(2,AMessage[i],['+'])); + // //LConsequence.PlayerNicname := P.Nicname; + // ShowPopUp(LConsequence.PointMessage(MID = 'M')); + // while FormMatrixGame.PopupNotifier.Visible do + // Application.ProcessMessages; + // + // {$IFDEF DEBUG} + // WriteLn('A consequence should have shown.'); + // {$ENDIF} + // end; + // end; + // end; + // end; + // end; + //end; begin @@ -779,12 +782,12 @@ begin if MHas(K_START) then NotifyPlayers; if MHas(K_CYCLES) then OnEndCycle; if MHas(K_QUESTION) then ShowQuestion; - if MHas(K_QMESSAGE) then QuestionMessages; + //if MHas(K_QMESSAGE) then QuestionMessages; end; // Here FActor is garanted to be a TZMQAdmin procedure TGameControl.ReceiveRequest(var ARequest: TStringList); - function MHas(const C : string) : Boolean; + function MHas(const C : UTF8string) : Boolean; begin Result := MessageHas(C,ARequest, 2); end; @@ -793,7 +796,7 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList); var i : integer; P : TPlayer; TS, - PS : UTF8string; + PS : string; begin if not FExperiment.PlayerIsPlaying[ARequest[0]] then begin @@ -822,8 +825,8 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList); P.Status:=gpsPlaying; P.Choice.Color:=gcNone; P.Choice.Row:=grNone; - // turns by entrance order or by random order - P.Turn := FExperiment.NextTurn; + // first turn always by entrance order + P.Turn := i; FExperiment.Player[i] := P; end; @@ -874,6 +877,7 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList); procedure ValidateChoice; var P : TPlayer; + S : string; begin P := FExperiment.PlayerFromID[ARequest[0]]; P.Choice.Row:= GetRowFromString(ARequest[3]); // row @@ -881,7 +885,14 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList); ARequest[2] := K_CHOICE+K_ARRIVED; //individual consequences - ARequest.Append(FExperiment.ConsequenceStringFromChoice[P]); + S := FExperiment.ConsequenceStringFromChoice[P]; + {$IFDEF DEBUG} + WriteLn('ValidateChoice:',s); + {$ENDIF} + + if Pos('$NICNAME',S) > 0 then + S := ReplaceStr(S,'$NICNAME',P.Nicname); + ARequest.Append(S); // update turn P.Turn := FExperiment.NextTurn; @@ -890,57 +901,63 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList); // broadcast choice FZMQActor.SendMessage([K_CHOICE,P.ID,ARequest[3],ARequest[4],IntToStr(P.Turn)]); - if ShouldAskQuestion then // TODO: prompt only when an odd row was selected + if ShouldStartCycle then begin - P.Turn := 0; - FZMQActor.SendMessage([K_QUESTION,FExperiment.Condition[FExperiment.CurrentCondition].Prompt.Question]); - end; - end; + while FormMatrixGame.PopupNotifier.Visible do + Application.ProcessMessages; - procedure ValidateQuestionResponse; - var - P : TPlayer; - M : array of UTF8string; - i : integer; - LPromptConsequences : TStringList; - begin - P := FExperiment.PlayerFromID[ARequest[0]]; - ARequest[2] := K_QUESTION+K_ARRIVED; - - // append response of each player - FExperiment.Condition[FExperiment.CurrentCondition].Prompt.AppendResponse(P.ID,ARequest[3]); - - // return to experiment and present the prompt consequence, if any - if FExperiment.Condition[FExperiment.CurrentCondition].Prompt.ResponsesCount = Experiment.PlayersCount then - begin - // M setup - - - // generate messages - LPromptConsequences := FExperiment.Condition[FExperiment.CurrentCondition].Prompt.AsString; - if LPromptConsequences.Count > 0 then + if ShouldAskQuestion then // TODO: prompt only when an odd row was selected begin - SetLength(M, 1+LPromptConsequences.Count); - M[0] := GA_ADMIN+K_QUESTION+K_QMESSAGE; - for i := 0 to LPromptConsequences.Count -1 do - M[i+1] := LPromptConsequences[i] + P.Turn := 0; + FZMQActor.SendMessage([K_QUESTION,FExperiment.Condition[FExperiment.CurrentCondition].Prompt.Question]); end; - - // send identified messages; each player takes only its own message and ignore the rest - FZMQActor.SendMessage(M); end; end; + + //procedure ValidateQuestionResponse; + //var + // P : TPlayer; + // M : array of UTF8string; + // i : integer; + // LPromptConsequences : TStringList; + //begin + // P := FExperiment.PlayerFromID[ARequest[0]]; + // ARequest[2] := K_QUESTION+K_ARRIVED; + // + // // append response of each player + // FExperiment.Condition[FExperiment.CurrentCondition].Prompt.AppendResponse(P.ID,ARequest[3]); + // + // // return to experiment and present the prompt consequence, if any + // if FExperiment.Condition[FExperiment.CurrentCondition].Prompt.ResponsesCount = Experiment.PlayersCount then + // begin + // // M setup + // + // + // // generate messages + // LPromptConsequences := FExperiment.Condition[FExperiment.CurrentCondition].Prompt.AsString; + // if LPromptConsequences.Count > 0 then + // begin + // SetLength(M, 1+LPromptConsequences.Count); + // M[0] := GA_ADMIN+K_QUESTION+K_QMESSAGE; + // for i := 0 to LPromptConsequences.Count -1 do + // M[i+1] := LPromptConsequences[i] + // end; + // + // // send identified messages; each player takes only its own message and ignore the rest + // FZMQActor.SendMessage(M); + // end; + //end; begin if MHas(K_LOGIN) then ReplyLoginRequest; if MHas(K_CHOICE) then ValidateChoice; - if MHas(K_QUESTION) then ValidateQuestionResponse; + //if MHas(K_QUESTION) then ValidateQuestionResponse; end; // Here FActor is garanted to be a TZMQPlayer, reply by: // - sending private data to player player // - sending data from early history to income players procedure TGameControl.ReceiveReply(AReply: TStringList); - function MHas(const C : string) : Boolean; + function MHas(const C : UTF8string) : Boolean; begin Result := MessageHas(C,AReply,2); end; @@ -1004,10 +1021,11 @@ procedure TGameControl.ReceiveReply(AReply: TStringList); end; end; - procedure QuestionValidated; - begin - // wait - end; + + //procedure QuestionValidated; + //begin + // // wait + //end; procedure ResumePlayer; begin @@ -1018,7 +1036,7 @@ begin if MHas(K_RESUME+K_ARRIVED) then ResumePlayer; if MHas(K_LOGIN+K_ARRIVED) then LoginAccepted; if MHas(K_CHOICE+K_ARRIVED) then ChoiceValidated; - if MHas(K_QUESTION+K_ARRIVED) then QuestionValidated; + //if MHas(K_QUESTION+K_ARRIVED) then QuestionValidated; end; diff --git a/units/game_resources.pas b/units/game_resources.pas index 402c0eb..0a9892c 100644 --- a/units/game_resources.pas +++ b/units/game_resources.pas @@ -9,7 +9,7 @@ uses , game_actors ; -function GenResourceName(i : integer) : UTF8string; +function GenResourceName(i : integer) : string; function GetColorFromCode(ACode : TGameColor) : TColor; resourcestring @@ -83,7 +83,7 @@ const const - CPlayerNamesMale : array [0..49] of UTF8String = + CPlayerNamesMale : array [0..49] of string = ('João','Rodrigo','Francisco','Martim','Santiago', 'Tomás','Afonso','Duarte','Miguel','Guilherme','Tiago', 'Gonçalo','Diogo','Gabriel','Pedro','Rafael','Salvador', @@ -94,7 +94,7 @@ const 'Alexandre','Leandro','Filipe','Enzo','Ricardo', 'Matias','Rúben','Samuel','Bruno','Isaac','Xavier','Nuno','Carlos'); - CPlayerNamesFemale : array [0..49] of UTF8String = + CPlayerNamesFemale : array [0..49] of string = ('Maria','Matilde','Thais','Beatriz','Mariana', 'Carolina','Ana','Inês','Sofia','Margarida', 'Lara','Joana','Laura','Francisca','Diana', @@ -238,7 +238,7 @@ implementation uses zhelpers; -function GenResourceName(i: integer): UTF8string; +function GenResourceName(i: integer): string; begin Randomize; if (i <= 49) and (i>=0) then diff --git a/units/string_methods.pas b/units/string_methods.pas index 4670434..158eabc 100644 --- a/units/string_methods.pas +++ b/units/string_methods.pas @@ -12,34 +12,34 @@ uses function GetAndDelFirstValue(var S: string;Sep:Char=','):string; deprecated 'Use ExtracteDelimited from strutils instead'; -function GetRowString(ARow : TGameRow) : UTF8String; -function GetRowFromString(S : UTF8String):TGameRow; +function GetRowString(ARow : TGameRow) : string; +function GetRowFromString(S : string):TGameRow; -function GetColorString(C : TColor):UTF8String; overload; -function GetColorFromString(S : UTF8String): TColor; -function GetColorString(AColor : TGameColor) : UTF8String; overload; -function GetGameColorFromString(S : UTF8String) : TGameColor; +function GetColorString(C : TColor):string; overload; +function GetColorFromString(S : string): TColor; +function GetColorString(AColor : TGameColor) : string; overload; +function GetGameColorFromString(S : string) : TGameColor; -function GetPromptStyleFromString(S : UTF8String) : TPromptStyle; -function GetPromptStyleString(AStyle : TPromptStyle) : UTF8String; +function GetPromptStyleFromString(S : string) : TPromptStyle; +function GetPromptStyleString(AStyle : TPromptStyle) : string; -function GetConsequenceStyleFromString(s : UTF8String):TGameConsequenceStyle; -function GetConsequenceStyleString(AStyle : TGameConsequenceStyle): UTF8String; -function GetConsequenceStylesFromString(S : UTF8String):TConsequenceStyle; -function GetConsequenceStylesString(CS : TConsequenceStyle): UTF8String; +function GetConsequenceStyleFromString(s : string):TGameConsequenceStyle; +function GetConsequenceStyleString(AStyle : TGameConsequenceStyle): string; +function GetConsequenceStylesFromString(S : string):TConsequenceStyle; +function GetConsequenceStylesString(CS : TConsequenceStyle): string; -function GetCriteriaString(ACriteria : TCriteria) : UTF8String; -function GetCriteriaFromString(S : UTF8String) : TCriteria; -function GetCriteriaStyleString(AStyle: TGameStyle) : UTF8String; +function GetCriteriaString(ACriteria : TCriteria) : string; +function GetCriteriaFromString(S : string) : TCriteria; +function GetCriteriaStyleString(AStyle: TGameStyle) : string; -function GetStatusString(AStatus : TGamePlayerStatus): UTF8String; -function GetPPointsString(APPoints : TPlayerPoints) : UTF8String; -function GetChoiceString(AChoice : TPlayerChoice) : UTF8String; -function GetPointsString(APoints : TPoints) : UTF8String; -function GetEndCriteriaString(AEndCriterium:TEndConditionCriterium) : UTF8String; +function GetStatusString(AStatus : TGamePlayerStatus): string; +function GetPPointsString(APPoints : TPlayerPoints) : string; +function GetChoiceString(AChoice : TPlayerChoice) : string; +function GetPointsString(APoints : TPoints) : string; +function GetEndCriteriaString(AEndCriterium:TEndConditionCriterium) : string; -function GetPlayerFromString(s: UTF8string): TPlayer; -function GetPlayerAsString(P: TPlayer): UTF8string; +function GetPlayerFromString(s: string): TPlayer; +function GetPlayerAsString(P: TPlayer): string; implementation @@ -52,7 +52,7 @@ begin if Length(S) > 0 then while S[1] = Sep do Delete(S, 1, 1); end; -function GetRowString(ARow: TGameRow): UTF8String; +function GetRowString(ARow: TGameRow): string; begin case ARow of grNone : Result := '0'; @@ -71,7 +71,7 @@ begin end; end; -function GetRowFromString(S: UTF8String): TGameRow; +function GetRowFromString(S: string): TGameRow; begin case UpperCase(S) of 'NA', '.' , '0', 'NONE' : Result := grNone; @@ -90,7 +90,7 @@ begin end; end; -function GetColorString(AColor: TGameColor): UTF8String; +function GetColorString(AColor: TGameColor): string; begin case AColor of gcNone :Result := 'INDIFERENTE'; @@ -104,7 +104,7 @@ begin end; end; -function GetGameColorFromString(S: UTF8String): TGameColor; +function GetGameColorFromString(S: string): TGameColor; begin case UpperCase(S) of '.', 'INDIFERENTE', 'NONE' : Result := gcNone; @@ -119,7 +119,7 @@ begin end; -function GetPromptStyleFromString(S: UTF8String): TPromptStyle; +function GetPromptStyleFromString(S: string): TPromptStyle; begin // todos,sim,metacontingência,recuperar pontos, case UpperCase(S) of @@ -134,7 +134,7 @@ begin end; end; -function GetPromptStyleString(AStyle: TPromptStyle): UTF8String; +function GetPromptStyleString(AStyle: TPromptStyle): string; var Style : TGamePromptStyle; begin Result:=''; @@ -151,7 +151,7 @@ begin end; end; -function GetConsequenceStyleFromString(s: UTF8String): TGameConsequenceStyle; +function GetConsequenceStyleFromString(s: string): TGameConsequenceStyle; begin case UpperCase(S) of 'NADA': Result:= gscNone; @@ -162,7 +162,7 @@ begin end; end; -function GetConsequenceStyleString(AStyle: TGameConsequenceStyle): UTF8String; +function GetConsequenceStyleString(AStyle: TGameConsequenceStyle): string; begin case AStyle of gscNone : Result:= 'NADA'; @@ -173,7 +173,7 @@ begin end; end; -function GetCriteriaString(ACriteria: TCriteria): UTF8String; +function GetCriteriaString(ACriteria: TCriteria): string; var R : TGameRow; C : TGameColor; begin @@ -188,7 +188,7 @@ begin Result += '|'; end; -function GetCriteriaFromString(S: UTF8String): TCriteria; +function GetCriteriaFromString(S: string): TCriteria; var s1 : string; i : integer; @@ -217,7 +217,7 @@ begin else Break; end; -function GetCriteriaStyleString(AStyle: TGameStyle): UTF8String; +function GetCriteriaStyleString(AStyle: TGameStyle): string; begin case AStyle of gtNone : Result := 'INDIFERENTE'; @@ -228,7 +228,7 @@ begin end; end; -function GetColorString(C: TColor): UTF8String; +function GetColorString(C: TColor): string; begin case C of ccYellow: Result := 'Y'; @@ -239,7 +239,7 @@ begin end; end; -function GetColorFromString(S: UTF8String): TColor; +function GetColorFromString(S: string): TColor; begin case S of 'Y' : Result := ccYellow; @@ -250,7 +250,7 @@ begin end; end; -function GetConsequenceStylesFromString(S:UTF8String):TConsequenceStyle; +function GetConsequenceStylesFromString(S:string):TConsequenceStyle; var LCount, i : integer; @@ -270,7 +270,7 @@ begin end; end; -function GetConsequenceStylesString(CS: TConsequenceStyle): UTF8String; +function GetConsequenceStylesString(CS: TConsequenceStyle): string; var ConsequenceStyle : TGameConsequenceStyle; begin Result := ''; @@ -291,7 +291,7 @@ begin end; function GetEndCriteriaString(AEndCriterium: TEndConditionCriterium - ): UTF8String; + ): string; begin // 2,20,10,10, case AEndCriterium.Value of @@ -305,25 +305,25 @@ begin Result := Result + IntToStr(AEndCriterium.LastCycles) + VV_SEP; end; -function GetPointsString(APoints: TPoints): UTF8String; +function GetPointsString(APoints: TPoints): string; begin Result := IntToStr(APoints.A) + VV_SEP; Result := Result + IntToStr(APoints.B) + VV_SEP; Result := Result + IntToStr(APoints.G) + VV_SEP; end; -function GetChoiceString(AChoice: TPlayerChoice): UTF8String; +function GetChoiceString(AChoice: TPlayerChoice): string; begin Result := GetRowString(AChoice.Row) + VV_SEP; Result := Result+ GetColorString(AChoice.Color) + VV_SEP; end; -function GetPPointsString(APPoints: TPlayerPoints): UTF8String; +function GetPPointsString(APPoints: TPlayerPoints): string; begin Result := IntToStr(APPoints.A)+VV_SEP+IntToStr(APPoints.B); end; -function GetStatusString(AStatus: TGamePlayerStatus): UTF8String; +function GetStatusString(AStatus: TGamePlayerStatus): string; begin case AStatus of gpsWaiting: Result := 'esperando'; @@ -332,12 +332,12 @@ begin end; end; -function GetPlayerAsString(P: TPlayer): UTF8string; +function GetPlayerAsString(P: TPlayer): string; var i : integer; - M : array of UTF8String; + M : array of string; - procedure SetM(A : array of UTF8String); + procedure SetM(A : array of string); var i : integer; begin SetLength(M,Length(A)); @@ -407,7 +407,7 @@ begin Result += M[i] + '|'; end; -function GetPlayerFromString(s: UTF8string): TPlayer; +function GetPlayerFromString(s: string): TPlayer; function RowFromString(S: string): TGameRow; begin -- libgit2 0.21.2