1 #include "city_overlay_education.h"
2
3 #include "game/state.h"
4
show_building_education(const building * b)5 static int show_building_education(const building *b)
6 {
7 return b->type == BUILDING_SCHOOL || b->type == BUILDING_LIBRARY || b->type == BUILDING_ACADEMY;
8 }
9
show_building_school(const building * b)10 static int show_building_school(const building *b)
11 {
12 return b->type == BUILDING_SCHOOL;
13 }
14
show_building_library(const building * b)15 static int show_building_library(const building *b)
16 {
17 return b->type == BUILDING_LIBRARY;
18 }
19
show_building_academy(const building * b)20 static int show_building_academy(const building *b)
21 {
22 return b->type == BUILDING_ACADEMY;
23 }
24
show_figure_education(const figure * f)25 static int show_figure_education(const figure *f)
26 {
27 return f->type == FIGURE_SCHOOL_CHILD || f->type == FIGURE_LIBRARIAN || f->type == FIGURE_TEACHER;
28 }
29
show_figure_school(const figure * f)30 static int show_figure_school(const figure *f)
31 {
32 return f->type == FIGURE_SCHOOL_CHILD;
33 }
34
show_figure_library(const figure * f)35 static int show_figure_library(const figure *f)
36 {
37 return f->type == FIGURE_LIBRARIAN;
38 }
39
show_figure_academy(const figure * f)40 static int show_figure_academy(const figure *f)
41 {
42 return f->type == FIGURE_TEACHER;
43 }
44
get_column_height_education(const building * b)45 static int get_column_height_education(const building *b)
46 {
47 return b->house_size && b->data.house.education ? b->data.house.education * 3 - 1 : NO_COLUMN;
48 }
49
get_column_height_school(const building * b)50 static int get_column_height_school(const building *b)
51 {
52 return b->house_size && b->data.house.school ? b->data.house.school / 10 : NO_COLUMN;
53 }
54
get_column_height_library(const building * b)55 static int get_column_height_library(const building *b)
56 {
57 return b->house_size && b->data.house.library ? b->data.house.library / 10 : NO_COLUMN;
58 }
59
get_column_height_academy(const building * b)60 static int get_column_height_academy(const building *b)
61 {
62 return b->house_size && b->data.house.academy ? b->data.house.academy / 10 : NO_COLUMN;
63 }
64
get_tooltip_education(tooltip_context * c,const building * b)65 static int get_tooltip_education(tooltip_context *c, const building *b)
66 {
67 switch (b->data.house.education) {
68 case 0: return 100;
69 case 1: return 101;
70 case 2: return 102;
71 case 3: return 103;
72 default: return 0;
73 }
74 }
75
get_tooltip_school(tooltip_context * c,const building * b)76 static int get_tooltip_school(tooltip_context *c, const building *b)
77 {
78 if (b->data.house.school <= 0) {
79 return 19;
80 } else if (b->data.house.school >= 80) {
81 return 20;
82 } else if (b->data.house.school >= 20) {
83 return 21;
84 } else {
85 return 22;
86 }
87 }
88
get_tooltip_library(tooltip_context * c,const building * b)89 static int get_tooltip_library(tooltip_context *c, const building *b)
90 {
91 if (b->data.house.library <= 0) {
92 return 23;
93 } else if (b->data.house.library >= 80) {
94 return 24;
95 } else if (b->data.house.library >= 20) {
96 return 25;
97 } else {
98 return 26;
99 }
100 }
101
get_tooltip_academy(tooltip_context * c,const building * b)102 static int get_tooltip_academy(tooltip_context *c, const building *b)
103 {
104 if (b->data.house.academy <= 0) {
105 return 27;
106 } else if (b->data.house.academy >= 80) {
107 return 28;
108 } else if (b->data.house.academy >= 20) {
109 return 29;
110 } else {
111 return 30;
112 }
113 }
114
city_overlay_for_education(void)115 const city_overlay *city_overlay_for_education(void)
116 {
117 static city_overlay overlay = {
118 OVERLAY_EDUCATION,
119 COLUMN_COLOR_GREEN,
120 show_building_education,
121 show_figure_education,
122 get_column_height_education,
123 0,
124 get_tooltip_education,
125 0,
126 0
127 };
128 return &overlay;
129 }
130
city_overlay_for_school(void)131 const city_overlay *city_overlay_for_school(void)
132 {
133 static city_overlay overlay = {
134 OVERLAY_SCHOOL,
135 COLUMN_COLOR_GREEN_TO_RED,
136 show_building_school,
137 show_figure_school,
138 get_column_height_school,
139 0,
140 get_tooltip_school,
141 0,
142 0
143 };
144 return &overlay;
145 }
146
city_overlay_for_library(void)147 const city_overlay *city_overlay_for_library(void)
148 {
149 static city_overlay overlay = {
150 OVERLAY_LIBRARY,
151 COLUMN_COLOR_GREEN_TO_RED,
152 show_building_library,
153 show_figure_library,
154 get_column_height_library,
155 0,
156 get_tooltip_library,
157 0,
158 0
159 };
160 return &overlay;
161 }
162
city_overlay_for_academy(void)163 const city_overlay *city_overlay_for_academy(void)
164 {
165 static city_overlay overlay = {
166 OVERLAY_ACADEMY,
167 COLUMN_COLOR_GREEN_TO_RED,
168 show_building_academy,
169 show_figure_academy,
170 get_column_height_academy,
171 0,
172 get_tooltip_academy,
173 0,
174 0
175 };
176 return &overlay;
177 }
178