Commit 269dad496f873a3a37281ceab155deff027a8293

Authored by Carlos Picanco
1 parent 74c507e3
Exists in master

improve customization of messages and stringgrid

Showing 1 changed file with 38 additions and 33 deletions   Show diff stats
units/game_actors_point.pas
@@ -33,7 +33,8 @@ type @@ -33,7 +33,8 @@ type
33 constructor Create(AOwner:TComponent;AValue : integer);overload; 33 constructor Create(AOwner:TComponent;AValue : integer);overload;
34 constructor Create(AOwner:TComponent;AValue : array of integer); overload; 34 constructor Create(AOwner:TComponent;AValue : array of integer); overload;
35 constructor Create(AOwner:TComponent;AResult : string); overload; 35 constructor Create(AOwner:TComponent;AResult : string); overload;
36 - function PointMessage(APrepend, AAppendicePlural, AAppendiceSingular: string; IsGroupPoint: Boolean) : string; 36 + function PointMessage(APrepend, APrependLoss, AAppendiceLossSingular,AAppendiceLossPlural,
  37 + APrependEarn,AAppendiceEarnSingular,AAppendiceEarnPlural,AAppendiceZero: string; IsGroupPoint: Boolean) : string;
37 property ValueWithVariation : integer read GetValue write FValue; 38 property ValueWithVariation : integer read GetValue write FValue;
38 property Variation : integer read FVariation write FVariation; 39 property Variation : integer read FVariation write FVariation;
39 40
@@ -92,12 +93,28 @@ end; @@ -92,12 +93,28 @@ end;
92 93
93 constructor TGamePoint.Create(AOwner: TComponent; AResult: string); 94 constructor TGamePoint.Create(AOwner: TComponent; AResult: string);
94 begin 95 begin
95 - FValue := 0;//does not matter here, this creation method is called by a player, admin sent a result 96 + inherited Create(AOwner);
  97 + FValue := 0;//does not matter here, this creation method is called by a player, result is sent by the admin
96 FVariation := 0; 98 FVariation := 0;
97 FResult := StrToInt(AResult); 99 FResult := StrToInt(AResult);
98 end; 100 end;
99 101
100 -function TGamePoint.PointMessage(APrepend, AAppendicePlural, AAppendiceSingular: string; IsGroupPoint: Boolean): string; 102 +function TGamePoint.PointMessage(APrepend,
  103 + APrependLoss, AAppendiceLossSingular, AAppendiceLossPlural,
  104 + APrependEarn, AAppendiceEarnSingular, AAppendiceEarnPlural,
  105 + AAppendiceZero: string; IsGroupPoint: Boolean): string;
  106 +
  107 + procedure ReadCustomMessage;
  108 + begin
  109 + case FResult of
  110 + -MaxInt..-2: Result += #32+APrependLoss+#32+Self.AsString+#32+AAppendiceLossPlural;
  111 + -1 : Result += #32+APrependLoss+#32+Self.AsString+#32+AAppendiceLossSingular;
  112 + 0 : Result += #32+AAppendiceZero;
  113 + 1 : Result += #32+APrependEarn+#32+Self.AsString+#32+AAppendiceEarnSingular;
  114 + 2..MaxInt: Result += #32+APrependEarn+#32+Self.AsString+#32+AAppendiceEarnPlural;
  115 + end;
  116 + end;
  117 +
101 begin 118 begin
102 if IsGroupPoint then 119 if IsGroupPoint then
103 begin 120 begin
@@ -106,26 +123,20 @@ begin @@ -106,26 +123,20 @@ begin
106 else 123 else
107 Result := APrepend; 124 Result := APrepend;
108 125
109 - if (AAppendiceSingular = '') or (AAppendicePlural = '') then 126 + if (APrependLoss = '') or (AAppendiceLossSingular = '') or (AAppendiceLossPlural = '') or
  127 + (APrependEarn = '') or (AAppendiceEarnSingular = '') or (AAppendiceEarnPlural = '') or
  128 + (AAppendiceZero = '') then
110 begin 129 begin
111 case FResult of 130 case FResult of
112 - -MaxInt..-2: Result += ' produziram a perda de '+Self.AsString+ ' pontos para o grupo';  
113 - -1 : Result += ' produziram a perda de 1 ponto para o grupo';  
114 - 0 : Result += ' não produziram nem perderam pontos para o grupo';  
115 - 1 : Result += ' produziram 1 ponto para o grupo';  
116 - 2..MaxInt: Result += ' produziram '+Self.AsString+' pontos para o grupo' 131 + -MaxInt..-2: Result += #32+'retiraram'+#32+Self.AsString+#32+'itens escolares de uma escola pública';
  132 + -1 : Result += #32+'retiraram'+#32+Self.AsString+#32+'item escolar de uma escola pública';
  133 + 0 : Result += #32+'não doaram e nem retiraram itens escolares';
  134 + 1 : Result += #32+'doaram'+#32+Self.AsString+#32+'item escolar a uma escola pública';
  135 + 2..MaxInt: Result += #32+'doaram'+#32+Self.AsString+#32+'itens escolares a uma escola pública';
117 end; 136 end;
118 end 137 end
119 else 138 else
120 - begin  
121 - case FResult of  
122 - -MaxInt..-2: Result += ' produziram a perda de ' + Self.AsString + ' ' + AAppendicePlural;  
123 - -1 : Result += ' produziram a perda de 1 ' + AAppendiceSingular;  
124 - 0 : Result += ' não produziram nem perderam ' + AAppendicePlural;  
125 - 1 : Result += ' produziram 1 ' + AAppendiceSingular;  
126 - 2..MaxInt: Result += ' produziram ' + Self.AsString + ' ' + AAppendicePlural;  
127 - end;  
128 - end; 139 + ReadCustomMessage;
129 end 140 end
130 else 141 else
131 begin 142 begin
@@ -134,26 +145,20 @@ begin @@ -134,26 +145,20 @@ begin
134 else 145 else
135 Result := APrepend; 146 Result := APrepend;
136 147
137 - if (AAppendiceSingular = '') or (AAppendicePlural = '') then 148 + if (APrependLoss = '') or (AAppendiceLossSingular = '') or (AAppendiceLossPlural = '') or
  149 + (APrependEarn = '') or (AAppendiceEarnSingular = '') or (AAppendiceEarnPlural = '') or
  150 + (AAppendiceZero = '') then
138 begin 151 begin
139 case FResult of 152 case FResult of
140 - -MaxInt..-2: Result += ' perdeu '+Self.AsString+ ' pontos';  
141 - -1 : Result += ' perdeu 1 ponto';  
142 - 0 : Result += ' não perdeu nem ganhou pontos';  
143 - 1 : Result += ' ganhou 1 ponto';  
144 - 2..MaxInt: Result += ' ganhou '+Self.AsString+' pontos' 153 + -MaxInt..-2: Result += #32+'perdeu'+#32+Self.AsString+#32+'pontos';
  154 + -1 : Result += #32+'perdeu'+#32+Self.AsString+#32+'ponto';
  155 + 0 : Result += #32+'não perdeu nem ganhou pontos';
  156 + 1 : Result += #32+'ganhou'+#32+Self.AsString+#32+'ponto';
  157 + 2..MaxInt: Result += #32+'ganhou'+#32+Self.AsString+#32+'pontos';
145 end; 158 end;
146 end 159 end
147 else 160 else
148 - begin  
149 - case FResult of  
150 - -MaxInt..-2: Result += ' perdeu '+Self.AsString+ ' ' + AAppendicePlural;  
151 - -1 : Result += ' perdeu 1 ' + AAppendiceSingular;  
152 - 0 : Result += ' não perdeu nem ganhou ' + AAppendicePlural;  
153 - 1 : Result += ' ganhou 1 ' + AAppendiceSingular;  
154 - 2..MaxInt: Result += ' ganhou '+Self.AsString+ ' ' + AAppendicePlural;  
155 - end;  
156 - end; 161 + ReadCustomMessage;
157 end; 162 end;
158 Result += '.'; 163 Result += '.';
159 end; 164 end;