1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
/**********************************************************************
Freeciv - Copyright (C) 2005 - The Freeciv Project
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
***********************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "unitlist.h"
#include "api_methods.h"
#include "script.h"
/**************************************************************************
Return the number of cities pplayer has.
**************************************************************************/
int api_methods_player_num_cities(Player *pplayer)
{
return city_list_size(pplayer->cities);
}
/**************************************************************************
Return the number of units pplayer has.
**************************************************************************/
int api_methods_player_num_units(Player *pplayer)
{
return unit_list_size(pplayer->units);
}
/**************************************************************************
Return TRUE if punit_type has flag.
**************************************************************************/
bool api_methods_unit_type_has_flag(Unit_Type *punit_type, const char *flag)
{
enum unit_flag_id id = find_unit_flag_by_rule_name(flag);
if (id != F_LAST) {
return utype_has_flag(punit_type, id);
} else {
script_error("Unit flag \"%s\" does not exist", flag);
return FALSE;
}
}
/**************************************************************************
Return TRUE if punit_type has role.
**************************************************************************/
bool api_methods_unit_type_has_role(Unit_Type *punit_type, const char *role)
{
enum unit_role_id id = find_unit_role_by_rule_name(role);
if (id != L_LAST) {
return utype_has_role(punit_type, id);
} else {
script_error("Unit role \"%s\" does not exist", role);
return FALSE;
}
}
/**************************************************************************
Return TRUE if pbuilding is a wonder.
**************************************************************************/
bool api_methods_building_type_is_wonder(Building_Type *pbuilding)
{
return is_wonder(pbuilding->index);
}
/**************************************************************************
Return TRUE if pbuilding is a great wonder.
**************************************************************************/
bool api_methods_building_type_is_great_wonder(Building_Type *pbuilding)
{
return is_great_wonder(pbuilding->index);
}
/**************************************************************************
Return TRUE if pbuilding is a small wonder.
**************************************************************************/
bool api_methods_building_type_is_small_wonder(Building_Type *pbuilding)
{
return is_small_wonder(pbuilding->index);
}
/**************************************************************************
Return TRUE if pbuilding is a building.
**************************************************************************/
bool api_methods_building_type_is_improvement(Building_Type *pbuilding)
{
return is_improvement(pbuilding->index);
}
|