Commit 58879ff1e63f90e4e1969e0b05e72e80acbce76d
1 parent
0d837c57
Exists in
master
runner: fix missing stringgrid and writereport bug
Showing
3 changed files
with
29 additions
and
7 deletions
Show diff stats
experiment_runner/form_matrixgame.pas
... | ... | @@ -339,6 +339,7 @@ begin |
339 | 339 | begin |
340 | 340 | if not FGameControl.Experiment.LoadFromFile(OpenDialog.FileName) then |
341 | 341 | Exit; |
342 | + FGameControl.SetMatrix; | |
342 | 343 | ButtonExpStart.Enabled := False; |
343 | 344 | ButtonExpStart.Caption := CAPTION_RUNNING; |
344 | 345 | ButtonExpCancel.Enabled := not ButtonExpStart.Enabled; | ... | ... |
experiment_runner/units/game_control.pas
... | ... | @@ -1100,8 +1100,10 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList); |
1100 | 1100 | if FExperiment.Player[i].ID <> P.ID then |
1101 | 1101 | begin |
1102 | 1102 | TS := FExperiment.PlayerAsString[FEXperiment.Player[i]]; |
1103 | - ARequest.Append(TS); // FROM 3 to COUNT-4 | |
1103 | + ARequest.Append(TS); // FROM 3 to COUNT-5 | |
1104 | 1104 | end; |
1105 | + // appen matrix type | |
1106 | + ARequest.Append(FExperiment.MatrixTypeAsString); // COUNT-4 | |
1105 | 1107 | |
1106 | 1108 | // append chat data if allowed |
1107 | 1109 | if FExperiment.SendChatHistoryForNewPlayers then |
... | ... | @@ -1300,13 +1302,16 @@ procedure TGameControl.ReceiveReply(AReply: TStringList); |
1300 | 1302 | begin |
1301 | 1303 | if Self.ID = AReply[0] then |
1302 | 1304 | begin |
1303 | - for i:= 3 to AReply.Count -4 do | |
1305 | + for i:= 3 to AReply.Count -5 do | |
1304 | 1306 | begin |
1305 | 1307 | P := FExperiment.PlayerFromString[AReply[i]]; |
1306 | 1308 | FExperiment.AppendPlayer(P); |
1307 | 1309 | CreatePlayerBox(P, False); |
1308 | 1310 | end; |
1309 | 1311 | |
1312 | + // set matrix type/ stringgrid | |
1313 | + FExperiment.MatrixTypeAsString:=AReply[AReply.Count-4]; | |
1314 | + | |
1310 | 1315 | // add chat |
1311 | 1316 | FormMatrixGame.ChatMemoRecv.Lines.Clear; |
1312 | 1317 | FormMatrixGame.ChatMemoRecv.Lines.Add(AReply[AReply.Count-3]); | ... | ... |
experiment_runner/units/game_experiment.pas
... | ... | @@ -103,7 +103,9 @@ type |
103 | 103 | FOnEndGeneration: TNotifyEvent; |
104 | 104 | FOnTargetInterlocking: TNotifyEvent; |
105 | 105 | procedure Consequence(Sender : TObject); |
106 | + function GetMatrixTypeAsUTF8String: UTF8String; | |
106 | 107 | procedure Interlocking(Sender : TObject); |
108 | + procedure SetMatrixTypeFromUTF8String(AValue: UTF8String); | |
107 | 109 | procedure SetOnTargetInterlocking(AValue: TNotifyEvent); |
108 | 110 | procedure TargetInterlocking(Sender : TObject); |
109 | 111 | procedure SetOnConsequence(AValue: TNotifyEvent); |
... | ... | @@ -133,6 +135,7 @@ type |
133 | 135 | property ShowChat : Boolean read FShowChat write FShowChat; |
134 | 136 | property SendChatHistoryForNewPlayers : Boolean read FSendChatHistoryForNewPlayers write SetSendChatHistoryForNewPlayers; |
135 | 137 | property MatrixType : TGameMatrixType read FMatrixType write SetMatrixType; |
138 | + property MatrixTypeAsString : UTF8String read GetMatrixTypeAsUTF8String write SetMatrixTypeFromUTF8String; | |
136 | 139 | public // manipulation/ self awareness |
137 | 140 | function AppendCondition : integer; overload; |
138 | 141 | function AppendCondition(ACondition : TCondition) : integer;overload; |
... | ... | @@ -567,6 +570,11 @@ begin |
567 | 570 | if Assigned(FOnConsequence) then FOnConsequence(Sender); |
568 | 571 | end; |
569 | 572 | |
573 | +function TExperiment.GetMatrixTypeAsUTF8String: UTF8String; | |
574 | +begin | |
575 | + Result := GetMatrixTypeString(MatrixType); | |
576 | +end; | |
577 | + | |
570 | 578 | procedure TExperiment.TargetInterlocking(Sender: TObject); |
571 | 579 | begin |
572 | 580 | if Assigned(FOnTargetInterlocking) then FOnTargetInterlocking(Sender); |
... | ... | @@ -598,6 +606,11 @@ begin |
598 | 606 | if Assigned(FOnInterlocking) then FOnInterlocking(Sender); |
599 | 607 | end; |
600 | 608 | |
609 | +procedure TExperiment.SetMatrixTypeFromUTF8String(AValue: UTF8String); | |
610 | +begin | |
611 | + MatrixType := GetMatrixTypeFromString(AValue); | |
612 | +end; | |
613 | + | |
601 | 614 | procedure TExperiment.SetOnTargetInterlocking(AValue: TNotifyEvent); |
602 | 615 | begin |
603 | 616 | if FOnTargetInterlocking=AValue then Exit; |
... | ... | @@ -719,9 +732,9 @@ var |
719 | 732 | c,i: integer; |
720 | 733 | LRow : string; |
721 | 734 | begin |
735 | + c := CurrentCondition; | |
722 | 736 | if Assigned(FRegData) and Assigned(Condition[c].Prompt) then |
723 | 737 | begin |
724 | - c := CurrentCondition; | |
725 | 738 | LRow := ''; |
726 | 739 | if Condition[c].Prompt.ResponsesCount = Condition[c].Turn.Value then |
727 | 740 | for i:=0 to Condition[c].Prompt.ResponsesCount-1 do |
... | ... | @@ -754,7 +767,7 @@ begin |
754 | 767 | end; |
755 | 768 | |
756 | 769 | constructor TExperiment.Create(AOwner: TComponent;AppPath:string); |
757 | -var LDataPath : string; | |
770 | +//var LDataPath : string; | |
758 | 771 | begin |
759 | 772 | inherited Create(AOwner); |
760 | 773 | FExperimentPath := AppPath; |
... | ... | @@ -782,9 +795,12 @@ constructor TExperiment.Create(AOwner:TComponent;AFilename,AppPath:string); |
782 | 795 | begin |
783 | 796 | inherited Create(AOwner); |
784 | 797 | FTurnsRandom := TStringList.Create; |
785 | - LoadExperimentFromFile(Self,AFilename); | |
786 | - CheckNeedForRandomTurns; | |
787 | - State := xsWaiting; | |
798 | + if LoadExperimentFromFile(Self,AFilename) then | |
799 | + begin | |
800 | + FExperimentPath := AppPath; | |
801 | + CheckNeedForRandomTurns; | |
802 | + State := xsWaiting; | |
803 | + end; | |
788 | 804 | //FReportReader := TReportReader.Create; |
789 | 805 | //FRegData := TRegData.Create(Self, AppPath+VAL_RESEARCHER+'es'+PathDelim+Researcher+PathDelim+ExperimentName+PathDelim+'000.dat'); |
790 | 806 | end; | ... | ... |