diff --git a/cultural_matrix.lpi b/cultural_matrix.lpi index 2fff18f..b86008a 100644 --- a/cultural_matrix.lpi +++ b/cultural_matrix.lpi @@ -47,18 +47,15 @@ - + - - - - + - + @@ -71,71 +68,55 @@ - + - - - - + - + - + - + - + - - - - + - + - + - + - + - + + + - - - - - - - - - - - - @@ -158,6 +139,9 @@ + + + diff --git a/cultural_matrix.lpr b/cultural_matrix.lpr index 3950e33..ec636ca 100644 --- a/cultural_matrix.lpr +++ b/cultural_matrix.lpr @@ -25,8 +25,8 @@ uses {$ENDIF} {$ENDIF} , StrUtils, Forms, Classes, sysutils - , form_matrixgame, form_chooseactor, game_actors - , zhelpers + , form_matrixgame, game_actors + , zhelpers, form_chooseactor ; @@ -86,7 +86,8 @@ begin Exit; end; end; - Application.CreateForm(TFormMatrixGame, FormMatrixGame); + Application.CreateForm(TFormMatrixGame, FormMatrixGame); + FormMatrixGame.SetID(F); if Paramcount > 0 then begin @@ -96,24 +97,6 @@ begin FormMatrixGame.SetGameActor(gaPlayer); if AnsiMatchStr(lowercase(ParamStr(0)), PWatcher) then FormMatrixGame.SetGameActor(gaWatcher); - end - else - begin - FormChooseActor := TFormChooseActor.Create(nil); - FormChooseActor.Style := '.Arrived'; - try - if FormChooseActor.ShowModal = 1 then - begin - case FormChooseActor.GameActor of - gaAdmin:FormMatrixGame.SetGameActor(gaAdmin); - gaPlayer: FormMatrixGame.SetGameActor(gaPlayer); - gaWatcher: FormMatrixGame.SetGameActor(gaWatcher); - end; - end - else Exit; - finally - FormChooseActor.Free; - end; end; Application.Run; end. diff --git a/form_chooseactor.lfm b/form_chooseactor.lfm index d3b0771..37ebb88 100644 --- a/form_chooseactor.lfm +++ b/form_chooseactor.lfm @@ -1,44 +1,66 @@ object FormChooseActor: TFormChooseActor - Left = 416 + Left = 396 Height = 240 - Top = 194 + Top = 185 Width = 320 + BorderIcons = [biSystemMenu] BorderStyle = bsDialog Caption = 'FormChooseActor' ClientHeight = 240 ClientWidth = 320 FormStyle = fsStayOnTop - OnCloseQuery = FormCloseQuery - OnCreate = FormCreate Position = poScreenCenter - LCLVersion = '1.6.0.4' - object btnAdmin: TButton - Left = 64 - Height = 25 - Top = 70 - Width = 184 - Caption = 'Administrador' - OnClick = btnAdminClick - TabOrder = 0 - end - object btnPlayer: TButton - Left = 64 - Height = 25 - Top = 125 - Width = 179 - Caption = 'Jogador' - OnClick = btnPlayerClick - TabOrder = 1 - end + ShowInTaskBar = stNever + LCLVersion = '1.6.2.0' object btnPlayerResume: TButton + AnchorSideLeft.Control = Owner + AnchorSideTop.Control = Owner + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Control = Owner + AnchorSideBottom.Side = asrBottom Left = 50 Height = 140 Top = 50 Width = 220 - Align = alClient + Align = alCustom + Anchors = [akTop, akLeft, akRight, akBottom] BorderSpacing.Around = 50 - Caption = 'ENTRAR' + Caption = 'Entrar' + Font.Height = -53 + Font.Name = 'Impact' OnClick = btnPlayerResumeClick + ParentFont = False TabOrder = 2 + Visible = False + end + object btnAdmin: TButton + Left = 0 + Height = 43 + Top = 50 + Width = 320 + Align = alTop + AutoSize = True + BorderSpacing.Top = 50 + Caption = 'Pesquisador' + Font.Height = -27 + Font.Name = 'Impact' + OnClick = btnAdminClick + ParentFont = False + TabOrder = 0 + end + object btnPlayer: TButton + Left = 0 + Height = 43 + Top = 143 + Width = 320 + Align = alTop + BorderSpacing.Top = 50 + Caption = 'Jogador' + Font.Height = -27 + Font.Name = 'Impact' + OnClick = btnPlayerClick + ParentFont = False + TabOrder = 1 end end diff --git a/form_chooseactor.pas b/form_chooseactor.pas index bb5a8c7..cf8a861 100644 --- a/form_chooseactor.pas +++ b/form_chooseactor.pas @@ -5,8 +5,7 @@ unit form_chooseactor; interface uses - Classes, SysUtils, FileUtil, Forms, Controls, - Graphics, Dialogs, StdCtrls,ExtCtrls, LCLType + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls , game_actors ; @@ -18,6 +17,9 @@ type btnAdmin: TButton; btnPlayer: TButton; btnPlayerResume: TButton; + //btnAdmin: TButton; + //btnPlayer: TButton; + //btnPlayerResume: TButton; procedure btnAdminClick(Sender: TObject); procedure btnPlayerClick(Sender: TObject); procedure btnPlayerResumeClick(Sender: TObject); @@ -63,8 +65,7 @@ begin ModalResult:=1; end; -procedure TFormChooseActor.FormCloseQuery(Sender: TObject; var CanClose: boolean - ); +procedure TFormChooseActor.FormCloseQuery(Sender: TObject; var CanClose: boolean ); begin CanClose := FCanClose; end; @@ -81,10 +82,10 @@ begin '.Arrived': btnPlayerResume.Visible:=False; '.Left': btnPlayerResume.Visible:=True; end; + btnAdmin.Visible:= not btnPlayerResume.Visible; + btnPlayer.Visible:= not btnPlayerResume.Visible; FStyle:=AValue; end; - - end. diff --git a/form_matrixgame.lfm b/form_matrixgame.lfm index 47a7313..9ad2989 100644 --- a/form_matrixgame.lfm +++ b/form_matrixgame.lfm @@ -1,17 +1,49 @@ object FormMatrixGame: TFormMatrixGame Left = 0 - Height = 657 - Top = 62 + Height = 560 + Top = 70 Width = 1278 HorzScrollBar.Page = 1278 VertScrollBar.Page = 542 AutoScroll = True Caption = 'FormMatrixGame' - ClientHeight = 647 + ClientHeight = 550 ClientWidth = 1278 Font.Name = 'Monospace' OnActivate = FormActivate - LCLVersion = '1.6.0.4' + LCLVersion = '1.6.2.0' + object GBIndividual: TGroupBox + AnchorSideLeft.Control = GBIndividualAB + AnchorSideTop.Control = GBIndividualAB + Left = 800 + Height = 122 + Top = 8 + Width = 170 + AutoSize = True + Caption = 'Pontuação Individual' + ChildSizing.LeftRightSpacing = 35 + ChildSizing.TopBottomSpacing = 45 + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 1 + ClientHeight = 105 + ClientWidth = 166 + TabOrder = 7 + Visible = False + object LabelIndCount: TLabel + Left = 35 + Height = 15 + Top = 45 + Width = 96 + Align = alClient + Alignment = taCenter + AutoSize = False + Caption = '0' + Color = clDefault + Layout = tlCenter + ParentColor = False + Transparent = False + end + end object StringGridMatrix: TStringGrid AnchorSideLeft.Control = Owner AnchorSideTop.Control = Owner @@ -30,17 +62,17 @@ object FormMatrixGame: TFormMatrixGame DefaultRowHeight = 30 Enabled = False FixedRows = 0 - Options = [goFixedHorzLine, goHorzLine, goDrawFocusSelected, goRowSelect, goSmoothScroll] + Options = [] RowCount = 10 TabOrder = 0 TitleFont.Name = 'Monospace' - OnBeforeSelection = StringGridMatrixBeforeSelection + OnClick = StringGridMatrixClick OnDrawCell = StringGridMatrixDrawCell end object GBIndividualAB: TGroupBox - Left = 796 + Left = 800 Height = 122 - Top = 0 + Top = 8 Width = 170 AutoSize = True Caption = 'Pontuação Individual' @@ -115,9 +147,9 @@ object FormMatrixGame: TFormMatrixGame AnchorSideLeft.Control = GBIndividualAB AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = GBIndividualAB - Left = 976 + Left = 980 Height = 122 - Top = 0 + Top = 8 Width = 170 AutoSize = True BorderSpacing.Left = 10 @@ -152,8 +184,8 @@ object FormMatrixGame: TFormMatrixGame AnchorSideBottom.Side = asrBottom Left = 0 Height = 17 - Top = 630 - Width = 1492 + Top = 533 + Width = 1632 Anchors = [akLeft, akRight, akBottom] AutoSize = True Caption = 'Escolhas na última jogada' @@ -168,61 +200,59 @@ object FormMatrixGame: TFormMatrixGame AnchorSideLeft.Control = GBGrupo AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = GBGrupo - Left = 1156 - Height = 208 - Top = 0 - Width = 336 + Left = 1160 + Height = 486 + Top = 8 + Width = 472 BorderSpacing.Left = 10 - Caption = 'Administrador' - ClientHeight = 191 - ClientWidth = 332 + Caption = 'Pesquisador' + ClientHeight = 469 + ClientWidth = 468 TabOrder = 4 Visible = False object GBExperiment: TGroupBox Left = 8 - Height = 172 - Top = 8 - Width = 218 + Height = 277 + Top = 60 + Width = 188 AutoSize = True Caption = 'Experimento' - ChildSizing.LeftRightSpacing = 20 + ChildSizing.LeftRightSpacing = 10 ChildSizing.TopBottomSpacing = 20 - ChildSizing.HorizontalSpacing = 30 + ChildSizing.HorizontalSpacing = 20 ChildSizing.VerticalSpacing = 10 ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 2 - ClientHeight = 155 - ClientWidth = 214 + ClientHeight = 260 + ClientWidth = 184 TabOrder = 0 object LabelExpCond: TLabel - Left = 20 + Left = 10 Height = 15 Top = 20 Width = 128 - AutoSize = False Caption = 'Condição:' ParentColor = False end - object LabelExpCondCount: TLabel - Left = 178 + object LabelExpCountCondition: TLabel + Left = 158 Height = 15 Top = 20 Width = 16 - AutoSize = False Caption = 'NA' ParentColor = False end object LabelExpGen: TLabel - Left = 20 + Left = 10 Height = 15 Top = 45 Width = 128 - Caption = 'Generation:' + Caption = 'Generação:' ParentColor = False end - object LabelExpGenCount: TLabel - Left = 178 + object LabelExpCountGeneration: TLabel + Left = 158 Height = 15 Top = 45 Width = 16 @@ -230,15 +260,15 @@ object FormMatrixGame: TFormMatrixGame ParentColor = False end object LabelExpCycle: TLabel - Left = 20 + Left = 10 Height = 15 Top = 70 Width = 128 - Caption = 'Cycle:' + Caption = 'Ciclo:' ParentColor = False end - object LabelExpCycleCount: TLabel - Left = 178 + object LabelExpCountCycle: TLabel + Left = 158 Height = 15 Top = 70 Width = 16 @@ -246,15 +276,15 @@ object FormMatrixGame: TFormMatrixGame ParentColor = False end object LabelExpNxtPlayer: TLabel - Left = 20 + Left = 10 Height = 15 Top = 95 Width = 128 Caption = 'Prox. Jog.:' ParentColor = False end - object LabelExpNxtPlayerCount: TLabel - Left = 178 + object LabelExpCountNxtPlayer: TLabel + Left = 158 Height = 15 Top = 95 Width = 16 @@ -262,28 +292,78 @@ object FormMatrixGame: TFormMatrixGame ParentColor = False end object LabelExpInterlocks: TLabel - Left = 20 + Left = 10 Height = 15 Top = 120 Width = 128 Caption = 'Entrelaçamentos:' ParentColor = False end - object LabelExpInterlocksCount: TLabel - Left = 178 + object LabelExpCountInterlocks: TLabel + Left = 158 Height = 15 Top = 120 Width = 16 Caption = 'NA' ParentColor = False end + object ButtonExpStart: TButton + Left = 10 + Height = 25 + Top = 145 + Width = 128 + Caption = 'Começar' + OnClick = ButtonExpStartClick + TabOrder = 0 + end + object LabelUnseen1: TLabel + Left = 158 + Height = 25 + Top = 145 + Width = 16 + ParentColor = False + end + object ButtonExpPause: TButton + Left = 10 + Height = 25 + Top = 180 + Width = 128 + Caption = 'Pausar' + Enabled = False + OnClick = ButtonExpPauseClick + TabOrder = 1 + end + object LabelUnseen2: TLabel + Left = 158 + Height = 25 + Top = 180 + Width = 16 + ParentColor = False + end + object ButtonExpCancel: TButton + Left = 10 + Height = 25 + Top = 215 + Width = 128 + Caption = 'Cancelar' + Enabled = False + OnClick = ButtonExpCancelClick + TabOrder = 2 + end + object LabelUnseen3: TLabel + Left = 158 + Height = 25 + Top = 215 + Width = 16 + ParentColor = False + end end end object btnConfirmRow: TButton Left = 712 - Height = 25 - Top = 320 - Width = 83 + Height = 26 + Top = 319 + Width = 86 Caption = 'Confirmar' OnClick = btnConfirmRowClick TabOrder = 5 @@ -295,9 +375,9 @@ object FormMatrixGame: TFormMatrixGame AnchorSideTop.Side = asrBottom AnchorSideRight.Control = GBGrupo AnchorSideRight.Side = asrBottom - Left = 796 + Left = 800 Height = 354 - Top = 132 + Top = 140 Width = 350 Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 10 @@ -351,63 +431,24 @@ object FormMatrixGame: TFormMatrixGame WantTabs = True end end - object GBIndividual: TGroupBox - AnchorSideLeft.Control = GBIndividualAB - AnchorSideTop.Control = GBIndividualAB - Left = 796 - Height = 122 - Top = 0 - Width = 170 - AutoSize = True - Caption = 'Pontuação Individual' - ChildSizing.LeftRightSpacing = 35 - ChildSizing.TopBottomSpacing = 45 - ChildSizing.Layout = cclLeftToRightThenTopToBottom - ChildSizing.ControlsPerLine = 1 - ClientHeight = 105 - ClientWidth = 166 - TabOrder = 7 - Visible = False - object LabelIndCount: TLabel - Left = 35 - Height = 15 - Top = 45 - Width = 96 - Align = alClient - Alignment = taCenter - AutoSize = False - Caption = '0' - Color = clDefault - Layout = tlCenter - ParentColor = False - Transparent = False - end - end - object Button1: TButton - Left = 216 - Height = 25 - Top = 432 - Width = 75 - Caption = 'Button1' - OnClick = Button1Click - TabOrder = 8 - end - object Button2: TButton - Left = 312 - Height = 25 - Top = 432 - Width = 75 - Caption = 'Button2' - OnClick = Button2Click - TabOrder = 9 - end object Button3: TButton - Left = 504 + Left = 568 Height = 91 - Top = 440 + Top = 352 Width = 141 Caption = 'Button3' OnClick = Button3Click - TabOrder = 10 + TabOrder = 8 + end + object OpenDialog: TOpenDialog + Width = 862 + Height = 434 + Title = 'Abrir Experimento' + DefaultExt = '.txt' + Filter = 'txt|*.txt|ini|*.ini' + InitialDir = 'Pesquisadores' + Options = [ofNoChangeDir, ofFileMustExist, ofNoNetworkButton, ofEnableSizing, ofDontAddToRecent] + left = 24 + top = 360 end end diff --git a/form_matrixgame.pas b/form_matrixgame.pas index 849bf73..4e0a642 100644 --- a/form_matrixgame.pas +++ b/form_matrixgame.pas @@ -29,24 +29,28 @@ type TFormMatrixGame = class(TForm) btnConfirmRow: TButton; - Button1: TButton; - Button2: TButton; + ButtonExpStart: TButton; + ButtonExpPause: TButton; Button3: TButton; + ButtonExpCancel: TButton; GBIndividual: TGroupBox; GBLastChoice: TGroupBox; GBIndividualAB: TGroupBox; GBGrupo: TGroupBox; GBAdmin: TGroupBox; GBExperiment: TGroupBox; - LabelExpCondCount: TLabel; + LabelUnseen1: TLabel; + LabelUnseen2: TLabel; + LabelUnseen3: TLabel; + LabelExpCountCondition: TLabel; LabelExpGen: TLabel; - LabelExpGenCount: TLabel; + LabelExpCountGeneration: TLabel; LabelExpCycle: TLabel; - LabelExpCycleCount: TLabel; + LabelExpCountCycle: TLabel; LabelExpNxtPlayer: TLabel; - LabelExpNxtPlayerCount: TLabel; + LabelExpCountNxtPlayer: TLabel; LabelExpInterlocks: TLabel; - LabelExpInterlocksCount: TLabel; + LabelExpCountInterlocks: TLabel; LabelIndCount: TLabel; LabelIndACount: TLabel; LabelIndBCount: TLabel; @@ -58,15 +62,16 @@ type ChatMemoSend: TMemo; ChatPanel: TPanel; ChatSplitter: TSplitter; + OpenDialog: TOpenDialog; StringGridMatrix: TStringGrid; procedure btnConfirmRowClick(Sender: TObject); - procedure Button1Click(Sender: TObject); - procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); + procedure ButtonExpCancelClick(Sender: TObject); + procedure ButtonExpPauseClick(Sender: TObject); + procedure ButtonExpStartClick(Sender: TObject); procedure ChatMemoSendKeyPress(Sender: TObject; var Key: char); - procedure CheckBoxDrawDotsChange(Sender: TObject); procedure FormActivate(Sender: TObject); - procedure StringGridMatrixBeforeSelection(Sender: TObject; aCol, aRow: integer); + procedure StringGridMatrixClick(Sender: TObject); procedure StringGridMatrixDrawCell(Sender: TObject; aCol, aRow: integer; aRect: TRect; aState: TGridDrawState); private @@ -80,14 +85,14 @@ type var FormMatrixGame: TFormMatrixGame; +resourcestring + RS_RESEARCHERS = 'Pesquisadores'; implementation -uses form_chooseactor, LCLType, game_resources; +uses form_chooseactor, game_resources; // uses datamodule; -var - MustDrawSelection : Boolean; // work around until a bug fix for ClearSelection is released {$R *.lfm} @@ -168,7 +173,7 @@ begin begin DrawLines(GetRowColor(aRow,RowBase)); - if (gdSelected in aState) and MustDrawSelection then + if (gdSelected in aState) and (goRowSelect in TStringGrid(Sender).Options)then begin TStringGrid(Sender).Canvas.Pen.Width := 10; TStringGrid(Sender).Canvas.Pen.Color := clWhite; @@ -195,11 +200,11 @@ begin TStringGrid(Sender).Canvas.Font.Color := clBlack; TStringGrid(Sender).Canvas.Brush.Style := bsClear; - if (aCol = 10) and (gdSelected in aState) and MustDrawSelection then + if (aCol = 10) and (gdSelected in aState) and (goRowSelect in TStringGrid(Sender).Options) then if (aRow = TStringGrid(Sender).Selection.Top) and (aCol = TStringGrid(Sender).Selection.Right) then begin - btnConfirmRow.Top := aRect.Top+5; - btnConfirmRow.Left := aRect.Right+5; + btnConfirmRow.Top := aRect.Top+4; + btnConfirmRow.Left := aRect.Right+8; end; finally @@ -219,7 +224,6 @@ procedure TFormMatrixGame.SetGameActor(AValue: TGameActor); procedure SetZMQPlayer; begin FGameControl := TGameControl.Create(TZMQPlayer.Create(Self,FID)); - btnConfirmRow.Visible := True; StringGridMatrix.Enabled := True; end; @@ -241,27 +245,39 @@ begin FID := S; end; -procedure TFormMatrixGame.CheckBoxDrawDotsChange(Sender: TObject); -begin - StringGridMatrix.Invalidate; -end; procedure TFormMatrixGame.FormActivate(Sender: TObject); begin - StringGridMatrix.ClearSelections; - StringGridMatrix.FocusRectVisible := False; - FGameControl.SetMatrix; + FormChooseActor := TFormChooseActor.Create(Self); + FormChooseActor.Style := '.Arrived'; + try + if FormChooseActor.ShowModal = 1 then + begin + case FormChooseActor.GameActor of + gaAdmin:FormMatrixGame.SetGameActor(gaAdmin); + gaPlayer: FormMatrixGame.SetGameActor(gaPlayer); + gaWatcher: FormMatrixGame.SetGameActor(gaWatcher); + end; + StringGridMatrix.ClearSelections; + StringGridMatrix.FocusRectVisible := False; + FGameControl.SetMatrix; + end + else Close; + finally + FormChooseActor.Free; + end; end; -procedure TFormMatrixGame.StringGridMatrixBeforeSelection(Sender: TObject; aCol, aRow: integer); +procedure TFormMatrixGame.StringGridMatrixClick(Sender: TObject); begin - if MustDrawSelection then Exit; - MustDrawSelection := True; + if goRowSelect in StringGridMatrix.Options then Exit; + StringGridMatrix.Options := StringGridMatrix.Options+[goRowSelect]; + btnConfirmRow.Visible := True; end; procedure TFormMatrixGame.ChatMemoSendKeyPress(Sender: TObject; var Key: char); begin - if Key = Char(VK_RETURN) then + if Key = Char(13) then begin FGameControl.SendMessage(K_CHAT_M); with ChatMemoSend do @@ -271,42 +287,61 @@ begin SelLength:=0; SetFocus; end; - Key := Char(VK_UNKNOWN); + Key := Char(0); end; end; procedure TFormMatrixGame.btnConfirmRowClick(Sender: TObject); begin - //StringGridMatrix.ClearSelections; - //MustDrawSelection := False; StringGridMatrix.Enabled:= False; - btnConfirmRow.Visible:=False; + btnConfirmRow.Enabled:=False; FGameControl.SendMessage(K_CHOICE); end; -procedure TFormMatrixGame.Button1Click(Sender: TObject); +procedure TFormMatrixGame.Button3Click(Sender: TObject); begin - + FGameControl.Experiment.SaveToFile(OpenDialog.FileName+'.ini'); end; -procedure TFormMatrixGame.Button2Click(Sender: TObject); +procedure TFormMatrixGame.ButtonExpCancelClick(Sender: TObject); begin + ButtonExpStart.Enabled := True; + ButtonExpStart.Caption := 'Começar'; + ButtonExpCancel.Enabled := not ButtonExpStart.Enabled; + ButtonExpPause.Enabled := not ButtonExpStart.Enabled; + //FGameControl.Experiment.SaveToFile(SaveDialog.FileName'.canceled'); + //FGameControl.Experiment.Clean; +end; +procedure TFormMatrixGame.ButtonExpPauseClick(Sender: TObject); +begin + ButtonExpStart.Enabled := True; + ButtonExpStart.Caption := 'Recomeçar'; + ButtonExpPause.Enabled := not ButtonExpStart.Enabled; + //FGameControl.Experiment.Pause; end; -procedure TFormMatrixGame.Button3Click(Sender: TObject); +procedure TFormMatrixGame.ButtonExpStartClick(Sender: TObject); begin - FGameControl.SendMessage(K_LEFT); - FormMatrixGame.Visible := False; - FormChooseActor := TFormChooseActor.Create(nil); - FormChooseActor.Style := K_LEFT; - if FormChooseActor.ShowModal = 1 then - begin - FGameControl.SendMessage(K_RESUME); - FormMatrixGame.Visible := True; - end - else Close; - FormChooseActor.Free; + OpenDialog.InitialDir:=ExtractFilePath(Application.ExeName)+RS_RESEARCHERS; + if ButtonExpStart.Caption = 'Começar' then + if OpenDialog.Execute then + begin + ButtonExpStart.Enabled := False; + ButtonExpStart.Caption := 'Rodando'; + ButtonExpCancel.Enabled := not ButtonExpStart.Enabled; + ButtonExpPause.Enabled := not ButtonExpStart.Enabled; + //FGameControl.Experiment.LoadFromFile(OpenDialog.FileName); + end; + + if ButtonExpStart.Caption = 'Recomeçar' then + begin + ButtonExpStart.Enabled := False; + ButtonExpStart.Caption := 'Rodando'; + ButtonExpCancel.Enabled := not ButtonExpStart.Enabled; + ButtonExpPause.Enabled := not ButtonExpStart.Enabled; + //FGameControl.Experiment.Resume; + end; end; end. diff --git a/units/backup/game_dialogs.lfm b/units/backup/game_dialogs.lfm new file mode 100644 index 0000000..0346aa8 --- /dev/null +++ b/units/backup/game_dialogs.lfm @@ -0,0 +1,18 @@ +object DataModule2: TDataModule2 + OldCreateOrder = False + Height = 210 + HorizontalOffset = 375 + VerticalOffset = 243 + Width = 412 + object OpenDialog: TOpenDialog + Width = 862 + Height = 434 + Title = 'Abrir Experimento' + DefaultExt = '.txt' + FileName = '/home/rafael/free-pascal/published' + Filter = 'txt|*.TXT|ini|*.INI' + InitialDir = '/home/rafael/free-pascal/' + left = 32 + top = 8 + end +end diff --git a/units/game_actors.pas b/units/game_actors.pas index af5668f..e59c888 100644 --- a/units/game_actors.pas +++ b/units/game_actors.pas @@ -10,7 +10,6 @@ uses ; type - TGameActor = ( gaNone, gaAdmin, gaPlayer, gaWatcher ); TGamePlayerStatus = (gpsWaiting, gpsPlaying, gpsPlayed); @@ -38,6 +37,7 @@ type TConsequenceStyle = set of TGameConsequenceStyle; TGamePromptStyle = (gsYes, gsNo, gsAll, gsMetacontingency, gsContingency, gsBasA, gsRevertPoints); + TPromptStyle = set of TGamePromptStyle; diff --git a/units/game_control.pas b/units/game_control.pas index 282382d..f177ddc 100644 --- a/units/game_control.pas +++ b/units/game_control.pas @@ -16,6 +16,7 @@ uses type + { TGameControl } TGameControl = class(TComponent) @@ -32,6 +33,7 @@ type function GetSelectedColorF(AStringGrid : TStringGrid) : UTF8string; function GetSelectedRowF(AStringGrid : TStringGrid) : UTF8string; function MessageHas(const A_CONST : string; AMessage : TStringList; I:ShortInt=0): Boolean; + procedure CreatePlayerBox(P:TPlayer; Me:Boolean); procedure SetMatrixType(AStringGrid : TStringGrid; AMatrixType:TGameMatrixType; var ARowBase:integer; var ADrawDots, ADrawClear : Boolean); procedure ReceiveMessage(AMessage : TStringList); @@ -42,15 +44,18 @@ type procedure SetRowBase(AValue: integer); private function CanStartExperiment : Boolean; + procedure KickPlayer(AID:string); procedure StartCycle; procedure StartCondition; procedure StartExperiment; + procedure StartTurn; public constructor Create(AOwner : TComponent);override; destructor Destroy; override; procedure SetMatrix; procedure SendRequest(ARequest : UTF8string); procedure SendMessage(AMessage : UTF8string); + property Experiment : TExperiment read FExperiment write FExperiment; property ID : string read FID; property RowBase : integer read FRowBase write SetRowBase; property MustDrawDots: Boolean read FMustDrawDots write SetMustDrawDots; @@ -61,25 +66,25 @@ type const K_FULLROOM = '.Full'; - K_PLAYING = '.Playing'; - K_ARRIVED = '.Arrived'; - K_REFUSED = '.Refused'; - K_CHAT_M = '.ChatM'; - K_CHOICE = '.Choice'; - K_LEFT = '.Left'; - K_RESUME = '.Resume'; - K_DATA_A = '.Data'; - K_LOGIN = '.login'; - + K_PLAYING = '.Playing'; + K_ARRIVED = '.Arrived'; + K_REFUSED = '.Refused'; + K_CHAT_M = '.ChatM'; + K_CHOICE = '.Choice'; + K_LEFT = '.Left'; + K_RESUME = '.Resume'; + K_DATA_A = '.Data'; + K_LOGIN = '.Login'; + K_KICK = '.Kick' // - K_STATUS = '.Status'; - K_CYCLES = '.OnCycleStart'; + K_STATUS = '.Status'; + K_CYCLES = '.OnCycleStart'; //K_RESPONSE = implementation -uses form_matrixgame, game_resources, string_methods, zhelpers; +uses LazUTF8, form_matrixgame, form_chooseactor, game_resources, string_methods, zhelpers; const GA_ADMIN = 'Admin'; @@ -106,7 +111,12 @@ end; function TGameControl.CanStartExperiment: Boolean; begin - Result := FExperiment.PlayersPlaying.Count = FExperiment.Condition[FExperiment.CurrentCondition].Turn.Value; + Result := FExperiment.PlayersCount = FExperiment.Condition[FExperiment.CurrentCondition].Turn.Value; +end; + +procedure TGameControl.KickPlayer(AID: string); +begin + FZMQActor.SendMessage([K_KICK, AID]); end; function TGameControl.GetPlayerBox(AID: string): TPlayerBox; @@ -141,6 +151,26 @@ begin Result := Pos(A_CONST,AMessage[I])>0; end; +procedure TGameControl.CreatePlayerBox(P: TPlayer; Me: Boolean); +var i1 : integer; +begin + with TPlayerBox.Create(FormMatrixGame.GBLastChoice,P.ID) do + begin + if Me then + Caption := P.Nicname+SysToUtf8(' (Você)' ) + else + Caption := P.Nicname; + i1 := Integer(P.Choice.Last.Row); + if i1 > 0 then + LabelLastRowCount.Caption := Format('%-*.*d', [1,2,i1]) + else + LabelLastRowCount.Caption := 'NA'; + PanelLastColor.Color := GetColorFromCode(P.Choice.Last.Color); + Enabled := True; + Parent := FormMatrixGame.GBLastChoice; + end; +end; + procedure TGameControl.SetMatrixType(AStringGrid: TStringGrid; AMatrixType: TGameMatrixType; var ARowBase: integer; var ADrawDots, ADrawClear: Boolean); @@ -166,7 +196,7 @@ begin AStringGrid.FixedRows := 0; AStringGrid.RowCount := 10; AStringGrid.Height:=305; - AStringGrid.Options := [goFixedHorzLine, goHorzLine, goDrawFocusSelected, goRowSelect]; + AStringGrid.Options := [goFixedHorzLine, goHorzLine]; WriteGridFixedNames(AStringGrid, False); end; @@ -177,7 +207,7 @@ begin AStringGrid.FixedRows := 1; AStringGrid.RowCount := 11; AStringGrid.Height:=335; - AStringGrid.Options := [goFixedHorzLine, goHorzLine, goDrawFocusSelected, goRowSelect, goVertLine]; + AStringGrid.Options := [goFixedHorzLine, goHorzLine, goVertLine]; WriteGridFixedNames(AStringGrid, True); end; @@ -237,6 +267,13 @@ begin end; +procedure TGameControl.StartTurn; +begin + FormMatrixGame.StringGridMatrix.Options := FormMatrixGame.StringGridMatrix.Options-[goRowSelect]; + FormMatrixGame.btnConfirmRow.Enabled:=True; + FormMatrixGame.btnConfirmRow.Visible := False; +end; + constructor TGameControl.Create(AOwner: TComponent); begin FZMQActor := TZMQActor(AOwner); @@ -284,28 +321,26 @@ var M[i] := A[i]; end; begin - case ARequest of - K_LOGIN : SetM([ - FZMQActor.ID - , ' ' - , ARequest - ]); - end; + SetM([ + FZMQActor.ID + , ' ' + , ARequest + ]); case FActor of gaAdmin: begin - M[2] := GA_ADMIN+M[2]; + //M[2] := GA_ADMIN+M[2];// for now cannot Requests end; gaPlayer:begin M[2] := GA_PLAYER+M[2]; end; - //gaWatcher:begin // for now cannot SendMessages + //gaWatcher:begin // M[0] := GA_WATCHER+M[0]; end; FZMQActor.Request(M); end; - +// called from outside procedure TGameControl.SendMessage(AMessage: UTF8string); var M : array of UTF8String; @@ -319,10 +354,6 @@ var end; begin case AMessage of - //K_ARRIVED : SetM([ - // AMessage - // , FZMQActor.ID - //]); K_CHOICE : SetM([ AMessage @@ -340,15 +371,6 @@ begin ]); end; - K_LEFT : SetM([ - AMessage - , FZMQActor.ID - ]); - - K_RESUME : SetM([ - AMessage - , FZMQActor.ID - ]); end; case FActor of @@ -358,7 +380,7 @@ begin gaPlayer:begin M[0] := GA_PLAYER+M[0]; end; - //gaWatcher:begin // for now cannot SendMessages + //gaWatcher:begin // M[0] := GA_WATCHER+M[0]; end; FZMQActor.SendMessage(M); @@ -383,38 +405,18 @@ procedure TGameControl.ReceiveMessage(AMessage: TStringList); gaPlayer: begin P := FExperiment.PlayerFromString[AMessage[1]]; - if Self.ID = P.ID then Exit; - with TPlayerBox.Create(FormMatrixGame.GBLastChoice,P.ID) do + if Self.ID = P.ID then begin - Caption := P.Nicname; - LabelLastRowCount.Caption := IntToStr(ShortInt(P.Choice.Last.Row)); - PanelLastColor.Color := GetColorFromCode(P.Choice.Last.Color); - Enabled := True; - Parent := FormMatrixGame.GBLastChoice; - end; + FExperiment.AppendPlayer(P); + CreatePlayerBox(P, True); + end + else + CreatePlayerBox(P,False); end; end; end; - - procedure ReceiveStatus; - //var P : PPlayer; - // i : integer; - begin - //P := New(PPlayer); - //case FActor of - // gaPlayer:begin - - // - // end; - // - // gaAdmin:begin - - //end; - //Dispose(P); - end; - procedure ReceiveChoice; begin case FActor of @@ -436,10 +438,17 @@ procedure TGameControl.ReceiveMessage(AMessage: TStringList); begin case FActor of gaPlayer:begin - - end; - gaAdmin:begin - + if Self.ID <> AMessage[1] then Exit; + FormMatrixGame.Visible := False; + FormChooseActor := TFormChooseActor.Create(nil); + FormChooseActor.Style := K_LEFT; + if FormChooseActor.ShowModal = 1 then + begin + FZMQActor.Request([K_RESUME,Self.ID]); + FormMatrixGame.Visible := True; + end + else; + FormChooseActor.Free; end; end; end; @@ -484,8 +493,7 @@ begin if MHas(K_ARRIVED) then ReceiveActor; if MHas(K_CHAT_M) then ReceiveChat; if MHas(K_CHOICE) then ReceiveChoice; - if MHas(K_LEFT) then SayGoodBye; - if MHas(K_RESUME) then ResumeActor; + if MHas(K_KICK) then SayGoodBye; if MHas(K_STATUS) then ReceiveStatus; end; @@ -499,11 +507,15 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList); procedure ReplyLoginRequest; var i : integer; P : TPlayer; - PS : string; + TS, + PS : UTF8string; begin if not FExperiment.PlayerIsPlaying[ARequest[0]] then begin - if FExperiment.PlayersPlaying.Count < FExperiment.Condition[FExperiment.CurrentCondition].Turn.Value then + {$IFDEF DEBUG} + WriteLn(FExperiment.PlayersCount,'<',FExperiment.Condition[FExperiment.CurrentCondition].Turn.Value); + {$ENDIF} + if FExperiment.PlayersCount < FExperiment.Condition[FExperiment.CurrentCondition].Turn.Value then begin // ok, let player login P.ID := ARequest[0]; @@ -517,7 +529,7 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList); end else begin - // if not save p data + // if not generate and save p data i := FExperiment.AppendPlayer; P.Nicname := GenResourceName(i); P.Turn := FExperiment.NextTurn; @@ -529,50 +541,40 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList); P.Choice.Last.Color:=gcNone; P.Choice.Last.Row:=grNone; // turns by entrance order - P.Turn := FExperiment.PlayersPlaying.Count; + P.Turn := FExperiment.PlayersCount; FExperiment.Player[i] := P; end; - // add player to playing list - FExperiment.PlayersPlaying.Add(FExperiment.PlayerPointer[i]); - // create/config playerbox - with TPlayerBox.Create(FormMatrixGame.GBLastChoice,P.ID) do - begin - Caption := P.Nicname; - i := Integer(P.Choice.Last.Row); - if i > 0 then - LabelLastRowCount.Caption := Format('%-*.*d', [1,2,i]); - - PanelLastColor.Color := GetColorFromCode(P.Choice.Last.Color); - Enabled := True; - Parent := FormMatrixGame.GBLastChoice; - end; + CreatePlayerBox(P,False); // Request is now a reply with the following standard: // [Requester.ID 0, ' ' 1, ReplyTag 2, PlayerData 3, PlayersPlaying 4 .. n, ChatData Last] ARequest[2] := GA_ADMIN+ARequest[2]+K_ARRIVED; - // append player + // player PS := FExperiment.PlayerAsString[P]; - ARequest.Append(PS); // 3 + //ARequest.Append(PS); // append current players playing - if FExperiment.PlayersPlaying.Count > 0 then - for i:=0 to FExperiment.PlayersPlaying.Count -1 do - if PPlayer(FExperiment.PlayersPlaying[i])^.ID <> P.ID then - ARequest.Append(FExperiment.PlayerAsString[PPlayer(FExperiment.PlayersPlaying[i])^]); // FROM 4 to COUNT-2 - - // send chat data if allowed at the last position + if FExperiment.PlayersCount > 0 then + for i:=0 to FExperiment.PlayersCount -1 do + if FExperiment.Player[i].ID <> P.ID then + begin + TS := FExperiment.PlayerAsString[FEXperiment.Player[i]]; + ARequest.Append(TS); // FROM 3 to COUNT-2 + end; + + // append chat data if allowed at the last position if FExperiment.SendChatHistoryForNewPlayers then ARequest.Append(FormMatrixGame.ChatMemoRecv.Lines.Text) // LAST else ARequest.Append('[CHAT]'); // must append something to keep the message envelop standard - // inform other players about the new player + // inform all players about the new player, including itself FZMQActor.SendMessage([K_ARRIVED,PS]); - // start cycle if allowed + // start Experiment if allowed if CanStartExperiment then StartExperiment; @@ -592,31 +594,12 @@ begin if MHas(K_LOGIN) then ReplyLoginRequest; end; -// Here FActor is garanted to be a TZMQPlayer +// Here FActor is garanted to be a TZMQPlayer, should be used to send all wanted history for new income players procedure TGameControl.ReceiveReply(AReply: TStringList); function MHas(const C : string) : Boolean; begin Result := MessageHas(C,AReply,2); end; - procedure CreatePlayerBox(P:TPlayer; Me:Boolean); - var i1 : integer; - begin - with TPlayerBox.Create(FormMatrixGame.GBLastChoice,P.ID) do - begin - if Me then - Caption := P.Nicname+'Você' - else - Caption := P.Nicname; - i1 := Integer(P.Choice.Last.Row); - if i1 > 0 then - LabelLastRowCount.Caption := Format('%-*.*d', [1,2,i1]) - else - LabelLastRowCount.Caption := 'NA'; - PanelLastColor.Color := GetColorFromCode(P.Choice.Last.Color); - Enabled := True; - Parent := FormMatrixGame.GBLastChoice; - end; - end; procedure LoginAccepted; var @@ -624,15 +607,12 @@ procedure TGameControl.ReceiveReply(AReply: TStringList); P : TPlayer; begin {$IFDEF DEBUG} - WriteLn(Self.ID +' self' + AReply[0] +' reply'); + WriteLn(Self.ID +' self'); + WriteLn(AReply[0] +' reply'); {$ENDIF} if Self.ID = AReply[0] then begin - P := FExperiment.PlayerFromString[AReply[3]]; - FExperiment.AppendPlayer(P); - CreatePlayerBox(P, True); - - for i:= 4 to AReply.Count -2 do + for i:= 3 to AReply.Count -2 do begin P := FExperiment.PlayerFromString[AReply[i]]; CreatePlayerBox(P, False); @@ -651,6 +631,7 @@ procedure TGameControl.ReceiveReply(AReply: TStringList); end; begin + if MHas(K_RESUME+K_ARRIVED) then ResumePlayer; if MHas(K_LOGIN+K_ARRIVED) then LoginAccepted; end; diff --git a/units/game_experiment.pas b/units/game_experiment.pas index 75e0dd9..dd7313d 100644 --- a/units/game_experiment.pas +++ b/units/game_experiment.pas @@ -14,6 +14,7 @@ type { TExperiment } + TExperimentState = (xsWaiting,xsRunning,xsPaused,xsCanceled); TPlayers = array of TPlayer; TConditions = array of TCondition; @@ -22,11 +23,10 @@ type FExperimentAim, FExperimentName, FFilename, - FResearcher : string; + FResearcher : UTF8string; FMatrixType: TGameMatrixType; FRegData : TRegData; FGenPlayersAsNeeded : Boolean; - FPlayersPlaying : TList; FPlayers : TPlayers; FCurrentCondition : integer; FConditions : TConditions; @@ -34,29 +34,28 @@ type FResearcherCanPlay: Boolean; FSendChatHistoryForNewPlayers: Boolean; FShowChat: Boolean; + FState: TExperimentState; function GetCondition(I : Integer): TCondition; function GetConditionsCount: integer; function GetContingency(ACondition, I : integer): TContingency; function GetNextTurn: integer; function GetNextTurnPlayerID: UTF8string; function GetPlayer(I : integer): TPlayer; overload; - function GetPlayer(AID : string): TPlayer; overload; + function GetPlayer(AID : UTF8string): TPlayer; overload; function GetPlayerAsString(P: TPlayer): UTF8string; - function GetPlayerFromString(s : string): TPlayer; - function GetPlayerIndexFromID(AID : string): integer; - function GetPlayerIsPlaying(AID : string): Boolean; - function GetPlayerPointer(i: integer): PPlayer; + function GetPlayerFromString(s : UTF8string): TPlayer; + function GetPlayerIndexFromID(AID : UTF8string): integer; + function GetPlayerIsPlaying(AID : UTF8string): Boolean; function GetPlayersCount: integer; - //function GetPlayersPlaying: TList; procedure SetCondition(I : Integer; AValue: TCondition); procedure SetContingency(ACondition, I : integer; AValue: TContingency); procedure SetMatrixType(AValue: TGameMatrixType); procedure SetPlayer(I : integer; AValue: TPlayer); overload; - procedure SetPlayer(S : string ; AValue: TPlayer); overload; - procedure SetPlayersPlaying(AValue: TList); + procedure SetPlayer(S : UTF8string ; AValue: TPlayer); overload; procedure SetResearcherCanChat(AValue: Boolean); procedure SetResearcherCanPlay(AValue: Boolean); procedure SetSendChatHistoryForNewPlayers(AValue: Boolean); + procedure SetState(AValue: TExperimentState); public constructor Create(AOwner:TComponent);override; constructor Create(AFilename: string; AOwner:TComponent); overload; @@ -71,30 +70,30 @@ type function AppendPlayer(APlayer : TPlayer) : integer; overload; procedure SaveToFile(AFilename: string); overload; procedure SaveToFile; overload; + procedure Clean; property ResearcherCanPlay : Boolean read FResearcherCanPlay write SetResearcherCanPlay; property ResearcherCanChat : Boolean read FResearcherCanChat write SetResearcherCanChat; - property Researcher : string read FResearcher write FResearcher; + property Researcher : UTF8string read FResearcher write FResearcher; property Condition[I : Integer]: TCondition read GetCondition write SetCondition; property ConditionsCount : integer read GetConditionsCount; property CurrentCondition : integer read FCurrentCondition write FCurrentCondition; property Contingency[C, I : integer] : TContingency read GetContingency write SetContingency; - property ExperimentAim : string read FExperimentAim write FExperimentAim; - property ExperimentName : string read FExperimentName write FExperimentName; + property ExperimentAim : UTF8string read FExperimentAim write FExperimentAim; + property ExperimentName : UTF8string read FExperimentName write FExperimentName; property GenPlayersAsNeeded : Boolean read FGenPlayersAsNeeded write FGenPlayersAsNeeded; property Player[I : integer] : TPlayer read GetPlayer write SetPlayer; - property PlayerFromID[S : string ] : TPlayer read GetPlayer write SetPlayer; - property PlayersCount : integer read GetPlayersCount; // how many players per turn? - property PlayersPlaying : TList read FPlayersPlaying write SetPlayersPlaying; // how many players are playing? - property PlayerIsPlaying[s : string] : Boolean read GetPlayerIsPlaying; - property PlayerIndexFromID[s : string]: integer read GetPlayerIndexFromID; + property PlayerFromID[S : UTF8string ] : TPlayer read GetPlayer write SetPlayer; + property PlayersCount : integer read GetPlayersCount; + property PlayerIsPlaying[s : UTF8string] : Boolean read GetPlayerIsPlaying; + property PlayerIndexFromID[s : UTF8string]: integer read GetPlayerIndexFromID; property PlayerAsString[P:TPlayer]: UTF8string read GetPlayerAsString; - property PlayerFromString[s : string]: TPlayer read GetPlayerFromString; - property PlayerPointer[i:integer]: PPlayer read GetPlayerPointer; + property PlayerFromString[s : UTF8string]: TPlayer read GetPlayerFromString; property ShowChat : Boolean read FShowChat write FShowChat; property SendChatHistoryForNewPlayers : Boolean read FSendChatHistoryForNewPlayers write SetSendChatHistoryForNewPlayers; property MatrixType : TGameMatrixType read FMatrixType write SetMatrixType; property NextTurnPlayerID : UTF8string read GetNextTurnPlayerID; property NextTurn : integer read GetNextTurn; + property State : TExperimentState read FState write SetState; end; resourcestring @@ -113,7 +112,7 @@ end; function TExperiment.GetConditionsCount: integer; begin - Result := High(FConditions); + Result := Length(FConditions); end; function TExperiment.GetContingency(ACondition, I : integer): TContingency; @@ -130,15 +129,9 @@ begin end; function TExperiment.GetNextTurnPlayerID: UTF8string; // used during cycles -var - P : PPlayer; begin - Result := ''; - P := New(PPlayer); - P := PlayersPlaying[FConditions[CurrentCondition].Turn.Count]; - Result := P^.ID; + Result := Player[FConditions[CurrentCondition].Turn.Count].ID; GetNextTurn; - Dispose(P); end; function TExperiment.GetPlayer(I : integer): TPlayer; @@ -146,7 +139,7 @@ begin Result := FPlayers[i]; end; -function TExperiment.GetPlayer(AID: string): TPlayer; +function TExperiment.GetPlayer(AID: UTF8string): TPlayer; var i : integer; begin @@ -236,7 +229,7 @@ begin Result += M[i] + '|'; end; -function TExperiment.GetPlayerFromString(s : string): TPlayer; +function TExperiment.GetPlayerFromString(s: UTF8string): TPlayer; function GetRowFromString(S: string): TGameRow; begin @@ -304,7 +297,7 @@ begin Result.Choice.Last := GetChoiceFromString(ExtractDelimited(6,s,['|'])); end; -function TExperiment.GetPlayerIndexFromID(AID: string): integer; +function TExperiment.GetPlayerIndexFromID(AID: UTF8string): integer; var i : integer; begin Result := -1; @@ -316,46 +309,23 @@ begin end; end; -function TExperiment.GetPlayerIsPlaying(AID: string): Boolean; +function TExperiment.GetPlayerIsPlaying(AID: UTF8string): Boolean; var i : integer; begin - Result := PlayersPlaying.Count > 0; + Result := PlayersCount > 0; if Result then - for i := 0 to PlayersPlaying.Count -1 do - if PPlayer(PlayersPlaying[i])^.ID = AID then + for i := 0 to PlayersCount -1 do + if Player[i].ID = AID then Exit; Result:= False; end; -function TExperiment.GetPlayerPointer(i: integer): PPlayer; -begin - Result := @FPlayers[i]; -end; function TExperiment.GetPlayersCount: integer; begin Result := Length(FPlayers); end; -//function TExperiment.GetPlayersPlaying: TList; -//var -// //i:integer; -// //P:PPlayer; -//begin -// //P := New(PPlayer); -// //if FPlayersPlaying.Count > 0 then -// // FPlayersPlaying.Clear; -// // -// //for i := Low(FPlayers) to High(FPlayers) do -// // if FPlayers[i].Status = gpsPlaying then -// // begin -// // P := @FPlayers[i]; -// // FPlayersPlaying.Add(P); -// // end; -// //Dispose(P); -// Result := FPlayersPlaying; -//end; - procedure TExperiment.SetCondition(I : Integer; AValue: TCondition); begin FConditions[I] := AValue; @@ -378,7 +348,7 @@ begin FPlayers[I] := AValue; end; -procedure TExperiment.SetPlayer(S : string ; AValue: TPlayer); +procedure TExperiment.SetPlayer(S: UTF8string; AValue: TPlayer); var i : integer; begin if PlayersCount > 0 then @@ -391,12 +361,6 @@ begin raise Exception.Create('TExperiment.SetPlayer: Could not set player.'); end; -procedure TExperiment.SetPlayersPlaying(AValue: TList); -begin - if FPlayersPlaying = AValue then Exit; - FPlayersPlaying := AValue; -end; - procedure TExperiment.SetResearcherCanChat(AValue: Boolean); begin if FResearcherCanChat=AValue then Exit; @@ -415,10 +379,15 @@ begin FSendChatHistoryForNewPlayers:=AValue; end; +procedure TExperiment.SetState(AValue: TExperimentState); +begin + if FState=AValue then Exit; + FState:=AValue; +end; + constructor TExperiment.Create(AOwner: TComponent); begin inherited Create(AOwner); - FPlayersPlaying := TList.Create; LoadExperimentFromResource(Self); end; @@ -430,7 +399,6 @@ end; destructor TExperiment.Destroy; begin - FPlayersPlaying.Free; inherited Destroy; end; @@ -503,5 +471,10 @@ begin {$ENDIF}; end; +procedure TExperiment.Clean; +begin + +end; + end. diff --git a/units/game_file_methods.pas b/units/game_file_methods.pas index 44bbe9d..c894770 100644 --- a/units/game_file_methods.pas +++ b/units/game_file_methods.pas @@ -34,6 +34,7 @@ uses LCLIntf, game_actors_point, game_resources, string_methods, regdata, zhelpe function LoadExperimentFromResource(var AExperiment: TExperiment): Boolean; var i,j : integer; + C : TCondition; begin Result := False; with AExperiment do @@ -47,18 +48,17 @@ begin GenPlayersAsNeeded:=True; CurrentCondition := 0; MatrixType:=[gmRows]; - PlayersPlaying := TList.Create; //AppendPlayer(C_PLAYER_TEMPLATE); //AppendPlayer(C_PLAYER_TEMPLATE); - i := AppendCondition(C_CONDITION_TEMPLATE); - with Condition[i] do + C := C_CONDITION_TEMPLATE; + with C do begin - ConditionName := SEC_CONDITION+IntToStr(i+1); + ConditionName := SEC_CONDITION+IntToStr(1); Turn.Count:=0; Turn.Value:=2; Turn.Random:=False; end; - //j := AppendContingency(i,C_METACONTINGENCY_A1); + i := AppendCondition(C); end; end; diff --git a/units/game_resources.pas b/units/game_resources.pas index f30a246..4502545 100644 --- a/units/game_resources.pas +++ b/units/game_resources.pas @@ -84,7 +84,7 @@ const const CPlayerNamesMale : array [0..49] of UTF8String = - ('Junho','Rodrigo','Francisco','Martim','Santiago', + ('João','Rodrigo','Francisco','Martim','Santiago', 'Tomás','Afonso','Duarte','Miguel','Guilherme','Tiago', 'Gonçalo','Diogo','Gabriel','Pedro','Rafael','Salvador', 'Dinis','Lucas','Simael','Gustavo','David', -- libgit2 0.21.2