Commit b74fe8d0656ded0a755b29d4f1c6d91d31d97489

Authored by Carlos Picanco
1 parent bc12e601
Exists in master

separate issues, actor helpers from resources

units/game_actors_helpers.pas 0 → 100644
@@ -0,0 +1,159 @@ @@ -0,0 +1,159 @@
  1 +unit game_actors_helpers;
  2 +
  3 +{$mode objfpc}{$H+}
  4 +
  5 +interface
  6 +
  7 +uses
  8 + Classes, SysUtils, Graphics, game_actors;
  9 +
  10 +function GetColorFromCode(ACode : TGameColor) : TColor;
  11 +
  12 +const
  13 +
  14 + C_PLAYER_TEMPLATE : TPlayer = (
  15 + ID : '';
  16 + Nicname : '';
  17 + Login :'';
  18 + Password : '';
  19 + Status : gpsWaiting;
  20 + Data : nil;
  21 + Choice : (Row:grNone; Color:gcNone;);
  22 + Points : (A:0; B:0);
  23 + Turn : -1;
  24 + );
  25 +
  26 + //C_OPERANT_1 : TContingency =
  27 + // (
  28 + // Consequence : (
  29 + // Style : [gscShowMessage,gscPoints, gscB];
  30 + // Message : '<$JOGADOR> produziu 1 ponto do tipo B.';
  31 + // Value: 1;
  32 + // Variation:1;
  33 + //
  34 + // Criteria : (
  35 + // Style : goNONE;
  36 + // Rows : [grEven];
  37 + // Colors : [gcNone];
  38 + // );
  39 + //
  40 + // Meta : False;
  41 + // );
  42 +
  43 + //C_OPERANT_2 : TContingency =
  44 + // (
  45 + // Consequence : (
  46 + // Style : [gscShowMessage,gscPoints, gscA];
  47 + // Message : '<$JOGADOR> produziu 3 pontos do tipo A.';
  48 + //
  49 + // Criteria : (
  50 + // Operator_ : goNONE;
  51 + // Rows : [grEven];
  52 + // Colors : [gcNone];
  53 + // );
  54 + //
  55 + // Meta : False;
  56 + // );
  57 +
  58 + //C_METACONTINGENCY_A1 : TContingency =
  59 + // (
  60 + // Consequence : (
  61 + // Style : [gscShowMessage,gscPoints,gscBroadcastMessage];
  62 + // Points :( A : 0; B : 0; G : 1;);
  63 + // Message : 'Vocês produziram 1 item escolar.'; // show first in case of last participant
  64 + // Cycles : 0; // absolute,
  65 + // VariationMin: 0; // porcentage,
  66 + // VariationMax : 0; // porcentage
  67 + // Prompt : (
  68 + // Message : '';
  69 + // Style : [];
  70 + // );
  71 + // );
  72 + //
  73 + // Response : (
  74 + // Operator_ : goAND;
  75 + // Rows : [grEven];
  76 + // Colors : [gcDiff];
  77 + // );
  78 + //
  79 + // Meta : True;
  80 + // );
  81 +
  82 +
  83 + //C_METACONTINGENCY_B2: TContingency =
  84 + // (
  85 + // Consequence : (
  86 + // Style : [gscShowMessage,gscPoints,gscBroadcastMessage,gscPromptQuestion];
  87 + // Points :(A :0; B : 0; G : -1;);
  88 + // Message : 'Vocês produziram a perda de 1 item escolar.';
  89 + // Cycles : 0; // absolute,
  90 + // VariationMin: 0; // porcentage,
  91 + // VariationMax : 0; // porcentage
  92 + // Prompt : (
  93 + // Message : 'Um item escolar foi perdido, desejam recuperá-lo gastando pontos do Tipo A?';
  94 + // Style : [gsAll,gsYes,gsMetacontingency,gsRecoverLostPoints, gsContingency, gsBasA];
  95 + // );
  96 + // );
  97 + //
  98 + // Response : (
  99 + // Operator_ : goNONE;
  100 + // Rows : [grOdd, grSome];
  101 + // Colors : [gcNone];
  102 + // );
  103 + //
  104 + // Meta : True;
  105 + // );
  106 +
  107 + C_CONDITION_TEMPLATE : TCondition =
  108 + (
  109 + ConditionName : '';
  110 + Contingencies : nil;
  111 + //Interlocks : (
  112 + // Count : 0;
  113 + // History : nil;
  114 + //);
  115 +
  116 + Points : (
  117 + Count : ( A:0; B:0; G:0; );
  118 + OnStart : ( A:0; B:0; G:0; );
  119 + );
  120 +
  121 + Turn : (
  122 + Count: 0;
  123 + Value : 0;
  124 + Random: False;
  125 + );
  126 +
  127 + Cycles : (
  128 + Count : 0;
  129 + Value : 0;
  130 + Generation : 0;
  131 + );
  132 +
  133 + Prompt : nil;
  134 + EndCriterium : (
  135 + Style : gecWhichComeFirst;
  136 + InterlockingPorcentage : 50;
  137 + LastCycles : 4;
  138 + AbsoluteCycles: 6;
  139 + );
  140 + );
  141 +
  142 +implementation
  143 +
  144 +uses game_resources;
  145 +
  146 +function GetColorFromCode(ACode: TGameColor): TColor;
  147 +begin
  148 + case ACode of
  149 + gcNone :Result := clInactiveCaption;
  150 + gcYellow :Result := ccYellow;
  151 + gcRed :Result := ccRed;
  152 + gcMagenta :Result := ccMagenta;
  153 + gcBlue :Result := ccBlue;
  154 + gcGreen :Result := ccGreen;
  155 + end;
  156 +end;
  157 +
  158 +end.
  159 +
units/game_control.pas
@@ -126,6 +126,7 @@ uses ButtonPanel,Controls,ExtCtrls,StdCtrls,LazUTF8, Forms, strutils @@ -126,6 +126,7 @@ uses ButtonPanel,Controls,ExtCtrls,StdCtrls,LazUTF8, Forms, strutils
126 , presentation_classes 126 , presentation_classes
127 , form_chooseactor 127 , form_chooseactor
128 , game_resources 128 , game_resources
  129 + , game_actors_helpers
129 , string_methods 130 , string_methods
130 ; 131 ;
131 132
units/game_file_methods.pas
@@ -32,14 +32,14 @@ type @@ -32,14 +32,14 @@ type
32 procedure SaveExperimentToFile(AExperiment: TExperiment; AFilename : string); 32 procedure SaveExperimentToFile(AExperiment: TExperiment; AFilename : string);
33 33
34 resourcestring 34 resourcestring
35 - ERROR_SECTION_NOT_FOUND = 'O arquivo não pode ser aberto, pois não foi encontrada a secção: '; 35 + ERROR_SECTION_NOT_FOUND = 'O arquivo não pode ser aberto, pois a secção não foi encontrada: ';
36 ERROR_FILE_NOT_FOUND = 'O arquivo não pode ser aberto, pois ele não existe.'; 36 ERROR_FILE_NOT_FOUND = 'O arquivo não pode ser aberto, pois ele não existe.';
37 WARN_CONDITION_WITH_NO_END = 'Condição sem critério de encerramento: '; 37 WARN_CONDITION_WITH_NO_END = 'Condição sem critério de encerramento: ';
38 WARN_END = ' será usado.'; 38 WARN_END = ' será usado.';
39 39
40 implementation 40 implementation
41 41
42 -uses LCLIntf, game_resources, string_methods, regdata, zhelpers, strutils; 42 +uses LCLIntf, game_resources, game_actors_helpers, string_methods, regdata, zhelpers, strutils;
43 43
44 function LoadExperimentFromResource(var AExperiment: TExperiment): Boolean; 44 function LoadExperimentFromResource(var AExperiment: TExperiment): Boolean;
45 var 45 var
@@ -72,12 +72,12 @@ begin @@ -72,12 +72,12 @@ begin
72 Result := False; 72 Result := False;
73 with AExperiment do 73 with AExperiment do
74 begin 74 begin
  75 + ExperimentName:='test_experiment';
  76 + ExperimentAim:='This is a test experiment.';
75 Researcher := VAL_RESEARCHER; 77 Researcher := VAL_RESEARCHER;
76 ResearcherCanPlay:=False; 78 ResearcherCanPlay:=False;
77 ResearcherCanChat:=True; 79 ResearcherCanChat:=True;
78 SendChatHistoryForNewPlayers:=True; 80 SendChatHistoryForNewPlayers:=True;
79 - ExperimentName:='test_experiment';  
80 - ExperimentAim:='This is a test experiment.';  
81 GenPlayersAsNeeded:=True; 81 GenPlayersAsNeeded:=True;
82 CurrentCondition := 0; 82 CurrentCondition := 0;
83 MatrixType:=[gmRows]; 83 MatrixType:=[gmRows];
units/game_resources.pas
@@ -14,12 +14,9 @@ unit game_resources; @@ -14,12 +14,9 @@ unit game_resources;
14 interface 14 interface
15 15
16 uses 16 uses
17 - Classes, SysUtils, Graphics  
18 - , game_actors  
19 - ; 17 + Classes, SysUtils, Graphics;
20 18
21 function GenResourceName(i : integer) : string; 19 function GenResourceName(i : integer) : string;
22 -function GetColorFromCode(ACode : TGameColor) : TColor;  
23 20
24 resourcestring 21 resourcestring
25 KV_SEP = '='; 22 KV_SEP = '=';
@@ -119,137 +116,10 @@ const @@ -119,137 +116,10 @@ const
119 'Nicole','Luísa','Daniela','Núria','Bruna', 116 'Nicole','Luísa','Daniela','Núria','Bruna',
120 'Victória','Alícia','Rafaela','Helena','Miriam'); 117 'Victória','Alícia','Rafaela','Helena','Miriam');
121 118
122 - C_PLAYER_TEMPLATE : TPlayer = (  
123 - ID : '';  
124 - Nicname : '';  
125 - Login :'';  
126 - Password : '';  
127 - Status : gpsWaiting;  
128 - Data : nil;  
129 - Choice : (Row:grNone; Color:gcNone;);  
130 - Points : (A:0; B:0);  
131 - Turn : -1;  
132 - );  
133 -  
134 - //C_OPERANT_1 : TContingency =  
135 - // (  
136 - // Consequence : (  
137 - // Style : [gscShowMessage,gscPoints, gscB];  
138 - // Message : '<$JOGADOR> produziu 1 ponto do tipo B.';  
139 - // Value: 1;  
140 - // Variation:1;  
141 - //  
142 - // Criteria : (  
143 - // Style : goNONE;  
144 - // Rows : [grEven];  
145 - // Colors : [gcNone];  
146 - // );  
147 - //  
148 - // Meta : False;  
149 - // );  
150 -  
151 - //C_OPERANT_2 : TContingency =  
152 - // (  
153 - // Consequence : (  
154 - // Style : [gscShowMessage,gscPoints, gscA];  
155 - // Message : '<$JOGADOR> produziu 3 pontos do tipo A.';  
156 - //  
157 - // Criteria : (  
158 - // Operator_ : goNONE;  
159 - // Rows : [grEven];  
160 - // Colors : [gcNone];  
161 - // );  
162 - //  
163 - // Meta : False;  
164 - // );  
165 -  
166 - //C_METACONTINGENCY_A1 : TContingency =  
167 - // (  
168 - // Consequence : (  
169 - // Style : [gscShowMessage,gscPoints,gscBroadcastMessage];  
170 - // Points :( A : 0; B : 0; G : 1;);  
171 - // Message : 'Vocês produziram 1 item escolar.'; // show first in case of last participant  
172 - // Cycles : 0; // absolute,  
173 - // VariationMin: 0; // porcentage,  
174 - // VariationMax : 0; // porcentage  
175 - // Prompt : (  
176 - // Message : '';  
177 - // Style : [];  
178 - // );  
179 - // );  
180 - //  
181 - // Response : (  
182 - // Operator_ : goAND;  
183 - // Rows : [grEven];  
184 - // Colors : [gcDiff];  
185 - // );  
186 - //  
187 - // Meta : True;  
188 - // );  
189 -  
190 -  
191 - //C_METACONTINGENCY_B2: TContingency =  
192 - // (  
193 - // Consequence : (  
194 - // Style : [gscShowMessage,gscPoints,gscBroadcastMessage,gscPromptQuestion];  
195 - // Points :(A :0; B : 0; G : -1;);  
196 - // Message : 'Vocês produziram a perda de 1 item escolar.';  
197 - // Cycles : 0; // absolute,  
198 - // VariationMin: 0; // porcentage,  
199 - // VariationMax : 0; // porcentage  
200 - // Prompt : (  
201 - // Message : 'Um item escolar foi perdido, desejam recuperá-lo gastando pontos do Tipo A?';  
202 - // Style : [gsAll,gsYes,gsMetacontingency,gsRecoverLostPoints, gsContingency, gsBasA];  
203 - // );  
204 - // );  
205 - //  
206 - // Response : (  
207 - // Operator_ : goNONE;  
208 - // Rows : [grOdd, grSome];  
209 - // Colors : [gcNone];  
210 - // );  
211 - //  
212 - // Meta : True;  
213 - // );  
214 -  
215 - C_CONDITION_TEMPLATE : TCondition =  
216 - (  
217 - ConditionName : '';  
218 - Contingencies : nil;  
219 - //Interlocks : (  
220 - // Count : 0;  
221 - // History : nil;  
222 - //);  
223 -  
224 - Points : (  
225 - Count : ( A:0; B:0; G:0; );  
226 - OnStart : ( A:0; B:0; G:0; );  
227 - );  
228 -  
229 - Turn : (  
230 - Count: 0;  
231 - Value : 0;  
232 - Random: False;  
233 - );  
234 -  
235 - Cycles : (  
236 - Count : 0;  
237 - Value : 0;  
238 - Generation : 0;  
239 - );  
240 -  
241 - Prompt : nil;  
242 - EndCriterium : (  
243 - Style : gecWhichComeFirst;  
244 - InterlockingPorcentage : 50;  
245 - LastCycles : 4;  
246 - AbsoluteCycles: 6;  
247 - );  
248 - );  
249 119
250 implementation 120 implementation
251 121
252 -uses zhelpers; 122 +//uses zhelpers;
253 123
254 function GenResourceName(i: integer): string; 124 function GenResourceName(i: integer): string;
255 var r :integer; 125 var r :integer;
@@ -265,17 +135,6 @@ begin @@ -265,17 +135,6 @@ begin
265 135
266 end; 136 end;
267 137
268 -function GetColorFromCode(ACode: TGameColor): TColor;  
269 -begin  
270 - case ACode of  
271 - gcNone :Result := clInactiveCaption;  
272 - gcYellow :Result := ccYellow;  
273 - gcRed :Result := ccRed;  
274 - gcMagenta :Result := ccMagenta;  
275 - gcBlue :Result := ccBlue;  
276 - gcGreen :Result := ccGreen;  
277 - end;  
278 -end;  
279 138
280 initialization 139 initialization
281 140