From b74fe8d0656ded0a755b29d4f1c6d91d31d97489 Mon Sep 17 00:00:00 2001 From: cpicanco Date: Tue, 6 Dec 2016 14:43:53 -0300 Subject: [PATCH] separate issues, actor helpers from resources --- units/game_actors_helpers.pas | 159 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ units/game_control.pas | 1 + units/game_file_methods.pas | 8 ++++---- units/game_resources.pas | 145 ++----------------------------------------------------------------------------------------------------------------------------------------------- 4 files changed, 166 insertions(+), 147 deletions(-) create mode 100644 units/game_actors_helpers.pas diff --git a/units/game_actors_helpers.pas b/units/game_actors_helpers.pas new file mode 100644 index 0000000..bfbb03e --- /dev/null +++ b/units/game_actors_helpers.pas @@ -0,0 +1,159 @@ +unit game_actors_helpers; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, Graphics, game_actors; + +function GetColorFromCode(ACode : TGameColor) : TColor; + +const + + C_PLAYER_TEMPLATE : TPlayer = ( + ID : ''; + Nicname : ''; + Login :''; + Password : ''; + Status : gpsWaiting; + Data : nil; + Choice : (Row:grNone; Color:gcNone;); + Points : (A:0; B:0); + Turn : -1; + ); + + //C_OPERANT_1 : TContingency = + // ( + // Consequence : ( + // Style : [gscShowMessage,gscPoints, gscB]; + // Message : '<$JOGADOR> produziu 1 ponto do tipo B.'; + // Value: 1; + // Variation:1; + // + // Criteria : ( + // Style : goNONE; + // Rows : [grEven]; + // Colors : [gcNone]; + // ); + // + // Meta : False; + // ); + + //C_OPERANT_2 : TContingency = + // ( + // Consequence : ( + // Style : [gscShowMessage,gscPoints, gscA]; + // Message : '<$JOGADOR> produziu 3 pontos do tipo A.'; + // + // Criteria : ( + // Operator_ : goNONE; + // Rows : [grEven]; + // Colors : [gcNone]; + // ); + // + // Meta : False; + // ); + + //C_METACONTINGENCY_A1 : TContingency = + // ( + // Consequence : ( + // Style : [gscShowMessage,gscPoints,gscBroadcastMessage]; + // Points :( A : 0; B : 0; G : 1;); + // Message : 'Vocês produziram 1 item escolar.'; // show first in case of last participant + // Cycles : 0; // absolute, + // VariationMin: 0; // porcentage, + // VariationMax : 0; // porcentage + // Prompt : ( + // Message : ''; + // Style : []; + // ); + // ); + // + // Response : ( + // Operator_ : goAND; + // Rows : [grEven]; + // Colors : [gcDiff]; + // ); + // + // Meta : True; + // ); + + + //C_METACONTINGENCY_B2: TContingency = + // ( + // Consequence : ( + // Style : [gscShowMessage,gscPoints,gscBroadcastMessage,gscPromptQuestion]; + // Points :(A :0; B : 0; G : -1;); + // Message : 'Vocês produziram a perda de 1 item escolar.'; + // Cycles : 0; // absolute, + // VariationMin: 0; // porcentage, + // VariationMax : 0; // porcentage + // Prompt : ( + // Message : 'Um item escolar foi perdido, desejam recuperá-lo gastando pontos do Tipo A?'; + // Style : [gsAll,gsYes,gsMetacontingency,gsRecoverLostPoints, gsContingency, gsBasA]; + // ); + // ); + // + // Response : ( + // Operator_ : goNONE; + // Rows : [grOdd, grSome]; + // Colors : [gcNone]; + // ); + // + // Meta : True; + // ); + + C_CONDITION_TEMPLATE : TCondition = + ( + ConditionName : ''; + Contingencies : nil; + //Interlocks : ( + // Count : 0; + // History : nil; + //); + + Points : ( + Count : ( A:0; B:0; G:0; ); + OnStart : ( A:0; B:0; G:0; ); + ); + + Turn : ( + Count: 0; + Value : 0; + Random: False; + ); + + Cycles : ( + Count : 0; + Value : 0; + Generation : 0; + ); + + Prompt : nil; + EndCriterium : ( + Style : gecWhichComeFirst; + InterlockingPorcentage : 50; + LastCycles : 4; + AbsoluteCycles: 6; + ); + ); + +implementation + +uses game_resources; + +function GetColorFromCode(ACode: TGameColor): TColor; +begin + case ACode of + gcNone :Result := clInactiveCaption; + gcYellow :Result := ccYellow; + gcRed :Result := ccRed; + gcMagenta :Result := ccMagenta; + gcBlue :Result := ccBlue; + gcGreen :Result := ccGreen; + end; +end; + +end. + diff --git a/units/game_control.pas b/units/game_control.pas index d5aa996..9f43edb 100644 --- a/units/game_control.pas +++ b/units/game_control.pas @@ -126,6 +126,7 @@ uses ButtonPanel,Controls,ExtCtrls,StdCtrls,LazUTF8, Forms, strutils , presentation_classes , form_chooseactor , game_resources + , game_actors_helpers , string_methods ; diff --git a/units/game_file_methods.pas b/units/game_file_methods.pas index 169dfef..5efc025 100644 --- a/units/game_file_methods.pas +++ b/units/game_file_methods.pas @@ -32,14 +32,14 @@ type procedure SaveExperimentToFile(AExperiment: TExperiment; AFilename : string); resourcestring - ERROR_SECTION_NOT_FOUND = 'O arquivo não pode ser aberto, pois não foi encontrada a secção: '; + ERROR_SECTION_NOT_FOUND = 'O arquivo não pode ser aberto, pois a secção não foi encontrada: '; ERROR_FILE_NOT_FOUND = 'O arquivo não pode ser aberto, pois ele não existe.'; WARN_CONDITION_WITH_NO_END = 'Condição sem critério de encerramento: '; WARN_END = ' será usado.'; implementation -uses LCLIntf, game_resources, string_methods, regdata, zhelpers, strutils; +uses LCLIntf, game_resources, game_actors_helpers, string_methods, regdata, zhelpers, strutils; function LoadExperimentFromResource(var AExperiment: TExperiment): Boolean; var @@ -72,12 +72,12 @@ begin Result := False; with AExperiment do begin + ExperimentName:='test_experiment'; + ExperimentAim:='This is a test experiment.'; Researcher := VAL_RESEARCHER; ResearcherCanPlay:=False; ResearcherCanChat:=True; SendChatHistoryForNewPlayers:=True; - ExperimentName:='test_experiment'; - ExperimentAim:='This is a test experiment.'; GenPlayersAsNeeded:=True; CurrentCondition := 0; MatrixType:=[gmRows]; diff --git a/units/game_resources.pas b/units/game_resources.pas index 71224bf..c219c0c 100644 --- a/units/game_resources.pas +++ b/units/game_resources.pas @@ -14,12 +14,9 @@ unit game_resources; interface uses - Classes, SysUtils, Graphics - , game_actors - ; + Classes, SysUtils, Graphics; function GenResourceName(i : integer) : string; -function GetColorFromCode(ACode : TGameColor) : TColor; resourcestring KV_SEP = '='; @@ -119,137 +116,10 @@ const 'Nicole','Luísa','Daniela','Núria','Bruna', 'Victória','Alícia','Rafaela','Helena','Miriam'); - C_PLAYER_TEMPLATE : TPlayer = ( - ID : ''; - Nicname : ''; - Login :''; - Password : ''; - Status : gpsWaiting; - Data : nil; - Choice : (Row:grNone; Color:gcNone;); - Points : (A:0; B:0); - Turn : -1; - ); - - //C_OPERANT_1 : TContingency = - // ( - // Consequence : ( - // Style : [gscShowMessage,gscPoints, gscB]; - // Message : '<$JOGADOR> produziu 1 ponto do tipo B.'; - // Value: 1; - // Variation:1; - // - // Criteria : ( - // Style : goNONE; - // Rows : [grEven]; - // Colors : [gcNone]; - // ); - // - // Meta : False; - // ); - - //C_OPERANT_2 : TContingency = - // ( - // Consequence : ( - // Style : [gscShowMessage,gscPoints, gscA]; - // Message : '<$JOGADOR> produziu 3 pontos do tipo A.'; - // - // Criteria : ( - // Operator_ : goNONE; - // Rows : [grEven]; - // Colors : [gcNone]; - // ); - // - // Meta : False; - // ); - - //C_METACONTINGENCY_A1 : TContingency = - // ( - // Consequence : ( - // Style : [gscShowMessage,gscPoints,gscBroadcastMessage]; - // Points :( A : 0; B : 0; G : 1;); - // Message : 'Vocês produziram 1 item escolar.'; // show first in case of last participant - // Cycles : 0; // absolute, - // VariationMin: 0; // porcentage, - // VariationMax : 0; // porcentage - // Prompt : ( - // Message : ''; - // Style : []; - // ); - // ); - // - // Response : ( - // Operator_ : goAND; - // Rows : [grEven]; - // Colors : [gcDiff]; - // ); - // - // Meta : True; - // ); - - - //C_METACONTINGENCY_B2: TContingency = - // ( - // Consequence : ( - // Style : [gscShowMessage,gscPoints,gscBroadcastMessage,gscPromptQuestion]; - // Points :(A :0; B : 0; G : -1;); - // Message : 'Vocês produziram a perda de 1 item escolar.'; - // Cycles : 0; // absolute, - // VariationMin: 0; // porcentage, - // VariationMax : 0; // porcentage - // Prompt : ( - // Message : 'Um item escolar foi perdido, desejam recuperá-lo gastando pontos do Tipo A?'; - // Style : [gsAll,gsYes,gsMetacontingency,gsRecoverLostPoints, gsContingency, gsBasA]; - // ); - // ); - // - // Response : ( - // Operator_ : goNONE; - // Rows : [grOdd, grSome]; - // Colors : [gcNone]; - // ); - // - // Meta : True; - // ); - - C_CONDITION_TEMPLATE : TCondition = - ( - ConditionName : ''; - Contingencies : nil; - //Interlocks : ( - // Count : 0; - // History : nil; - //); - - Points : ( - Count : ( A:0; B:0; G:0; ); - OnStart : ( A:0; B:0; G:0; ); - ); - - Turn : ( - Count: 0; - Value : 0; - Random: False; - ); - - Cycles : ( - Count : 0; - Value : 0; - Generation : 0; - ); - - Prompt : nil; - EndCriterium : ( - Style : gecWhichComeFirst; - InterlockingPorcentage : 50; - LastCycles : 4; - AbsoluteCycles: 6; - ); - ); implementation -uses zhelpers; +//uses zhelpers; function GenResourceName(i: integer): string; var r :integer; @@ -265,17 +135,6 @@ begin end; -function GetColorFromCode(ACode: TGameColor): TColor; -begin - case ACode of - gcNone :Result := clInactiveCaption; - gcYellow :Result := ccYellow; - gcRed :Result := ccRed; - gcMagenta :Result := ccMagenta; - gcBlue :Result := ccBlue; - gcGreen :Result := ccGreen; - end; -end; initialization -- libgit2 0.21.2