Comment fix: OS is not excluded from permissive.
[freeciv.git] / common / reqtext.c
blob10260e654df6c71b0867cc77eb7265c5978de634
1 /****************************************************************************
2 Freeciv - Copyright (C) 2004 - The Freeciv Team
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ****************************************************************************/
14 #ifdef HAVE_CONFIG_H
15 #include <fc_config.h>
16 #endif
18 /* utility */
19 #include "astring.h"
20 #include "fcintl.h"
22 /* common */
23 #include "achievements.h"
24 #include "actions.h"
25 #include "calendar.h"
26 #include "extras.h"
27 #include "government.h"
28 #include "map.h"
29 #include "movement.h"
30 #include "player.h"
31 #include "requirements.h"
32 #include "specialist.h"
34 #include "reqtext.h"
36 /****************************************************************
37 Append text for the requirement. Something like
39 "Requires knowledge of the technology Communism."
41 pplayer may be NULL. Note that it must be updated everytime
42 a new requirement type or range is defined.
43 *****************************************************************/
44 bool req_text_insert(char *buf, size_t bufsz, struct player *pplayer,
45 const struct requirement *preq,
46 enum rt_verbosity verb)
48 if (preq->quiet && verb != VERB_ACTUAL) {
49 return FALSE;
52 switch (preq->source.kind) {
53 case VUT_NONE:
54 return FALSE;
56 case VUT_ADVANCE:
57 switch (preq->range) {
58 case REQ_RANGE_PLAYER:
59 if (preq->present) {
60 cat_snprintf(buf, bufsz,
61 _("Requires knowledge of the technology %s."),
62 advance_name_translation(preq->source.value.advance));
63 } else {
64 cat_snprintf(buf, bufsz,
65 _("Prevented by knowledge of the technology %s."),
66 advance_name_translation(preq->source.value.advance));
68 return TRUE;
69 case REQ_RANGE_TEAM:
70 if (preq->present) {
71 cat_snprintf(buf, bufsz,
72 _("Requires that a player on your team knows the "
73 "technology %s."),
74 advance_name_translation(preq->source.value.advance));
75 } else {
76 cat_snprintf(buf, bufsz,
77 _("Prevented if any player on your team knows the "
78 "technology %s."),
79 advance_name_translation(preq->source.value.advance));
81 return TRUE;
82 case REQ_RANGE_ALLIANCE:
83 if (preq->present) {
84 cat_snprintf(buf, bufsz,
85 _("Requires that a player allied to you knows the "
86 "technology %s."),
87 advance_name_translation(preq->source.value.advance));
88 } else {
89 cat_snprintf(buf, bufsz,
90 _("Prevented if any player allied to you knows the "
91 "technology %s."),
92 advance_name_translation(preq->source.value.advance));
94 return TRUE;
95 case REQ_RANGE_WORLD:
96 if (preq->survives) {
97 if (preq->present) {
98 cat_snprintf(buf, bufsz,
99 _("Requires that someone has discovered the "
100 "technology %s."),
101 advance_name_translation(preq->source.value.advance));
102 } else {
103 cat_snprintf(buf, bufsz,
104 _("Requires that no-one has yet discovered the "
105 "technology %s."),
106 advance_name_translation(preq->source.value.advance));
108 } else {
109 if (preq->present) {
110 cat_snprintf(buf, bufsz,
111 _("Requires that some player knows the "
112 "technology %s."),
113 advance_name_translation(preq->source.value.advance));
114 } else {
115 cat_snprintf(buf, bufsz,
116 _("Requires that no player knows the "
117 "technology %s."),
118 advance_name_translation(preq->source.value.advance));
121 return TRUE;
122 case REQ_RANGE_LOCAL:
123 case REQ_RANGE_CADJACENT:
124 case REQ_RANGE_ADJACENT:
125 case REQ_RANGE_CITY:
126 case REQ_RANGE_TRADEROUTE:
127 case REQ_RANGE_CONTINENT:
128 case REQ_RANGE_COUNT:
129 /* Not supported. */
130 break;
132 break;
134 case VUT_TECHFLAG:
135 switch (preq->range) {
136 case REQ_RANGE_PLAYER:
137 if (preq->present) {
138 cat_snprintf(buf, bufsz,
139 /* TRANS: %s is a (translatable) tech flag. */
140 _("Requires knowledge of a technology with the "
141 "\"%s\" flag."),
142 tech_flag_id_translated_name(preq->source.value.techflag));
143 } else {
144 cat_snprintf(buf, bufsz,
145 /* TRANS: %s is a (translatable) tech flag. */
146 _("Prevented by knowledge of any technology with the "
147 "\"%s\" flag."),
148 tech_flag_id_translated_name(preq->source.value.techflag));
150 return TRUE;
151 case REQ_RANGE_TEAM:
152 if (preq->present) {
153 cat_snprintf(buf, bufsz,
154 /* TRANS: %s is a (translatable) tech flag. */
155 _("Requires that a player on your team knows "
156 "a technology with the \"%s\" flag."),
157 tech_flag_id_translated_name(preq->source.value.techflag));
158 } else {
159 cat_snprintf(buf, bufsz,
160 /* TRANS: %s is a (translatable) tech flag. */
161 _("Prevented if any player on your team knows "
162 "any technology with the \"%s\" flag."),
163 tech_flag_id_translated_name(preq->source.value.techflag));
165 return TRUE;
166 case REQ_RANGE_ALLIANCE:
167 if (preq->present) {
168 cat_snprintf(buf, bufsz,
169 /* TRANS: %s is a (translatable) tech flag. */
170 _("Requires that a player allied to you knows "
171 "a technology with the \"%s\" flag."),
172 tech_flag_id_translated_name(preq->source.value.techflag));
173 } else {
174 cat_snprintf(buf, bufsz,
175 /* TRANS: %s is a (translatable) tech flag. */
176 _("Prevented if any player allied to you knows "
177 "any technology with the \"%s\" flag."),
178 tech_flag_id_translated_name(preq->source.value.techflag));
180 return TRUE;
181 case REQ_RANGE_WORLD:
182 if (preq->present) {
183 cat_snprintf(buf, bufsz,
184 /* TRANS: %s is a (translatable) tech flag. */
185 _("Requires that some player knows a technology "
186 "with the \"%s\" flag."),
187 tech_flag_id_translated_name(preq->source.value.techflag));
188 } else {
189 cat_snprintf(buf, bufsz,
190 /* TRANS: %s is a (translatable) tech flag. */
191 _("Requires that no player knows any technology with "
192 "the \"%s\" flag."),
193 tech_flag_id_translated_name(preq->source.value.techflag));
195 return TRUE;
196 case REQ_RANGE_LOCAL:
197 case REQ_RANGE_CADJACENT:
198 case REQ_RANGE_ADJACENT:
199 case REQ_RANGE_CITY:
200 case REQ_RANGE_TRADEROUTE:
201 case REQ_RANGE_CONTINENT:
202 case REQ_RANGE_COUNT:
203 /* Not supported. */
204 break;
206 break;
208 case VUT_GOVERNMENT:
209 if (preq->range != REQ_RANGE_PLAYER) {
210 break;
212 if (preq->present) {
213 cat_snprintf(buf, bufsz, _("Requires the %s government."),
214 government_name_translation(preq->source.value.govern));
215 } else {
216 cat_snprintf(buf, bufsz, _("Not available under the %s government."),
217 government_name_translation(preq->source.value.govern));
219 return TRUE;
221 case VUT_ACHIEVEMENT:
222 switch (preq->range) {
223 case REQ_RANGE_PLAYER:
224 if (preq->present) {
225 cat_snprintf(buf, bufsz, _("Requires you to have achieved \"%s\"."),
226 achievement_name_translation(preq->source.value.achievement));
227 } else {
228 cat_snprintf(buf, bufsz, _("Not available once you have achieved "
229 "\"%s\"."),
230 achievement_name_translation(preq->source.value.achievement));
232 return TRUE;
233 case REQ_RANGE_TEAM:
234 if (preq->present) {
235 cat_snprintf(buf, bufsz, _("Requires that at least one of your "
236 "team-mates has achieved \"%s\"."),
237 achievement_name_translation(preq->source.value.achievement));
238 } else {
239 cat_snprintf(buf, bufsz, _("Not available if any of your team-mates "
240 "has achieved \"%s\"."),
241 achievement_name_translation(preq->source.value.achievement));
243 return TRUE;
244 case REQ_RANGE_ALLIANCE:
245 if (preq->present) {
246 cat_snprintf(buf, bufsz, _("Requires that at least one of your allies "
247 "has achieved \"%s\"."),
248 achievement_name_translation(preq->source.value.achievement));
249 } else {
250 cat_snprintf(buf, bufsz, _("Not available if any of your allies has "
251 "achieved \"%s\"."),
252 achievement_name_translation(preq->source.value.achievement));
254 return TRUE;
255 case REQ_RANGE_WORLD:
256 if (preq->present) {
257 cat_snprintf(buf, bufsz, _("Requires that at least one player "
258 "has achieved \"%s\"."),
259 achievement_name_translation(preq->source.value.achievement));
260 } else {
261 cat_snprintf(buf, bufsz, _("Not available if any player has "
262 "achieved \"%s\"."),
263 achievement_name_translation(preq->source.value.achievement));
265 return TRUE;
266 case REQ_RANGE_LOCAL:
267 case REQ_RANGE_CADJACENT:
268 case REQ_RANGE_ADJACENT:
269 case REQ_RANGE_CITY:
270 case REQ_RANGE_TRADEROUTE:
271 case REQ_RANGE_CONTINENT:
272 case REQ_RANGE_COUNT:
273 /* Not supported. */
274 break;
276 break;
278 case VUT_ACTION:
279 switch (preq->range) {
280 case REQ_RANGE_LOCAL:
281 if (preq->present) {
282 cat_snprintf(buf, bufsz, _("Applies to the \"%s\" action."),
283 action_name_translation(preq->source.value.action));
284 } else {
285 cat_snprintf(buf, bufsz, _("Doesn't apply to the \"%s\""
286 " action."),
287 action_name_translation(preq->source.value.action));
289 return TRUE;
290 default:
291 /* Not supported. */
292 break;
294 break;
296 case VUT_IMPR_GENUS:
297 switch (preq->range) {
298 case REQ_RANGE_LOCAL:
299 if (preq->present) {
300 cat_snprintf(buf, bufsz, _("Applies to \"%s\" buildings."),
301 impr_genus_id_translated_name(
302 preq->source.value.impr_genus));
303 } else {
304 cat_snprintf(buf, bufsz, _("Doesn't apply to \"%s\" buildings."),
305 impr_genus_id_translated_name(
306 preq->source.value.impr_genus));
308 return TRUE;
309 default:
310 /* Not supported. */
311 break;
313 break;
315 case VUT_IMPROVEMENT:
316 switch (preq->range) {
317 case REQ_RANGE_WORLD:
318 if (is_great_wonder(preq->source.value.building)) {
319 if (preq->survives) {
320 if (preq->present) {
321 if (can_improvement_go_obsolete(preq->source.value.building)) {
322 cat_snprintf(buf, bufsz,
323 /* TRANS: %s is a wonder */
324 _("Requires that %s was built at some point, "
325 "and that it has not yet been rendered "
326 "obsolete."),
327 improvement_name_translation
328 (preq->source.value.building));
329 } else {
330 cat_snprintf(buf, bufsz,
331 /* TRANS: %s is a wonder */
332 _("Requires that %s was built at some point."),
333 improvement_name_translation
334 (preq->source.value.building));
336 } else {
337 if (can_improvement_go_obsolete(preq->source.value.building)) {
338 cat_snprintf(buf, bufsz,
339 /* TRANS: %s is a wonder */
340 _("Prevented if %s has ever been built, "
341 "unless it would be obsolete."),
342 improvement_name_translation
343 (preq->source.value.building));
344 } else {
345 cat_snprintf(buf, bufsz,
346 /* TRANS: %s is a wonder */
347 _("Prevented if %s has ever been built."),
348 improvement_name_translation
349 (preq->source.value.building));
352 } else {
353 /* Non-surviving requirement */
354 if (preq->present) {
355 if (can_improvement_go_obsolete(preq->source.value.building)) {
356 cat_snprintf(buf, bufsz,
357 /* TRANS: %s is a wonder */
358 _("Requires %s to be owned by any player "
359 "and not yet obsolete."),
360 improvement_name_translation
361 (preq->source.value.building));
362 } else {
363 cat_snprintf(buf, bufsz,
364 /* TRANS: %s is a wonder */
365 _("Requires %s to be owned by any player."),
366 improvement_name_translation
367 (preq->source.value.building));
369 } else {
370 if (can_improvement_go_obsolete(preq->source.value.building)) {
371 cat_snprintf(buf, bufsz,
372 /* TRANS: %s is a wonder */
373 _("Prevented if %s is currently owned by "
374 "any player, unless it is obsolete."),
375 improvement_name_translation
376 (preq->source.value.building));
377 } else {
378 cat_snprintf(buf, bufsz,
379 /* TRANS: %s is a wonder */
380 _("Prevented if %s is currently owned by "
381 "any player."),
382 improvement_name_translation
383 (preq->source.value.building));
387 return TRUE;
389 /* non-great-wonder world-ranged requirements not supported */
390 break;
391 case REQ_RANGE_ALLIANCE:
392 if (is_wonder(preq->source.value.building)) {
393 if (preq->survives) {
394 if (preq->present) {
395 if (can_improvement_go_obsolete(preq->source.value.building)) {
396 cat_snprintf(buf, bufsz,
397 /* TRANS: %s is a wonder */
398 _("Requires someone who is currently allied to "
399 "you to have built %s at some point, and for "
400 "it not to have been rendered obsolete."),
401 improvement_name_translation
402 (preq->source.value.building));
403 } else {
404 cat_snprintf(buf, bufsz,
405 /* TRANS: %s is a wonder */
406 _("Requires someone who is currently allied to "
407 "you to have built %s at some point."),
408 improvement_name_translation
409 (preq->source.value.building));
411 } else {
412 if (can_improvement_go_obsolete(preq->source.value.building)) {
413 cat_snprintf(buf, bufsz,
414 /* TRANS: %s is a wonder */
415 _("Prevented if someone currently allied to you "
416 "has ever built %s, unless it would be "
417 "obsolete."),
418 improvement_name_translation
419 (preq->source.value.building));
420 } else {
421 cat_snprintf(buf, bufsz,
422 /* TRANS: %s is a wonder */
423 _("Prevented if someone currently allied to you "
424 "has ever built %s."),
425 improvement_name_translation
426 (preq->source.value.building));
429 } else {
430 /* Non-surviving requirement */
431 if (preq->present) {
432 if (can_improvement_go_obsolete(preq->source.value.building)) {
433 cat_snprintf(buf, bufsz,
434 /* TRANS: %s is a wonder */
435 _("Requires someone allied to you to own %s, "
436 "and for it not to have been rendered "
437 "obsolete."),
438 improvement_name_translation
439 (preq->source.value.building));
440 } else {
441 cat_snprintf(buf, bufsz,
442 /* TRANS: %s is a wonder */
443 _("Requires someone allied to you to own %s."),
444 improvement_name_translation
445 (preq->source.value.building));
447 } else {
448 if (can_improvement_go_obsolete(preq->source.value.building)) {
449 cat_snprintf(buf, bufsz,
450 /* TRANS: %s is a wonder */
451 _("Prevented if someone allied to you owns %s, "
452 "unless it is obsolete."),
453 improvement_name_translation
454 (preq->source.value.building));
455 } else {
456 cat_snprintf(buf, bufsz,
457 /* TRANS: %s is a wonder */
458 _("Prevented if someone allied to you owns %s."),
459 improvement_name_translation
460 (preq->source.value.building));
464 return TRUE;
466 /* non-wonder alliance-ranged requirements not supported */
467 break;
468 case REQ_RANGE_TEAM:
469 if (is_wonder(preq->source.value.building)) {
470 if (preq->survives) {
471 if (preq->present) {
472 if (can_improvement_go_obsolete(preq->source.value.building)) {
473 cat_snprintf(buf, bufsz,
474 /* TRANS: %s is a wonder */
475 _("Requires someone on your team to have "
476 "built %s at some point, and for it not "
477 "to have been rendered obsolete."),
478 improvement_name_translation
479 (preq->source.value.building));
480 } else {
481 cat_snprintf(buf, bufsz,
482 /* TRANS: %s is a wonder */
483 _("Requires someone on your team to have "
484 "built %s at some point."),
485 improvement_name_translation
486 (preq->source.value.building));
488 } else {
489 if (can_improvement_go_obsolete(preq->source.value.building)) {
490 cat_snprintf(buf, bufsz,
491 /* TRANS: %s is a wonder */
492 _("Prevented if someone on your team has ever "
493 "built %s, unless it would be obsolete."),
494 improvement_name_translation
495 (preq->source.value.building));
496 } else {
497 cat_snprintf(buf, bufsz,
498 /* TRANS: %s is a wonder */
499 _("Prevented if someone on your team has ever "
500 "built %s."),
501 improvement_name_translation
502 (preq->source.value.building));
505 } else {
506 /* Non-surviving requirement */
507 if (preq->present) {
508 if (can_improvement_go_obsolete(preq->source.value.building)) {
509 cat_snprintf(buf, bufsz,
510 /* TRANS: %s is a wonder */
511 _("Requires someone on your team to own %s, "
512 "and for it not to have been rendered "
513 "obsolete."),
514 improvement_name_translation
515 (preq->source.value.building));
516 } else {
517 cat_snprintf(buf, bufsz,
518 /* TRANS: %s is a wonder */
519 _("Requires someone on your team to own %s."),
520 improvement_name_translation
521 (preq->source.value.building));
523 } else {
524 if (can_improvement_go_obsolete(preq->source.value.building)) {
525 cat_snprintf(buf, bufsz,
526 /* TRANS: %s is a wonder */
527 _("Prevented if someone on your team owns %s, "
528 "unless it is obsolete."),
529 improvement_name_translation
530 (preq->source.value.building));
531 } else {
532 cat_snprintf(buf, bufsz,
533 /* TRANS: %s is a wonder */
534 _("Prevented if someone on your team owns %s."),
535 improvement_name_translation
536 (preq->source.value.building));
540 return TRUE;
542 /* non-wonder team-ranged requirements not supported */
543 break;
544 case REQ_RANGE_PLAYER:
545 if (is_wonder(preq->source.value.building)) {
546 if (preq->survives) {
547 if (preq->present) {
548 if (can_improvement_go_obsolete(preq->source.value.building)) {
549 cat_snprintf(buf, bufsz,
550 /* TRANS: %s is a wonder */
551 _("Requires you to have built %s at some point, "
552 "and for it not to have been rendered "
553 "obsolete."),
554 improvement_name_translation
555 (preq->source.value.building));
556 } else {
557 cat_snprintf(buf, bufsz,
558 /* TRANS: %s is a wonder */
559 _("Requires you to have built %s at some point."),
560 improvement_name_translation
561 (preq->source.value.building));
563 } else {
564 if (can_improvement_go_obsolete(preq->source.value.building)) {
565 cat_snprintf(buf, bufsz,
566 /* TRANS: %s is a wonder */
567 _("Prevented if you have ever built %s, "
568 "unless it would be obsolete."),
569 improvement_name_translation
570 (preq->source.value.building));
571 } else {
572 cat_snprintf(buf, bufsz,
573 /* TRANS: %s is a wonder */
574 _("Prevented if you have ever built %s."),
575 improvement_name_translation
576 (preq->source.value.building));
579 } else {
580 /* Non-surviving requirement */
581 if (preq->present) {
582 if (can_improvement_go_obsolete(preq->source.value.building)) {
583 cat_snprintf(buf, bufsz,
584 /* TRANS: %s is a wonder */
585 _("Requires you to own %s, which must not "
586 "be obsolete."),
587 improvement_name_translation
588 (preq->source.value.building));
589 } else {
590 cat_snprintf(buf, bufsz,
591 /* TRANS: %s is a wonder */
592 _("Requires you to own %s."),
593 improvement_name_translation
594 (preq->source.value.building));
596 } else {
597 if (can_improvement_go_obsolete(preq->source.value.building)) {
598 cat_snprintf(buf, bufsz,
599 /* TRANS: %s is a wonder */
600 _("Prevented if you own %s, unless it is "
601 "obsolete."),
602 improvement_name_translation
603 (preq->source.value.building));
604 } else {
605 cat_snprintf(buf, bufsz,
606 /* TRANS: %s is a wonder */
607 _("Prevented if you own %s."),
608 improvement_name_translation
609 (preq->source.value.building));
613 return TRUE;
615 /* non-wonder player-ranged requirements not supported */
616 break;
617 case REQ_RANGE_CONTINENT:
618 if (is_wonder(preq->source.value.building)) {
619 if (preq->present) {
620 if (can_improvement_go_obsolete(preq->source.value.building)) {
621 cat_snprintf(buf, bufsz,
622 /* TRANS: %s is a wonder */
623 _("Requires %s in one of your cities on the same "
624 "continent, and not yet obsolete."),
625 improvement_name_translation
626 (preq->source.value.building));
627 } else {
628 cat_snprintf(buf, bufsz,
629 /* TRANS: %s is a wonder */
630 _("Requires %s in one of your cities on the same "
631 "continent."),
632 improvement_name_translation
633 (preq->source.value.building));
635 } else {
636 if (can_improvement_go_obsolete(preq->source.value.building)) {
637 cat_snprintf(buf, bufsz,
638 /* TRANS: %s is a wonder */
639 _("Prevented if %s is in one of your cities on the "
640 "same continent, unless it is obsolete."),
641 improvement_name_translation
642 (preq->source.value.building));
643 } else {
644 cat_snprintf(buf, bufsz,
645 /* TRANS: %s is a wonder */
646 _("Prevented if %s is in one of your cities on the "
647 "same continent."),
648 improvement_name_translation
649 (preq->source.value.building));
652 return TRUE;
654 /* surviving or non-wonder continent-ranged requirements not supported */
655 break;
656 case REQ_RANGE_TRADEROUTE:
657 if (preq->present) {
658 if (can_improvement_go_obsolete(preq->source.value.building)) {
659 /* Should only apply to wonders */
660 cat_snprintf(buf, bufsz,
661 /* TRANS: %s is a building or wonder */
662 _("Requires %s in the city or a trade partner "
663 "(and not yet obsolete)."),
664 improvement_name_translation
665 (preq->source.value.building));
666 } else {
667 cat_snprintf(buf, bufsz,
668 /* TRANS: %s is a building or wonder */
669 _("Requires %s in the city or a trade partner."),
670 improvement_name_translation
671 (preq->source.value.building));
673 } else {
674 if (can_improvement_go_obsolete(preq->source.value.building)) {
675 /* Should only apply to wonders */
676 cat_snprintf(buf, bufsz,
677 /* TRANS: %s is a building or wonder */
678 _("Prevented by %s in the city or a trade partner "
679 "(unless it is obsolete)."),
680 improvement_name_translation
681 (preq->source.value.building));
682 } else {
683 cat_snprintf(buf, bufsz,
684 /* TRANS: %s is a building or wonder */
685 _("Prevented by %s in the city or a trade partner."),
686 improvement_name_translation
687 (preq->source.value.building));
690 return TRUE;
691 case REQ_RANGE_CITY:
692 if (preq->present) {
693 if (can_improvement_go_obsolete(preq->source.value.building)) {
694 /* Should only apply to wonders */
695 cat_snprintf(buf, bufsz,
696 /* TRANS: %s is a building or wonder */
697 _("Requires %s in the city (and not yet obsolete)."),
698 improvement_name_translation
699 (preq->source.value.building));
700 } else {
701 cat_snprintf(buf, bufsz,
702 /* TRANS: %s is a building or wonder */
703 _("Requires %s in the city."),
704 improvement_name_translation
705 (preq->source.value.building));
707 } else {
708 if (can_improvement_go_obsolete(preq->source.value.building)) {
709 /* Should only apply to wonders */
710 cat_snprintf(buf, bufsz,
711 /* TRANS: %s is a building or wonder */
712 _("Prevented by %s in the city (unless it is "
713 "obsolete)."),
714 improvement_name_translation
715 (preq->source.value.building));
716 } else {
717 cat_snprintf(buf, bufsz,
718 /* TRANS: %s is a building or wonder */
719 _("Prevented by %s in the city."),
720 improvement_name_translation
721 (preq->source.value.building));
724 return TRUE;
725 case REQ_RANGE_LOCAL:
726 if (preq->present) {
727 cat_snprintf(buf, bufsz,
728 _("Only applies to \"%s\" buildings."),
729 improvement_name_translation
730 (preq->source.value.building));
731 } else {
732 cat_snprintf(buf, bufsz,
733 _("Does not apply to \"%s\" buildings."),
734 improvement_name_translation
735 (preq->source.value.building));
737 return TRUE;
738 case REQ_RANGE_CADJACENT:
739 case REQ_RANGE_ADJACENT:
740 case REQ_RANGE_COUNT:
741 /* Not supported. */
742 break;
744 break;
746 case VUT_EXTRA:
747 switch (preq->range) {
748 case REQ_RANGE_LOCAL:
749 if (preq->present) {
750 cat_snprintf(buf, bufsz,
751 Q_("?extra:Requires %s on the tile."),
752 extra_name_translation(preq->source.value.extra));
753 } else {
754 cat_snprintf(buf, bufsz,
755 Q_("?extra:Prevented by %s on the tile."),
756 extra_name_translation(preq->source.value.extra));
758 return TRUE;
759 case REQ_RANGE_CADJACENT:
760 if (preq->present) {
761 cat_snprintf(buf, bufsz,
762 Q_("?extra:Requires %s on the tile or a cardinally "
763 "adjacent tile."),
764 extra_name_translation(preq->source.value.extra));
765 } else {
766 cat_snprintf(buf, bufsz,
767 Q_("?extra:Prevented by %s on the tile or any cardinally "
768 "adjacent tile."),
769 extra_name_translation(preq->source.value.extra));
771 return TRUE;
772 case REQ_RANGE_ADJACENT:
773 if (preq->present) {
774 cat_snprintf(buf, bufsz,
775 Q_("?extra:Requires %s on the tile or an adjacent "
776 "tile."),
777 extra_name_translation(preq->source.value.extra));
778 } else {
779 cat_snprintf(buf, bufsz,
780 Q_("?extra:Prevented by %s on the tile or any adjacent "
781 "tile."),
782 extra_name_translation(preq->source.value.extra));
784 return TRUE;
785 case REQ_RANGE_CITY:
786 if (preq->present) {
787 cat_snprintf(buf, bufsz,
788 Q_("?extra:Requires %s on a tile within the city "
789 "radius."),
790 extra_name_translation(preq->source.value.extra));
791 } else {
792 cat_snprintf(buf, bufsz,
793 Q_("?extra:Prevented by %s on any tile within the city "
794 "radius."),
795 extra_name_translation(preq->source.value.extra));
797 return TRUE;
798 case REQ_RANGE_TRADEROUTE:
799 if (preq->present) {
800 cat_snprintf(buf, bufsz,
801 Q_("?extra:Requires %s on a tile within the city "
802 "radius, or the city radius of a trade partner."),
803 extra_name_translation(preq->source.value.extra));
804 } else {
805 cat_snprintf(buf, bufsz,
806 Q_("?extra:Prevented by %s on any tile within the city "
807 "radius or the city radius of a trade partner."),
808 extra_name_translation(preq->source.value.extra));
810 return TRUE;
811 case REQ_RANGE_CONTINENT:
812 case REQ_RANGE_PLAYER:
813 case REQ_RANGE_TEAM:
814 case REQ_RANGE_ALLIANCE:
815 case REQ_RANGE_WORLD:
816 case REQ_RANGE_COUNT:
817 /* Not supported. */
818 break;
820 break;
822 case VUT_GOOD:
823 switch (preq->range) {
824 case REQ_RANGE_CITY:
825 if (preq->present) {
826 cat_snprintf(buf, bufsz, Q_("?good:Requires import of %s ."),
827 goods_name_translation(preq->source.value.good));
828 } else {
829 cat_snprintf(buf, bufsz, Q_("?goods:Prevented by import of %s."),
830 goods_name_translation(preq->source.value.good));
832 return TRUE;
833 case REQ_RANGE_LOCAL:
834 case REQ_RANGE_CADJACENT:
835 case REQ_RANGE_ADJACENT:
836 case REQ_RANGE_TRADEROUTE:
837 case REQ_RANGE_CONTINENT:
838 case REQ_RANGE_PLAYER:
839 case REQ_RANGE_TEAM:
840 case REQ_RANGE_ALLIANCE:
841 case REQ_RANGE_WORLD:
842 case REQ_RANGE_COUNT:
843 /* Not supported. */
844 break;
846 break;
848 case VUT_TERRAIN:
849 switch (preq->range) {
850 case REQ_RANGE_LOCAL:
851 if (preq->present) {
852 cat_snprintf(buf, bufsz, Q_("?terrain:Requires %s on the tile."),
853 terrain_name_translation(preq->source.value.terrain));
854 } else {
855 cat_snprintf(buf, bufsz, Q_("?terrain:Prevented by %s on the tile."),
856 terrain_name_translation(preq->source.value.terrain));
858 return TRUE;
859 case REQ_RANGE_CADJACENT:
860 if (preq->present) {
861 cat_snprintf(buf, bufsz,
862 Q_("?terrain:Requires %s on the tile or a cardinally "
863 "adjacent tile."),
864 terrain_name_translation(preq->source.value.terrain));
865 } else {
866 cat_snprintf(buf, bufsz,
867 Q_("?terrain:Prevented by %s on the tile or any "
868 "cardinally adjacent tile."),
869 terrain_name_translation(preq->source.value.terrain));
871 return TRUE;
872 case REQ_RANGE_ADJACENT:
873 if (preq->present) {
874 cat_snprintf(buf, bufsz,
875 Q_("?terrain:Requires %s on the tile or an adjacent "
876 "tile."),
877 terrain_name_translation(preq->source.value.terrain));
878 } else {
879 cat_snprintf(buf, bufsz,
880 Q_("?terrain:Prevented by %s on the tile or any "
881 "adjacent tile."),
882 terrain_name_translation(preq->source.value.terrain));
884 return TRUE;
885 case REQ_RANGE_CITY:
886 if (preq->present) {
887 cat_snprintf(buf, bufsz,
888 Q_("?terrain:Requires %s on a tile within the city "
889 "radius."),
890 terrain_name_translation(preq->source.value.terrain));
891 } else {
892 cat_snprintf(buf, bufsz,
893 Q_("?terrain:Prevented by %s on any tile within the city "
894 "radius."),
895 terrain_name_translation(preq->source.value.terrain));
897 return TRUE;
898 case REQ_RANGE_TRADEROUTE:
899 if (preq->present) {
900 cat_snprintf(buf, bufsz,
901 Q_("?terrain:Requires %s on a tile within the city "
902 "radius, or the city radius of a trade partner."),
903 terrain_name_translation(preq->source.value.terrain));
904 } else {
905 cat_snprintf(buf, bufsz,
906 Q_("?terrain:Prevented by %s on any tile within the city "
907 "radius or the city radius of a trade partner."),
908 terrain_name_translation(preq->source.value.terrain));
910 return TRUE;
911 case REQ_RANGE_CONTINENT:
912 case REQ_RANGE_PLAYER:
913 case REQ_RANGE_TEAM:
914 case REQ_RANGE_ALLIANCE:
915 case REQ_RANGE_WORLD:
916 case REQ_RANGE_COUNT:
917 /* Not supported. */
918 break;
920 break;
922 case VUT_NATION:
923 switch (preq->range) {
924 case REQ_RANGE_PLAYER:
925 if (preq->present) {
926 cat_snprintf(buf, bufsz,
927 /* TRANS: "... playing as the Swedes." */
928 _("Requires that you are playing as the %s."),
929 nation_plural_translation(preq->source.value.nation));
930 } else {
931 cat_snprintf(buf, bufsz,
932 /* TRANS: "... playing as the Turks." */
933 _("Requires that you are not playing as the %s."),
934 nation_plural_translation(preq->source.value.nation));
936 return TRUE;
937 case REQ_RANGE_TEAM:
938 if (preq->present) {
939 cat_snprintf(buf, bufsz,
940 /* TRANS: "... same team as the Indonesians." */
941 _("Requires that you are on the same team as "
942 "the %s."),
943 nation_plural_translation(preq->source.value.nation));
944 } else {
945 cat_snprintf(buf, bufsz,
946 /* TRANS: "... same team as the Greeks." */
947 _("Requires that you are not on the same team as "
948 "the %s."),
949 nation_plural_translation(preq->source.value.nation));
951 return TRUE;
952 case REQ_RANGE_ALLIANCE:
953 if (preq->present) {
954 cat_snprintf(buf, bufsz,
955 /* TRANS: "... allied with the Koreans." */
956 _("Requires that you are allied with the %s."),
957 nation_plural_translation(preq->source.value.nation));
958 } else {
959 cat_snprintf(buf, bufsz,
960 /* TRANS: "... allied with the Danes." */
961 _("Requires that you are not allied with the %s."),
962 nation_plural_translation(preq->source.value.nation));
964 return TRUE;
965 case REQ_RANGE_WORLD:
966 if (preq->survives) {
967 if (preq->present) {
968 cat_snprintf(buf, bufsz,
969 /* TRANS: "Requires the Apaches to have ..." */
970 _("Requires the %s to have been in the game."),
971 nation_plural_translation(preq->source.value.nation));
972 } else {
973 cat_snprintf(buf, bufsz,
974 /* TRANS: "Requires the Celts never to have ..." */
975 _("Requires the %s never to have been in the "
976 "game."),
977 nation_plural_translation(preq->source.value.nation));
979 } else {
980 if (preq->present) {
981 cat_snprintf(buf, bufsz,
982 /* TRANS: "Requires the Belgians in the game." */
983 _("Requires the %s in the game."),
984 nation_plural_translation(preq->source.value.nation));
985 } else {
986 cat_snprintf(buf, bufsz,
987 /* TRANS: "Requires that the Russians are not ... */
988 _("Requires that the %s are not in the game."),
989 nation_plural_translation(preq->source.value.nation));
992 return TRUE;
993 case REQ_RANGE_LOCAL:
994 case REQ_RANGE_CADJACENT:
995 case REQ_RANGE_ADJACENT:
996 case REQ_RANGE_CITY:
997 case REQ_RANGE_TRADEROUTE:
998 case REQ_RANGE_CONTINENT:
999 case REQ_RANGE_COUNT:
1000 /* Not supported. */
1001 break;
1003 break;
1005 case VUT_NATIONGROUP:
1006 switch (preq->range) {
1007 case REQ_RANGE_PLAYER:
1008 if (preq->present) {
1009 cat_snprintf(buf, bufsz,
1010 /* TRANS: nation group: "... playing African nation." */
1011 _("Requires that you are playing %s nation."),
1012 nation_group_name_translation(preq->source.value.nationgroup));
1013 } else {
1014 cat_snprintf(buf, bufsz,
1015 /* TRANS: nation group: "... playing Imaginary nation." */
1016 _("Prevented if you are playing %s nation."),
1017 nation_group_name_translation(preq->source.value.nationgroup));
1019 return TRUE;
1020 case REQ_RANGE_TEAM:
1021 if (preq->present) {
1022 cat_snprintf(buf, bufsz,
1023 /* TRANS: nation group: "Requires Medieval nation ..." */
1024 _("Requires %s nation on your team."),
1025 nation_group_name_translation(preq->source.value.nationgroup));
1026 } else {
1027 cat_snprintf(buf, bufsz,
1028 /* TRANS: nation group: "Prevented by Medieval nation ..." */
1029 _("Prevented by %s nation on your team."),
1030 nation_group_name_translation(preq->source.value.nationgroup));
1032 return TRUE;
1033 case REQ_RANGE_ALLIANCE:
1034 if (preq->present) {
1035 cat_snprintf(buf, bufsz,
1036 /* TRANS: nation group: "Requires Modern nation ..." */
1037 _("Requires %s nation in alliance with you."),
1038 nation_group_name_translation(preq->source.value.nationgroup));
1039 } else {
1040 cat_snprintf(buf, bufsz,
1041 /* TRANS: nation group: "Prevented by Modern nation ..." */
1042 _("Prevented if %s nation is in alliance with you."),
1043 nation_group_name_translation(preq->source.value.nationgroup));
1045 return TRUE;
1046 case REQ_RANGE_WORLD:
1047 if (preq->present) {
1048 cat_snprintf(buf, bufsz,
1049 /* TRANS: nation group: "Requires Asian nation ..." */
1050 _("Requires %s nation in the game."),
1051 nation_group_name_translation(preq->source.value.nationgroup));
1052 } else {
1053 cat_snprintf(buf, bufsz,
1054 /* TRANS: nation group: "Prevented by Asian nation ..." */
1055 _("Prevented by %s nation in the game."),
1056 nation_group_name_translation(preq->source.value.nationgroup));
1058 return TRUE;
1059 case REQ_RANGE_LOCAL:
1060 case REQ_RANGE_CADJACENT:
1061 case REQ_RANGE_ADJACENT:
1062 case REQ_RANGE_CITY:
1063 case REQ_RANGE_TRADEROUTE:
1064 case REQ_RANGE_CONTINENT:
1065 case REQ_RANGE_COUNT:
1066 /* Not supported. */
1067 break;
1069 break;
1071 case VUT_STYLE:
1072 if (preq->range != REQ_RANGE_PLAYER) {
1073 break;
1075 if (preq->present) {
1076 cat_snprintf(buf, bufsz,
1077 /* TRANS: "Requires that you are playing Asian style
1078 * nation." */
1079 _("Requires that you are playing %s style nation."),
1080 style_name_translation(preq->source.value.style));
1081 } else {
1082 cat_snprintf(buf, bufsz,
1083 /* TRANS: "Requires that you are not playing Classical
1084 * style nation." */
1085 _("Requires that you are not playing %s style nation."),
1086 style_name_translation(preq->source.value.style));
1088 return TRUE;
1090 case VUT_NATIONALITY:
1091 switch (preq->range) {
1092 case REQ_RANGE_TRADEROUTE:
1093 if (preq->present) {
1094 cat_snprintf(buf, bufsz,
1095 /* TRANS: "Requires at least one Barbarian citizen ..." */
1096 _("Requires at least one %s citizen in the city or a "
1097 "trade partner."),
1098 nation_adjective_translation(preq->source.value.nationality));
1099 } else {
1100 cat_snprintf(buf, bufsz,
1101 /* TRANS: "... no Pirate citizens ..." */
1102 _("Requires that there are no %s citizens in "
1103 "the city or any trade partners."),
1104 nation_adjective_translation(preq->source.value.nationality));
1106 return TRUE;
1107 case REQ_RANGE_CITY:
1108 if (preq->present) {
1109 cat_snprintf(buf, bufsz,
1110 /* TRANS: "Requires at least one Barbarian citizen ..." */
1111 _("Requires at least one %s citizen in the city."),
1112 nation_adjective_translation(preq->source.value.nationality));
1113 } else {
1114 cat_snprintf(buf, bufsz,
1115 /* TRANS: "... no Pirate citizens ..." */
1116 _("Requires that there are no %s citizens in "
1117 "the city."),
1118 nation_adjective_translation(preq->source.value.nationality));
1120 return TRUE;
1121 case REQ_RANGE_WORLD:
1122 case REQ_RANGE_ALLIANCE:
1123 case REQ_RANGE_TEAM:
1124 case REQ_RANGE_PLAYER:
1125 case REQ_RANGE_LOCAL:
1126 case REQ_RANGE_CADJACENT:
1127 case REQ_RANGE_ADJACENT:
1128 case REQ_RANGE_CONTINENT:
1129 case REQ_RANGE_COUNT:
1130 /* Not supported. */
1131 break;
1133 break;
1135 case VUT_DIPLREL:
1136 switch (preq->range) {
1137 case REQ_RANGE_PLAYER:
1138 if (preq->present) {
1139 cat_snprintf(buf, bufsz,
1140 /* TRANS: in this and following strings, '%s' can be one
1141 * of a wide range of relationships; e.g., 'Peace',
1142 * 'Never met', 'Is foreign', 'Hosts embassy',
1143 * 'Provided Casus Belli' */
1144 _("Requires that you have the relationship '%s' with at "
1145 "least one other living player."),
1146 diplrel_name_translation(preq->source.value.diplrel));
1147 } else {
1148 cat_snprintf(buf, bufsz,
1149 _("Requires that you do not have the relationship '%s' "
1150 "with any living player."),
1151 diplrel_name_translation(preq->source.value.diplrel));
1153 return TRUE;
1154 case REQ_RANGE_TEAM:
1155 if (preq->present) {
1156 cat_snprintf(buf, bufsz,
1157 _("Requires that somebody on your team has the "
1158 "relationship '%s' with at least one other living "
1159 "player."),
1160 diplrel_name_translation(preq->source.value.diplrel));
1161 } else {
1162 cat_snprintf(buf, bufsz,
1163 _("Requires that nobody on your team has the "
1164 "relationship '%s' with any living player."),
1165 diplrel_name_translation(preq->source.value.diplrel));
1167 return TRUE;
1168 case REQ_RANGE_ALLIANCE:
1169 if (preq->present) {
1170 cat_snprintf(buf, bufsz,
1171 _("Requires that somebody in your alliance has the "
1172 "relationship '%s' with at least one other living "
1173 "player."),
1174 diplrel_name_translation(preq->source.value.diplrel));
1175 } else {
1176 cat_snprintf(buf, bufsz,
1177 _("Requires that nobody in your alliance has the "
1178 "relationship '%s' with any living player."),
1179 diplrel_name_translation(preq->source.value.diplrel));
1181 return TRUE;
1182 case REQ_RANGE_WORLD:
1183 if (preq->present) {
1184 cat_snprintf(buf, bufsz,
1185 _("Requires the relationship '%s' between two living "
1186 "players."),
1187 diplrel_name_translation(preq->source.value.diplrel));
1188 } else {
1189 cat_snprintf(buf, bufsz,
1190 _("Requires that no two living players have the "
1191 "relationship '%s'."),
1192 diplrel_name_translation(preq->source.value.diplrel));
1194 return TRUE;
1195 case REQ_RANGE_LOCAL:
1196 if (preq->present) {
1197 cat_snprintf(buf, bufsz,
1198 _("Requires that you have the relationship '%s' with the "
1199 "other player."),
1200 diplrel_name_translation(preq->source.value.diplrel));
1201 } else {
1202 cat_snprintf(buf, bufsz,
1203 _("Requires that you do not have the relationship '%s' "
1204 "with the other player."),
1205 diplrel_name_translation(preq->source.value.diplrel));
1207 return TRUE;
1208 case REQ_RANGE_CADJACENT:
1209 case REQ_RANGE_ADJACENT:
1210 case REQ_RANGE_CITY:
1211 case REQ_RANGE_TRADEROUTE:
1212 case REQ_RANGE_CONTINENT:
1213 case REQ_RANGE_COUNT:
1214 /* Not supported. */
1215 break;
1217 break;
1219 case VUT_UTYPE:
1220 switch (preq->range) {
1221 case REQ_RANGE_LOCAL:
1222 if (preq->present) {
1223 /* TRANS: %s is a single kind of unit (e.g., "Settlers"). */
1224 cat_snprintf(buf, bufsz, Q_("?unit:Requires %s."),
1225 utype_name_translation(preq->source.value.utype));
1226 } else {
1227 /* TRANS: %s is a single kind of unit (e.g., "Settlers"). */
1228 cat_snprintf(buf, bufsz, Q_("?unit:Does not apply to %s."),
1229 utype_name_translation(preq->source.value.utype));
1231 return TRUE;
1232 case REQ_RANGE_CADJACENT:
1233 case REQ_RANGE_ADJACENT:
1234 case REQ_RANGE_CITY:
1235 case REQ_RANGE_TRADEROUTE:
1236 case REQ_RANGE_CONTINENT:
1237 case REQ_RANGE_PLAYER:
1238 case REQ_RANGE_TEAM:
1239 case REQ_RANGE_ALLIANCE:
1240 case REQ_RANGE_WORLD:
1241 case REQ_RANGE_COUNT:
1242 /* Not supported. */
1243 break;
1245 break;
1247 case VUT_UTFLAG:
1248 switch (preq->range) {
1249 case REQ_RANGE_LOCAL:
1251 struct astring astr = ASTRING_INIT;
1253 /* Unit type flags mean nothing to users. Explicitly list the unit
1254 * types with those flags. */
1255 if (role_units_translations(&astr, preq->source.value.unitflag,
1256 TRUE)) {
1257 if (preq->present) {
1258 /* TRANS: %s is a list of unit types separated by "or". */
1259 cat_snprintf(buf, bufsz, Q_("?ulist:Requires %s."),
1260 astr_str(&astr));
1261 } else {
1262 /* TRANS: %s is a list of unit types separated by "or". */
1263 cat_snprintf(buf, bufsz, Q_("?ulist:Does not apply to %s."),
1264 astr_str(&astr));
1266 astr_free(&astr);
1267 return TRUE;
1270 break;
1271 case REQ_RANGE_CADJACENT:
1272 case REQ_RANGE_ADJACENT:
1273 case REQ_RANGE_CITY:
1274 case REQ_RANGE_TRADEROUTE:
1275 case REQ_RANGE_CONTINENT:
1276 case REQ_RANGE_PLAYER:
1277 case REQ_RANGE_TEAM:
1278 case REQ_RANGE_ALLIANCE:
1279 case REQ_RANGE_WORLD:
1280 case REQ_RANGE_COUNT:
1281 /* Not supported. */
1282 break;
1284 break;
1286 case VUT_UCLASS:
1287 switch (preq->range) {
1288 case REQ_RANGE_LOCAL:
1289 if (preq->present) {
1290 /* TRANS: %s is a single unit class (e.g., "Air"). */
1291 cat_snprintf(buf, bufsz, Q_("?uclass:Requires %s units."),
1292 uclass_name_translation(preq->source.value.uclass));
1293 } else {
1294 /* TRANS: %s is a single unit class (e.g., "Air"). */
1295 cat_snprintf(buf, bufsz, Q_("?uclass:Does not apply to %s units."),
1296 uclass_name_translation(preq->source.value.uclass));
1298 return TRUE;
1299 case REQ_RANGE_CADJACENT:
1300 case REQ_RANGE_ADJACENT:
1301 case REQ_RANGE_CITY:
1302 case REQ_RANGE_TRADEROUTE:
1303 case REQ_RANGE_CONTINENT:
1304 case REQ_RANGE_PLAYER:
1305 case REQ_RANGE_TEAM:
1306 case REQ_RANGE_ALLIANCE:
1307 case REQ_RANGE_WORLD:
1308 case REQ_RANGE_COUNT:
1309 /* Not supported. */
1310 break;
1312 break;
1314 case VUT_UCFLAG:
1316 const char *classes[uclass_count()];
1317 int i = 0;
1318 bool done = FALSE;
1319 struct astring list = ASTRING_INIT;
1321 unit_class_iterate(uclass) {
1322 if (uclass_has_flag(uclass, preq->source.value.unitclassflag)) {
1323 classes[i++] = uclass_name_translation(uclass);
1325 } unit_class_iterate_end;
1326 astr_build_or_list(&list, classes, i);
1328 switch (preq->range) {
1329 case REQ_RANGE_LOCAL:
1330 if (preq->present) {
1331 /* TRANS: %s is a list of unit classes separated by "or". */
1332 cat_snprintf(buf, bufsz, Q_("?uclasslist:Requires %s units."),
1333 astr_str(&list));
1334 } else {
1335 /* TRANS: %s is a list of unit classes separated by "or". */
1336 cat_snprintf(buf, bufsz, Q_("?uclasslist:Does not apply to "
1337 "%s units."),
1338 astr_str(&list));
1340 done = TRUE;
1341 break;
1342 case REQ_RANGE_CADJACENT:
1343 case REQ_RANGE_ADJACENT:
1344 case REQ_RANGE_CITY:
1345 case REQ_RANGE_TRADEROUTE:
1346 case REQ_RANGE_CONTINENT:
1347 case REQ_RANGE_PLAYER:
1348 case REQ_RANGE_TEAM:
1349 case REQ_RANGE_ALLIANCE:
1350 case REQ_RANGE_WORLD:
1351 case REQ_RANGE_COUNT:
1352 /* Not supported. */
1353 break;
1355 astr_free(&list);
1356 if (done) {
1357 return TRUE;
1360 break;
1362 case VUT_UNITSTATE:
1364 switch (preq->range) {
1365 case REQ_RANGE_LOCAL:
1366 switch (preq->source.value.unit_state) {
1367 case USP_TRANSPORTED:
1368 if (preq->present) {
1369 cat_snprintf(buf, bufsz,
1370 _("Requires that the unit is transported."));
1371 } else {
1372 cat_snprintf(buf, bufsz,
1373 _("Requires that the unit isn't transported."));
1375 return TRUE;
1376 case USP_LIVABLE_TILE:
1377 if (preq->present) {
1378 cat_snprintf(buf, bufsz,
1379 _("Requires that the unit is on livable tile."));
1380 } else {
1381 cat_snprintf(buf, bufsz,
1382 _("Requires that the unit isn't on livable tile."));
1384 return TRUE;
1385 case USP_DOMESTIC_TILE:
1386 if (preq->present) {
1387 cat_snprintf(buf, bufsz,
1388 _("Requires that the unit is on a domestic "
1389 "tile."));
1390 } else {
1391 cat_snprintf(buf, bufsz,
1392 _("Requires that the unit isn't on a domestic "
1393 "tile."));
1395 return TRUE;
1396 case USP_TRANSPORTING:
1397 if (preq->present) {
1398 cat_snprintf(buf, bufsz,
1399 _("Requires that the unit does transport one or "
1400 "more cargo units."));
1401 } else {
1402 cat_snprintf(buf, bufsz,
1403 _("Requires that the unit doesn't transport "
1404 "any cargo units."));
1406 return TRUE;
1407 case USP_HAS_HOME_CITY:
1408 if (preq->present) {
1409 cat_snprintf(buf, bufsz,
1410 _("Requires that the unit has a home city."));
1411 } else {
1412 cat_snprintf(buf, bufsz,
1413 _("Requires that the unit is homeless."));
1415 return TRUE;
1416 case USP_NATIVE_TILE:
1417 if (preq->present) {
1418 cat_snprintf(buf, bufsz,
1419 _("Requires that the unit is on native tile."));
1420 } else {
1421 cat_snprintf(buf, bufsz,
1422 _("Requires that the unit isn't on native tile."));
1424 return TRUE;
1425 case USP_COUNT:
1426 fc_assert_msg(preq->source.value.unit_state != USP_COUNT,
1427 "Invalid unit state property.");
1429 break;
1430 case REQ_RANGE_CADJACENT:
1431 case REQ_RANGE_ADJACENT:
1432 case REQ_RANGE_CITY:
1433 case REQ_RANGE_TRADEROUTE:
1434 case REQ_RANGE_CONTINENT:
1435 case REQ_RANGE_PLAYER:
1436 case REQ_RANGE_TEAM:
1437 case REQ_RANGE_ALLIANCE:
1438 case REQ_RANGE_WORLD:
1439 case REQ_RANGE_COUNT:
1440 /* Not supported. */
1441 break;
1444 break;
1446 case VUT_MINMOVES:
1448 switch (preq->range) {
1449 case REQ_RANGE_LOCAL:
1450 if (preq->present) {
1451 cat_snprintf(buf, bufsz,
1452 /* %s is numeric move points; it may have a
1453 * fractional part ("1 1/3 MP"). */
1454 _("Requires that the unit has at least %s MP left."),
1455 move_points_text(preq->source.value.minmoves, TRUE));
1456 } else {
1457 cat_snprintf(buf, bufsz,
1458 /* %s is numeric move points; it may have a
1459 * fractional part ("1 1/3 MP"). */
1460 _("Requires that the unit has less than %s MP left."),
1461 move_points_text(preq->source.value.minmoves, TRUE));
1463 return TRUE;
1464 case REQ_RANGE_CADJACENT:
1465 case REQ_RANGE_ADJACENT:
1466 case REQ_RANGE_CITY:
1467 case REQ_RANGE_TRADEROUTE:
1468 case REQ_RANGE_CONTINENT:
1469 case REQ_RANGE_PLAYER:
1470 case REQ_RANGE_TEAM:
1471 case REQ_RANGE_ALLIANCE:
1472 case REQ_RANGE_WORLD:
1473 case REQ_RANGE_COUNT:
1474 /* Not supported. */
1475 break;
1478 break;
1480 case VUT_MINVETERAN:
1481 if (preq->range != REQ_RANGE_LOCAL) {
1482 break;
1484 /* FIXME: this would be better with veteran level names, but that's
1485 * potentially unit type dependent. */
1486 if (preq->present) {
1487 cat_snprintf(buf, bufsz,
1488 PL_("Requires a unit with at least %d veteran level.",
1489 "Requires a unit with at least %d veteran levels.",
1490 preq->source.value.minveteran),
1491 preq->source.value.minveteran);
1492 } else {
1493 cat_snprintf(buf, bufsz,
1494 PL_("Requires a unit with fewer than %d veteran level.",
1495 "Requires a unit with fewer than %d veteran levels.",
1496 preq->source.value.minveteran),
1497 preq->source.value.minveteran);
1499 return TRUE;
1501 case VUT_MINHP:
1502 if (preq->range != REQ_RANGE_LOCAL) {
1503 break;
1506 if (preq->present) {
1507 cat_snprintf(buf, bufsz,
1508 PL_("Requires a unit with at least %d hit point left.",
1509 "Requires a unit with at least %d hit points left.",
1510 preq->source.value.min_hit_points),
1511 preq->source.value.min_hit_points);
1512 } else {
1513 cat_snprintf(buf, bufsz,
1514 PL_("Requires a unit with fewer than %d hit point "
1515 "left.",
1516 "Requires a unit with fewer than %d hit points "
1517 "left.",
1518 preq->source.value.min_hit_points),
1519 preq->source.value.min_hit_points);
1521 return TRUE;
1523 case VUT_OTYPE:
1524 if (preq->range != REQ_RANGE_LOCAL) {
1525 break;
1527 if (preq->present) {
1528 /* TRANS: "Applies only to Food." */
1529 cat_snprintf(buf, bufsz, Q_("?output:Applies only to %s."),
1530 get_output_name(preq->source.value.outputtype));
1531 } else {
1532 /* TRANS: "Does not apply to Food." */
1533 cat_snprintf(buf, bufsz, Q_("?output:Does not apply to %s."),
1534 get_output_name(preq->source.value.outputtype));
1536 return TRUE;
1538 case VUT_SPECIALIST:
1539 if (preq->range != REQ_RANGE_LOCAL) {
1540 break;
1542 if (preq->present) {
1543 /* TRANS: "Applies only to Scientists." */
1544 cat_snprintf(buf, bufsz, Q_("?specialist:Applies only to %s."),
1545 specialist_plural_translation(preq->source.value.specialist));
1546 } else {
1547 /* TRANS: "Does not apply to Scientists." */
1548 cat_snprintf(buf, bufsz, Q_("?specialist:Does not apply to %s."),
1549 specialist_plural_translation(preq->source.value.specialist));
1551 return TRUE;
1553 case VUT_MINSIZE:
1554 switch (preq->range) {
1555 case REQ_RANGE_TRADEROUTE:
1556 if (preq->present) {
1557 cat_snprintf(buf, bufsz,
1558 PL_("Requires a minimum city size of %d for this "
1559 "city or a trade partner.",
1560 "Requires a minimum city size of %d for this "
1561 "city or a trade partner.",
1562 preq->source.value.minsize),
1563 preq->source.value.minsize);
1564 } else {
1565 cat_snprintf(buf, bufsz,
1566 PL_("Requires the city size to be less than %d "
1567 "for this city and all trade partners.",
1568 "Requires the city size to be less than %d "
1569 "for this city and all trade partners.",
1570 preq->source.value.minsize),
1571 preq->source.value.minsize);
1573 return TRUE;
1574 case REQ_RANGE_CITY:
1575 if (preq->present) {
1576 cat_snprintf(buf, bufsz,
1577 PL_("Requires a minimum city size of %d.",
1578 "Requires a minimum city size of %d.",
1579 preq->source.value.minsize),
1580 preq->source.value.minsize);
1581 } else {
1582 cat_snprintf(buf, bufsz,
1583 PL_("Requires the city size to be less than %d.",
1584 "Requires the city size to be less than %d.",
1585 preq->source.value.minsize),
1586 preq->source.value.minsize);
1588 return TRUE;
1589 case REQ_RANGE_LOCAL:
1590 case REQ_RANGE_CADJACENT:
1591 case REQ_RANGE_ADJACENT:
1592 case REQ_RANGE_CONTINENT:
1593 case REQ_RANGE_PLAYER:
1594 case REQ_RANGE_TEAM:
1595 case REQ_RANGE_ALLIANCE:
1596 case REQ_RANGE_WORLD:
1597 case REQ_RANGE_COUNT:
1598 /* Not supported. */
1599 break;
1602 case VUT_MINCULTURE:
1603 switch (preq->range) {
1604 case REQ_RANGE_CITY:
1605 if (preq->present) {
1606 cat_snprintf(buf, bufsz,
1607 PL_("Requires a minimum culture of %d in the city.",
1608 "Requires a minimum culture of %d in the city.",
1609 preq->source.value.minculture),
1610 preq->source.value.minculture);
1611 } else {
1612 cat_snprintf(buf, bufsz,
1613 PL_("Requires the culture in the city to be less "
1614 "than %d.",
1615 "Requires the culture in the city to be less "
1616 "than %d.",
1617 preq->source.value.minculture),
1618 preq->source.value.minculture);
1620 return TRUE;
1621 case REQ_RANGE_TRADEROUTE:
1622 if (preq->present) {
1623 cat_snprintf(buf, bufsz,
1624 PL_("Requires a minimum culture of %d in this city or "
1625 "a trade partner.",
1626 "Requires a minimum culture of %d in this city or "
1627 "a trade partner.",
1628 preq->source.value.minculture),
1629 preq->source.value.minculture);
1630 } else {
1631 cat_snprintf(buf, bufsz,
1632 PL_("Requires the culture in this city and all trade "
1633 "partners to be less than %d.",
1634 "Requires the culture in this city and all trade "
1635 "partners to be less than %d.",
1636 preq->source.value.minculture),
1637 preq->source.value.minculture);
1639 return TRUE;
1640 case REQ_RANGE_PLAYER:
1641 if (preq->present) {
1642 cat_snprintf(buf, bufsz,
1643 PL_("Requires your nation to have culture "
1644 "of at least %d.",
1645 "Requires your nation to have culture "
1646 "of at least %d.",
1647 preq->source.value.minculture),
1648 preq->source.value.minculture);
1649 } else {
1650 cat_snprintf(buf, bufsz,
1651 PL_("Prevented if your nation has culture of "
1652 "%d or more.",
1653 "Prevented if your nation has culture of "
1654 "%d or more.",
1655 preq->source.value.minculture),
1656 preq->source.value.minculture);
1658 return TRUE;
1659 case REQ_RANGE_TEAM:
1660 if (preq->present) {
1661 cat_snprintf(buf, bufsz,
1662 PL_("Requires someone on your team to have culture of "
1663 "at least %d.",
1664 "Requires someone on your team to have culture of "
1665 "at least %d.",
1666 preq->source.value.minculture),
1667 preq->source.value.minculture);
1668 } else {
1669 cat_snprintf(buf, bufsz,
1670 PL_("Prevented if anyone on your team has culture of "
1671 "%d or more.",
1672 "Prevented if anyone on your team has culture of "
1673 "%d or more.",
1674 preq->source.value.minculture),
1675 preq->source.value.minculture);
1677 return TRUE;
1678 case REQ_RANGE_ALLIANCE:
1679 if (preq->present) {
1680 cat_snprintf(buf, bufsz,
1681 PL_("Requires someone in your current alliance to "
1682 "have culture of at least %d.",
1683 "Requires someone in your current alliance to "
1684 "have culture of at least %d.",
1685 preq->source.value.minculture),
1686 preq->source.value.minculture);
1687 } else {
1688 cat_snprintf(buf, bufsz,
1689 PL_("Prevented if anyone in your current alliance has "
1690 "culture of %d or more.",
1691 "Prevented if anyone in your current alliance has "
1692 "culture of %d or more.",
1693 preq->source.value.minculture),
1694 preq->source.value.minculture);
1696 return TRUE;
1697 case REQ_RANGE_WORLD:
1698 if (preq->present) {
1699 cat_snprintf(buf, bufsz,
1700 PL_("Requires that some player has culture of at "
1701 "least %d.",
1702 "Requires that some player has culture of at "
1703 "least %d.",
1704 preq->source.value.minculture),
1705 preq->source.value.minculture);
1706 } else {
1707 cat_snprintf(buf, bufsz,
1708 PL_("Requires that no player has culture of %d "
1709 "or more.",
1710 "Requires that no player has culture of %d "
1711 "or more.",
1712 preq->source.value.minculture),
1713 preq->source.value.minculture);
1715 return TRUE;
1716 case REQ_RANGE_LOCAL:
1717 case REQ_RANGE_CADJACENT:
1718 case REQ_RANGE_ADJACENT:
1719 case REQ_RANGE_CONTINENT:
1720 case REQ_RANGE_COUNT:
1721 break;
1723 break;
1725 case VUT_MAXTILEUNITS:
1726 switch (preq->range) {
1727 case REQ_RANGE_LOCAL:
1728 if (preq->present) {
1729 cat_snprintf(buf, bufsz,
1730 PL_("At most %d unit may be present on the tile.",
1731 "At most %d units may be present on the tile.",
1732 preq->source.value.max_tile_units),
1733 preq->source.value.max_tile_units);
1734 } else {
1735 cat_snprintf(buf, bufsz,
1736 PL_("There must be more than %d unit present on "
1737 "the tile.",
1738 "There must be more than %d units present on "
1739 "the tile.",
1740 preq->source.value.max_tile_units),
1741 preq->source.value.max_tile_units);
1743 return TRUE;
1744 case REQ_RANGE_CADJACENT:
1745 if (preq->present) {
1746 cat_snprintf(buf, bufsz,
1747 PL_("The tile or at least one cardinally adjacent tile "
1748 "must have %d unit or fewer.",
1749 "The tile or at least one cardinally adjacent tile "
1750 "must have %d units or fewer.",
1751 preq->source.value.max_tile_units),
1752 preq->source.value.max_tile_units);
1753 } else {
1754 cat_snprintf(buf, bufsz,
1755 PL_("The tile and all cardinally adjacent tiles must "
1756 "have more than %d unit each.",
1757 "The tile and all cardinally adjacent tiles must "
1758 "have more than %d units each.",
1759 preq->source.value.max_tile_units),
1760 preq->source.value.max_tile_units);
1762 return TRUE;
1763 case REQ_RANGE_ADJACENT:
1764 if (preq->present) {
1765 cat_snprintf(buf, bufsz,
1766 PL_("The tile or at least one adjacent tile must have "
1767 "%d unit or fewer.",
1768 "The tile or at least one adjacent tile must have "
1769 "%d units or fewer.",
1770 preq->source.value.max_tile_units),
1771 preq->source.value.max_tile_units);
1772 } else {
1773 cat_snprintf(buf, bufsz,
1774 PL_("The tile and all adjacent tiles must have more "
1775 "than %d unit each.",
1776 "The tile and all adjacent tiles must have more "
1777 "than %d units each.",
1778 preq->source.value.max_tile_units),
1779 preq->source.value.max_tile_units);
1781 return TRUE;
1782 case REQ_RANGE_CITY:
1783 case REQ_RANGE_TRADEROUTE:
1784 case REQ_RANGE_CONTINENT:
1785 case REQ_RANGE_PLAYER:
1786 case REQ_RANGE_TEAM:
1787 case REQ_RANGE_ALLIANCE:
1788 case REQ_RANGE_WORLD:
1789 case REQ_RANGE_COUNT:
1790 /* Not supported. */
1791 break;
1794 case VUT_AI_LEVEL:
1795 if (preq->range != REQ_RANGE_PLAYER) {
1796 break;
1798 if (preq->present) {
1799 cat_snprintf(buf, bufsz,
1800 /* TRANS: AI level (e.g., "Handicapped") */
1801 _("Applies to %s AI players."),
1802 ai_level_translated_name(preq->source.value.ai_level));
1803 } else {
1804 cat_snprintf(buf, bufsz,
1805 /* TRANS: AI level (e.g., "Cheating") */
1806 _("Does not apply to %s AI players."),
1807 ai_level_translated_name(preq->source.value.ai_level));
1809 return TRUE;
1811 case VUT_TERRAINCLASS:
1812 switch (preq->range) {
1813 case REQ_RANGE_LOCAL:
1814 if (preq->present) {
1815 cat_snprintf(buf, bufsz,
1816 /* TRANS: %s is a terrain class */
1817 Q_("?terrainclass:Requires %s terrain on the tile."),
1818 terrain_class_name_translation
1819 (preq->source.value.terrainclass));
1820 } else {
1821 cat_snprintf(buf, bufsz,
1822 /* TRANS: %s is a terrain class */
1823 Q_("?terrainclass:Prevented by %s terrain on the tile."),
1824 terrain_class_name_translation
1825 (preq->source.value.terrainclass));
1827 return TRUE;
1828 case REQ_RANGE_CADJACENT:
1829 if (preq->present) {
1830 cat_snprintf(buf, bufsz,
1831 /* TRANS: %s is a terrain class */
1832 Q_("?terrainclass:Requires %s terrain on the tile or a "
1833 "cardinally adjacent tile."),
1834 terrain_class_name_translation
1835 (preq->source.value.terrainclass));
1836 } else {
1837 cat_snprintf(buf, bufsz,
1838 /* TRANS: %s is a terrain class */
1839 Q_("?terrainclass:Prevented by %s terrain on the tile or "
1840 "any cardinally adjacent tile."),
1841 terrain_class_name_translation
1842 (preq->source.value.terrainclass));
1844 return TRUE;
1845 case REQ_RANGE_ADJACENT:
1846 if (preq->present) {
1847 cat_snprintf(buf, bufsz,
1848 /* TRANS: %s is a terrain class */
1849 Q_("?terrainclass:Requires %s terrain on the tile or an "
1850 "adjacent tile."),
1851 terrain_class_name_translation
1852 (preq->source.value.terrainclass));
1853 } else {
1854 cat_snprintf(buf, bufsz,
1855 /* TRANS: %s is a terrain class */
1856 Q_("?terrainclass:Prevented by %s terrain on the tile or "
1857 "any adjacent tile."),
1858 terrain_class_name_translation
1859 (preq->source.value.terrainclass));
1861 return TRUE;
1862 case REQ_RANGE_CITY:
1863 if (preq->present) {
1864 cat_snprintf(buf, bufsz,
1865 /* TRANS: %s is a terrain class */
1866 Q_("?terrainclass:Requires %s terrain on a tile within "
1867 "the city radius."),
1868 terrain_class_name_translation
1869 (preq->source.value.terrainclass));
1870 } else {
1871 cat_snprintf(buf, bufsz,
1872 /* TRANS: %s is a terrain class */
1873 Q_("?terrainclass:Prevented by %s terrain on any tile "
1874 "within the city radius."),
1875 terrain_class_name_translation
1876 (preq->source.value.terrainclass));
1878 return TRUE;
1879 case REQ_RANGE_TRADEROUTE:
1880 if (preq->present) {
1881 cat_snprintf(buf, bufsz,
1882 /* TRANS: %s is a terrain class */
1883 Q_("?terrainclass:Requires %s terrain on a tile within "
1884 "the city radius or the city radius of a trade "
1885 "partner."),
1886 terrain_class_name_translation
1887 (preq->source.value.terrainclass));
1888 } else {
1889 cat_snprintf(buf, bufsz,
1890 /* TRANS: %s is a terrain class */
1891 Q_("?terrainclass:Prevented by %s terrain on any tile "
1892 "within the city radius or the city radius of a trade "
1893 "partner."),
1894 terrain_class_name_translation
1895 (preq->source.value.terrainclass));
1897 return TRUE;
1898 case REQ_RANGE_CONTINENT:
1899 case REQ_RANGE_PLAYER:
1900 case REQ_RANGE_TEAM:
1901 case REQ_RANGE_ALLIANCE:
1902 case REQ_RANGE_WORLD:
1903 case REQ_RANGE_COUNT:
1904 /* Not supported. */
1905 break;
1907 break;
1909 case VUT_TERRFLAG:
1910 switch (preq->range) {
1911 case REQ_RANGE_LOCAL:
1912 if (preq->present) {
1913 cat_snprintf(buf, bufsz,
1914 /* TRANS: %s is a (translatable) terrain flag. */
1915 _("Requires terrain with the \"%s\" flag on the tile."),
1916 terrain_flag_id_translated_name(preq->source.value.terrainflag));
1917 } else {
1918 cat_snprintf(buf, bufsz,
1919 /* TRANS: %s is a (translatable) terrain flag. */
1920 _("Prevented by terrain with the \"%s\" flag on the "
1921 "tile."),
1922 terrain_flag_id_translated_name(preq->source.value.terrainflag));
1924 return TRUE;
1925 case REQ_RANGE_CADJACENT:
1926 if (preq->present) {
1927 cat_snprintf(buf, bufsz,
1928 /* TRANS: %s is a (translatable) terrain flag. */
1929 _("Requires terrain with the \"%s\" flag on the "
1930 "tile or a cardinally adjacent tile."),
1931 terrain_flag_id_translated_name(preq->source.value.terrainflag));
1932 } else {
1933 cat_snprintf(buf, bufsz,
1934 /* TRANS: %s is a (translatable) terrain flag. */
1935 _("Prevented by terrain with the \"%s\" flag on "
1936 "the tile or any cardinally adjacent tile."),
1937 terrain_flag_id_translated_name(preq->source.value.terrainflag));
1939 return TRUE;
1940 case REQ_RANGE_ADJACENT:
1941 if (preq->present) {
1942 cat_snprintf(buf, bufsz,
1943 /* TRANS: %s is a (translatable) terrain flag. */
1944 _("Requires terrain with the \"%s\" flag on the "
1945 "tile or an adjacent tile."),
1946 terrain_flag_id_translated_name(preq->source.value.terrainflag));
1947 } else {
1948 cat_snprintf(buf, bufsz,
1949 /* TRANS: %s is a (translatable) terrain flag. */
1950 _("Prevented by terrain with the \"%s\" flag on "
1951 "the tile or any adjacent tile."),
1952 terrain_flag_id_translated_name(preq->source.value.terrainflag));
1954 return TRUE;
1955 case REQ_RANGE_CITY:
1956 if (preq->present) {
1957 cat_snprintf(buf, bufsz,
1958 /* TRANS: %s is a (translatable) terrain flag. */
1959 _("Requires terrain with the \"%s\" flag on a tile "
1960 "within the city radius."),
1961 terrain_flag_id_translated_name(preq->source.value.terrainflag));
1962 } else {
1963 cat_snprintf(buf, bufsz,
1964 /* TRANS: %s is a (translatable) terrain flag. */
1965 _("Prevented by terrain with the \"%s\" flag on any tile "
1966 "within the city radius."),
1967 terrain_flag_id_translated_name(preq->source.value.terrainflag));
1969 return TRUE;
1970 case REQ_RANGE_TRADEROUTE:
1971 if (preq->present) {
1972 cat_snprintf(buf, bufsz,
1973 /* TRANS: %s is a (translatable) terrain flag. */
1974 _("Requires terrain with the \"%s\" flag on a tile "
1975 "within the city radius or the city radius of "
1976 "a trade partner."),
1977 terrain_flag_id_translated_name(preq->source.value.terrainflag));
1978 } else {
1979 cat_snprintf(buf, bufsz,
1980 /* TRANS: %s is a (translatable) terrain flag. */
1981 _("Prevented by terrain with the \"%s\" flag on any tile "
1982 "within the city radius or the city radius of "
1983 "a trade partner."),
1984 terrain_flag_id_translated_name(preq->source.value.terrainflag));
1986 return TRUE;
1987 case REQ_RANGE_CONTINENT:
1988 case REQ_RANGE_PLAYER:
1989 case REQ_RANGE_TEAM:
1990 case REQ_RANGE_ALLIANCE:
1991 case REQ_RANGE_WORLD:
1992 case REQ_RANGE_COUNT:
1993 /* Not supported. */
1994 break;
1996 break;
1998 case VUT_BASEFLAG:
1999 switch (preq->range) {
2000 case REQ_RANGE_LOCAL:
2001 if (preq->present) {
2002 cat_snprintf(buf, bufsz,
2003 /* TRANS: %s is a (translatable) base flag. */
2004 _("Requires a base with the \"%s\" flag on the tile."),
2005 base_flag_id_translated_name(preq->source.value.baseflag));
2006 } else {
2007 cat_snprintf(buf, bufsz,
2008 /* TRANS: %s is a (translatable) base flag. */
2009 _("Prevented by a base with the \"%s\" flag on the "
2010 "tile."),
2011 base_flag_id_translated_name(preq->source.value.baseflag));
2013 return TRUE;
2014 case REQ_RANGE_CADJACENT:
2015 if (preq->present) {
2016 cat_snprintf(buf, bufsz,
2017 /* TRANS: %s is a (translatable) base flag. */
2018 _("Requires a base with the \"%s\" flag on the "
2019 "tile or a cardinally adjacent tile."),
2020 base_flag_id_translated_name(preq->source.value.baseflag));
2021 } else {
2022 cat_snprintf(buf, bufsz,
2023 /* TRANS: %s is a (translatable) base flag. */
2024 _("Prevented by a base with the \"%s\" flag on "
2025 "the tile or any cardinally adjacent tile."),
2026 base_flag_id_translated_name(preq->source.value.baseflag));
2028 return TRUE;
2029 case REQ_RANGE_ADJACENT:
2030 if (preq->present) {
2031 cat_snprintf(buf, bufsz,
2032 /* TRANS: %s is a (translatable) base flag. */
2033 _("Requires a base with the \"%s\" flag on the "
2034 "tile or an adjacent tile."),
2035 base_flag_id_translated_name(preq->source.value.baseflag));
2036 } else {
2037 cat_snprintf(buf, bufsz,
2038 /* TRANS: %s is a (translatable) base flag. */
2039 _("Prevented by a base with the \"%s\" flag on "
2040 "the tile or any adjacent tile."),
2041 base_flag_id_translated_name(preq->source.value.baseflag));
2043 return TRUE;
2044 case REQ_RANGE_CITY:
2045 if (preq->present) {
2046 cat_snprintf(buf, bufsz,
2047 /* TRANS: %s is a (translatable) base flag. */
2048 _("Requires a base with the \"%s\" flag on a tile "
2049 "within the city radius."),
2050 base_flag_id_translated_name(preq->source.value.baseflag));
2051 } else {
2052 cat_snprintf(buf, bufsz,
2053 /* TRANS: %s is a (translatable) base flag. */
2054 _("Prevented by a base with the \"%s\" flag on any tile "
2055 "within the city radius."),
2056 base_flag_id_translated_name(preq->source.value.baseflag));
2058 return TRUE;
2059 case REQ_RANGE_TRADEROUTE:
2060 if (preq->present) {
2061 cat_snprintf(buf, bufsz,
2062 /* TRANS: %s is a (translatable) base flag. */
2063 _("Requires a base with the \"%s\" flag on a tile "
2064 "within the city radius or the city radius of a "
2065 "trade partner."),
2066 base_flag_id_translated_name(preq->source.value.baseflag));
2067 } else {
2068 cat_snprintf(buf, bufsz,
2069 /* TRANS: %s is a (translatable) base flag. */
2070 _("Prevented by a base with the \"%s\" flag on any tile "
2071 "within the city radius or the city radius of a "
2072 "trade partner."),
2073 base_flag_id_translated_name(preq->source.value.baseflag));
2075 return TRUE;
2076 case REQ_RANGE_CONTINENT:
2077 case REQ_RANGE_PLAYER:
2078 case REQ_RANGE_TEAM:
2079 case REQ_RANGE_ALLIANCE:
2080 case REQ_RANGE_WORLD:
2081 case REQ_RANGE_COUNT:
2082 /* Not supported. */
2083 break;
2085 break;
2087 case VUT_ROADFLAG:
2088 switch (preq->range) {
2089 case REQ_RANGE_LOCAL:
2090 if (preq->present) {
2091 cat_snprintf(buf, bufsz,
2092 /* TRANS: %s is a (translatable) road flag. */
2093 _("Requires a road with the \"%s\" flag on the tile."),
2094 road_flag_id_translated_name(preq->source.value.roadflag));
2095 } else {
2096 cat_snprintf(buf, bufsz,
2097 /* TRANS: %s is a (translatable) road flag. */
2098 _("Prevented by a road with the \"%s\" flag on the "
2099 "tile."),
2100 road_flag_id_translated_name(preq->source.value.roadflag));
2102 return TRUE;
2103 case REQ_RANGE_CADJACENT:
2104 if (preq->present) {
2105 cat_snprintf(buf, bufsz,
2106 /* TRANS: %s is a (translatable) road flag. */
2107 _("Requires a road with the \"%s\" flag on the "
2108 "tile or a cardinally adjacent tile."),
2109 road_flag_id_translated_name(preq->source.value.roadflag));
2110 } else {
2111 cat_snprintf(buf, bufsz,
2112 /* TRANS: %s is a (translatable) road flag. */
2113 _("Prevented by a road with the \"%s\" flag on "
2114 "the tile or any cardinally adjacent tile."),
2115 road_flag_id_translated_name(preq->source.value.roadflag));
2117 return TRUE;
2118 case REQ_RANGE_ADJACENT:
2119 if (preq->present) {
2120 cat_snprintf(buf, bufsz,
2121 /* TRANS: %s is a (translatable) road flag. */
2122 _("Requires a road with the \"%s\" flag on the "
2123 "tile or an adjacent tile."),
2124 road_flag_id_translated_name(preq->source.value.roadflag));
2125 } else {
2126 cat_snprintf(buf, bufsz,
2127 /* TRANS: %s is a (translatable) road flag. */
2128 _("Prevented by a road with the \"%s\" flag on "
2129 "the tile or any adjacent tile."),
2130 road_flag_id_translated_name(preq->source.value.roadflag));
2132 return TRUE;
2133 case REQ_RANGE_CITY:
2134 if (preq->present) {
2135 cat_snprintf(buf, bufsz,
2136 /* TRANS: %s is a (translatable) road flag. */
2137 _("Requires a road with the \"%s\" flag on a tile "
2138 "within the city radius."),
2139 road_flag_id_translated_name(preq->source.value.roadflag));
2140 } else {
2141 cat_snprintf(buf, bufsz,
2142 /* TRANS: %s is a (translatable) road flag. */
2143 _("Prevented by a road with the \"%s\" flag on any tile "
2144 "within the city radius."),
2145 road_flag_id_translated_name(preq->source.value.roadflag));
2147 return TRUE;
2148 case REQ_RANGE_TRADEROUTE:
2149 if (preq->present) {
2150 cat_snprintf(buf, bufsz,
2151 /* TRANS: %s is a (translatable) road flag. */
2152 _("Requires a road with the \"%s\" flag on a tile "
2153 "within the city radius or the city radius of a "
2154 "trade partner."),
2155 road_flag_id_translated_name(preq->source.value.roadflag));
2156 } else {
2157 cat_snprintf(buf, bufsz,
2158 /* TRANS: %s is a (translatable) road flag. */
2159 _("Prevented by a road with the \"%s\" flag on any tile "
2160 "within the city radius or the city radius of a "
2161 "trade partner."),
2162 road_flag_id_translated_name(preq->source.value.roadflag));
2164 return TRUE;
2165 case REQ_RANGE_CONTINENT:
2166 case REQ_RANGE_PLAYER:
2167 case REQ_RANGE_TEAM:
2168 case REQ_RANGE_ALLIANCE:
2169 case REQ_RANGE_WORLD:
2170 case REQ_RANGE_COUNT:
2171 /* Not supported. */
2172 break;
2174 break;
2176 case VUT_EXTRAFLAG:
2177 switch (preq->range) {
2178 case REQ_RANGE_LOCAL:
2179 if (preq->present) {
2180 cat_snprintf(buf, bufsz,
2181 /* TRANS: %s is a (translatable) extra flag. */
2182 _("Requires an extra with the \"%s\" flag on the tile."),
2183 extra_flag_id_translated_name(preq->source.value.extraflag));
2184 } else {
2185 cat_snprintf(buf, bufsz,
2186 /* TRANS: %s is a (translatable) extra flag. */
2187 _("Prevented by an extra with the \"%s\" flag on the "
2188 "tile."),
2189 extra_flag_id_translated_name(preq->source.value.extraflag));
2191 return TRUE;
2192 case REQ_RANGE_CADJACENT:
2193 if (preq->present) {
2194 cat_snprintf(buf, bufsz,
2195 /* TRANS: %s is a (translatable) extra flag. */
2196 _("Requires an extra with the \"%s\" flag on the "
2197 "tile or a cardinally adjacent tile."),
2198 extra_flag_id_translated_name(preq->source.value.extraflag));
2199 } else {
2200 cat_snprintf(buf, bufsz,
2201 /* TRANS: %s is a (translatable) extra flag. */
2202 _("Prevented by an extra with the \"%s\" flag on "
2203 "the tile or any cardinally adjacent tile."),
2204 extra_flag_id_translated_name(preq->source.value.extraflag));
2206 return TRUE;
2207 case REQ_RANGE_ADJACENT:
2208 if (preq->present) {
2209 cat_snprintf(buf, bufsz,
2210 /* TRANS: %s is a (translatable) extra flag. */
2211 _("Requires an extra with the \"%s\" flag on the "
2212 "tile or an adjacent tile."),
2213 extra_flag_id_translated_name(preq->source.value.extraflag));
2214 } else {
2215 cat_snprintf(buf, bufsz,
2216 /* TRANS: %s is a (translatable) extra flag. */
2217 _("Prevented by an extra with the \"%s\" flag on "
2218 "the tile or any adjacent tile."),
2219 extra_flag_id_translated_name(preq->source.value.extraflag));
2221 return TRUE;
2222 case REQ_RANGE_CITY:
2223 if (preq->present) {
2224 cat_snprintf(buf, bufsz,
2225 /* TRANS: %s is a (translatable) extra flag. */
2226 _("Requires an extra with the \"%s\" flag on a tile "
2227 "within the city radius."),
2228 extra_flag_id_translated_name(preq->source.value.extraflag));
2229 } else {
2230 cat_snprintf(buf, bufsz,
2231 /* TRANS: %s is a (translatable) extra flag. */
2232 _("Prevented by an extra with the \"%s\" flag on any tile "
2233 "within the city radius."),
2234 extra_flag_id_translated_name(preq->source.value.extraflag));
2236 return TRUE;
2237 case REQ_RANGE_TRADEROUTE:
2238 if (preq->present) {
2239 cat_snprintf(buf, bufsz,
2240 /* TRANS: %s is a (translatable) extra flag. */
2241 _("Requires an extra with the \"%s\" flag on a tile "
2242 "within the city radius or the city radius of a "
2243 "trade partner."),
2244 extra_flag_id_translated_name(preq->source.value.extraflag));
2245 } else {
2246 cat_snprintf(buf, bufsz,
2247 /* TRANS: %s is a (translatable) extra flag. */
2248 _("Prevented by an extra with the \"%s\" flag on any tile "
2249 "within the city radius or the city radius of a "
2250 "trade partner."),
2251 extra_flag_id_translated_name(preq->source.value.extraflag));
2253 return TRUE;
2254 case REQ_RANGE_CONTINENT:
2255 case REQ_RANGE_PLAYER:
2256 case REQ_RANGE_TEAM:
2257 case REQ_RANGE_ALLIANCE:
2258 case REQ_RANGE_WORLD:
2259 case REQ_RANGE_COUNT:
2260 /* Not supported. */
2261 break;
2263 break;
2265 case VUT_MINYEAR:
2266 if (preq->range != REQ_RANGE_WORLD) {
2267 break;
2269 if (preq->present) {
2270 cat_snprintf(buf, bufsz,
2271 _("Requires the game to have reached the year %s."),
2272 textyear(preq->source.value.minyear));
2273 } else {
2274 cat_snprintf(buf, bufsz,
2275 _("Requires that the game has not yet reached the "
2276 "year %s."),
2277 textyear(preq->source.value.minyear));
2279 return TRUE;
2281 case VUT_MINCALFRAG:
2282 if (preq->range != REQ_RANGE_WORLD) {
2283 break;
2285 if (preq->present) {
2286 cat_snprintf(buf, bufsz,
2287 /* TRANS: %s is a representation of a calendar fragment,
2288 * from the ruleset. May be a bare number. */
2289 _("Requires the game to have reached %s."),
2290 textcalfrag(preq->source.value.mincalfrag));
2291 } else {
2292 cat_snprintf(buf, bufsz,
2293 /* TRANS: %s is a representation of a calendar fragment,
2294 * from the ruleset. May be a bare number. */
2295 _("Requires that the game has not yet reached %s."),
2296 textcalfrag(preq->source.value.mincalfrag));
2298 return TRUE;
2300 case VUT_TOPO:
2301 if (preq->range != REQ_RANGE_WORLD) {
2302 break;
2304 if (preq->present) {
2305 cat_snprintf(buf, bufsz,
2306 _("Requires %s map."),
2307 _(topo_flag_name(preq->source.value.topo_property)));
2308 } else {
2309 cat_snprintf(buf, bufsz,
2310 _("Prevented on %s map."),
2311 _(topo_flag_name(preq->source.value.topo_property)));
2313 return TRUE;
2315 case VUT_AGE:
2316 if (preq->present) {
2317 cat_snprintf(buf, bufsz,
2318 _("Requires age of %d turns."),
2319 preq->source.value.age);
2320 } else {
2321 cat_snprintf(buf, bufsz,
2322 _("Prevented if age is over %d turns."),
2323 preq->source.value.age);
2325 return TRUE;
2327 case VUT_MINTECHS:
2328 switch (preq->range) {
2329 case REQ_RANGE_WORLD:
2330 if (preq->present) {
2331 cat_snprintf(buf, bufsz,
2332 _("Requires %d techs to be known in the world."),
2333 preq->source.value.min_techs);
2334 } else {
2335 cat_snprintf(buf, bufsz,
2336 _("Prevented when %d techs are known in the world."),
2337 preq->source.value.min_techs);
2339 return TRUE;
2340 case REQ_RANGE_PLAYER:
2341 if (preq->present) {
2342 cat_snprintf(buf, bufsz,
2343 _("Requires player to know %d techs."),
2344 preq->source.value.min_techs);
2345 } else {
2346 cat_snprintf(buf, bufsz,
2347 _("Prevented when player knows %d techs."),
2348 preq->source.value.min_techs);
2350 return TRUE;
2351 case REQ_RANGE_LOCAL:
2352 case REQ_RANGE_CADJACENT:
2353 case REQ_RANGE_ADJACENT:
2354 case REQ_RANGE_CITY:
2355 case REQ_RANGE_TRADEROUTE:
2356 case REQ_RANGE_CONTINENT:
2357 case REQ_RANGE_TEAM:
2358 case REQ_RANGE_ALLIANCE:
2359 case REQ_RANGE_COUNT:
2360 /* Not supported. */
2361 break;
2363 break;
2365 case VUT_TERRAINALTER:
2366 switch (preq->range) {
2367 case REQ_RANGE_LOCAL:
2368 if (preq->present) {
2369 cat_snprintf(buf, bufsz,
2370 _("Requires terrain on which alteration %s is "
2371 "possible."),
2372 Q_(terrain_alteration_name(preq->source.value.terrainalter)));
2373 } else {
2374 cat_snprintf(buf, bufsz,
2375 _("Prevented by terrain on which alteration %s "
2376 "can be made."),
2377 Q_(terrain_alteration_name(preq->source.value.terrainalter)));
2379 return TRUE;
2380 case REQ_RANGE_CADJACENT:
2381 case REQ_RANGE_ADJACENT:
2382 case REQ_RANGE_CITY:
2383 case REQ_RANGE_TRADEROUTE:
2384 case REQ_RANGE_CONTINENT:
2385 case REQ_RANGE_PLAYER:
2386 case REQ_RANGE_TEAM:
2387 case REQ_RANGE_ALLIANCE:
2388 case REQ_RANGE_WORLD:
2389 case REQ_RANGE_COUNT:
2390 /* Not supported. */
2391 break;
2393 break;
2395 case VUT_CITYTILE:
2396 if (preq->source.value.citytile == CITYT_LAST) {
2397 break;
2398 } else {
2399 static char *tile_property = NULL;
2401 switch (preq->source.value.citytile) {
2402 case CITYT_CENTER:
2403 tile_property = "city centers";
2404 break;
2405 case CITYT_CLAIMED:
2406 tile_property = "claimed tiles";
2407 break;
2408 case CITYT_LAST:
2409 fc_assert(preq->source.value.citytile != CITYT_LAST);
2410 break;
2413 switch (preq->range) {
2414 case REQ_RANGE_LOCAL:
2415 if (preq->present) {
2416 cat_snprintf(buf, bufsz,
2417 /* TRANS: tile property ("city centers", etc) */
2418 Q_("?tileprop:Applies only to %s."), tile_property);
2419 } else {
2420 cat_snprintf(buf, bufsz,
2421 /* TRANS: tile property ("city centers", etc) */
2422 Q_("?tileprop:Does not apply to %s."), tile_property);
2424 return TRUE;
2425 case REQ_RANGE_CADJACENT:
2426 if (preq->present) {
2427 /* TRANS: tile property ("city centers", etc) */
2428 cat_snprintf(buf, bufsz, Q_("?tileprop:Applies only to %s and "
2429 "cardinally adjacent tiles."),
2430 tile_property);
2431 } else {
2432 /* TRANS: tile property ("city centers", etc) */
2433 cat_snprintf(buf, bufsz, Q_("?tileprop:Does not apply to %s or "
2434 "cardinally adjacent tiles."),
2435 tile_property);
2437 return TRUE;
2438 case REQ_RANGE_ADJACENT:
2439 if (preq->present) {
2440 /* TRANS: tile property ("city centers", etc) */
2441 cat_snprintf(buf, bufsz, Q_("?tileprop:Applies only to %s and "
2442 "adjacent tiles."), tile_property);
2443 } else {
2444 /* TRANS: tile property ("city centers", etc) */
2445 cat_snprintf(buf, bufsz, Q_("?tileprop:Does not apply to %s or "
2446 "adjacent tiles."), tile_property);
2448 return TRUE;
2449 case REQ_RANGE_CITY:
2450 case REQ_RANGE_TRADEROUTE:
2451 case REQ_RANGE_CONTINENT:
2452 case REQ_RANGE_PLAYER:
2453 case REQ_RANGE_TEAM:
2454 case REQ_RANGE_ALLIANCE:
2455 case REQ_RANGE_WORLD:
2456 case REQ_RANGE_COUNT:
2457 /* Not supported. */
2458 break;
2462 case VUT_COUNT:
2463 break;
2466 if (verb == VERB_DEFAULT) {
2467 char text[256];
2469 log_error("%s requirement %s in range %d is not supported in reqtext.c.",
2470 preq->present ? "Present" : "Absent",
2471 universal_name_translation(&preq->source, text, sizeof(text)),
2472 preq->range);
2475 return FALSE;
2478 /****************************************************************
2479 Append text for the requirement. Added line ends to a newline.
2480 *****************************************************************/
2481 bool req_text_insert_nl(char *buf, size_t bufsz, struct player *pplayer,
2482 const struct requirement *preq,
2483 enum rt_verbosity verb)
2485 if (req_text_insert(buf, bufsz, pplayer, preq, verb)) {
2486 fc_strlcat(buf, "\n", bufsz);
2488 return TRUE;
2491 return FALSE;