1 | {$INCLUDE Switches.inc}
|
---|
2 | unit Diplomacy;
|
---|
3 |
|
---|
4 | interface
|
---|
5 |
|
---|
6 | uses Protocol;
|
---|
7 |
|
---|
8 | function DipCommandToString(pSender, pTarget, Treaty, OppCommand,
|
---|
9 | Command: Integer; const OppOffer, Offer: TOffer): string;
|
---|
10 |
|
---|
11 |
|
---|
12 | implementation
|
---|
13 |
|
---|
14 | uses
|
---|
15 | ScreenTools, Tribes, SysUtils;
|
---|
16 |
|
---|
17 | function DipCommandToString;
|
---|
18 |
|
---|
19 | function PriceToString(P, Price: Integer): string;
|
---|
20 | begin
|
---|
21 | case Price and opMask of
|
---|
22 | opChoose:
|
---|
23 | Result := Phrases.Lookup('PRICE_CHOOSE');
|
---|
24 | opCivilReport:
|
---|
25 | Result := Tribe[P].TPhrase('PRICE_CIVIL');
|
---|
26 | opMilReport:
|
---|
27 | Result := Tribe[P].TPhrase('PRICE_MIL');
|
---|
28 | opMap:
|
---|
29 | Result := Tribe[P].TPhrase('PRICE_MAP');
|
---|
30 | opTreaty:
|
---|
31 | { if Price-opTreaty<Treaty then
|
---|
32 | case Treaty of
|
---|
33 | trPeace: Result:=Phrases.Lookup('FRENDTREATY_PEACE');
|
---|
34 | trFriendlyContact: Result:=Phrases.Lookup('FRENDTREATY_FRIENDLY');
|
---|
35 | trAlliance: Result:=Phrases.Lookup('FRENDTREATY_ALLIANCE');
|
---|
36 | end
|
---|
37 | else } Result := Phrases.Lookup('TREATY', Price - opTreaty);
|
---|
38 | opShipParts:
|
---|
39 | case Price shr 16 and $F of
|
---|
40 | 0:
|
---|
41 | Result := Format(Phrases.Lookup('PRICE_SHIPCOMP'),
|
---|
42 | [Price and $FFFF]);
|
---|
43 | 1:
|
---|
44 | Result := Format(Phrases.Lookup('PRICE_SHIPPOW'),
|
---|
45 | [Price and $FFFF]);
|
---|
46 | 2:
|
---|
47 | Result := Format(Phrases.Lookup('PRICE_SHIPHAB'),
|
---|
48 | [Price and $FFFF]);
|
---|
49 | end;
|
---|
50 | opMoney:
|
---|
51 | Result := Format('%d%%c', [Price - opMoney]);
|
---|
52 | opTribute:
|
---|
53 | Result := Format(Phrases.Lookup('PRICE_TRIBUTE'), [Price - opTribute]);
|
---|
54 | opTech:
|
---|
55 | Result := Phrases.Lookup('ADVANCES', Price - opTech);
|
---|
56 | opAllTech:
|
---|
57 | Result := Tribe[P].TPhrase('PRICE_ALLTECH');
|
---|
58 | opModel:
|
---|
59 | Result := Tribe[P].ModelName[Price - opModel];
|
---|
60 | opAllModel:
|
---|
61 | Result := Tribe[P].TPhrase('PRICE_ALLMODEL');
|
---|
62 | { opCity:
|
---|
63 | Result:=Format(TPhrase('PRICE_CITY',P),[CityName(Price-opCity)]); }
|
---|
64 | end
|
---|
65 | end;
|
---|
66 |
|
---|
67 | var
|
---|
68 | I: Integer;
|
---|
69 | sAdd, sDeliver, sCost: string;
|
---|
70 | DoIntro: Boolean;
|
---|
71 | begin
|
---|
72 | DoIntro := OppCommand = scDipStart;
|
---|
73 | case Command of
|
---|
74 | scDipCancelTreaty:
|
---|
75 | begin
|
---|
76 | case Treaty of
|
---|
77 | trPeace:
|
---|
78 | Result := Phrases.Lookup('FRCANCELTREATY_PEACE');
|
---|
79 | trFriendlyContact:
|
---|
80 | Result := Phrases.Lookup('FRCANCELTREATY_FRIENDLY');
|
---|
81 | trAlliance:
|
---|
82 | Result := Phrases.Lookup('FRCANCELTREATY_ALLIANCE');
|
---|
83 | end;
|
---|
84 | DoIntro := False;
|
---|
85 | end;
|
---|
86 | scDipNotice:
|
---|
87 | Result := Phrases.Lookup('FRNOTICE');
|
---|
88 | scDipAccept:
|
---|
89 | begin
|
---|
90 | if (OppOffer.nDeliver + OppOffer.nCost = 1) and
|
---|
91 | (OppOffer.Price[0] and opMask = opTreaty) and
|
---|
92 | (Integer(OppOffer.Price[0] - opTreaty) > Treaty) then
|
---|
93 | // simple treaty offer
|
---|
94 | { if OppOffer.Price[0]-opTreaty=trCeaseFire then
|
---|
95 | Result:=Tribe[pTarget].TPhrase('FRACCEPTCEASEFIRE')
|
---|
96 | else } Result := Tribe[pTarget].TPhrase('FRACCEPTTREATY')
|
---|
97 | else if OppOffer.nDeliver = 0 then
|
---|
98 | Result := Tribe[pSender].TPhrase('FRACCEPTDEMAND_STRONG')
|
---|
99 | else if OppOffer.nCost = 0 then
|
---|
100 | Result := Tribe[pSender].TPhrase('FRACCEPTPRESENT')
|
---|
101 | else
|
---|
102 | Result := Tribe[pSender].TPhrase('FRACCEPTOFFER');
|
---|
103 | end;
|
---|
104 | scDipBreak:
|
---|
105 | begin
|
---|
106 | Result := Tribe[pTarget].TPhrase('FRBREAK');
|
---|
107 | DoIntro := False;
|
---|
108 | end;
|
---|
109 | scDipOffer:
|
---|
110 | begin
|
---|
111 | Result := '';
|
---|
112 | if (OppCommand = scDipOffer) and
|
---|
113 | ((OppOffer.nDeliver > 0) or (OppOffer.nCost > 0)) and
|
---|
114 | (Offer.nCost + Offer.nDeliver <= 2) then
|
---|
115 | begin // respond to made offer before making own one
|
---|
116 | if (OppOffer.nDeliver + OppOffer.nCost = 1) and
|
---|
117 | (OppOffer.Price[0] and opMask = opTreaty) and
|
---|
118 | (Integer(OppOffer.Price[0] - opTreaty) > Treaty) then
|
---|
119 | // simple treaty offer
|
---|
120 | Result := Tribe[pSender].TPhrase('FRNOTACCEPTTREATY') + '\'
|
---|
121 | else if OppOffer.nDeliver = 0 then
|
---|
122 | Result := Tribe[pSender].TPhrase('FRNOTACCEPTDEMAND_STRONG') + '\'
|
---|
123 | else if OppOffer.nCost = 0 then
|
---|
124 | Result := Tribe[pSender].TPhrase('FRNOTACCEPTPRESENT') + '\';
|
---|
125 | end;
|
---|
126 |
|
---|
127 | sDeliver := '';
|
---|
128 | for I := 0 to Offer.nDeliver - 1 do
|
---|
129 | begin
|
---|
130 | sAdd := PriceToString(pSender, Offer.Price[I]);
|
---|
131 | if I = 0 then
|
---|
132 | sDeliver := sAdd
|
---|
133 | else
|
---|
134 | sDeliver := Format(Phrases.Lookup('PRICE_CONCAT'), [sDeliver, sAdd])
|
---|
135 | end;
|
---|
136 | sCost := '';
|
---|
137 | for I := 0 to Offer.nCost - 1 do
|
---|
138 | begin
|
---|
139 | sAdd := PriceToString(pTarget, Offer.Price[Offer.nDeliver + I]);
|
---|
140 | if I = 0 then
|
---|
141 | sCost := sAdd
|
---|
142 | else
|
---|
143 | sCost := Format(Phrases.Lookup('PRICE_CONCAT'), [sCost, sAdd])
|
---|
144 | end;
|
---|
145 |
|
---|
146 | if (Offer.nDeliver = 0) and (Offer.nCost = 0) then
|
---|
147 | begin // no offer made
|
---|
148 | if (OppCommand = scDipOffer) and
|
---|
149 | ((OppOffer.nDeliver = 0) and (OppOffer.nCost = 0)) then
|
---|
150 | Result := Tribe[pTarget].TPhrase('FRBYE')
|
---|
151 | else
|
---|
152 | begin
|
---|
153 | if (Result = '') and (OppCommand = scDipOffer) and
|
---|
154 | ((OppOffer.nDeliver > 0) or (OppOffer.nCost > 0)) then
|
---|
155 | begin
|
---|
156 | if (OppOffer.nDeliver = 1) and (OppOffer.Price[0] = opChoose) and
|
---|
157 | not Phrases2FallenBackToEnglish then
|
---|
158 | Result := Tribe[pSender].TString
|
---|
159 | (Phrases2.Lookup('FRNOTACCEPTANYOFFER')) + ' '
|
---|
160 | else if (OppOffer.nCost = 1) and
|
---|
161 | (OppOffer.Price[OppOffer.nDeliver] = opChoose) and not Phrases2FallenBackToEnglish
|
---|
162 | then
|
---|
163 | Result := Tribe[pSender].TString
|
---|
164 | (Phrases2.Lookup('FRNOTACCEPTANYWANT')) + ' '
|
---|
165 | else
|
---|
166 | Result := Tribe[pSender].TPhrase('FRNOTACCEPTOFFER') + ' ';
|
---|
167 | end;
|
---|
168 | Result := Result + Phrases.Lookup('FRDONE');
|
---|
169 | DoIntro := False
|
---|
170 | end
|
---|
171 | end
|
---|
172 | else if (Offer.nDeliver + Offer.nCost = 1) and
|
---|
173 | (Offer.Price[0] and opMask = opTreaty) and
|
---|
174 | (Integer(Offer.Price[0] - opTreaty) > Treaty) then
|
---|
175 | // simple treaty offer
|
---|
176 | begin
|
---|
177 | case Offer.Price[0] - opTreaty of
|
---|
178 | // trCeaseFire: result:=result+Tribe[pTarget].TPhrase('FRCEASEFIRE');
|
---|
179 | trPeace:
|
---|
180 | Result := Result + Tribe[pTarget].TPhrase('FRPEACE');
|
---|
181 | trFriendlyContact:
|
---|
182 | Result := Result + Tribe[pTarget].TPhrase('FRFRIENDLY');
|
---|
183 | trAlliance:
|
---|
184 | Result := Result + Tribe[pTarget].TPhrase('FRALLIANCE');
|
---|
185 | end
|
---|
186 | end
|
---|
187 | else if Offer.nDeliver = 0 then // demand
|
---|
188 | begin
|
---|
189 | if (Treaty >= trFriendlyContact) and not Phrases2FallenBackToEnglish
|
---|
190 | then
|
---|
191 | Result := Result +
|
---|
192 | Format(Tribe[pTarget].TString(Phrases2.Lookup('FRDEMAND_SOFT')
|
---|
193 | ), [sCost])
|
---|
194 | else
|
---|
195 | begin
|
---|
196 | Result := Result +
|
---|
197 | Format(Tribe[pTarget].TPhrase('FRDEMAND_STRONG'), [sCost]);
|
---|
198 | DoIntro := False
|
---|
199 | end
|
---|
200 | end
|
---|
201 | else if Offer.nCost = 0 then // present
|
---|
202 | Result := Result + Format(Tribe[pTarget].TPhrase('FRPRESENT'),
|
---|
203 | [sDeliver])
|
---|
204 | else if (Offer.nDeliver = 1) and (Offer.Price[0] = opChoose) then
|
---|
205 | Result := Result + Format(Phrases.Lookup('FRDELCHOICE'), [sCost])
|
---|
206 | else if (Offer.nCost = 1) and (Offer.Price[Offer.nDeliver] = opChoose)
|
---|
207 | then
|
---|
208 | Result := Result + Format(Phrases.Lookup('FRCOSTCHOICE'), [sDeliver])
|
---|
209 | else
|
---|
210 | Result := Result + Format(Phrases.Lookup('FROFFER'),
|
---|
211 | [sDeliver, sCost]);
|
---|
212 | end;
|
---|
213 | end;
|
---|
214 | if DoIntro then
|
---|
215 | if Treaty < trPeace then
|
---|
216 | Result := Tribe[pSender].TPhrase('FRSTART_NOTREATY') + ' ' + Result
|
---|
217 | else
|
---|
218 | Result := Tribe[pSender].TPhrase('FRSTART_PEACE') + ' ' + Result
|
---|
219 | end;
|
---|
220 |
|
---|
221 | end.
|
---|