Commit 74c507e3598dd549c388b04e9f5cde9b25a81f9e

Authored by Carlos Picanco
1 parent 992809a6
Exists in master

improve customization of messages and stringgrid

Showing 1 changed file with 81 additions and 30 deletions   Show diff stats
units/game_actors.pas
... ... @@ -23,7 +23,8 @@ type
23 23 TGameActor = ( gaNone, gaAdmin, gaPlayer, gaWatcher );
24 24 TGamePlayerStatus = (gpsWaiting, gpsPlaying, gpsPlayed);
25 25  
26   - TGameMatrix = (gmRows,gmColumns, gmDots,gmClearDots);
  26 + TGameMatrix = (gmColors, gmRows, gmColumns, gmDots, gmClearDots,gmDotsClearDots);
  27 +
27 28 TGameMatrixType = set of TGameMatrix;
28 29  
29 30 TGameRow = (grNone,
... ... @@ -88,8 +89,13 @@ type
88 89  
89 90 TConsequence = class(TComponent)
90 91 private
91   - FAppendicePlural: string;
92   - FAppendiceSingular: string;
  92 + FPrependEarn,
  93 + FPrependLoss,
  94 + FAppendiceZero,
  95 + FAppendiceLossPlural,
  96 + FAppendiceLossSingular,
  97 + FAppendiceEarnPlural,
  98 + FAppendiceEarnSingular,
93 99 FNicname: string;
94 100 FStyle : TConsequenceStyle;
95 101 FP : TGamePoint;
... ... @@ -101,7 +107,9 @@ type
101 107 procedure StopTimer(Sender:TObject;var ACloseAction:TCloseAction);
102 108 procedure SelfDestroy(Sender:TOBject);virtual;
103 109 public
104   - constructor Create(AOwner:TComponent; AP:TGamePoint; AStyle:TConsequenceStyle; AAppendiceSingular,AAppendicePlural:string);overload;
  110 + constructor Create(AOwner:TComponent; AP:TGamePoint; AStyle:TConsequenceStyle; ANicname,
  111 + APrependLoss,AAppendiceLossSingular,AAppendiceLossPlural,
  112 + APrependEarn,AAppendiceEarnSingular,AAppendiceEarnPlural,AAppendiceZero:string);overload;
105 113 constructor Create(AOwner:TComponent; AP:integer; AStyle: TConsequenceStyle; AMessage:array of string);overload;
106 114 constructor Create(AOwner:TComponent; AConsequenceString: string);virtual;overload;
107 115 destructor Destroy;override;
... ... @@ -113,8 +121,13 @@ type
113 121 procedure PresentPoints(APlayerBox: TPlayerBox; G: TLabel); overload;
114 122 property ShouldPublishMessage : Boolean read GetShouldPublishMessage;
115 123 property PlayerNicname : string read FNicname write FNicname;
116   - property AppendiceSingular : string read FAppendiceSingular;
117   - property AppendicePlural : string read FAppendicePlural;
  124 + property AppendiceLossSingular : string read FAppendiceLossSingular;
  125 + property AppendiceLossPlural : string read FAppendiceLossPlural;
  126 + property AppendiceEarnSingular : string read FAppendiceEarnSingular;
  127 + property AppendiceEarnPlural : string read FAppendiceEarnPlural;
  128 + property AppendiceZero : string read FAppendiceZero;
  129 + property PrependLoss : string read FPrependLoss;
  130 + property PrependEarn : string read FPrependEarn;
118 131 property Style : TConsequenceStyle read FStyle;
119 132 property ConsequenseByPlayerID : TStringList read FConsequenceByPlayerID;
120 133 end;
... ... @@ -463,8 +476,10 @@ end;
463 476 function TPrompt.AsString: TStringList;
464 477 var
465 478 j,i : integer;
466   - LAppendiceSingular,
467   - LAppendicePlural,
  479 + LPrependLoss,LPrependEarn,
  480 + LAppendiceLossSingular,LAppendiceLossPlural,
  481 + LAppendiceEarnSingular,LAppendiceEarnPlural,
  482 + LAppendiceZero,
468 483 LConsequence,
469 484 LID : string;
470 485 LCsqStyle : TConsequenceStyle;
... ... @@ -500,8 +515,13 @@ var
500 515 if not FPromptTargets[i].Meta then
501 516 if gscA in FPromptTargets[i].Consequence.Style then
502 517 begin
503   - LAppendiceSingular := FPromptTargets[i].Consequence.AppendiceSingular;
504   - LAppendicePlural := FPromptTargets[i].Consequence.AppendicePlural;
  518 + LPrependLoss := FPromptTargets[i].Consequence.PrependLoss;
  519 + LAppendiceLossSingular := FPromptTargets[i].Consequence.AppendiceLossSingular;
  520 + LAppendiceLossPlural := FPromptTargets[i].Consequence.AppendiceLossPlural;
  521 + LPrependEarn := FPromptTargets[i].Consequence.PrependEarn;
  522 + LAppendiceEarnSingular := FPromptTargets[i].Consequence.AppendiceEarnSingular;
  523 + LAppendiceEarnPlural := FPromptTargets[i].Consequence.AppendiceEarnPlural;
  524 + LAppendiceZero := FPromptTargets[i].Consequence.AppendiceZero;
505 525 Break;
506 526 end;
507 527 end;
... ... @@ -515,8 +535,13 @@ var
515 535 IntToStr(Pts) +'|'+
516 536 GetConsequenceStylesString(LCsqStyle) +'|'+
517 537 ExtractDelimited(3,LConsequence, ['|']) +'|'+
518   - LAppendiceSingular +'|'+
519   - LAppendicePlural;
  538 + LPrependLoss +'|'+
  539 + LAppendiceLossSingular +'|'+
  540 + LAppendiceLossPlural +'|'+
  541 + LPrependEarn +'|'+
  542 + LAppendiceEarnSingular +'|'+
  543 + LAppendiceEarnPlural +'|'+
  544 + LAppendiceZero;
520 545 end;
521 546 begin
522 547 Result := TStringList.Create;
... ... @@ -531,22 +556,25 @@ begin
531 556 LConsequence := FPromptTargets[i].Consequence.ConsequenseByPlayerID.Values[LID];
532 557 LCsqStyle := GetConsequenceStylesFromString(ExtractDelimited(2,LConsequence, ['|']));
533 558  
534   - // BasA must revert appendices
535   - LAppendiceSingular := ExtractDelimited(4,LConsequence, ['|']);
536   - LAppendicePlural := ExtractDelimited(5,LConsequence, ['|']);
  559 + // BasA must revert message variables
  560 + LPrependLoss := ExtractDelimited(4,LConsequence, ['|']);
  561 + LAppendiceLossSingular := ExtractDelimited(5,LConsequence, ['|']);
  562 + LAppendiceLossPlural := ExtractDelimited(6,LConsequence, ['|']);
  563 + LPrependEarn := ExtractDelimited(7,LConsequence, ['|']);
  564 + LAppendiceEarnSingular := ExtractDelimited(8,LConsequence, ['|']);
  565 + LAppendiceEarnPlural := ExtractDelimited(9,LConsequence, ['|']);
  566 + LAppendiceZero := ExtractDelimited(10,LConsequence, ['|']);
537 567  
538 568 if gsContingency in FPromptStyle then
539 569 if (FPromptTargets[i].Fired) and (not FPromptTargets[i].Meta) then
540 570 if (gscA in LCsqStyle) or (gscB in LCsqStyle) then
541 571 ApplyPointsConditions(False);
542 572  
543   -
544 573 if gsMetacontingency in FPromptStyle then
545 574 if (FPromptTargets[i].Fired) and FPromptTargets[i].Meta then
546 575 if gscG in LCsqStyle then
547 576 ApplyPointsConditions(True);
548 577  
549   -
550 578 Result.Add(LConsequence);
551 579 end;
552 580  
... ... @@ -554,14 +582,21 @@ end;
554 582  
555 583 { TConsequence }
556 584  
557   -constructor TConsequence.Create(AOwner: TComponent; AP: TGamePoint;
558   - AStyle: TConsequenceStyle; AAppendiceSingular, AAppendicePlural: string);
  585 +constructor TConsequence.Create(AOwner: TComponent; AP: TGamePoint;AStyle: TConsequenceStyle; ANicname,
  586 + APrependLoss, AAppendiceLossSingular, AAppendiceLossPlural,
  587 + APrependEarn, AAppendiceEarnSingular, AAppendiceEarnPlural, AAppendiceZero: string);
559 588 begin
560 589 inherited Create(AOwner);
561 590 FStyle:=AStyle;
562   - FNicname:='';
563   - FAppendiceSingular:=AAppendiceSingular;
564   - FAppendicePlural:=AAppendicePlural;
  591 + FNicname:=ANicname;
  592 + FPrependLoss:=APrependLoss;
  593 + FAppendiceLossSingular:=AAppendiceLossSingular;
  594 + FAppendiceLossPlural:=AAppendiceLossPlural;
  595 + FPrependEarn:=APrependEarn;
  596 + FAppendiceEarnSingular:=AAppendiceEarnSingular;
  597 + FAppendiceEarnPlural:=AAppendiceEarnPlural;
  598 + FAppendiceZero:=AAppendiceZero;
  599 +
565 600 FP := AP;
566 601 FMessage := TPopupNotifier.Create(AOwner);
567 602 FConsequenceByPlayerID := TStringList.Create;
... ... @@ -574,9 +609,13 @@ begin
574 609 FP := TGamePoint.Create(AOwner,AP);
575 610 FStyle:=AStyle;
576 611 FNicname:=AMessage[0];
577   - FAppendiceSingular:=AMessage[1];
578   - FAppendicePlural:=AMessage[2];
579   -
  612 + FPrependLoss:=AMessage[1];
  613 + FAppendiceLossSingular:=AMessage[2];
  614 + FAppendiceLossPlural:=AMessage[3];
  615 + FPrependEarn:=AMessage[4];
  616 + FAppendiceEarnSingular:=AMessage[5];
  617 + FAppendiceEarnPlural:=AMessage[6];
  618 + FAppendiceZero:=AMessage[7];
580 619 FMessage := TPopupNotifier.Create(AOwner);
581 620 FConsequenceByPlayerID := TStringList.Create;
582 621 end;
... ... @@ -588,8 +627,13 @@ begin
588 627 FP := TGamePoint.Create(AOwner,ExtractDelimited(1,AConsequenceString,['|']));
589 628 FStyle:=GetConsequenceStylesFromString(ExtractDelimited(2,AConsequenceString,['|']));
590 629 FNicname:=ExtractDelimited(3,AConsequenceString,['|']);
591   - FAppendiceSingular:=ExtractDelimited(4,AConsequenceString,['|']);
592   - FAppendicePlural:=ExtractDelimited(5,AConsequenceString,['|']);
  630 + FPrependLoss:=ExtractDelimited(4,AConsequenceString,['|']);
  631 + FAppendiceLossSingular:=ExtractDelimited(5,AConsequenceString,['|']);
  632 + FAppendiceLossPlural:=ExtractDelimited(6,AConsequenceString,['|']);
  633 + FPrependEarn:=ExtractDelimited(7,AConsequenceString,['|']);
  634 + FAppendiceEarnSingular:=ExtractDelimited(8,AConsequenceString,['|']);
  635 + FAppendiceEarnPlural:=ExtractDelimited(9,AConsequenceString,['|']);
  636 + FAppendiceZero:=ExtractDelimited(10,AConsequenceString,['|']);
593 637  
594 638 FMessage := TPopupNotifier.Create(Self);
595 639 FTimer := TTimer.Create(Self);
... ... @@ -610,14 +654,21 @@ begin
610 654 Result := IntToStr(FP.ValueWithVariation) + '|';
611 655 Result += GetConsequenceStylesString(FStyle)+'|';
612 656 Result += FNicname +'|';
613   - Result += FAppendiceSingular + '|';
614   - Result += FAppendicePlural + '|+';
  657 + Result += FPrependLoss + '|';
  658 + Result += FAppendiceLossSingular + '|';
  659 + Result += FAppendiceLossPlural + '|';
  660 + Result += FPrependEarn + '|';
  661 + Result += FAppendiceEarnSingular + '|';
  662 + Result += FAppendiceEarnPlural + '|';
  663 + Result += FAppendiceZero + '|';
  664 +
615 665 FConsequenceByPlayerID.Values[AID]:=Result;
616 666 end;
617 667  
618 668 function TConsequence.GenerateMessage(ForGroup: Boolean): string;
619 669 begin
620   - Result := FP.PointMessage(FNicname,FAppendicePlural, FAppendiceSingular,ForGroup);
  670 + Result := FP.PointMessage(FNicname,FPrependLoss,FAppendiceLossSingular,FAppendiceLossPlural,
  671 + FPrependEarn,FAppendiceEarnSingular,FAppendiceEarnPlural,FAppendiceZero, ForGroup);
621 672 FMessage.Text := Result;
622 673 end;
623 674  
... ...