Commit 5111a7e7f16ea8fb4385e0da0e9b7dc16835b3d2

Authored by Carlos Picanco
1 parent 226750d3
Exists in master

cleaning, simple loading gui and dump

cultural_matrix.lpi
@@ -47,18 +47,15 @@ @@ -47,18 +47,15 @@
47 <FormatVersion Value="1"/> 47 <FormatVersion Value="1"/>
48 </local> 48 </local>
49 </RunParams> 49 </RunParams>
50 - <RequiredPackages Count="3"> 50 + <RequiredPackages Count="2">
51 <Item1> 51 <Item1>
52 <PackageName Value="FCL"/> 52 <PackageName Value="FCL"/>
53 </Item1> 53 </Item1>
54 <Item2> 54 <Item2>
55 - <PackageName Value="SQLDBLaz"/>  
56 - </Item2>  
57 - <Item3>  
58 <PackageName Value="LCL"/> 55 <PackageName Value="LCL"/>
59 - </Item3> 56 + </Item2>
60 </RequiredPackages> 57 </RequiredPackages>
61 - <Units Count="17"> 58 + <Units Count="14">
62 <Unit0> 59 <Unit0>
63 <Filename Value="cultural_matrix.lpr"/> 60 <Filename Value="cultural_matrix.lpr"/>
64 <IsPartOfProject Value="True"/> 61 <IsPartOfProject Value="True"/>
@@ -71,71 +68,55 @@ @@ -71,71 +68,55 @@
71 <ResourceBaseClass Value="Form"/> 68 <ResourceBaseClass Value="Form"/>
72 </Unit1> 69 </Unit1>
73 <Unit2> 70 <Unit2>
74 - <Filename Value="datamodule.pas"/> 71 + <Filename Value="README.md"/>
75 <IsPartOfProject Value="True"/> 72 <IsPartOfProject Value="True"/>
76 - <ComponentName Value="DataModule1"/>  
77 - <HasResources Value="True"/>  
78 - <ResourceBaseClass Value="DataModule"/>  
79 </Unit2> 73 </Unit2>
80 <Unit3> 74 <Unit3>
81 - <Filename Value="README.md"/> 75 + <Filename Value="units/zmq_network.pas"/>
82 <IsPartOfProject Value="True"/> 76 <IsPartOfProject Value="True"/>
83 </Unit3> 77 </Unit3>
84 <Unit4> 78 <Unit4>
85 - <Filename Value="units/zmq_network.pas"/> 79 + <Filename Value="units/game_zmq_actors.pas"/>
86 <IsPartOfProject Value="True"/> 80 <IsPartOfProject Value="True"/>
87 </Unit4> 81 </Unit4>
88 <Unit5> 82 <Unit5>
89 - <Filename Value="units/game_zmq_actors.pas"/> 83 + <Filename Value="units/game_actors.pas"/>
90 <IsPartOfProject Value="True"/> 84 <IsPartOfProject Value="True"/>
91 </Unit5> 85 </Unit5>
92 <Unit6> 86 <Unit6>
93 - <Filename Value="units/game_actors.pas"/> 87 + <Filename Value="units/game_experiment.pas"/>
94 <IsPartOfProject Value="True"/> 88 <IsPartOfProject Value="True"/>
95 </Unit6> 89 </Unit6>
96 <Unit7> 90 <Unit7>
97 - <Filename Value="form_chooseactor.pas"/> 91 + <Filename Value="units/game_file_methods.pas"/>
98 <IsPartOfProject Value="True"/> 92 <IsPartOfProject Value="True"/>
99 - <ComponentName Value="FormChooseActor"/>  
100 - <HasResources Value="True"/>  
101 - <ResourceBaseClass Value="Form"/>  
102 </Unit7> 93 </Unit7>
103 <Unit8> 94 <Unit8>
104 - <Filename Value="units/game_message.pas"/> 95 + <Filename Value="units/game_resources.pas"/>
105 <IsPartOfProject Value="True"/> 96 <IsPartOfProject Value="True"/>
106 </Unit8> 97 </Unit8>
107 <Unit9> 98 <Unit9>
108 - <Filename Value="units/game_experiment.pas"/> 99 + <Filename Value="units/game_control.pas"/>
109 <IsPartOfProject Value="True"/> 100 <IsPartOfProject Value="True"/>
110 </Unit9> 101 </Unit9>
111 <Unit10> 102 <Unit10>
112 - <Filename Value="units/game_file_methods.pas"/> 103 + <Filename Value="units/string_methods.pas"/>
113 <IsPartOfProject Value="True"/> 104 <IsPartOfProject Value="True"/>
114 </Unit10> 105 </Unit10>
115 <Unit11> 106 <Unit11>
116 - <Filename Value="units/game_resources.pas"/> 107 + <Filename Value="units/game_actors_point.pas"/>
117 <IsPartOfProject Value="True"/> 108 <IsPartOfProject Value="True"/>
118 </Unit11> 109 </Unit11>
119 <Unit12> 110 <Unit12>
120 - <Filename Value="units/game_control.pas"/> 111 + <Filename Value="units/game_visual_elements.pas"/>
121 <IsPartOfProject Value="True"/> 112 <IsPartOfProject Value="True"/>
122 </Unit12> 113 </Unit12>
123 <Unit13> 114 <Unit13>
124 - <Filename Value="units/string_methods.pas"/> 115 + <Filename Value="form_chooseactor.pas"/>
125 <IsPartOfProject Value="True"/> 116 <IsPartOfProject Value="True"/>
  117 + <ComponentName Value="FormChooseActor"/>
  118 + <ResourceBaseClass Value="Form"/>
126 </Unit13> 119 </Unit13>
127 - <Unit14>  
128 - <Filename Value="units/game_actors_point.pas"/>  
129 - <IsPartOfProject Value="True"/>  
130 - </Unit14>  
131 - <Unit15>  
132 - <Filename Value="units/game_visual_elements.pas"/>  
133 - <IsPartOfProject Value="True"/>  
134 - </Unit15>  
135 - <Unit16>  
136 - <Filename Value="units/zmq_network3.pas"/>  
137 - <IsPartOfProject Value="True"/>  
138 - </Unit16>  
139 </Units> 120 </Units>
140 </ProjectOptions> 121 </ProjectOptions>
141 <CompilerOptions> 122 <CompilerOptions>
@@ -158,6 +139,9 @@ @@ -158,6 +139,9 @@
158 </Linking> 139 </Linking>
159 <Other> 140 <Other>
160 <CustomOptions Value="-dUseCThreads"/> 141 <CustomOptions Value="-dUseCThreads"/>
  142 + <OtherDefines Count="1">
  143 + <Define0 Value="UseCThreads"/>
  144 + </OtherDefines>
161 </Other> 145 </Other>
162 </CompilerOptions> 146 </CompilerOptions>
163 <Debugging> 147 <Debugging>
cultural_matrix.lpr
@@ -25,8 +25,8 @@ uses @@ -25,8 +25,8 @@ uses
25 {$ENDIF} 25 {$ENDIF}
26 {$ENDIF} 26 {$ENDIF}
27 , StrUtils, Forms, Classes, sysutils 27 , StrUtils, Forms, Classes, sysutils
28 - , form_matrixgame, form_chooseactor, game_actors  
29 - , zhelpers 28 + , form_matrixgame, game_actors
  29 + , zhelpers, form_chooseactor
30 ; 30 ;
31 31
32 32
@@ -86,7 +86,8 @@ begin @@ -86,7 +86,8 @@ begin
86 Exit; 86 Exit;
87 end; 87 end;
88 end; 88 end;
89 - Application.CreateForm(TFormMatrixGame, FormMatrixGame); 89 + Application.CreateForm(TFormMatrixGame, FormMatrixGame);
  90 +
90 FormMatrixGame.SetID(F); 91 FormMatrixGame.SetID(F);
91 if Paramcount > 0 then 92 if Paramcount > 0 then
92 begin 93 begin
@@ -96,24 +97,6 @@ begin @@ -96,24 +97,6 @@ begin
96 FormMatrixGame.SetGameActor(gaPlayer); 97 FormMatrixGame.SetGameActor(gaPlayer);
97 if AnsiMatchStr(lowercase(ParamStr(0)), PWatcher) then 98 if AnsiMatchStr(lowercase(ParamStr(0)), PWatcher) then
98 FormMatrixGame.SetGameActor(gaWatcher); 99 FormMatrixGame.SetGameActor(gaWatcher);
99 - end  
100 - else  
101 - begin  
102 - FormChooseActor := TFormChooseActor.Create(nil);  
103 - FormChooseActor.Style := '.Arrived';  
104 - try  
105 - if FormChooseActor.ShowModal = 1 then  
106 - begin  
107 - case FormChooseActor.GameActor of  
108 - gaAdmin:FormMatrixGame.SetGameActor(gaAdmin);  
109 - gaPlayer: FormMatrixGame.SetGameActor(gaPlayer);  
110 - gaWatcher: FormMatrixGame.SetGameActor(gaWatcher);  
111 - end;  
112 - end  
113 - else Exit;  
114 - finally  
115 - FormChooseActor.Free;  
116 - end;  
117 end; 100 end;
118 Application.Run; 101 Application.Run;
119 end. 102 end.
form_chooseactor.lfm
1 object FormChooseActor: TFormChooseActor 1 object FormChooseActor: TFormChooseActor
2 - Left = 416 2 + Left = 396
3 Height = 240 3 Height = 240
4 - Top = 194 4 + Top = 185
5 Width = 320 5 Width = 320
  6 + BorderIcons = [biSystemMenu]
6 BorderStyle = bsDialog 7 BorderStyle = bsDialog
7 Caption = 'FormChooseActor' 8 Caption = 'FormChooseActor'
8 ClientHeight = 240 9 ClientHeight = 240
9 ClientWidth = 320 10 ClientWidth = 320
10 FormStyle = fsStayOnTop 11 FormStyle = fsStayOnTop
11 - OnCloseQuery = FormCloseQuery  
12 - OnCreate = FormCreate  
13 Position = poScreenCenter 12 Position = poScreenCenter
14 - LCLVersion = '1.6.0.4'  
15 - object btnAdmin: TButton  
16 - Left = 64  
17 - Height = 25  
18 - Top = 70  
19 - Width = 184  
20 - Caption = 'Administrador'  
21 - OnClick = btnAdminClick  
22 - TabOrder = 0  
23 - end  
24 - object btnPlayer: TButton  
25 - Left = 64  
26 - Height = 25  
27 - Top = 125  
28 - Width = 179  
29 - Caption = 'Jogador'  
30 - OnClick = btnPlayerClick  
31 - TabOrder = 1  
32 - end 13 + ShowInTaskBar = stNever
  14 + LCLVersion = '1.6.2.0'
33 object btnPlayerResume: TButton 15 object btnPlayerResume: TButton
  16 + AnchorSideLeft.Control = Owner
  17 + AnchorSideTop.Control = Owner
  18 + AnchorSideRight.Control = Owner
  19 + AnchorSideRight.Side = asrBottom
  20 + AnchorSideBottom.Control = Owner
  21 + AnchorSideBottom.Side = asrBottom
34 Left = 50 22 Left = 50
35 Height = 140 23 Height = 140
36 Top = 50 24 Top = 50
37 Width = 220 25 Width = 220
38 - Align = alClient 26 + Align = alCustom
  27 + Anchors = [akTop, akLeft, akRight, akBottom]
39 BorderSpacing.Around = 50 28 BorderSpacing.Around = 50
40 - Caption = 'ENTRAR' 29 + Caption = 'Entrar'
  30 + Font.Height = -53
  31 + Font.Name = 'Impact'
41 OnClick = btnPlayerResumeClick 32 OnClick = btnPlayerResumeClick
  33 + ParentFont = False
42 TabOrder = 2 34 TabOrder = 2
  35 + Visible = False
  36 + end
  37 + object btnAdmin: TButton
  38 + Left = 0
  39 + Height = 43
  40 + Top = 50
  41 + Width = 320
  42 + Align = alTop
  43 + AutoSize = True
  44 + BorderSpacing.Top = 50
  45 + Caption = 'Pesquisador'
  46 + Font.Height = -27
  47 + Font.Name = 'Impact'
  48 + OnClick = btnAdminClick
  49 + ParentFont = False
  50 + TabOrder = 0
  51 + end
  52 + object btnPlayer: TButton
  53 + Left = 0
  54 + Height = 43
  55 + Top = 143
  56 + Width = 320
  57 + Align = alTop
  58 + BorderSpacing.Top = 50
  59 + Caption = 'Jogador'
  60 + Font.Height = -27
  61 + Font.Name = 'Impact'
  62 + OnClick = btnPlayerClick
  63 + ParentFont = False
  64 + TabOrder = 1
43 end 65 end
44 end 66 end
form_chooseactor.pas
@@ -5,8 +5,7 @@ unit form_chooseactor; @@ -5,8 +5,7 @@ unit form_chooseactor;
5 interface 5 interface
6 6
7 uses 7 uses
8 - Classes, SysUtils, FileUtil, Forms, Controls,  
9 - Graphics, Dialogs, StdCtrls,ExtCtrls, LCLType 8 + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls
10 , game_actors 9 , game_actors
11 ; 10 ;
12 11
@@ -18,6 +17,9 @@ type @@ -18,6 +17,9 @@ type
18 btnAdmin: TButton; 17 btnAdmin: TButton;
19 btnPlayer: TButton; 18 btnPlayer: TButton;
20 btnPlayerResume: TButton; 19 btnPlayerResume: TButton;
  20 + //btnAdmin: TButton;
  21 + //btnPlayer: TButton;
  22 + //btnPlayerResume: TButton;
21 procedure btnAdminClick(Sender: TObject); 23 procedure btnAdminClick(Sender: TObject);
22 procedure btnPlayerClick(Sender: TObject); 24 procedure btnPlayerClick(Sender: TObject);
23 procedure btnPlayerResumeClick(Sender: TObject); 25 procedure btnPlayerResumeClick(Sender: TObject);
@@ -63,8 +65,7 @@ begin @@ -63,8 +65,7 @@ begin
63 ModalResult:=1; 65 ModalResult:=1;
64 end; 66 end;
65 67
66 -procedure TFormChooseActor.FormCloseQuery(Sender: TObject; var CanClose: boolean  
67 - ); 68 +procedure TFormChooseActor.FormCloseQuery(Sender: TObject; var CanClose: boolean );
68 begin 69 begin
69 CanClose := FCanClose; 70 CanClose := FCanClose;
70 end; 71 end;
@@ -81,10 +82,10 @@ begin @@ -81,10 +82,10 @@ begin
81 '.Arrived': btnPlayerResume.Visible:=False; 82 '.Arrived': btnPlayerResume.Visible:=False;
82 '.Left': btnPlayerResume.Visible:=True; 83 '.Left': btnPlayerResume.Visible:=True;
83 end; 84 end;
  85 + btnAdmin.Visible:= not btnPlayerResume.Visible;
  86 + btnPlayer.Visible:= not btnPlayerResume.Visible;
84 FStyle:=AValue; 87 FStyle:=AValue;
85 end; 88 end;
86 89
87 -  
88 -  
89 end. 90 end.
90 91
form_matrixgame.lfm
1 object FormMatrixGame: TFormMatrixGame 1 object FormMatrixGame: TFormMatrixGame
2 Left = 0 2 Left = 0
3 - Height = 657  
4 - Top = 62 3 + Height = 560
  4 + Top = 70
5 Width = 1278 5 Width = 1278
6 HorzScrollBar.Page = 1278 6 HorzScrollBar.Page = 1278
7 VertScrollBar.Page = 542 7 VertScrollBar.Page = 542
8 AutoScroll = True 8 AutoScroll = True
9 Caption = 'FormMatrixGame' 9 Caption = 'FormMatrixGame'
10 - ClientHeight = 647 10 + ClientHeight = 550
11 ClientWidth = 1278 11 ClientWidth = 1278
12 Font.Name = 'Monospace' 12 Font.Name = 'Monospace'
13 OnActivate = FormActivate 13 OnActivate = FormActivate
14 - LCLVersion = '1.6.0.4' 14 + LCLVersion = '1.6.2.0'
  15 + object GBIndividual: TGroupBox
  16 + AnchorSideLeft.Control = GBIndividualAB
  17 + AnchorSideTop.Control = GBIndividualAB
  18 + Left = 800
  19 + Height = 122
  20 + Top = 8
  21 + Width = 170
  22 + AutoSize = True
  23 + Caption = 'Pontuação Individual'
  24 + ChildSizing.LeftRightSpacing = 35
  25 + ChildSizing.TopBottomSpacing = 45
  26 + ChildSizing.Layout = cclLeftToRightThenTopToBottom
  27 + ChildSizing.ControlsPerLine = 1
  28 + ClientHeight = 105
  29 + ClientWidth = 166
  30 + TabOrder = 7
  31 + Visible = False
  32 + object LabelIndCount: TLabel
  33 + Left = 35
  34 + Height = 15
  35 + Top = 45
  36 + Width = 96
  37 + Align = alClient
  38 + Alignment = taCenter
  39 + AutoSize = False
  40 + Caption = '0'
  41 + Color = clDefault
  42 + Layout = tlCenter
  43 + ParentColor = False
  44 + Transparent = False
  45 + end
  46 + end
15 object StringGridMatrix: TStringGrid 47 object StringGridMatrix: TStringGrid
16 AnchorSideLeft.Control = Owner 48 AnchorSideLeft.Control = Owner
17 AnchorSideTop.Control = Owner 49 AnchorSideTop.Control = Owner
@@ -30,17 +62,17 @@ object FormMatrixGame: TFormMatrixGame @@ -30,17 +62,17 @@ object FormMatrixGame: TFormMatrixGame
30 DefaultRowHeight = 30 62 DefaultRowHeight = 30
31 Enabled = False 63 Enabled = False
32 FixedRows = 0 64 FixedRows = 0
33 - Options = [goFixedHorzLine, goHorzLine, goDrawFocusSelected, goRowSelect, goSmoothScroll] 65 + Options = []
34 RowCount = 10 66 RowCount = 10
35 TabOrder = 0 67 TabOrder = 0
36 TitleFont.Name = 'Monospace' 68 TitleFont.Name = 'Monospace'
37 - OnBeforeSelection = StringGridMatrixBeforeSelection 69 + OnClick = StringGridMatrixClick
38 OnDrawCell = StringGridMatrixDrawCell 70 OnDrawCell = StringGridMatrixDrawCell
39 end 71 end
40 object GBIndividualAB: TGroupBox 72 object GBIndividualAB: TGroupBox
41 - Left = 796 73 + Left = 800
42 Height = 122 74 Height = 122
43 - Top = 0 75 + Top = 8
44 Width = 170 76 Width = 170
45 AutoSize = True 77 AutoSize = True
46 Caption = 'Pontuação Individual' 78 Caption = 'Pontuação Individual'
@@ -115,9 +147,9 @@ object FormMatrixGame: TFormMatrixGame @@ -115,9 +147,9 @@ object FormMatrixGame: TFormMatrixGame
115 AnchorSideLeft.Control = GBIndividualAB 147 AnchorSideLeft.Control = GBIndividualAB
116 AnchorSideLeft.Side = asrBottom 148 AnchorSideLeft.Side = asrBottom
117 AnchorSideTop.Control = GBIndividualAB 149 AnchorSideTop.Control = GBIndividualAB
118 - Left = 976 150 + Left = 980
119 Height = 122 151 Height = 122
120 - Top = 0 152 + Top = 8
121 Width = 170 153 Width = 170
122 AutoSize = True 154 AutoSize = True
123 BorderSpacing.Left = 10 155 BorderSpacing.Left = 10
@@ -152,8 +184,8 @@ object FormMatrixGame: TFormMatrixGame @@ -152,8 +184,8 @@ object FormMatrixGame: TFormMatrixGame
152 AnchorSideBottom.Side = asrBottom 184 AnchorSideBottom.Side = asrBottom
153 Left = 0 185 Left = 0
154 Height = 17 186 Height = 17
155 - Top = 630  
156 - Width = 1492 187 + Top = 533
  188 + Width = 1632
157 Anchors = [akLeft, akRight, akBottom] 189 Anchors = [akLeft, akRight, akBottom]
158 AutoSize = True 190 AutoSize = True
159 Caption = 'Escolhas na última jogada' 191 Caption = 'Escolhas na última jogada'
@@ -168,61 +200,59 @@ object FormMatrixGame: TFormMatrixGame @@ -168,61 +200,59 @@ object FormMatrixGame: TFormMatrixGame
168 AnchorSideLeft.Control = GBGrupo 200 AnchorSideLeft.Control = GBGrupo
169 AnchorSideLeft.Side = asrBottom 201 AnchorSideLeft.Side = asrBottom
170 AnchorSideTop.Control = GBGrupo 202 AnchorSideTop.Control = GBGrupo
171 - Left = 1156  
172 - Height = 208  
173 - Top = 0  
174 - Width = 336 203 + Left = 1160
  204 + Height = 486
  205 + Top = 8
  206 + Width = 472
175 BorderSpacing.Left = 10 207 BorderSpacing.Left = 10
176 - Caption = 'Administrador'  
177 - ClientHeight = 191  
178 - ClientWidth = 332 208 + Caption = 'Pesquisador'
  209 + ClientHeight = 469
  210 + ClientWidth = 468
179 TabOrder = 4 211 TabOrder = 4
180 Visible = False 212 Visible = False
181 object GBExperiment: TGroupBox 213 object GBExperiment: TGroupBox
182 Left = 8 214 Left = 8
183 - Height = 172  
184 - Top = 8  
185 - Width = 218 215 + Height = 277
  216 + Top = 60
  217 + Width = 188
186 AutoSize = True 218 AutoSize = True
187 Caption = 'Experimento' 219 Caption = 'Experimento'
188 - ChildSizing.LeftRightSpacing = 20 220 + ChildSizing.LeftRightSpacing = 10
189 ChildSizing.TopBottomSpacing = 20 221 ChildSizing.TopBottomSpacing = 20
190 - ChildSizing.HorizontalSpacing = 30 222 + ChildSizing.HorizontalSpacing = 20
191 ChildSizing.VerticalSpacing = 10 223 ChildSizing.VerticalSpacing = 10
192 ChildSizing.EnlargeHorizontal = crsHomogenousChildResize 224 ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
193 ChildSizing.Layout = cclLeftToRightThenTopToBottom 225 ChildSizing.Layout = cclLeftToRightThenTopToBottom
194 ChildSizing.ControlsPerLine = 2 226 ChildSizing.ControlsPerLine = 2
195 - ClientHeight = 155  
196 - ClientWidth = 214 227 + ClientHeight = 260
  228 + ClientWidth = 184
197 TabOrder = 0 229 TabOrder = 0
198 object LabelExpCond: TLabel 230 object LabelExpCond: TLabel
199 - Left = 20 231 + Left = 10
200 Height = 15 232 Height = 15
201 Top = 20 233 Top = 20
202 Width = 128 234 Width = 128
203 - AutoSize = False  
204 Caption = 'Condição:' 235 Caption = 'Condição:'
205 ParentColor = False 236 ParentColor = False
206 end 237 end
207 - object LabelExpCondCount: TLabel  
208 - Left = 178 238 + object LabelExpCountCondition: TLabel
  239 + Left = 158
209 Height = 15 240 Height = 15
210 Top = 20 241 Top = 20
211 Width = 16 242 Width = 16
212 - AutoSize = False  
213 Caption = 'NA' 243 Caption = 'NA'
214 ParentColor = False 244 ParentColor = False
215 end 245 end
216 object LabelExpGen: TLabel 246 object LabelExpGen: TLabel
217 - Left = 20 247 + Left = 10
218 Height = 15 248 Height = 15
219 Top = 45 249 Top = 45
220 Width = 128 250 Width = 128
221 - Caption = 'Generation:' 251 + Caption = 'Generação:'
222 ParentColor = False 252 ParentColor = False
223 end 253 end
224 - object LabelExpGenCount: TLabel  
225 - Left = 178 254 + object LabelExpCountGeneration: TLabel
  255 + Left = 158
226 Height = 15 256 Height = 15
227 Top = 45 257 Top = 45
228 Width = 16 258 Width = 16
@@ -230,15 +260,15 @@ object FormMatrixGame: TFormMatrixGame @@ -230,15 +260,15 @@ object FormMatrixGame: TFormMatrixGame
230 ParentColor = False 260 ParentColor = False
231 end 261 end
232 object LabelExpCycle: TLabel 262 object LabelExpCycle: TLabel
233 - Left = 20 263 + Left = 10
234 Height = 15 264 Height = 15
235 Top = 70 265 Top = 70
236 Width = 128 266 Width = 128
237 - Caption = 'Cycle:' 267 + Caption = 'Ciclo:'
238 ParentColor = False 268 ParentColor = False
239 end 269 end
240 - object LabelExpCycleCount: TLabel  
241 - Left = 178 270 + object LabelExpCountCycle: TLabel
  271 + Left = 158
242 Height = 15 272 Height = 15
243 Top = 70 273 Top = 70
244 Width = 16 274 Width = 16
@@ -246,15 +276,15 @@ object FormMatrixGame: TFormMatrixGame @@ -246,15 +276,15 @@ object FormMatrixGame: TFormMatrixGame
246 ParentColor = False 276 ParentColor = False
247 end 277 end
248 object LabelExpNxtPlayer: TLabel 278 object LabelExpNxtPlayer: TLabel
249 - Left = 20 279 + Left = 10
250 Height = 15 280 Height = 15
251 Top = 95 281 Top = 95
252 Width = 128 282 Width = 128
253 Caption = 'Prox. Jog.:' 283 Caption = 'Prox. Jog.:'
254 ParentColor = False 284 ParentColor = False
255 end 285 end
256 - object LabelExpNxtPlayerCount: TLabel  
257 - Left = 178 286 + object LabelExpCountNxtPlayer: TLabel
  287 + Left = 158
258 Height = 15 288 Height = 15
259 Top = 95 289 Top = 95
260 Width = 16 290 Width = 16
@@ -262,28 +292,78 @@ object FormMatrixGame: TFormMatrixGame @@ -262,28 +292,78 @@ object FormMatrixGame: TFormMatrixGame
262 ParentColor = False 292 ParentColor = False
263 end 293 end
264 object LabelExpInterlocks: TLabel 294 object LabelExpInterlocks: TLabel
265 - Left = 20 295 + Left = 10
266 Height = 15 296 Height = 15
267 Top = 120 297 Top = 120
268 Width = 128 298 Width = 128
269 Caption = 'Entrelaçamentos:' 299 Caption = 'Entrelaçamentos:'
270 ParentColor = False 300 ParentColor = False
271 end 301 end
272 - object LabelExpInterlocksCount: TLabel  
273 - Left = 178 302 + object LabelExpCountInterlocks: TLabel
  303 + Left = 158
274 Height = 15 304 Height = 15
275 Top = 120 305 Top = 120
276 Width = 16 306 Width = 16
277 Caption = 'NA' 307 Caption = 'NA'
278 ParentColor = False 308 ParentColor = False
279 end 309 end
  310 + object ButtonExpStart: TButton
  311 + Left = 10
  312 + Height = 25
  313 + Top = 145
  314 + Width = 128
  315 + Caption = 'Começar'
  316 + OnClick = ButtonExpStartClick
  317 + TabOrder = 0
  318 + end
  319 + object LabelUnseen1: TLabel
  320 + Left = 158
  321 + Height = 25
  322 + Top = 145
  323 + Width = 16
  324 + ParentColor = False
  325 + end
  326 + object ButtonExpPause: TButton
  327 + Left = 10
  328 + Height = 25
  329 + Top = 180
  330 + Width = 128
  331 + Caption = 'Pausar'
  332 + Enabled = False
  333 + OnClick = ButtonExpPauseClick
  334 + TabOrder = 1
  335 + end
  336 + object LabelUnseen2: TLabel
  337 + Left = 158
  338 + Height = 25
  339 + Top = 180
  340 + Width = 16
  341 + ParentColor = False
  342 + end
  343 + object ButtonExpCancel: TButton
  344 + Left = 10
  345 + Height = 25
  346 + Top = 215
  347 + Width = 128
  348 + Caption = 'Cancelar'
  349 + Enabled = False
  350 + OnClick = ButtonExpCancelClick
  351 + TabOrder = 2
  352 + end
  353 + object LabelUnseen3: TLabel
  354 + Left = 158
  355 + Height = 25
  356 + Top = 215
  357 + Width = 16
  358 + ParentColor = False
  359 + end
280 end 360 end
281 end 361 end
282 object btnConfirmRow: TButton 362 object btnConfirmRow: TButton
283 Left = 712 363 Left = 712
284 - Height = 25  
285 - Top = 320  
286 - Width = 83 364 + Height = 26
  365 + Top = 319
  366 + Width = 86
287 Caption = 'Confirmar' 367 Caption = 'Confirmar'
288 OnClick = btnConfirmRowClick 368 OnClick = btnConfirmRowClick
289 TabOrder = 5 369 TabOrder = 5
@@ -295,9 +375,9 @@ object FormMatrixGame: TFormMatrixGame @@ -295,9 +375,9 @@ object FormMatrixGame: TFormMatrixGame
295 AnchorSideTop.Side = asrBottom 375 AnchorSideTop.Side = asrBottom
296 AnchorSideRight.Control = GBGrupo 376 AnchorSideRight.Control = GBGrupo
297 AnchorSideRight.Side = asrBottom 377 AnchorSideRight.Side = asrBottom
298 - Left = 796 378 + Left = 800
299 Height = 354 379 Height = 354
300 - Top = 132 380 + Top = 140
301 Width = 350 381 Width = 350
302 Anchors = [akTop, akLeft, akRight] 382 Anchors = [akTop, akLeft, akRight]
303 BorderSpacing.Top = 10 383 BorderSpacing.Top = 10
@@ -351,63 +431,24 @@ object FormMatrixGame: TFormMatrixGame @@ -351,63 +431,24 @@ object FormMatrixGame: TFormMatrixGame
351 WantTabs = True 431 WantTabs = True
352 end 432 end
353 end 433 end
354 - object GBIndividual: TGroupBox  
355 - AnchorSideLeft.Control = GBIndividualAB  
356 - AnchorSideTop.Control = GBIndividualAB  
357 - Left = 796  
358 - Height = 122  
359 - Top = 0  
360 - Width = 170  
361 - AutoSize = True  
362 - Caption = 'Pontuação Individual'  
363 - ChildSizing.LeftRightSpacing = 35  
364 - ChildSizing.TopBottomSpacing = 45  
365 - ChildSizing.Layout = cclLeftToRightThenTopToBottom  
366 - ChildSizing.ControlsPerLine = 1  
367 - ClientHeight = 105  
368 - ClientWidth = 166  
369 - TabOrder = 7  
370 - Visible = False  
371 - object LabelIndCount: TLabel  
372 - Left = 35  
373 - Height = 15  
374 - Top = 45  
375 - Width = 96  
376 - Align = alClient  
377 - Alignment = taCenter  
378 - AutoSize = False  
379 - Caption = '0'  
380 - Color = clDefault  
381 - Layout = tlCenter  
382 - ParentColor = False  
383 - Transparent = False  
384 - end  
385 - end  
386 - object Button1: TButton  
387 - Left = 216  
388 - Height = 25  
389 - Top = 432  
390 - Width = 75  
391 - Caption = 'Button1'  
392 - OnClick = Button1Click  
393 - TabOrder = 8  
394 - end  
395 - object Button2: TButton  
396 - Left = 312  
397 - Height = 25  
398 - Top = 432  
399 - Width = 75  
400 - Caption = 'Button2'  
401 - OnClick = Button2Click  
402 - TabOrder = 9  
403 - end  
404 object Button3: TButton 434 object Button3: TButton
405 - Left = 504 435 + Left = 568
406 Height = 91 436 Height = 91
407 - Top = 440 437 + Top = 352
408 Width = 141 438 Width = 141
409 Caption = 'Button3' 439 Caption = 'Button3'
410 OnClick = Button3Click 440 OnClick = Button3Click
411 - TabOrder = 10 441 + TabOrder = 8
  442 + end
  443 + object OpenDialog: TOpenDialog
  444 + Width = 862
  445 + Height = 434
  446 + Title = 'Abrir Experimento'
  447 + DefaultExt = '.txt'
  448 + Filter = 'txt|*.txt|ini|*.ini'
  449 + InitialDir = 'Pesquisadores'
  450 + Options = [ofNoChangeDir, ofFileMustExist, ofNoNetworkButton, ofEnableSizing, ofDontAddToRecent]
  451 + left = 24
  452 + top = 360
412 end 453 end
413 end 454 end
form_matrixgame.pas
@@ -29,24 +29,28 @@ type @@ -29,24 +29,28 @@ type
29 29
30 TFormMatrixGame = class(TForm) 30 TFormMatrixGame = class(TForm)
31 btnConfirmRow: TButton; 31 btnConfirmRow: TButton;
32 - Button1: TButton;  
33 - Button2: TButton; 32 + ButtonExpStart: TButton;
  33 + ButtonExpPause: TButton;
34 Button3: TButton; 34 Button3: TButton;
  35 + ButtonExpCancel: TButton;
35 GBIndividual: TGroupBox; 36 GBIndividual: TGroupBox;
36 GBLastChoice: TGroupBox; 37 GBLastChoice: TGroupBox;
37 GBIndividualAB: TGroupBox; 38 GBIndividualAB: TGroupBox;
38 GBGrupo: TGroupBox; 39 GBGrupo: TGroupBox;
39 GBAdmin: TGroupBox; 40 GBAdmin: TGroupBox;
40 GBExperiment: TGroupBox; 41 GBExperiment: TGroupBox;
41 - LabelExpCondCount: TLabel; 42 + LabelUnseen1: TLabel;
  43 + LabelUnseen2: TLabel;
  44 + LabelUnseen3: TLabel;
  45 + LabelExpCountCondition: TLabel;
42 LabelExpGen: TLabel; 46 LabelExpGen: TLabel;
43 - LabelExpGenCount: TLabel; 47 + LabelExpCountGeneration: TLabel;
44 LabelExpCycle: TLabel; 48 LabelExpCycle: TLabel;
45 - LabelExpCycleCount: TLabel; 49 + LabelExpCountCycle: TLabel;
46 LabelExpNxtPlayer: TLabel; 50 LabelExpNxtPlayer: TLabel;
47 - LabelExpNxtPlayerCount: TLabel; 51 + LabelExpCountNxtPlayer: TLabel;
48 LabelExpInterlocks: TLabel; 52 LabelExpInterlocks: TLabel;
49 - LabelExpInterlocksCount: TLabel; 53 + LabelExpCountInterlocks: TLabel;
50 LabelIndCount: TLabel; 54 LabelIndCount: TLabel;
51 LabelIndACount: TLabel; 55 LabelIndACount: TLabel;
52 LabelIndBCount: TLabel; 56 LabelIndBCount: TLabel;
@@ -58,15 +62,16 @@ type @@ -58,15 +62,16 @@ type
58 ChatMemoSend: TMemo; 62 ChatMemoSend: TMemo;
59 ChatPanel: TPanel; 63 ChatPanel: TPanel;
60 ChatSplitter: TSplitter; 64 ChatSplitter: TSplitter;
  65 + OpenDialog: TOpenDialog;
61 StringGridMatrix: TStringGrid; 66 StringGridMatrix: TStringGrid;
62 procedure btnConfirmRowClick(Sender: TObject); 67 procedure btnConfirmRowClick(Sender: TObject);
63 - procedure Button1Click(Sender: TObject);  
64 - procedure Button2Click(Sender: TObject);  
65 procedure Button3Click(Sender: TObject); 68 procedure Button3Click(Sender: TObject);
  69 + procedure ButtonExpCancelClick(Sender: TObject);
  70 + procedure ButtonExpPauseClick(Sender: TObject);
  71 + procedure ButtonExpStartClick(Sender: TObject);
66 procedure ChatMemoSendKeyPress(Sender: TObject; var Key: char); 72 procedure ChatMemoSendKeyPress(Sender: TObject; var Key: char);
67 - procedure CheckBoxDrawDotsChange(Sender: TObject);  
68 procedure FormActivate(Sender: TObject); 73 procedure FormActivate(Sender: TObject);
69 - procedure StringGridMatrixBeforeSelection(Sender: TObject; aCol, aRow: integer); 74 + procedure StringGridMatrixClick(Sender: TObject);
70 procedure StringGridMatrixDrawCell(Sender: TObject; aCol, aRow: integer; 75 procedure StringGridMatrixDrawCell(Sender: TObject; aCol, aRow: integer;
71 aRect: TRect; aState: TGridDrawState); 76 aRect: TRect; aState: TGridDrawState);
72 private 77 private
@@ -80,14 +85,14 @@ type @@ -80,14 +85,14 @@ type
80 85
81 var 86 var
82 FormMatrixGame: TFormMatrixGame; 87 FormMatrixGame: TFormMatrixGame;
  88 +resourcestring
  89 + RS_RESEARCHERS = 'Pesquisadores';
83 90
84 implementation 91 implementation
85 92
86 -uses form_chooseactor, LCLType, game_resources; 93 +uses form_chooseactor, game_resources;
87 94
88 // uses datamodule; 95 // uses datamodule;
89 -var  
90 - MustDrawSelection : Boolean; // work around until a bug fix for ClearSelection is released  
91 96
92 {$R *.lfm} 97 {$R *.lfm}
93 98
@@ -168,7 +173,7 @@ begin @@ -168,7 +173,7 @@ begin
168 begin 173 begin
169 DrawLines(GetRowColor(aRow,RowBase)); 174 DrawLines(GetRowColor(aRow,RowBase));
170 175
171 - if (gdSelected in aState) and MustDrawSelection then 176 + if (gdSelected in aState) and (goRowSelect in TStringGrid(Sender).Options)then
172 begin 177 begin
173 TStringGrid(Sender).Canvas.Pen.Width := 10; 178 TStringGrid(Sender).Canvas.Pen.Width := 10;
174 TStringGrid(Sender).Canvas.Pen.Color := clWhite; 179 TStringGrid(Sender).Canvas.Pen.Color := clWhite;
@@ -195,11 +200,11 @@ begin @@ -195,11 +200,11 @@ begin
195 TStringGrid(Sender).Canvas.Font.Color := clBlack; 200 TStringGrid(Sender).Canvas.Font.Color := clBlack;
196 TStringGrid(Sender).Canvas.Brush.Style := bsClear; 201 TStringGrid(Sender).Canvas.Brush.Style := bsClear;
197 202
198 - if (aCol = 10) and (gdSelected in aState) and MustDrawSelection then 203 + if (aCol = 10) and (gdSelected in aState) and (goRowSelect in TStringGrid(Sender).Options) then
199 if (aRow = TStringGrid(Sender).Selection.Top) and (aCol = TStringGrid(Sender).Selection.Right) then 204 if (aRow = TStringGrid(Sender).Selection.Top) and (aCol = TStringGrid(Sender).Selection.Right) then
200 begin 205 begin
201 - btnConfirmRow.Top := aRect.Top+5;  
202 - btnConfirmRow.Left := aRect.Right+5; 206 + btnConfirmRow.Top := aRect.Top+4;
  207 + btnConfirmRow.Left := aRect.Right+8;
203 end; 208 end;
204 209
205 finally 210 finally
@@ -219,7 +224,6 @@ procedure TFormMatrixGame.SetGameActor(AValue: TGameActor); @@ -219,7 +224,6 @@ procedure TFormMatrixGame.SetGameActor(AValue: TGameActor);
219 procedure SetZMQPlayer; 224 procedure SetZMQPlayer;
220 begin 225 begin
221 FGameControl := TGameControl.Create(TZMQPlayer.Create(Self,FID)); 226 FGameControl := TGameControl.Create(TZMQPlayer.Create(Self,FID));
222 - btnConfirmRow.Visible := True;  
223 StringGridMatrix.Enabled := True; 227 StringGridMatrix.Enabled := True;
224 end; 228 end;
225 229
@@ -241,27 +245,39 @@ begin @@ -241,27 +245,39 @@ begin
241 FID := S; 245 FID := S;
242 end; 246 end;
243 247
244 -procedure TFormMatrixGame.CheckBoxDrawDotsChange(Sender: TObject);  
245 -begin  
246 - StringGridMatrix.Invalidate;  
247 -end;  
248 248
249 procedure TFormMatrixGame.FormActivate(Sender: TObject); 249 procedure TFormMatrixGame.FormActivate(Sender: TObject);
250 begin 250 begin
251 - StringGridMatrix.ClearSelections;  
252 - StringGridMatrix.FocusRectVisible := False;  
253 - FGameControl.SetMatrix; 251 + FormChooseActor := TFormChooseActor.Create(Self);
  252 + FormChooseActor.Style := '.Arrived';
  253 + try
  254 + if FormChooseActor.ShowModal = 1 then
  255 + begin
  256 + case FormChooseActor.GameActor of
  257 + gaAdmin:FormMatrixGame.SetGameActor(gaAdmin);
  258 + gaPlayer: FormMatrixGame.SetGameActor(gaPlayer);
  259 + gaWatcher: FormMatrixGame.SetGameActor(gaWatcher);
  260 + end;
  261 + StringGridMatrix.ClearSelections;
  262 + StringGridMatrix.FocusRectVisible := False;
  263 + FGameControl.SetMatrix;
  264 + end
  265 + else Close;
  266 + finally
  267 + FormChooseActor.Free;
  268 + end;
254 end; 269 end;
255 270
256 -procedure TFormMatrixGame.StringGridMatrixBeforeSelection(Sender: TObject; aCol, aRow: integer); 271 +procedure TFormMatrixGame.StringGridMatrixClick(Sender: TObject);
257 begin 272 begin
258 - if MustDrawSelection then Exit;  
259 - MustDrawSelection := True; 273 + if goRowSelect in StringGridMatrix.Options then Exit;
  274 + StringGridMatrix.Options := StringGridMatrix.Options+[goRowSelect];
  275 + btnConfirmRow.Visible := True;
260 end; 276 end;
261 277
262 procedure TFormMatrixGame.ChatMemoSendKeyPress(Sender: TObject; var Key: char); 278 procedure TFormMatrixGame.ChatMemoSendKeyPress(Sender: TObject; var Key: char);
263 begin 279 begin
264 - if Key = Char(VK_RETURN) then 280 + if Key = Char(13) then
265 begin 281 begin
266 FGameControl.SendMessage(K_CHAT_M); 282 FGameControl.SendMessage(K_CHAT_M);
267 with ChatMemoSend do 283 with ChatMemoSend do
@@ -271,42 +287,61 @@ begin @@ -271,42 +287,61 @@ begin
271 SelLength:=0; 287 SelLength:=0;
272 SetFocus; 288 SetFocus;
273 end; 289 end;
274 - Key := Char(VK_UNKNOWN); 290 + Key := Char(0);
275 end; 291 end;
276 end; 292 end;
277 293
278 procedure TFormMatrixGame.btnConfirmRowClick(Sender: TObject); 294 procedure TFormMatrixGame.btnConfirmRowClick(Sender: TObject);
279 begin 295 begin
280 - //StringGridMatrix.ClearSelections;  
281 - //MustDrawSelection := False;  
282 StringGridMatrix.Enabled:= False; 296 StringGridMatrix.Enabled:= False;
283 - btnConfirmRow.Visible:=False; 297 + btnConfirmRow.Enabled:=False;
284 FGameControl.SendMessage(K_CHOICE); 298 FGameControl.SendMessage(K_CHOICE);
285 end; 299 end;
286 300
287 -procedure TFormMatrixGame.Button1Click(Sender: TObject); 301 +procedure TFormMatrixGame.Button3Click(Sender: TObject);
288 begin 302 begin
289 - 303 + FGameControl.Experiment.SaveToFile(OpenDialog.FileName+'.ini');
290 end; 304 end;
291 305
292 -procedure TFormMatrixGame.Button2Click(Sender: TObject); 306 +procedure TFormMatrixGame.ButtonExpCancelClick(Sender: TObject);
293 begin 307 begin
  308 + ButtonExpStart.Enabled := True;
  309 + ButtonExpStart.Caption := 'Começar';
  310 + ButtonExpCancel.Enabled := not ButtonExpStart.Enabled;
  311 + ButtonExpPause.Enabled := not ButtonExpStart.Enabled;
  312 + //FGameControl.Experiment.SaveToFile(SaveDialog.FileName'.canceled');
  313 + //FGameControl.Experiment.Clean;
  314 +end;
294 315
  316 +procedure TFormMatrixGame.ButtonExpPauseClick(Sender: TObject);
  317 +begin
  318 + ButtonExpStart.Enabled := True;
  319 + ButtonExpStart.Caption := 'Recomeçar';
  320 + ButtonExpPause.Enabled := not ButtonExpStart.Enabled;
  321 + //FGameControl.Experiment.Pause;
295 end; 322 end;
296 323
297 -procedure TFormMatrixGame.Button3Click(Sender: TObject); 324 +procedure TFormMatrixGame.ButtonExpStartClick(Sender: TObject);
298 begin 325 begin
299 - FGameControl.SendMessage(K_LEFT);  
300 - FormMatrixGame.Visible := False;  
301 - FormChooseActor := TFormChooseActor.Create(nil);  
302 - FormChooseActor.Style := K_LEFT;  
303 - if FormChooseActor.ShowModal = 1 then  
304 - begin  
305 - FGameControl.SendMessage(K_RESUME);  
306 - FormMatrixGame.Visible := True;  
307 - end  
308 - else Close;  
309 - FormChooseActor.Free; 326 + OpenDialog.InitialDir:=ExtractFilePath(Application.ExeName)+RS_RESEARCHERS;
  327 + if ButtonExpStart.Caption = 'Começar' then
  328 + if OpenDialog.Execute then
  329 + begin
  330 + ButtonExpStart.Enabled := False;
  331 + ButtonExpStart.Caption := 'Rodando';
  332 + ButtonExpCancel.Enabled := not ButtonExpStart.Enabled;
  333 + ButtonExpPause.Enabled := not ButtonExpStart.Enabled;
  334 + //FGameControl.Experiment.LoadFromFile(OpenDialog.FileName);
  335 + end;
  336 +
  337 + if ButtonExpStart.Caption = 'Recomeçar' then
  338 + begin
  339 + ButtonExpStart.Enabled := False;
  340 + ButtonExpStart.Caption := 'Rodando';
  341 + ButtonExpCancel.Enabled := not ButtonExpStart.Enabled;
  342 + ButtonExpPause.Enabled := not ButtonExpStart.Enabled;
  343 + //FGameControl.Experiment.Resume;
  344 + end;
310 end; 345 end;
311 346
312 end. 347 end.
units/backup/game_dialogs.lfm 0 → 100644
@@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
  1 +object DataModule2: TDataModule2
  2 + OldCreateOrder = False
  3 + Height = 210
  4 + HorizontalOffset = 375
  5 + VerticalOffset = 243
  6 + Width = 412
  7 + object OpenDialog: TOpenDialog
  8 + Width = 862
  9 + Height = 434
  10 + Title = 'Abrir Experimento'
  11 + DefaultExt = '.txt'
  12 + FileName = '/home/rafael/free-pascal/published'
  13 + Filter = 'txt|*.TXT|ini|*.INI'
  14 + InitialDir = '/home/rafael/free-pascal/'
  15 + left = 32
  16 + top = 8
  17 + end
  18 +end
units/game_actors.pas
@@ -10,7 +10,6 @@ uses @@ -10,7 +10,6 @@ uses
10 ; 10 ;
11 type 11 type
12 12
13 -  
14 TGameActor = ( gaNone, gaAdmin, gaPlayer, gaWatcher ); 13 TGameActor = ( gaNone, gaAdmin, gaPlayer, gaWatcher );
15 TGamePlayerStatus = (gpsWaiting, gpsPlaying, gpsPlayed); 14 TGamePlayerStatus = (gpsWaiting, gpsPlaying, gpsPlayed);
16 15
@@ -38,6 +37,7 @@ type @@ -38,6 +37,7 @@ type
38 TConsequenceStyle = set of TGameConsequenceStyle; 37 TConsequenceStyle = set of TGameConsequenceStyle;
39 38
40 TGamePromptStyle = (gsYes, gsNo, gsAll, gsMetacontingency, gsContingency, gsBasA, gsRevertPoints); 39 TGamePromptStyle = (gsYes, gsNo, gsAll, gsMetacontingency, gsContingency, gsBasA, gsRevertPoints);
  40 +
41 TPromptStyle = set of TGamePromptStyle; 41 TPromptStyle = set of TGamePromptStyle;
42 42
43 43
units/game_control.pas
@@ -16,6 +16,7 @@ uses @@ -16,6 +16,7 @@ uses
16 16
17 type 17 type
18 18
  19 +
19 { TGameControl } 20 { TGameControl }
20 21
21 TGameControl = class(TComponent) 22 TGameControl = class(TComponent)
@@ -32,6 +33,7 @@ type @@ -32,6 +33,7 @@ type
32 function GetSelectedColorF(AStringGrid : TStringGrid) : UTF8string; 33 function GetSelectedColorF(AStringGrid : TStringGrid) : UTF8string;
33 function GetSelectedRowF(AStringGrid : TStringGrid) : UTF8string; 34 function GetSelectedRowF(AStringGrid : TStringGrid) : UTF8string;
34 function MessageHas(const A_CONST : string; AMessage : TStringList; I:ShortInt=0): Boolean; 35 function MessageHas(const A_CONST : string; AMessage : TStringList; I:ShortInt=0): Boolean;
  36 + procedure CreatePlayerBox(P:TPlayer; Me:Boolean);
35 procedure SetMatrixType(AStringGrid : TStringGrid; AMatrixType:TGameMatrixType; 37 procedure SetMatrixType(AStringGrid : TStringGrid; AMatrixType:TGameMatrixType;
36 var ARowBase:integer; var ADrawDots, ADrawClear : Boolean); 38 var ARowBase:integer; var ADrawDots, ADrawClear : Boolean);
37 procedure ReceiveMessage(AMessage : TStringList); 39 procedure ReceiveMessage(AMessage : TStringList);
@@ -42,15 +44,18 @@ type @@ -42,15 +44,18 @@ type
42 procedure SetRowBase(AValue: integer); 44 procedure SetRowBase(AValue: integer);
43 private 45 private
44 function CanStartExperiment : Boolean; 46 function CanStartExperiment : Boolean;
  47 + procedure KickPlayer(AID:string);
45 procedure StartCycle; 48 procedure StartCycle;
46 procedure StartCondition; 49 procedure StartCondition;
47 procedure StartExperiment; 50 procedure StartExperiment;
  51 + procedure StartTurn;
48 public 52 public
49 constructor Create(AOwner : TComponent);override; 53 constructor Create(AOwner : TComponent);override;
50 destructor Destroy; override; 54 destructor Destroy; override;
51 procedure SetMatrix; 55 procedure SetMatrix;
52 procedure SendRequest(ARequest : UTF8string); 56 procedure SendRequest(ARequest : UTF8string);
53 procedure SendMessage(AMessage : UTF8string); 57 procedure SendMessage(AMessage : UTF8string);
  58 + property Experiment : TExperiment read FExperiment write FExperiment;
54 property ID : string read FID; 59 property ID : string read FID;
55 property RowBase : integer read FRowBase write SetRowBase; 60 property RowBase : integer read FRowBase write SetRowBase;
56 property MustDrawDots: Boolean read FMustDrawDots write SetMustDrawDots; 61 property MustDrawDots: Boolean read FMustDrawDots write SetMustDrawDots;
@@ -61,25 +66,25 @@ type @@ -61,25 +66,25 @@ type
61 66
62 const 67 const
63 K_FULLROOM = '.Full'; 68 K_FULLROOM = '.Full';
64 - K_PLAYING = '.Playing';  
65 - K_ARRIVED = '.Arrived';  
66 - K_REFUSED = '.Refused';  
67 - K_CHAT_M = '.ChatM';  
68 - K_CHOICE = '.Choice';  
69 - K_LEFT = '.Left';  
70 - K_RESUME = '.Resume';  
71 - K_DATA_A = '.Data';  
72 - K_LOGIN = '.login';  
73 - 69 + K_PLAYING = '.Playing';
  70 + K_ARRIVED = '.Arrived';
  71 + K_REFUSED = '.Refused';
  72 + K_CHAT_M = '.ChatM';
  73 + K_CHOICE = '.Choice';
  74 + K_LEFT = '.Left';
  75 + K_RESUME = '.Resume';
  76 + K_DATA_A = '.Data';
  77 + K_LOGIN = '.Login';
  78 + K_KICK = '.Kick'
74 // 79 //
75 - K_STATUS = '.Status';  
76 - K_CYCLES = '.OnCycleStart'; 80 + K_STATUS = '.Status';
  81 + K_CYCLES = '.OnCycleStart';
77 82
78 //K_RESPONSE = 83 //K_RESPONSE =
79 84
80 implementation 85 implementation
81 86
82 -uses form_matrixgame, game_resources, string_methods, zhelpers; 87 +uses LazUTF8, form_matrixgame, form_chooseactor, game_resources, string_methods, zhelpers;
83 88
84 const 89 const
85 GA_ADMIN = 'Admin'; 90 GA_ADMIN = 'Admin';
@@ -106,7 +111,12 @@ end; @@ -106,7 +111,12 @@ end;
106 111
107 function TGameControl.CanStartExperiment: Boolean; 112 function TGameControl.CanStartExperiment: Boolean;
108 begin 113 begin
109 - Result := FExperiment.PlayersPlaying.Count = FExperiment.Condition[FExperiment.CurrentCondition].Turn.Value; 114 + Result := FExperiment.PlayersCount = FExperiment.Condition[FExperiment.CurrentCondition].Turn.Value;
  115 +end;
  116 +
  117 +procedure TGameControl.KickPlayer(AID: string);
  118 +begin
  119 + FZMQActor.SendMessage([K_KICK, AID]);
110 end; 120 end;
111 121
112 function TGameControl.GetPlayerBox(AID: string): TPlayerBox; 122 function TGameControl.GetPlayerBox(AID: string): TPlayerBox;
@@ -141,6 +151,26 @@ begin @@ -141,6 +151,26 @@ begin
141 Result := Pos(A_CONST,AMessage[I])>0; 151 Result := Pos(A_CONST,AMessage[I])>0;
142 end; 152 end;
143 153
  154 +procedure TGameControl.CreatePlayerBox(P: TPlayer; Me: Boolean);
  155 +var i1 : integer;
  156 +begin
  157 + with TPlayerBox.Create(FormMatrixGame.GBLastChoice,P.ID) do
  158 + begin
  159 + if Me then
  160 + Caption := P.Nicname+SysToUtf8(' (Você)' )
  161 + else
  162 + Caption := P.Nicname;
  163 + i1 := Integer(P.Choice.Last.Row);
  164 + if i1 > 0 then
  165 + LabelLastRowCount.Caption := Format('%-*.*d', [1,2,i1])
  166 + else
  167 + LabelLastRowCount.Caption := 'NA';
  168 + PanelLastColor.Color := GetColorFromCode(P.Choice.Last.Color);
  169 + Enabled := True;
  170 + Parent := FormMatrixGame.GBLastChoice;
  171 + end;
  172 +end;
  173 +
144 procedure TGameControl.SetMatrixType(AStringGrid: TStringGrid; 174 procedure TGameControl.SetMatrixType(AStringGrid: TStringGrid;
145 AMatrixType: TGameMatrixType; var ARowBase: integer; var ADrawDots, 175 AMatrixType: TGameMatrixType; var ARowBase: integer; var ADrawDots,
146 ADrawClear: Boolean); 176 ADrawClear: Boolean);
@@ -166,7 +196,7 @@ begin @@ -166,7 +196,7 @@ begin
166 AStringGrid.FixedRows := 0; 196 AStringGrid.FixedRows := 0;
167 AStringGrid.RowCount := 10; 197 AStringGrid.RowCount := 10;
168 AStringGrid.Height:=305; 198 AStringGrid.Height:=305;
169 - AStringGrid.Options := [goFixedHorzLine, goHorzLine, goDrawFocusSelected, goRowSelect]; 199 + AStringGrid.Options := [goFixedHorzLine, goHorzLine];
170 WriteGridFixedNames(AStringGrid, False); 200 WriteGridFixedNames(AStringGrid, False);
171 end; 201 end;
172 202
@@ -177,7 +207,7 @@ begin @@ -177,7 +207,7 @@ begin
177 AStringGrid.FixedRows := 1; 207 AStringGrid.FixedRows := 1;
178 AStringGrid.RowCount := 11; 208 AStringGrid.RowCount := 11;
179 AStringGrid.Height:=335; 209 AStringGrid.Height:=335;
180 - AStringGrid.Options := [goFixedHorzLine, goHorzLine, goDrawFocusSelected, goRowSelect, goVertLine]; 210 + AStringGrid.Options := [goFixedHorzLine, goHorzLine, goVertLine];
181 WriteGridFixedNames(AStringGrid, True); 211 WriteGridFixedNames(AStringGrid, True);
182 end; 212 end;
183 213
@@ -237,6 +267,13 @@ begin @@ -237,6 +267,13 @@ begin
237 267
238 end; 268 end;
239 269
  270 +procedure TGameControl.StartTurn;
  271 +begin
  272 + FormMatrixGame.StringGridMatrix.Options := FormMatrixGame.StringGridMatrix.Options-[goRowSelect];
  273 + FormMatrixGame.btnConfirmRow.Enabled:=True;
  274 + FormMatrixGame.btnConfirmRow.Visible := False;
  275 +end;
  276 +
240 constructor TGameControl.Create(AOwner: TComponent); 277 constructor TGameControl.Create(AOwner: TComponent);
241 begin 278 begin
242 FZMQActor := TZMQActor(AOwner); 279 FZMQActor := TZMQActor(AOwner);
@@ -284,28 +321,26 @@ var @@ -284,28 +321,26 @@ var
284 M[i] := A[i]; 321 M[i] := A[i];
285 end; 322 end;
286 begin 323 begin
287 - case ARequest of  
288 - K_LOGIN : SetM([  
289 - FZMQActor.ID  
290 - , ' '  
291 - , ARequest  
292 - ]);  
293 - end; 324 + SetM([
  325 + FZMQActor.ID
  326 + , ' '
  327 + , ARequest
  328 + ]);
294 329
295 case FActor of 330 case FActor of
296 gaAdmin: begin 331 gaAdmin: begin
297 - M[2] := GA_ADMIN+M[2]; 332 + //M[2] := GA_ADMIN+M[2];// for now cannot Requests
298 end; 333 end;
299 gaPlayer:begin 334 gaPlayer:begin
300 M[2] := GA_PLAYER+M[2]; 335 M[2] := GA_PLAYER+M[2];
301 end; 336 end;
302 - //gaWatcher:begin // for now cannot SendMessages 337 + //gaWatcher:begin
303 // M[0] := GA_WATCHER+M[0]; 338 // M[0] := GA_WATCHER+M[0];
304 end; 339 end;
305 FZMQActor.Request(M); 340 FZMQActor.Request(M);
306 end; 341 end;
307 342
308 - 343 +// called from outside
309 procedure TGameControl.SendMessage(AMessage: UTF8string); 344 procedure TGameControl.SendMessage(AMessage: UTF8string);
310 var 345 var
311 M : array of UTF8String; 346 M : array of UTF8String;
@@ -319,10 +354,6 @@ var @@ -319,10 +354,6 @@ var
319 end; 354 end;
320 begin 355 begin
321 case AMessage of 356 case AMessage of
322 - //K_ARRIVED : SetM([  
323 - // AMessage  
324 - // , FZMQActor.ID  
325 - //]);  
326 357
327 K_CHOICE : SetM([ 358 K_CHOICE : SetM([
328 AMessage 359 AMessage
@@ -340,15 +371,6 @@ begin @@ -340,15 +371,6 @@ begin
340 ]); 371 ]);
341 end; 372 end;
342 373
343 - K_LEFT : SetM([  
344 - AMessage  
345 - , FZMQActor.ID  
346 - ]);  
347 -  
348 - K_RESUME : SetM([  
349 - AMessage  
350 - , FZMQActor.ID  
351 - ]);  
352 end; 374 end;
353 375
354 case FActor of 376 case FActor of
@@ -358,7 +380,7 @@ begin @@ -358,7 +380,7 @@ begin
358 gaPlayer:begin 380 gaPlayer:begin
359 M[0] := GA_PLAYER+M[0]; 381 M[0] := GA_PLAYER+M[0];
360 end; 382 end;
361 - //gaWatcher:begin // for now cannot SendMessages 383 + //gaWatcher:begin
362 // M[0] := GA_WATCHER+M[0]; 384 // M[0] := GA_WATCHER+M[0];
363 end; 385 end;
364 FZMQActor.SendMessage(M); 386 FZMQActor.SendMessage(M);
@@ -383,38 +405,18 @@ procedure TGameControl.ReceiveMessage(AMessage: TStringList); @@ -383,38 +405,18 @@ procedure TGameControl.ReceiveMessage(AMessage: TStringList);
383 gaPlayer: 405 gaPlayer:
384 begin 406 begin
385 P := FExperiment.PlayerFromString[AMessage[1]]; 407 P := FExperiment.PlayerFromString[AMessage[1]];
386 - if Self.ID = P.ID then Exit;  
387 - with TPlayerBox.Create(FormMatrixGame.GBLastChoice,P.ID) do 408 + if Self.ID = P.ID then
388 begin 409 begin
389 - Caption := P.Nicname;  
390 - LabelLastRowCount.Caption := IntToStr(ShortInt(P.Choice.Last.Row));  
391 - PanelLastColor.Color := GetColorFromCode(P.Choice.Last.Color);  
392 - Enabled := True;  
393 - Parent := FormMatrixGame.GBLastChoice;  
394 - end; 410 + FExperiment.AppendPlayer(P);
  411 + CreatePlayerBox(P, True);
  412 + end
  413 + else
  414 + CreatePlayerBox(P,False);
395 end; 415 end;
396 end; 416 end;
397 417
398 end; 418 end;
399 419
400 -  
401 - procedure ReceiveStatus;  
402 - //var P : PPlayer;  
403 - // i : integer;  
404 - begin  
405 - //P := New(PPlayer);  
406 - //case FActor of  
407 - // gaPlayer:begin  
408 -  
409 - //  
410 - // end;  
411 - //  
412 - // gaAdmin:begin  
413 -  
414 - //end;  
415 - //Dispose(P);  
416 - end;  
417 -  
418 procedure ReceiveChoice; 420 procedure ReceiveChoice;
419 begin 421 begin
420 case FActor of 422 case FActor of
@@ -436,10 +438,17 @@ procedure TGameControl.ReceiveMessage(AMessage: TStringList); @@ -436,10 +438,17 @@ procedure TGameControl.ReceiveMessage(AMessage: TStringList);
436 begin 438 begin
437 case FActor of 439 case FActor of
438 gaPlayer:begin 440 gaPlayer:begin
439 -  
440 - end;  
441 - gaAdmin:begin  
442 - 441 + if Self.ID <> AMessage[1] then Exit;
  442 + FormMatrixGame.Visible := False;
  443 + FormChooseActor := TFormChooseActor.Create(nil);
  444 + FormChooseActor.Style := K_LEFT;
  445 + if FormChooseActor.ShowModal = 1 then
  446 + begin
  447 + FZMQActor.Request([K_RESUME,Self.ID]);
  448 + FormMatrixGame.Visible := True;
  449 + end
  450 + else;
  451 + FormChooseActor.Free;
443 end; 452 end;
444 end; 453 end;
445 end; 454 end;
@@ -484,8 +493,7 @@ begin @@ -484,8 +493,7 @@ begin
484 if MHas(K_ARRIVED) then ReceiveActor; 493 if MHas(K_ARRIVED) then ReceiveActor;
485 if MHas(K_CHAT_M) then ReceiveChat; 494 if MHas(K_CHAT_M) then ReceiveChat;
486 if MHas(K_CHOICE) then ReceiveChoice; 495 if MHas(K_CHOICE) then ReceiveChoice;
487 - if MHas(K_LEFT) then SayGoodBye;  
488 - if MHas(K_RESUME) then ResumeActor; 496 + if MHas(K_KICK) then SayGoodBye;
489 if MHas(K_STATUS) then ReceiveStatus; 497 if MHas(K_STATUS) then ReceiveStatus;
490 end; 498 end;
491 499
@@ -499,11 +507,15 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList); @@ -499,11 +507,15 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList);
499 procedure ReplyLoginRequest; 507 procedure ReplyLoginRequest;
500 var i : integer; 508 var i : integer;
501 P : TPlayer; 509 P : TPlayer;
502 - PS : string; 510 + TS,
  511 + PS : UTF8string;
503 begin 512 begin
504 if not FExperiment.PlayerIsPlaying[ARequest[0]] then 513 if not FExperiment.PlayerIsPlaying[ARequest[0]] then
505 begin 514 begin
506 - if FExperiment.PlayersPlaying.Count < FExperiment.Condition[FExperiment.CurrentCondition].Turn.Value then 515 + {$IFDEF DEBUG}
  516 + WriteLn(FExperiment.PlayersCount,'<',FExperiment.Condition[FExperiment.CurrentCondition].Turn.Value);
  517 + {$ENDIF}
  518 + if FExperiment.PlayersCount < FExperiment.Condition[FExperiment.CurrentCondition].Turn.Value then
507 begin 519 begin
508 // ok, let player login 520 // ok, let player login
509 P.ID := ARequest[0]; 521 P.ID := ARequest[0];
@@ -517,7 +529,7 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList); @@ -517,7 +529,7 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList);
517 end 529 end
518 else 530 else
519 begin 531 begin
520 - // if not save p data 532 + // if not generate and save p data
521 i := FExperiment.AppendPlayer; 533 i := FExperiment.AppendPlayer;
522 P.Nicname := GenResourceName(i); 534 P.Nicname := GenResourceName(i);
523 P.Turn := FExperiment.NextTurn; 535 P.Turn := FExperiment.NextTurn;
@@ -529,50 +541,40 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList); @@ -529,50 +541,40 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList);
529 P.Choice.Last.Color:=gcNone; 541 P.Choice.Last.Color:=gcNone;
530 P.Choice.Last.Row:=grNone; 542 P.Choice.Last.Row:=grNone;
531 // turns by entrance order 543 // turns by entrance order
532 - P.Turn := FExperiment.PlayersPlaying.Count; 544 + P.Turn := FExperiment.PlayersCount;
533 FExperiment.Player[i] := P; 545 FExperiment.Player[i] := P;
534 end; 546 end;
535 547
536 - // add player to playing list  
537 - FExperiment.PlayersPlaying.Add(FExperiment.PlayerPointer[i]);  
538 -  
539 // create/config playerbox 548 // create/config playerbox
540 - with TPlayerBox.Create(FormMatrixGame.GBLastChoice,P.ID) do  
541 - begin  
542 - Caption := P.Nicname;  
543 - i := Integer(P.Choice.Last.Row);  
544 - if i > 0 then  
545 - LabelLastRowCount.Caption := Format('%-*.*d', [1,2,i]);  
546 -  
547 - PanelLastColor.Color := GetColorFromCode(P.Choice.Last.Color);  
548 - Enabled := True;  
549 - Parent := FormMatrixGame.GBLastChoice;  
550 - end; 549 + CreatePlayerBox(P,False);
551 550
552 // Request is now a reply with the following standard: 551 // Request is now a reply with the following standard:
553 // [Requester.ID 0, ' ' 1, ReplyTag 2, PlayerData 3, PlayersPlaying 4 .. n, ChatData Last] 552 // [Requester.ID 0, ' ' 1, ReplyTag 2, PlayerData 3, PlayersPlaying 4 .. n, ChatData Last]
554 ARequest[2] := GA_ADMIN+ARequest[2]+K_ARRIVED; 553 ARequest[2] := GA_ADMIN+ARequest[2]+K_ARRIVED;
555 554
556 - // append player 555 + // player
557 PS := FExperiment.PlayerAsString[P]; 556 PS := FExperiment.PlayerAsString[P];
558 - ARequest.Append(PS); // 3 557 + //ARequest.Append(PS);
559 558
560 // append current players playing 559 // append current players playing
561 - if FExperiment.PlayersPlaying.Count > 0 then  
562 - for i:=0 to FExperiment.PlayersPlaying.Count -1 do  
563 - if PPlayer(FExperiment.PlayersPlaying[i])^.ID <> P.ID then  
564 - ARequest.Append(FExperiment.PlayerAsString[PPlayer(FExperiment.PlayersPlaying[i])^]); // FROM 4 to COUNT-2  
565 -  
566 - // send chat data if allowed at the last position 560 + if FExperiment.PlayersCount > 0 then
  561 + for i:=0 to FExperiment.PlayersCount -1 do
  562 + if FExperiment.Player[i].ID <> P.ID then
  563 + begin
  564 + TS := FExperiment.PlayerAsString[FEXperiment.Player[i]];
  565 + ARequest.Append(TS); // FROM 3 to COUNT-2
  566 + end;
  567 +
  568 + // append chat data if allowed at the last position
567 if FExperiment.SendChatHistoryForNewPlayers then 569 if FExperiment.SendChatHistoryForNewPlayers then
568 ARequest.Append(FormMatrixGame.ChatMemoRecv.Lines.Text) // LAST 570 ARequest.Append(FormMatrixGame.ChatMemoRecv.Lines.Text) // LAST
569 else 571 else
570 ARequest.Append('[CHAT]'); // must append something to keep the message envelop standard 572 ARequest.Append('[CHAT]'); // must append something to keep the message envelop standard
571 573
572 - // inform other players about the new player 574 + // inform all players about the new player, including itself
573 FZMQActor.SendMessage([K_ARRIVED,PS]); 575 FZMQActor.SendMessage([K_ARRIVED,PS]);
574 576
575 - // start cycle if allowed 577 + // start Experiment if allowed
576 if CanStartExperiment then 578 if CanStartExperiment then
577 StartExperiment; 579 StartExperiment;
578 580
@@ -592,31 +594,12 @@ begin @@ -592,31 +594,12 @@ begin
592 if MHas(K_LOGIN) then ReplyLoginRequest; 594 if MHas(K_LOGIN) then ReplyLoginRequest;
593 end; 595 end;
594 596
595 -// Here FActor is garanted to be a TZMQPlayer 597 +// Here FActor is garanted to be a TZMQPlayer, should be used to send all wanted history for new income players
596 procedure TGameControl.ReceiveReply(AReply: TStringList); 598 procedure TGameControl.ReceiveReply(AReply: TStringList);
597 function MHas(const C : string) : Boolean; 599 function MHas(const C : string) : Boolean;
598 begin 600 begin
599 Result := MessageHas(C,AReply,2); 601 Result := MessageHas(C,AReply,2);
600 end; 602 end;
601 - procedure CreatePlayerBox(P:TPlayer; Me:Boolean);  
602 - var i1 : integer;  
603 - begin  
604 - with TPlayerBox.Create(FormMatrixGame.GBLastChoice,P.ID) do  
605 - begin  
606 - if Me then  
607 - Caption := P.Nicname+'Você'  
608 - else  
609 - Caption := P.Nicname;  
610 - i1 := Integer(P.Choice.Last.Row);  
611 - if i1 > 0 then  
612 - LabelLastRowCount.Caption := Format('%-*.*d', [1,2,i1])  
613 - else  
614 - LabelLastRowCount.Caption := 'NA';  
615 - PanelLastColor.Color := GetColorFromCode(P.Choice.Last.Color);  
616 - Enabled := True;  
617 - Parent := FormMatrixGame.GBLastChoice;  
618 - end;  
619 - end;  
620 603
621 procedure LoginAccepted; 604 procedure LoginAccepted;
622 var 605 var
@@ -624,15 +607,12 @@ procedure TGameControl.ReceiveReply(AReply: TStringList); @@ -624,15 +607,12 @@ procedure TGameControl.ReceiveReply(AReply: TStringList);
624 P : TPlayer; 607 P : TPlayer;
625 begin 608 begin
626 {$IFDEF DEBUG} 609 {$IFDEF DEBUG}
627 - WriteLn(Self.ID +' self' + AReply[0] +' reply'); 610 + WriteLn(Self.ID +' self');
  611 + WriteLn(AReply[0] +' reply');
628 {$ENDIF} 612 {$ENDIF}
629 if Self.ID = AReply[0] then 613 if Self.ID = AReply[0] then
630 begin 614 begin
631 - P := FExperiment.PlayerFromString[AReply[3]];  
632 - FExperiment.AppendPlayer(P);  
633 - CreatePlayerBox(P, True);  
634 -  
635 - for i:= 4 to AReply.Count -2 do 615 + for i:= 3 to AReply.Count -2 do
636 begin 616 begin
637 P := FExperiment.PlayerFromString[AReply[i]]; 617 P := FExperiment.PlayerFromString[AReply[i]];
638 CreatePlayerBox(P, False); 618 CreatePlayerBox(P, False);
@@ -651,6 +631,7 @@ procedure TGameControl.ReceiveReply(AReply: TStringList); @@ -651,6 +631,7 @@ procedure TGameControl.ReceiveReply(AReply: TStringList);
651 end; 631 end;
652 632
653 begin 633 begin
  634 + if MHas(K_RESUME+K_ARRIVED) then ResumePlayer;
654 if MHas(K_LOGIN+K_ARRIVED) then LoginAccepted; 635 if MHas(K_LOGIN+K_ARRIVED) then LoginAccepted;
655 end; 636 end;
656 637
units/game_experiment.pas
@@ -14,6 +14,7 @@ type @@ -14,6 +14,7 @@ type
14 14
15 { TExperiment } 15 { TExperiment }
16 16
  17 + TExperimentState = (xsWaiting,xsRunning,xsPaused,xsCanceled);
17 TPlayers = array of TPlayer; 18 TPlayers = array of TPlayer;
18 TConditions = array of TCondition; 19 TConditions = array of TCondition;
19 20
@@ -22,11 +23,10 @@ type @@ -22,11 +23,10 @@ type
22 FExperimentAim, 23 FExperimentAim,
23 FExperimentName, 24 FExperimentName,
24 FFilename, 25 FFilename,
25 - FResearcher : string; 26 + FResearcher : UTF8string;
26 FMatrixType: TGameMatrixType; 27 FMatrixType: TGameMatrixType;
27 FRegData : TRegData; 28 FRegData : TRegData;
28 FGenPlayersAsNeeded : Boolean; 29 FGenPlayersAsNeeded : Boolean;
29 - FPlayersPlaying : TList;  
30 FPlayers : TPlayers; 30 FPlayers : TPlayers;
31 FCurrentCondition : integer; 31 FCurrentCondition : integer;
32 FConditions : TConditions; 32 FConditions : TConditions;
@@ -34,29 +34,28 @@ type @@ -34,29 +34,28 @@ type
34 FResearcherCanPlay: Boolean; 34 FResearcherCanPlay: Boolean;
35 FSendChatHistoryForNewPlayers: Boolean; 35 FSendChatHistoryForNewPlayers: Boolean;
36 FShowChat: Boolean; 36 FShowChat: Boolean;
  37 + FState: TExperimentState;
37 function GetCondition(I : Integer): TCondition; 38 function GetCondition(I : Integer): TCondition;
38 function GetConditionsCount: integer; 39 function GetConditionsCount: integer;
39 function GetContingency(ACondition, I : integer): TContingency; 40 function GetContingency(ACondition, I : integer): TContingency;
40 function GetNextTurn: integer; 41 function GetNextTurn: integer;
41 function GetNextTurnPlayerID: UTF8string; 42 function GetNextTurnPlayerID: UTF8string;
42 function GetPlayer(I : integer): TPlayer; overload; 43 function GetPlayer(I : integer): TPlayer; overload;
43 - function GetPlayer(AID : string): TPlayer; overload; 44 + function GetPlayer(AID : UTF8string): TPlayer; overload;
44 function GetPlayerAsString(P: TPlayer): UTF8string; 45 function GetPlayerAsString(P: TPlayer): UTF8string;
45 - function GetPlayerFromString(s : string): TPlayer;  
46 - function GetPlayerIndexFromID(AID : string): integer;  
47 - function GetPlayerIsPlaying(AID : string): Boolean;  
48 - function GetPlayerPointer(i: integer): PPlayer; 46 + function GetPlayerFromString(s : UTF8string): TPlayer;
  47 + function GetPlayerIndexFromID(AID : UTF8string): integer;
  48 + function GetPlayerIsPlaying(AID : UTF8string): Boolean;
49 function GetPlayersCount: integer; 49 function GetPlayersCount: integer;
50 - //function GetPlayersPlaying: TList;  
51 procedure SetCondition(I : Integer; AValue: TCondition); 50 procedure SetCondition(I : Integer; AValue: TCondition);
52 procedure SetContingency(ACondition, I : integer; AValue: TContingency); 51 procedure SetContingency(ACondition, I : integer; AValue: TContingency);
53 procedure SetMatrixType(AValue: TGameMatrixType); 52 procedure SetMatrixType(AValue: TGameMatrixType);
54 procedure SetPlayer(I : integer; AValue: TPlayer); overload; 53 procedure SetPlayer(I : integer; AValue: TPlayer); overload;
55 - procedure SetPlayer(S : string ; AValue: TPlayer); overload;  
56 - procedure SetPlayersPlaying(AValue: TList); 54 + procedure SetPlayer(S : UTF8string ; AValue: TPlayer); overload;
57 procedure SetResearcherCanChat(AValue: Boolean); 55 procedure SetResearcherCanChat(AValue: Boolean);
58 procedure SetResearcherCanPlay(AValue: Boolean); 56 procedure SetResearcherCanPlay(AValue: Boolean);
59 procedure SetSendChatHistoryForNewPlayers(AValue: Boolean); 57 procedure SetSendChatHistoryForNewPlayers(AValue: Boolean);
  58 + procedure SetState(AValue: TExperimentState);
60 public 59 public
61 constructor Create(AOwner:TComponent);override; 60 constructor Create(AOwner:TComponent);override;
62 constructor Create(AFilename: string; AOwner:TComponent); overload; 61 constructor Create(AFilename: string; AOwner:TComponent); overload;
@@ -71,30 +70,30 @@ type @@ -71,30 +70,30 @@ type
71 function AppendPlayer(APlayer : TPlayer) : integer; overload; 70 function AppendPlayer(APlayer : TPlayer) : integer; overload;
72 procedure SaveToFile(AFilename: string); overload; 71 procedure SaveToFile(AFilename: string); overload;
73 procedure SaveToFile; overload; 72 procedure SaveToFile; overload;
  73 + procedure Clean;
74 property ResearcherCanPlay : Boolean read FResearcherCanPlay write SetResearcherCanPlay; 74 property ResearcherCanPlay : Boolean read FResearcherCanPlay write SetResearcherCanPlay;
75 property ResearcherCanChat : Boolean read FResearcherCanChat write SetResearcherCanChat; 75 property ResearcherCanChat : Boolean read FResearcherCanChat write SetResearcherCanChat;
76 - property Researcher : string read FResearcher write FResearcher; 76 + property Researcher : UTF8string read FResearcher write FResearcher;
77 property Condition[I : Integer]: TCondition read GetCondition write SetCondition; 77 property Condition[I : Integer]: TCondition read GetCondition write SetCondition;
78 property ConditionsCount : integer read GetConditionsCount; 78 property ConditionsCount : integer read GetConditionsCount;
79 property CurrentCondition : integer read FCurrentCondition write FCurrentCondition; 79 property CurrentCondition : integer read FCurrentCondition write FCurrentCondition;
80 property Contingency[C, I : integer] : TContingency read GetContingency write SetContingency; 80 property Contingency[C, I : integer] : TContingency read GetContingency write SetContingency;
81 - property ExperimentAim : string read FExperimentAim write FExperimentAim;  
82 - property ExperimentName : string read FExperimentName write FExperimentName; 81 + property ExperimentAim : UTF8string read FExperimentAim write FExperimentAim;
  82 + property ExperimentName : UTF8string read FExperimentName write FExperimentName;
83 property GenPlayersAsNeeded : Boolean read FGenPlayersAsNeeded write FGenPlayersAsNeeded; 83 property GenPlayersAsNeeded : Boolean read FGenPlayersAsNeeded write FGenPlayersAsNeeded;
84 property Player[I : integer] : TPlayer read GetPlayer write SetPlayer; 84 property Player[I : integer] : TPlayer read GetPlayer write SetPlayer;
85 - property PlayerFromID[S : string ] : TPlayer read GetPlayer write SetPlayer;  
86 - property PlayersCount : integer read GetPlayersCount; // how many players per turn?  
87 - property PlayersPlaying : TList read FPlayersPlaying write SetPlayersPlaying; // how many players are playing?  
88 - property PlayerIsPlaying[s : string] : Boolean read GetPlayerIsPlaying;  
89 - property PlayerIndexFromID[s : string]: integer read GetPlayerIndexFromID; 85 + property PlayerFromID[S : UTF8string ] : TPlayer read GetPlayer write SetPlayer;
  86 + property PlayersCount : integer read GetPlayersCount;
  87 + property PlayerIsPlaying[s : UTF8string] : Boolean read GetPlayerIsPlaying;
  88 + property PlayerIndexFromID[s : UTF8string]: integer read GetPlayerIndexFromID;
90 property PlayerAsString[P:TPlayer]: UTF8string read GetPlayerAsString; 89 property PlayerAsString[P:TPlayer]: UTF8string read GetPlayerAsString;
91 - property PlayerFromString[s : string]: TPlayer read GetPlayerFromString;  
92 - property PlayerPointer[i:integer]: PPlayer read GetPlayerPointer; 90 + property PlayerFromString[s : UTF8string]: TPlayer read GetPlayerFromString;
93 property ShowChat : Boolean read FShowChat write FShowChat; 91 property ShowChat : Boolean read FShowChat write FShowChat;
94 property SendChatHistoryForNewPlayers : Boolean read FSendChatHistoryForNewPlayers write SetSendChatHistoryForNewPlayers; 92 property SendChatHistoryForNewPlayers : Boolean read FSendChatHistoryForNewPlayers write SetSendChatHistoryForNewPlayers;
95 property MatrixType : TGameMatrixType read FMatrixType write SetMatrixType; 93 property MatrixType : TGameMatrixType read FMatrixType write SetMatrixType;
96 property NextTurnPlayerID : UTF8string read GetNextTurnPlayerID; 94 property NextTurnPlayerID : UTF8string read GetNextTurnPlayerID;
97 property NextTurn : integer read GetNextTurn; 95 property NextTurn : integer read GetNextTurn;
  96 + property State : TExperimentState read FState write SetState;
98 end; 97 end;
99 98
100 resourcestring 99 resourcestring
@@ -113,7 +112,7 @@ end; @@ -113,7 +112,7 @@ end;
113 112
114 function TExperiment.GetConditionsCount: integer; 113 function TExperiment.GetConditionsCount: integer;
115 begin 114 begin
116 - Result := High(FConditions); 115 + Result := Length(FConditions);
117 end; 116 end;
118 117
119 function TExperiment.GetContingency(ACondition, I : integer): TContingency; 118 function TExperiment.GetContingency(ACondition, I : integer): TContingency;
@@ -130,15 +129,9 @@ begin @@ -130,15 +129,9 @@ begin
130 end; 129 end;
131 130
132 function TExperiment.GetNextTurnPlayerID: UTF8string; // used during cycles 131 function TExperiment.GetNextTurnPlayerID: UTF8string; // used during cycles
133 -var  
134 - P : PPlayer;  
135 begin 132 begin
136 - Result := '';  
137 - P := New(PPlayer);  
138 - P := PlayersPlaying[FConditions[CurrentCondition].Turn.Count];  
139 - Result := P^.ID; 133 + Result := Player[FConditions[CurrentCondition].Turn.Count].ID;
140 GetNextTurn; 134 GetNextTurn;
141 - Dispose(P);  
142 end; 135 end;
143 136
144 function TExperiment.GetPlayer(I : integer): TPlayer; 137 function TExperiment.GetPlayer(I : integer): TPlayer;
@@ -146,7 +139,7 @@ begin @@ -146,7 +139,7 @@ begin
146 Result := FPlayers[i]; 139 Result := FPlayers[i];
147 end; 140 end;
148 141
149 -function TExperiment.GetPlayer(AID: string): TPlayer; 142 +function TExperiment.GetPlayer(AID: UTF8string): TPlayer;
150 var 143 var
151 i : integer; 144 i : integer;
152 begin 145 begin
@@ -236,7 +229,7 @@ begin @@ -236,7 +229,7 @@ begin
236 Result += M[i] + '|'; 229 Result += M[i] + '|';
237 end; 230 end;
238 231
239 -function TExperiment.GetPlayerFromString(s : string): TPlayer; 232 +function TExperiment.GetPlayerFromString(s: UTF8string): TPlayer;
240 233
241 function GetRowFromString(S: string): TGameRow; 234 function GetRowFromString(S: string): TGameRow;
242 begin 235 begin
@@ -304,7 +297,7 @@ begin @@ -304,7 +297,7 @@ begin
304 Result.Choice.Last := GetChoiceFromString(ExtractDelimited(6,s,['|'])); 297 Result.Choice.Last := GetChoiceFromString(ExtractDelimited(6,s,['|']));
305 end; 298 end;
306 299
307 -function TExperiment.GetPlayerIndexFromID(AID: string): integer; 300 +function TExperiment.GetPlayerIndexFromID(AID: UTF8string): integer;
308 var i : integer; 301 var i : integer;
309 begin 302 begin
310 Result := -1; 303 Result := -1;
@@ -316,46 +309,23 @@ begin @@ -316,46 +309,23 @@ begin
316 end; 309 end;
317 end; 310 end;
318 311
319 -function TExperiment.GetPlayerIsPlaying(AID: string): Boolean; 312 +function TExperiment.GetPlayerIsPlaying(AID: UTF8string): Boolean;
320 var i : integer; 313 var i : integer;
321 begin 314 begin
322 - Result := PlayersPlaying.Count > 0; 315 + Result := PlayersCount > 0;
323 if Result then 316 if Result then
324 - for i := 0 to PlayersPlaying.Count -1 do  
325 - if PPlayer(PlayersPlaying[i])^.ID = AID then 317 + for i := 0 to PlayersCount -1 do
  318 + if Player[i].ID = AID then
326 Exit; 319 Exit;
327 Result:= False; 320 Result:= False;
328 end; 321 end;
329 322
330 -function TExperiment.GetPlayerPointer(i: integer): PPlayer;  
331 -begin  
332 - Result := @FPlayers[i];  
333 -end;  
334 323
335 function TExperiment.GetPlayersCount: integer; 324 function TExperiment.GetPlayersCount: integer;
336 begin 325 begin
337 Result := Length(FPlayers); 326 Result := Length(FPlayers);
338 end; 327 end;
339 328
340 -//function TExperiment.GetPlayersPlaying: TList;  
341 -//var  
342 -// //i:integer;  
343 -// //P:PPlayer;  
344 -//begin  
345 -// //P := New(PPlayer);  
346 -// //if FPlayersPlaying.Count > 0 then  
347 -// // FPlayersPlaying.Clear;  
348 -// //  
349 -// //for i := Low(FPlayers) to High(FPlayers) do  
350 -// // if FPlayers[i].Status = gpsPlaying then  
351 -// // begin  
352 -// // P := @FPlayers[i];  
353 -// // FPlayersPlaying.Add(P);  
354 -// // end;  
355 -// //Dispose(P);  
356 -// Result := FPlayersPlaying;  
357 -//end;  
358 -  
359 procedure TExperiment.SetCondition(I : Integer; AValue: TCondition); 329 procedure TExperiment.SetCondition(I : Integer; AValue: TCondition);
360 begin 330 begin
361 FConditions[I] := AValue; 331 FConditions[I] := AValue;
@@ -378,7 +348,7 @@ begin @@ -378,7 +348,7 @@ begin
378 FPlayers[I] := AValue; 348 FPlayers[I] := AValue;
379 end; 349 end;
380 350
381 -procedure TExperiment.SetPlayer(S : string ; AValue: TPlayer); 351 +procedure TExperiment.SetPlayer(S: UTF8string; AValue: TPlayer);
382 var i : integer; 352 var i : integer;
383 begin 353 begin
384 if PlayersCount > 0 then 354 if PlayersCount > 0 then
@@ -391,12 +361,6 @@ begin @@ -391,12 +361,6 @@ begin
391 raise Exception.Create('TExperiment.SetPlayer: Could not set player.'); 361 raise Exception.Create('TExperiment.SetPlayer: Could not set player.');
392 end; 362 end;
393 363
394 -procedure TExperiment.SetPlayersPlaying(AValue: TList);  
395 -begin  
396 - if FPlayersPlaying = AValue then Exit;  
397 - FPlayersPlaying := AValue;  
398 -end;  
399 -  
400 procedure TExperiment.SetResearcherCanChat(AValue: Boolean); 364 procedure TExperiment.SetResearcherCanChat(AValue: Boolean);
401 begin 365 begin
402 if FResearcherCanChat=AValue then Exit; 366 if FResearcherCanChat=AValue then Exit;
@@ -415,10 +379,15 @@ begin @@ -415,10 +379,15 @@ begin
415 FSendChatHistoryForNewPlayers:=AValue; 379 FSendChatHistoryForNewPlayers:=AValue;
416 end; 380 end;
417 381
  382 +procedure TExperiment.SetState(AValue: TExperimentState);
  383 +begin
  384 + if FState=AValue then Exit;
  385 + FState:=AValue;
  386 +end;
  387 +
418 constructor TExperiment.Create(AOwner: TComponent); 388 constructor TExperiment.Create(AOwner: TComponent);
419 begin 389 begin
420 inherited Create(AOwner); 390 inherited Create(AOwner);
421 - FPlayersPlaying := TList.Create;  
422 LoadExperimentFromResource(Self); 391 LoadExperimentFromResource(Self);
423 end; 392 end;
424 393
@@ -430,7 +399,6 @@ end; @@ -430,7 +399,6 @@ end;
430 399
431 destructor TExperiment.Destroy; 400 destructor TExperiment.Destroy;
432 begin 401 begin
433 - FPlayersPlaying.Free;  
434 inherited Destroy; 402 inherited Destroy;
435 end; 403 end;
436 404
@@ -503,5 +471,10 @@ begin @@ -503,5 +471,10 @@ begin
503 {$ENDIF}; 471 {$ENDIF};
504 end; 472 end;
505 473
  474 +procedure TExperiment.Clean;
  475 +begin
  476 +
  477 +end;
  478 +
506 end. 479 end.
507 480
units/game_file_methods.pas
@@ -34,6 +34,7 @@ uses LCLIntf, game_actors_point, game_resources, string_methods, regdata, zhelpe @@ -34,6 +34,7 @@ uses LCLIntf, game_actors_point, game_resources, string_methods, regdata, zhelpe
34 34
35 function LoadExperimentFromResource(var AExperiment: TExperiment): Boolean; 35 function LoadExperimentFromResource(var AExperiment: TExperiment): Boolean;
36 var i,j : integer; 36 var i,j : integer;
  37 + C : TCondition;
37 begin 38 begin
38 Result := False; 39 Result := False;
39 with AExperiment do 40 with AExperiment do
@@ -47,18 +48,17 @@ begin @@ -47,18 +48,17 @@ begin
47 GenPlayersAsNeeded:=True; 48 GenPlayersAsNeeded:=True;
48 CurrentCondition := 0; 49 CurrentCondition := 0;
49 MatrixType:=[gmRows]; 50 MatrixType:=[gmRows];
50 - PlayersPlaying := TList.Create;  
51 //AppendPlayer(C_PLAYER_TEMPLATE); 51 //AppendPlayer(C_PLAYER_TEMPLATE);
52 //AppendPlayer(C_PLAYER_TEMPLATE); 52 //AppendPlayer(C_PLAYER_TEMPLATE);
53 - i := AppendCondition(C_CONDITION_TEMPLATE);  
54 - with Condition[i] do 53 + C := C_CONDITION_TEMPLATE;
  54 + with C do
55 begin 55 begin
56 - ConditionName := SEC_CONDITION+IntToStr(i+1); 56 + ConditionName := SEC_CONDITION+IntToStr(1);
57 Turn.Count:=0; 57 Turn.Count:=0;
58 Turn.Value:=2; 58 Turn.Value:=2;
59 Turn.Random:=False; 59 Turn.Random:=False;
60 end; 60 end;
61 - //j := AppendContingency(i,C_METACONTINGENCY_A1); 61 + i := AppendCondition(C);
62 end; 62 end;
63 end; 63 end;
64 64
units/game_resources.pas
@@ -84,7 +84,7 @@ const @@ -84,7 +84,7 @@ const
84 const 84 const
85 85
86 CPlayerNamesMale : array [0..49] of UTF8String = 86 CPlayerNamesMale : array [0..49] of UTF8String =
87 - ('Junho','Rodrigo','Francisco','Martim','Santiago', 87 + ('Jo','Rodrigo','Francisco','Martim','Santiago',
88 'Tomás','Afonso','Duarte','Miguel','Guilherme','Tiago', 88 'Tomás','Afonso','Duarte','Miguel','Guilherme','Tiago',
89 'Gonçalo','Diogo','Gabriel','Pedro','Rafael','Salvador', 89 'Gonçalo','Diogo','Gabriel','Pedro','Rafael','Salvador',
90 'Dinis','Lucas','Simael','Gustavo','David', 90 'Dinis','Lucas','Simael','Gustavo','David',