1 #include "city_overlay_entertainment.h"
2 
3 #include "game/state.h"
4 #include "translation/translation.h"
5 
show_building_entertainment(const building * b)6 static int show_building_entertainment(const building *b)
7 {
8     return
9         b->type == BUILDING_ACTOR_COLONY || b->type == BUILDING_THEATER ||
10         b->type == BUILDING_GLADIATOR_SCHOOL || b->type == BUILDING_AMPHITHEATER ||
11         b->type == BUILDING_LION_HOUSE || b->type == BUILDING_COLOSSEUM ||
12         b->type == BUILDING_CHARIOT_MAKER || b->type == BUILDING_HIPPODROME ||
13         b->type == BUILDING_TAVERN || b->type == BUILDING_ARENA;
14 }
15 
show_building_theater(const building * b)16 static int show_building_theater(const building *b)
17 {
18     return b->type == BUILDING_ACTOR_COLONY || b->type == BUILDING_THEATER;
19 }
20 
show_building_amphitheater(const building * b)21 static int show_building_amphitheater(const building *b)
22 {
23     return b->type == BUILDING_ACTOR_COLONY
24         || b->type == BUILDING_GLADIATOR_SCHOOL
25         || b->type == BUILDING_AMPHITHEATER;
26 }
27 
show_building_arena(const building * b)28 static int show_building_arena(const building *b)
29 {
30     return b->type == BUILDING_GLADIATOR_SCHOOL || b->type == BUILDING_LION_HOUSE || b->type == BUILDING_ARENA;
31 }
32 
show_building_colosseum(const building * b)33 static int show_building_colosseum(const building *b)
34 {
35     return b->type == BUILDING_GLADIATOR_SCHOOL || b->type == BUILDING_LION_HOUSE || b->type == BUILDING_COLOSSEUM;
36 }
37 
show_building_hippodrome(const building * b)38 static int show_building_hippodrome(const building *b)
39 {
40     return b->type == BUILDING_CHARIOT_MAKER || b->type == BUILDING_HIPPODROME;
41 }
42 
show_building_tavern(const building * b)43 static int show_building_tavern(const building *b)
44 {
45     return b->type == BUILDING_TAVERN;
46 }
47 
get_entertainment_building(const figure * f)48 static building *get_entertainment_building(const figure *f)
49 {
50     if (f->action_state == FIGURE_ACTION_94_ENTERTAINER_ROAMING ||
51         f->action_state == FIGURE_ACTION_95_ENTERTAINER_RETURNING) {
52         return building_get(f->building_id);
53     } else {
54         return building_get(f->destination_building_id);
55     }
56 }
57 
show_figure_entertainment(const figure * f)58 static int show_figure_entertainment(const figure *f)
59 {
60     return f->type == FIGURE_ACTOR || f->type == FIGURE_GLADIATOR ||
61         f->type == FIGURE_LION_TAMER || f->type == FIGURE_CHARIOTEER || f->type == FIGURE_BARKEEP_SUPPLIER || f->type == FIGURE_BARKEEP;
62 }
63 
show_figure_theater(const figure * f)64 static int show_figure_theater(const figure *f)
65 {
66     if (f->type == FIGURE_ACTOR) {
67         return get_entertainment_building(f)->type == BUILDING_THEATER;
68     }
69     return 0;
70 }
71 
show_figure_amphitheater(const figure * f)72 static int show_figure_amphitheater(const figure *f)
73 {
74     if (f->type == FIGURE_ACTOR || f->type == FIGURE_GLADIATOR) {
75         return get_entertainment_building(f)->type == BUILDING_AMPHITHEATER;
76     }
77     return 0;
78 }
79 
show_figure_arena(const figure * f)80 static int show_figure_arena(const figure *f)
81 {
82     if (f->type == FIGURE_GLADIATOR) {
83         return get_entertainment_building(f)->type == BUILDING_ARENA;
84     } else if (f->type == FIGURE_LION_TAMER) {
85         return 1;
86     }
87     return 0;
88 }
89 
show_figure_colosseum(const figure * f)90 static int show_figure_colosseum(const figure *f)
91 {
92     if (f->type == FIGURE_GLADIATOR) {
93         return get_entertainment_building(f)->type == BUILDING_COLOSSEUM;
94     } else if (f->type == FIGURE_LION_TAMER) {
95         return 1;
96     }
97     return 0;
98 }
99 
show_figure_hippodrome(const figure * f)100 static int show_figure_hippodrome(const figure *f)
101 {
102     return f->type == FIGURE_CHARIOTEER;
103 }
104 
show_figure_tavern(const figure * f)105 static int show_figure_tavern(const figure *f)
106 {
107     return f->type == FIGURE_BARKEEP || f->type == FIGURE_BARKEEP_SUPPLIER;
108 }
109 
get_column_height_entertainment(const building * b)110 static int get_column_height_entertainment(const building *b)
111 {
112     return b->house_size && b->data.house.entertainment ? b->data.house.entertainment / 10 : NO_COLUMN;
113 }
114 
get_column_height_theater(const building * b)115 static int get_column_height_theater(const building *b)
116 {
117     return b->house_size && b->data.house.theater ? b->data.house.theater / 10 : NO_COLUMN;
118 }
119 
get_column_height_amphitheater(const building * b)120 static int get_column_height_amphitheater(const building *b)
121 {
122     return b->house_size && b->data.house.amphitheater_actor ? b->data.house.amphitheater_actor / 10 : NO_COLUMN;
123 }
124 
get_column_height_arena(const building * b)125 static int get_column_height_arena(const building *b)
126 {
127     return b->house_size && b->house_arena_gladiator ? b->house_arena_gladiator / 10 : NO_COLUMN;
128 }
129 
get_column_height_colosseum(const building * b)130 static int get_column_height_colosseum(const building *b)
131 {
132     return b->house_size && b->data.house.colosseum_gladiator ? b->data.house.colosseum_gladiator / 10 : NO_COLUMN;
133 }
134 
get_column_height_hippodrome(const building * b)135 static int get_column_height_hippodrome(const building *b)
136 {
137     return b->house_size && b->data.house.hippodrome ? b->data.house.hippodrome / 10 : NO_COLUMN;
138 }
139 
get_column_height_tavern(const building * b)140 static int get_column_height_tavern(const building *b)
141 {
142     if (!b->house_size || !b->house_tavern_wine_access) {
143         return NO_COLUMN;
144     }
145     return (((b->house_tavern_wine_access / 10) * 2) + (b->house_tavern_meat_access / 10)) / 3;
146 }
147 
get_tooltip_entertainment(tooltip_context * c,const building * b)148 static int get_tooltip_entertainment(tooltip_context *c, const building *b)
149 {
150     if (b->data.house.entertainment <= 0) {
151         return 64;
152     } else if (b->data.house.entertainment < 10) {
153         return 65;
154     } else if (b->data.house.entertainment < 20) {
155         return 66;
156     } else if (b->data.house.entertainment < 30) {
157         return 67;
158     } else if (b->data.house.entertainment < 40) {
159         return 68;
160     } else if (b->data.house.entertainment < 50) {
161         return 69;
162     } else if (b->data.house.entertainment < 60) {
163         return 70;
164     } else if (b->data.house.entertainment < 70) {
165         return 71;
166     } else if (b->data.house.entertainment < 80) {
167         return 72;
168     } else if (b->data.house.entertainment < 90) {
169         return 73;
170     } else {
171         return 74;
172     }
173 }
174 
get_tooltip_theater(tooltip_context * c,const building * b)175 static int get_tooltip_theater(tooltip_context *c, const building *b)
176 {
177     if (b->data.house.theater <= 0) {
178         return 75;
179     } else if (b->data.house.theater >= 80) {
180         return 76;
181     } else if (b->data.house.theater >= 20) {
182         return 77;
183     } else {
184         return 78;
185     }
186 }
187 
get_tooltip_amphitheater(tooltip_context * c,const building * b)188 static int get_tooltip_amphitheater(tooltip_context *c, const building *b)
189 {
190     if (b->data.house.amphitheater_actor <= 0) {
191         return 79;
192     } else if (b->data.house.amphitheater_actor >= 80) {
193         return 80;
194     } else if (b->data.house.amphitheater_actor >= 20) {
195         return 81;
196     } else {
197         return 82;
198     }
199 }
200 
get_tooltip_colosseum(tooltip_context * c,const building * b)201 static int get_tooltip_colosseum(tooltip_context *c, const building *b)
202 {
203     if (b->data.house.colosseum_gladiator && b->data.house.colosseum_lion) {
204         c->translation_key = TR_TOOLTIP_OVERLAY_ARENA_COL_5;
205     } else if (b->data.house.colosseum_gladiator) {
206         c->translation_key = TR_TOOLTIP_OVERLAY_ARENA_COL_4;
207     } else if (b->house_arena_gladiator && b->house_arena_lion) {
208         c->translation_key = TR_TOOLTIP_OVERLAY_ARENA_COL_3;
209     } else if (b->house_arena_gladiator) {
210         c->translation_key = TR_TOOLTIP_OVERLAY_ARENA_COL_2;
211     } else {
212         c->translation_key = TR_TOOLTIP_OVERLAY_ARENA_COL_1;
213     }
214     return 0;
215 }
216 
get_tooltip_hippodrome(tooltip_context * c,const building * b)217 static int get_tooltip_hippodrome(tooltip_context *c, const building *b)
218 {
219     if (b->data.house.hippodrome <= 0) {
220         return 87;
221     } else if (b->data.house.hippodrome >= 80) {
222         return 88;
223     } else if (b->data.house.hippodrome >= 20) {
224         return 89;
225     } else {
226         return 90;
227     }
228 }
229 
get_tooltip_tavern(tooltip_context * c,const building * b)230 static int get_tooltip_tavern(tooltip_context *c, const building *b)
231 {
232     if (b->house_tavern_wine_access <= 0) {
233         c->translation_key = TR_TOOLTIP_OVERLAY_TAVERN_1;
234     } else if (b->house_tavern_wine_access <= 20) {
235         c->translation_key = TR_TOOLTIP_OVERLAY_TAVERN_2;
236     } else if (b->data.house.hippodrome <= 80) {
237         if (!b->house_tavern_meat_access) {
238             c->translation_key = TR_TOOLTIP_OVERLAY_TAVERN_3;
239         } else {
240             c->translation_key = TR_TOOLTIP_OVERLAY_TAVERN_4;
241         }
242     } else {
243         if (!b->house_tavern_meat_access) {
244             c->translation_key = TR_TOOLTIP_OVERLAY_TAVERN_5;
245         } else {
246             c->translation_key = TR_TOOLTIP_OVERLAY_TAVERN_6;
247         }
248     }
249 
250     return 0;
251 }
252 
city_overlay_for_entertainment(void)253 const city_overlay *city_overlay_for_entertainment(void)
254 {
255     static city_overlay overlay = {
256         OVERLAY_ENTERTAINMENT,
257         COLUMN_COLOR_GREEN,
258         show_building_entertainment,
259         show_figure_entertainment,
260         get_column_height_entertainment,
261         0,
262         get_tooltip_entertainment,
263         0,
264         0
265     };
266     return &overlay;
267 }
268 
city_overlay_for_theater(void)269 const city_overlay *city_overlay_for_theater(void)
270 {
271     static city_overlay overlay = {
272         OVERLAY_THEATER,
273         COLUMN_COLOR_GREEN_TO_RED,
274         show_building_theater,
275         show_figure_theater,
276         get_column_height_theater,
277         0,
278         get_tooltip_theater,
279         0,
280         0
281     };
282     return &overlay;
283 }
284 
city_overlay_for_amphitheater(void)285 const city_overlay *city_overlay_for_amphitheater(void)
286 {
287     static city_overlay overlay = {
288         OVERLAY_AMPHITHEATER,
289         COLUMN_COLOR_GREEN_TO_RED,
290         show_building_amphitheater,
291         show_figure_amphitheater,
292         get_column_height_amphitheater,
293         0,
294         get_tooltip_amphitheater,
295         0,
296         0
297     };
298     return &overlay;
299 }
300 
city_overlay_for_arena(void)301 const city_overlay *city_overlay_for_arena(void)
302 {
303     static city_overlay overlay = {
304         OVERLAY_ARENA,
305         COLUMN_COLOR_GREEN_TO_RED,
306         show_building_arena,
307         show_figure_arena,
308         get_column_height_arena,
309         0,
310         get_tooltip_colosseum,
311         0,
312         0
313     };
314     return &overlay;
315 }
316 
city_overlay_for_colosseum(void)317 const city_overlay *city_overlay_for_colosseum(void)
318 {
319     static city_overlay overlay = {
320         OVERLAY_COLOSSEUM,
321         COLUMN_COLOR_GREEN_TO_RED,
322         show_building_colosseum,
323         show_figure_colosseum,
324         get_column_height_colosseum,
325         0,
326         get_tooltip_colosseum,
327         0,
328         0
329     };
330     return &overlay;
331 }
332 
city_overlay_for_hippodrome(void)333 const city_overlay *city_overlay_for_hippodrome(void)
334 {
335     static city_overlay overlay = {
336         OVERLAY_HIPPODROME,
337         COLUMN_COLOR_GREEN_TO_RED,
338         show_building_hippodrome,
339         show_figure_hippodrome,
340         get_column_height_hippodrome,
341         0,
342         get_tooltip_hippodrome,
343         0,
344         0
345     };
346     return &overlay;
347 }
348 
city_overlay_for_tavern(void)349 const city_overlay *city_overlay_for_tavern(void)
350 {
351     static city_overlay overlay = {
352         OVERLAY_TAVERN,
353         COLUMN_COLOR_GREEN_TO_RED,
354         show_building_tavern,
355         show_figure_tavern,
356         get_column_height_tavern,
357         0,
358         get_tooltip_tavern,
359         0,
360         0
361     };
362     return &overlay;
363 }