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