138 struct player_list *achievers)
140 struct player *credited =
nullptr;
146 pplayer->history += ach->
culture;
149 player_list_append(achievers, pplayer);
154 if (ach->
first !=
nullptr) {
159 if (player_list_size(achievers) > 0) {
163 player_list_get(achievers,
fc_rand(player_list_size(achievers)));
165 ach->
first = credited;
191 case ACHIEVEMENT_SPACESHIP:
193 case ACHIEVEMENT_MAP: {
208 max_unknown = (total * (100 - ach->
value)) / 100;
209 required = total - max_unknown;
213 bool this_is_known =
false;
217 this_is_known =
true;
222 this_is_known =
true;
228 if (known >= required) {
233 if (unknown >= max_unknown) {
242 case ACHIEVEMENT_MULTICULTURAL: {
243 bv_player seen_citizens;
254 if (!
BV_ISSET(seen_citizens, idx)) {
255 BV_SET(seen_citizens, idx);
257 if (count >= ach->
value) {
269 case ACHIEVEMENT_CULTURED_CITY:
279 case ACHIEVEMENT_CULTURED_NATION:
285 case ACHIEVEMENT_LUCKY:
287 case ACHIEVEMENT_HUTS:
289 case ACHIEVEMENT_METROPOLIS:
299 case ACHIEVEMENT_LITERATE:
301 case ACHIEVEMENT_LAND_AHOY: {
307 bool this_is_known =
false;
311 this_is_known =
true;
316 this_is_known =
true;
323 if (ptile->continent > 0 && !seen[ptile->continent - 1]) {
324 if (++count >= ach->
value) {
327 seen[ptile->continent - 1] =
true;
335 case ACHIEVEMENT_COUNT:
339 qCritical(
"achievement_check(): Illegal achievement type %d", ach->
type);
368 const struct player *pplayer)
370 if (pplayer ==
nullptr) {
382 return pach->
first !=
nullptr;
395 }
else if (pop >= 10000) {
bool achievement_check(struct achievement *ach, struct player *pplayer)
Check if player has now achieved the achievement.
void achievements_init()
Initialize achievements.
bool achievement_player_has(const struct achievement *pach, const struct player *pplayer)
Has the given player got the achievement?
const char * achievement_first_msg(struct achievement *pach)
Return message to send to first player gaining the achievement.
static struct achievement achievements[MAX_ACHIEVEMENT_TYPES]
const char * achievement_later_msg(struct achievement *pach)
Return message to send to other players gaining the achievement.
int achievement_index(const struct achievement *pach)
Return the achievement index.
struct player * achievement_plr(struct achievement *ach, struct player_list *achievers)
Check if some player has now achieved the achievement and return the player in question.
int get_literacy(const struct player *pplayer)
Literacy score calculated one way.
int achievement_number(const struct achievement *pach)
Return the achievement id.
const char * achievement_rule_name(struct achievement *pach)
Return untranslated name of this achievement type.
void achievements_free()
Free the memory associated with achievements.
struct achievement * achievement_by_number(int id)
Return achievements of given id.
struct achievement * achievement_by_rule_name(const char *name)
Returns achievement matching rule name or nullptr if there is no achievement with such name.
bool achievement_claimed(const struct achievement *pach)
Has anybody got the achievement?
const char * achievement_name_translation(struct achievement *pach)
Return translated name of this achievement type.
#define achievements_iterate_end
#define achievements_iterate(_ach_)
bool BV_ISSET(const BV &bv, int bit)
#define citizens_iterate_end
#define citizens_iterate(_pcity, _pslot, _nationality)
citizens city_size_get(const struct city *pcity)
Get the city size.
#define city_list_iterate(citylist, pcity)
#define city_list_iterate_end
int city_culture(const struct city *pcity)
Return current culture score of the city.
int player_culture(const struct player *plr)
Return current culture score of the player.
#define MAX_ACHIEVEMENT_TYPES
bool is_server()
Is program type server?
int civ_population(const struct player *pplayer)
Count the # of thousand citizen in a civilisation.
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
int map_num_tiles()
Returns the total number of (real) positions (or tiles) on the map.
#define whole_map_iterate(_map, _tile)
#define whole_map_iterate_end
static const char * rule_name_get(const struct name_translation *ptrans)
static const char * name_translation_get(const struct name_translation *ptrans)
int player_index(const struct player *pplayer)
Return the player index.
struct player * player_slot_get_player(const struct player_slot *pslot)
Returns the team corresponding to the slot.
#define players_iterate_end
#define players_iterate(_pplayer)
enum achievement_type type
struct name_translation name
struct packet_ruleset_control control
enum spaceship_state state
struct city_list * cities
struct player::@65::@67 server
struct player_spaceship spaceship
struct player_score score
int fc_strcasecmp(const char *str0, const char *str1)
Compare strings like strcmp(), but ignoring case.