diff --git a/form_chooseactor.pas b/form_chooseactor.pas index 98c1d4e..50aaf09 100644 --- a/form_chooseactor.pas +++ b/form_chooseactor.pas @@ -41,6 +41,8 @@ type procedure SetStyle(AValue: string); { private declarations } public + procedure ShowPoints(A, B, G : string); + procedure ShowResumeButton; property GameActor : TGameActor read FGameActor; property Style : string read FStyle write SetStyle; end; @@ -96,5 +98,10 @@ begin FStyle:=AValue; end; +procedure TFormChooseActor.ShowPoints(A, B, G: string); +begin + +end; + end. diff --git a/form_matrixgame.lfm b/form_matrixgame.lfm index a54437c..d711e70 100644 --- a/form_matrixgame.lfm +++ b/form_matrixgame.lfm @@ -248,7 +248,7 @@ object FormMatrixGame: TFormMatrixGame Height = 15 Top = 45 Width = 128 - Caption = 'Generação:' + Caption = 'Geração:' ParentColor = False end object LabelExpCountGeneration: TLabel diff --git a/units/game_actors.pas b/units/game_actors.pas index 329b70e..ce25d9c 100644 --- a/units/game_actors.pas +++ b/units/game_actors.pas @@ -160,6 +160,7 @@ type public constructor Create(AOwner:TComponent; APStyle:TPromptStyle; APTarget : TContingencies; AMessage:string);reintroduce; function ResponsesCount : integer; + function Response(I:integer):string; function AsString: TStringList; overload; procedure AppendResponse(AID,R:string); procedure Clean;override; @@ -437,6 +438,11 @@ begin Result := Length(FResponses); end; +function TPrompt.Response(I: integer): string; +begin + Result := FResponses[I] +end; + procedure TPrompt.AppendResponse(AID, R: string); begin SetLength(FResponses,Length(FResponses)+1); diff --git a/units/game_control.pas b/units/game_control.pas index a9d9d06..46cce58 100644 --- a/units/game_control.pas +++ b/units/game_control.pas @@ -11,8 +11,6 @@ unit game_control; {$mode objfpc}{$H+} -//{$DEFINE DEBUG} - interface uses @@ -43,6 +41,7 @@ type function GetSelectedRowF(AStringGrid : TStringGrid) : UTF8string; function MessageHas(const A_CONST : UTF8string; AMessage : TStringList; I:ShortInt=0): Boolean; procedure CreatePlayerBox(P:TPlayer; Me:Boolean); + procedure DeletePlayerBox(AID : string); procedure SetMatrixType(AStringGrid : TStringGrid; AMatrixType:TGameMatrixType; var ARowBase:integer; var ADrawDots, ADrawClear : Boolean); procedure ReceiveMessage(AMessage : TStringList); @@ -62,8 +61,8 @@ type function ShouldStartExperiment: Boolean; function ShouldEndCycle : Boolean; + function ShouldEndGeneration : Boolean; function ShouldAskQuestion : Boolean; - procedure KickPlayer(AID:string); procedure NextTurn(Sender: TObject); procedure NextCycle(Sender: TObject); procedure NextLineage(Sender: TObject); @@ -91,6 +90,8 @@ type function GetRowColor(ARow : integer;ARowBase:integer) : TColor; +// TODO: PUT MESSAGES IN RESOURCE STRING + const K_FULLROOM = '.Full'; K_PLAYING = '.Playing'; @@ -100,17 +101,16 @@ const K_CHOICE = '.Choice'; K_MESSAGE = '.Message'; K_START = '.Start'; - K_LEFT = '.Left'; K_RESUME = '.Resume'; K_DATA_A = '.Data'; K_LOGIN = '.Login'; - K_KICK = '.Kick'; K_QUESTION = '.Question'; K_QMESSAGE = '.QMessage'; + K_MOVQUEUE = '.Queue'; // K_STATUS = '.Status'; - K_CYCLES = '.OnEndCycle'; - + K_LEFT = '.Left'; + K_WAIT = '.Wait'; //K_RESPONSE = implementation @@ -152,14 +152,14 @@ begin Result := FExperiment.Condition[FExperiment.CurrentCondition].Turn.Count = FExperiment.Condition[FExperiment.CurrentCondition].Turn.Value-1; end; -function TGameControl.ShouldAskQuestion: Boolean; +function TGameControl.ShouldEndGeneration: Boolean; begin - Result := Assigned(FExperiment.Condition[FExperiment.CurrentCondition].Prompt) and FExperiment.Condition[FExperiment.CurrentCondition].Contingencies[3].Fired; + Result := FExperiment.Condition[FExperiment.CurrentCondition].Cycles.Count = FExperiment.Condition[FExperiment.CurrentCondition].Cycles.Value-1; end; -procedure TGameControl.KickPlayer(AID: string); +function TGameControl.ShouldAskQuestion: Boolean; begin - FZMQActor.SendMessage([K_KICK, AID]); + Result := Assigned(FExperiment.Condition[FExperiment.CurrentCondition].Prompt) and FExperiment.Condition[FExperiment.CurrentCondition].Contingencies[3].Fired; end; procedure TGameControl.NextTurn(Sender: TObject); @@ -295,6 +295,18 @@ begin end; end; +procedure TGameControl.DeletePlayerBox(AID: string); +var i : integer; +begin + for i := 0 to FormMatrixGame.GBLastChoice.ComponentCount -1 do + if FormMatrixGame.GBLastChoice.Components[i] is TPlayerBox then + if TPlayerBox(FormMatrixGame.GBLastChoice.Components[i]).ID = AID then + begin + TPlayerBox(FormMatrixGame.GBLastChoice.Components[i]).Free; + Break; + end; +end; + procedure TGameControl.SetMatrixType(AStringGrid: TStringGrid; AMatrixType: TGameMatrixType; var ARowBase: integer; var ADrawDots, ADrawClear: Boolean); @@ -437,15 +449,17 @@ procedure TGameControl.ShowConsequenceMessage(AID, S: string; ForGroup: Boolean) var LConsequence : TConsequence; begin - LConsequence := TConsequence.Create(nil,S); - LConsequence.GenerateMessage(ForGroup); - LConsequence.PresentMessage; - if ForGroup then - LConsequence.PresentPoints - else - if Self.ID = AID then - LConsequence.PresentPoints; - + if FActor = gaPlayer then + begin + LConsequence := TConsequence.Create(nil,S); + LConsequence.GenerateMessage(ForGroup); + LConsequence.PresentMessage; + if ForGroup then + LConsequence.PresentPoints + else + if Self.ID = AID then + LConsequence.PresentPoints; + end; end; procedure TGameControl.DisableConfirmationButton; @@ -629,12 +643,7 @@ procedure TGameControl.ReceiveMessage(AMessage: TStringList); begin P := FExperiment.PlayerFromString[AMessage[1]]; FExperiment.AppendPlayer(P); - if Self.ID = P.ID then - begin - CreatePlayerBox(P, True) - end - else - CreatePlayerBox(P,False); + CreatePlayerBox(P, Self.ID = P.ID) end; end; end; @@ -647,8 +656,10 @@ procedure TGameControl.ReceiveMessage(AMessage: TStringList); , ' ' , GA_PLAYER+K_QUESTION , AskQuestion(AMessage[1]) + , AMessage[2] ]); end; + end; procedure ReceiveChoice; @@ -656,7 +667,6 @@ procedure TGameControl.ReceiveMessage(AMessage: TStringList); P : TPlayer; begin P := FExperiment.PlayerFromID[AMessage[1]]; - // add last responses to player box with GetPlayerBox(P.ID) do begin @@ -722,45 +732,65 @@ procedure TGameControl.ReceiveMessage(AMessage: TStringList); end; end; - //procedure OnEndCycle; - //var - // LConsequence : TConsequence; - //begin - // case FActor of - // gaPlayer: - // begin - // LConsequence := TConsequence.Create(nil,AMessage[1]); - // LConsequence.GenerateMessage(True); - // - // LConsequence.PresentPoints; - // LConsequence.PresentMessage; - // end; - // end; - //end; - procedure ReceiveChat; begin FormMatrixGame.ChatMemoRecv.Lines.Append(('['+AMessage[1]+']: ')+AMessage[2]); end; - procedure SayGoodBye; + procedure MovePlayerQueue; + var P : TPlayer; + begin + P := FExperiment.PlayerFromString[AMessage[1]]; // new + CreatePlayerBox(P,Self.ID = P.ID); + + if FActor = gaPlayer then + begin + FExperiment.Player[FExperiment.PlayerIndexFromID[AMessage[2]]] := P; + EnablePlayerMatrix(Self.ID,0, True); + end; + end; + + procedure SayGoodBye(AID:string); begin + DeletePlayerBox(AID); // old player case FActor of gaPlayer:begin - if Self.ID <> AMessage[1] then Exit; - FormMatrixGame.Visible := False; - FormChooseActor := TFormChooseActor.Create(nil); - FormChooseActor.Style := K_LEFT; - if FormChooseActor.ShowModal = 1 then + if Self.ID = AID then begin - FZMQActor.Request([K_RESUME,Self.ID]); - FormMatrixGame.Visible := True; + // TODO: SHOW EARNED POINTS TO PARTICIPANT + //FormMatrixGame.LabelIndA.Caption; + //FormMatrixGame.LabelIndB.Caption; + //FormMatrixGame.LabelIndG.Caption; + + FormMatrixGame.Visible := False; + FormChooseActor := TFormChooseActor.Create(nil); + FormChooseActor.Style := K_LEFT; + if FormChooseActor.ShowModal = 1 then + begin + FZMQActor.Request([AID,' ',K_RESUME]); + FormMatrixGame.Visible := True; + end + else; + FormChooseActor.Free; end - else; - FormChooseActor.Free; + else + ShowPopUp('O jogador '+FExperiment.PlayerFromID[ID].Nicname+ ' saiu. Por favor, aguarde...'); end; + + gaAdmin:ShowPopUp( + 'O participante '+ + FExperiment.PlayerFromID[ID].Nicname+ + ' saiu. Aguardando a entrada do próximo participante.' + ); end; end; + procedure ResumeNextTurn; + begin + if AMessage[1] <> #32 then + SayGoodBye(AMessage[1]) + else + EnablePlayerMatrix(Self.ID,0, True); + end; procedure QuestionMessages; var @@ -771,7 +801,7 @@ procedure TGameControl.ReceiveMessage(AMessage: TStringList); gaPlayer:begin if AMessage.Count > 1 then begin - for i := 1 to AMessage.Count -1 do + for i := 2 to AMessage.Count -1 do begin MID := ExtractDelimited(1,AMessage[i],['+']); ShowConsequenceMessage(MID, ExtractDelimited(2,AMessage[i],['+']),MID = 'M'); @@ -781,36 +811,21 @@ procedure TGameControl.ReceiveMessage(AMessage: TStringList); {$ENDIF} end; end; - EnablePlayerMatrix(Self.ID,0, True); - WriteLn('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'); end; end; + ResumeNextTurn; end; - - // procedure ResumeActor; - // begin - // case FActor of - // gaPlayer:begin - // - // end; - // gaAdmin:begin - // - // end; - // end; - // end; - begin if MHas(K_ARRIVED) then ReceiveActor; if MHas(K_CHAT_M) then ReceiveChat; if MHas(K_CHOICE) then ReceiveChoice; if MHas(K_MESSAGE) then ShowConsequenceMessage(AMessage[1],AMessage[2],StrToBool(AMessage[3])); - if MHas(K_KICK) then SayGoodBye; if MHas(K_START) then NotifyPlayers; if MHas(K_QUESTION) then ShowQuestion; - if MHAS(K_RESUME) then EnablePlayerMatrix(Self.ID,0, True); - //if MHas(K_CYCLES) then OnEndCycle; + if MHas(K_MOVQUEUE) then MovePlayerQueue; if MHas(K_QMESSAGE) then QuestionMessages; + if MHas(K_RESUME) then ResumeNextTurn; end; // Here FActor is garanted to be a TZMQAdmin @@ -925,22 +940,29 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList); S := ReplaceStr(S,'$NICNAME',P.Nicname); // update turn - LEndCycle:=ShouldEndCycle; + LEndCycle := ShouldEndCycle; P.Turn := FExperiment.NextTurn; - FExperiment.Player[P.ID] := P; + FExperiment.Player[FExperiment.PlayerIndexFromID[P.ID]] := P; // append results - ARequest.Append(IntToStr(P.Turn)); - ARequest.Append(S); - if LEndCycle then + ARequest.Append(IntToStr(P.Turn)); //5 + ARequest.Append(S); //6 + if LEndCycle then // >7 = EndCycle begin + LConsequences := FExperiment.ConsequenceStringFromChoices;// AsString generates the pts result - ARequest.Append(LConsequences); + ARequest.Append(LConsequences); //7 - if ShouldAskQuestion then // TODO: prompt only when an odd row was selected - ARequest.Append(FExperiment.Condition[FExperiment.CurrentCondition].Prompt.Question) + if ShouldAskQuestion then // DONE: prompt only when an odd row was selected + ARequest.Append(FExperiment.Condition[FExperiment.CurrentCondition].Prompt.Question) //8 else - FExperiment.Clean; + begin + ARequest.Append(#32); // 8 + if Assigned(FExperiment.Condition[FExperiment.CurrentCondition].Prompt) then + FExperiment.WriteReportRowPrompt; + FExperiment.Clean; + end; + ARequest.Append(FExperiment.NextGeneration); // #32 no, else NextGeneration = PlayerToKick end; end; @@ -963,8 +985,9 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList); // generate messages LPromptConsequences := FExperiment.Condition[FExperiment.CurrentCondition].Prompt.AsString; - SetLength(M, 1+LPromptConsequences.Count); + SetLength(M, 2+LPromptConsequences.Count); M[0] := K_QMESSAGE; + M[1] := ARequest[4]; // generations if LPromptConsequences.Count > 0 then begin for i := 0 to LPromptConsequences.Count-1 do @@ -974,17 +997,37 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList); LPromptConsequences[i] := ReplaceStr(LPromptConsequences[i],'$NICNAME', P.Nicname); end; for i := 0 to LPromptConsequences.Count -1 do - M[i+1] := LPromptConsequences[i]; + M[i+2] := LPromptConsequences[i]; end else; // send identified messages; each player takes only its own message and ignore the rest FZMQActor.SendMessage(M); + FExperiment.WriteReportRowPrompt; FExperiment.Clean; end; end; + + procedure ReplyResume;// old player becomes a new player + var + P : TPlayer; + S : string; + begin + P := FExperiment.PlayerFromID[ARequest[0]]; + ARequest[2] := K_RESUME+K_ARRIVED; + if AskQuestion( + 'Um novo participante entrou no lugar do participante mais antigo. Criar um novo apelido para o novo participante?' + ) = 'S' then + P.Nicname := GenResourceName(-1); + + S := FExperiment.PlayerAsString[P]; + ARequest.Append(S); // 3 + FExperiment.NextGeneration := S; + end; + begin if MHas(K_LOGIN) then ReplyLoginRequest; + if MHas(K_RESUME) then ReplyResume; if MHas(K_CHOICE) then ValidateChoice; if MHas(K_QUESTION) then ValidateQuestionResponse; end; @@ -1074,29 +1117,23 @@ procedure TGameControl.ReceiveReply(AReply: TStringList); //Sleep(1000); end; - if AReply.Count > 8 then - FZMQActor.SendMessage([K_QUESTION,AReply[8]]) + if AReply[8] <> #32 then + FZMQActor.SendMessage([K_QUESTION,AReply[8],AReply[9]]) else - FZMQActor.SendMessage([K_RESUME]); + FZMQActor.SendMessage([K_RESUME,AReply[9]]); end; end; end; - //procedure QuestionValidated; - //begin - // // wait - //end; - - //procedure ResumePlayer; - //begin - // - //end; + procedure ResumePlayer; + begin + FZMQActor.SendMessage([K_MOVQUEUE, AReply[3],AReply[0]]); //new player,old player (self.id) + end; begin - //if MHas(K_RESUME+K_ARRIVED) then ResumePlayer; + 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; end; diff --git a/units/game_experiment.pas b/units/game_experiment.pas index 9206079..9450c74 100644 --- a/units/game_experiment.pas +++ b/units/game_experiment.pas @@ -11,8 +11,6 @@ unit game_experiment; {$mode objfpc}{$H+} -//{$DEFINE DEBUG} - interface uses @@ -34,7 +32,6 @@ type FExperimentName, FFilename, FResearcher : string; - FExperimentStart : Boolean; FGenPlayersAsNeeded : Boolean; FResearcherCanChat: Boolean; FResearcherCanPlay: Boolean; @@ -57,6 +54,7 @@ type function GetNextTurnPlayerID: UTF8string; function GetNextCycle:integer; function GetNextCondition:integer; + function GetCurrentAbsoluteCycle : integer; function GetPlayer(I : integer): TPlayer; overload; function GetPlayer(AID : UTF8string): TPlayer; overload; function AliasPlayerAsString(P: TPlayer): UTF8string; @@ -85,6 +83,7 @@ type procedure SetSendChatHistoryForNewPlayers(AValue: Boolean); procedure SetState(AValue: TExperimentState); private + FChangeGeneration: string; FOnConsequence: TNotifyEvent; FOnInterlocking: TNotifyEvent; FOnEndTurn: TNotifyEvent; @@ -93,7 +92,9 @@ type FOnEndExperiment: TNotifyEvent; FOnEndGeneration: TNotifyEvent; procedure Consequence(Sender : TObject); + function GetPlayerToKick: string; procedure Interlocking(Sender : TObject); + procedure SetPlayersQueue(AValue: string); procedure WriteReportHeader; procedure WriteReportRowNames; procedure WriteReportRow; @@ -108,6 +109,7 @@ type procedure SaveToFile; overload; procedure Clean; procedure Play; + procedure WriteReportRowPrompt; property ExperimentAim : string read FExperimentAim write FExperimentAim; property ExperimentName : string read FExperimentName write FExperimentName; property GenPlayersAsNeeded : Boolean read FGenPlayersAsNeeded write FGenPlayersAsNeeded; @@ -144,6 +146,8 @@ type property NextTurn : integer read GetNextTurn; property NextCycle : integer read GetNextCycle; property NextCondition : integer read GetNextCondition; + property NextGeneration: string read GetPlayerToKick write SetPlayersQueue; + property ChangeGeneration : string read FChangeGeneration write FChangeGeneration; // helper property State : TExperimentState read FState write SetState; public property OnEndTurn : TNotifyEvent read FOnEndTurn write SetOnEndTurn; @@ -213,6 +217,7 @@ end; function TExperiment.GetNextCycle: integer; begin Result := FConditions[CurrentCondition].Cycles.Count; + WriteReportRow; if Assigned(FOnEndCycle) then FOnEndCycle(Self); if FConditions[CurrentCondition].Cycles.Count < FConditions[CurrentCondition].Cycles.Value-1 then @@ -231,32 +236,30 @@ end; function TExperiment.GetNextCondition: integer; var - LAbsCycles : integer; LInterlocks : integer; procedure EndCondition; begin if Assigned(FOnEndCondition) then FOnEndCondition(Self); Inc(FCurrentCondition); + WriteReportRowNames; end; begin Result := CurrentCondition; - LAbsCycles := (FConditions[CurrentCondition].Cycles.Value * - FConditions[CurrentCondition].Cycles.Generation) + FConditions[CurrentCondition].Cycles.Count; // interlockings in last x cycles LInterlocks := InterlockingsIn[FConditions[CurrentCondition].EndCriterium.LastCycles]; case FConditions[CurrentCondition].EndCriterium.Value of gecWhichComeFirst: begin - if (LAbsCycles = FConditions[CurrentCondition].EndCriterium.AbsoluteCycles) or + if (GetCurrentAbsoluteCycle = FConditions[CurrentCondition].EndCriterium.AbsoluteCycles) or (LInterlocks = FConditions[CurrentCondition].EndCriterium.InterlockingPorcentage) then EndCondition; end; gecAbsoluteCycles: - if LAbsCycles = FConditions[CurrentCondition].EndCriterium.AbsoluteCycles then + if GetCurrentAbsoluteCycle = FConditions[CurrentCondition].EndCriterium.AbsoluteCycles then EndCondition; gecInterlockingPorcentage: @@ -269,6 +272,13 @@ begin {$ENDIF} end; +function TExperiment.GetCurrentAbsoluteCycle: integer; +var c:integer; +begin + c := CurrentCondition; + Result := (Condition[c].Cycles.Value*Condition[c].Cycles.Generation)+Condition[c].Cycles.Count; +end; + function TExperiment.GetPlayer(I : integer): TPlayer; begin Result := FPlayers[i]; @@ -496,6 +506,28 @@ begin if Assigned(FOnInterlocking) then FOnInterlocking(Sender); end; +procedure TExperiment.SetPlayersQueue(AValue: string); +var + i : integer; +begin + for i := 0 to PlayersCount-2 do + begin + FPlayers[i] := FPlayers[i+1]; + end; + FPlayers[High(FPlayers)] := PlayerFromString[AValue]; +end; + +function TExperiment.GetPlayerToKick: string; +var c : integer; +begin + c := CurrentCondition; + if Condition[c].Cycles.Count < Condition[c].Cycles.Value -1 then + Result := #32 + else + Result := FPlayers[0].ID; +end; + + procedure TExperiment.WriteReportHeader; var LHeader : string; @@ -511,79 +543,105 @@ end; procedure TExperiment.WriteReportRowNames; var c,j,i: integer; - LHeader : string; + LNames : string; begin c:= CurrentCondition; + // column names, line 1 - LHeader := 'Experimento'+#9+#9; + LNames := 'Experimento'+#9+#9+#9; for i:=0 to Condition[c].Turn.Value-1 do // player's response - LHeader += 'P'+IntToStr(i+1)+#9+#9; + LNames += 'P'+IntToStr(i+1)+#9+#9; for i:=0 to ContingenciesCount[c]-1 do if not Contingency[c,i].Meta then begin - LHeader += Contingency[c,i].ContingencyName; + LNames += Contingency[c,i].ContingencyName; for j:=0 to Condition[c].Turn.Value-1 do - LHeader += #9; + LNames += #9; end; - LHeader += VAL_INTERLOCKING+'s'; + LNames += VAL_INTERLOCKING+'s'; for i:=0 to ContingenciesCount[c]-1 do if Contingency[c,i].Meta then - LHeader += #9; - - LHeader += LineEnding; + LNames += #9; + if Assigned(Condition[c].Prompt) then + begin + LNames += 'Respostas à Pergunta'; + for i:=0 to Condition[c].Turn.Value-1 do + LNames += #9; + end; + LNames += LineEnding; // column names, line 2 - LHeader += 'Condição'+#9+'Ciclo'+#9; + LNames += 'Condição'+#9+'Ciclo (Absoluto)'+#9+'Ciclo (Geração)'+#9; for i:=0 to Condition[c].Turn.Value-1 do - LHeader += 'Linha'+#9+'Cor'+#9; + LNames += 'Linha'+#9+'Cor'+#9; for i:=0 to ContingenciesCount[c]-1 do if not Contingency[c,i].Meta then for j:=0 to Condition[c].Turn.Value-1 do - LHeader += 'P'+IntToStr(j+1)+#9; + LNames += 'P'+IntToStr(j+1)+#9; for i:=0 to ContingenciesCount[c]-1 do if Contingency[c,i].Meta then - LHeader += Contingency[c,i].ContingencyName+#9; - LHeader += LineEnding; + LNames += Contingency[c,i].ContingencyName+#9; - FLastReportColNames := LHeader; - FRegData.SaveData(LHeader); + if Assigned(Condition[c].Prompt) then + for i:=0 to Condition[c].Turn.Value-1 do + LNames += 'P'+IntToStr(i+1)+#9; + + if FLastReportColNames <> LNames then + begin + FLastReportColNames := LNames; + FRegData.SaveData(LNames); + end; end; procedure TExperiment.WriteReportRow; var c,j,i: integer; - LHeader : string; + LRow : string; begin c:= CurrentCondition; - LHeader := IntToStr(c+1)+#9+IntToStr(Condition[c].Cycles.Count+1)+#9; + LRow := LineEnding + IntToStr(c+1)+#9+IntToStr(GetCurrentAbsoluteCycle)+#9+IntToStr(Condition[c].Cycles.Count+1)+#9; for i:=0 to Condition[c].Turn.Value-1 do - LHeader += GetRowString(FPlayers[i].Choice.Row)+#9+GetColorString(FPlayers[i].Choice.Color)+#9; + LRow += GetRowString(FPlayers[i].Choice.Row)+#9+GetColorString(FPlayers[i].Choice.Color)+#9; for i:=0 to ContingenciesCount[c]-1 do if not Contingency[c,i].Meta then for j:=0 to Condition[c].Turn.Value-1 do if Contingency[c,i].ConsequenceFromPlayerID(FPlayers[j].ID) <> '' then - LHeader += '1'+#9 + LRow += '1'+#9 else - LHeader += '0'+#9; + LRow += '0'+#9; for i:=0 to ContingenciesCount[c]-1 do if Contingency[c,i].Meta then if Contingency[c,i].Fired then - LHeader += '1'+#9 + LRow += '1'+#9 else - LHeader += '0'+#9; - LHeader += LineEnding; + LRow += '0'+#9; - FLastReportColNames := LHeader; - FRegData.SaveData(LHeader); + FRegData.SaveData(LRow); +end; +procedure TExperiment.WriteReportRowPrompt; +var + c,i: integer; + LRow : string; +begin + c := CurrentCondition; + LRow := ''; + if Condition[c].Prompt.ResponsesCount = Condition[c].Turn.Value then + for i:=0 to Condition[c].Prompt.ResponsesCount-1 do + LRow += Condition[c].Prompt.Response(i)+#9 + else + for i:=0 to Condition[c].Turn.Value-1 do + LRow += 'NA'+#9; + + FRegData.SaveData(LRow); end; constructor TExperiment.Create(AOwner: TComponent); @@ -692,7 +750,6 @@ end; procedure TExperiment.Clean; var c,i : integer; begin - WriteReportRow; for i := 0 to PlayersCount -1 do begin FPlayers[i].Choice.Row:=grNone; @@ -717,5 +774,6 @@ begin FState:=xsRunning; end; + end. diff --git a/units/game_file_methods.pas b/units/game_file_methods.pas index 5e184d9..a35e08d 100644 --- a/units/game_file_methods.pas +++ b/units/game_file_methods.pas @@ -101,7 +101,7 @@ begin Contingencies[0].ContingencyName := 'CRF 1B'; LConcequence := TConsequence.Create(AExperiment,3,[gscPoints, gscA, gscMessage,gscBroadcastMessage],['$NICNAME','pão','pães']); Contingencies[1] := TContingency.Create(AExperiment,LConcequence,LCriteria2,False); - Contingencies[1].ContingencyName := 'CRF 1A'; + Contingencies[1].ContingencyName := 'CRF 3A'; LConcequence := TConsequence.Create(AExperiment,1,[gscPoints, gscG, gscMessage],['','item escolar','itens escolares']); Contingencies[2] := TContingency.Create(AExperiment,LConcequence,LCriteria3,True); Contingencies[2].ContingencyName := 'MCRF 1G'; diff --git a/units/game_resources.pas b/units/game_resources.pas index 6b18edd..d341c2a 100644 --- a/units/game_resources.pas +++ b/units/game_resources.pas @@ -252,16 +252,17 @@ implementation uses zhelpers; function GenResourceName(i: integer): string; +var r :integer; begin - Randomize; - if (i <= 49) and (i>=0) then - begin - if Random>0.5 then - Result := CPlayerNamesMale[i] - else - Result := CPlayerNamesFemale[i]; - end - else s_random(10); + if (i >= 0) and (i <= 49) then + r := i + else r := Random(50); + + if Random > 0.5 then + Result := CPlayerNamesMale[r] + else + Result := CPlayerNamesFemale[r]; + end; function GetColorFromCode(ACode: TGameColor): TColor; @@ -276,5 +277,9 @@ begin end; end; +initialization + + Randomize; + end. diff --git a/units/game_zmq_actors.pas b/units/game_zmq_actors.pas index 9be9919..0df0a2e 100644 --- a/units/game_zmq_actors.pas +++ b/units/game_zmq_actors.pas @@ -19,8 +19,6 @@ uses //, zmq_client ; - {$DEFINE DEBUG} - type { TZMQActor } diff --git a/units/zmq_network.pas b/units/zmq_network.pas index 6ad4959..76dbfd6 100644 --- a/units/zmq_network.pas +++ b/units/zmq_network.pas @@ -11,8 +11,6 @@ unit zmq_network; {$mode objfpc}{$H+} -//{$DEFINE DEBUG} - interface uses Classes, SysUtils, Process -- libgit2 0.21.2