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