<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39450 >
Patch attached, applies to trunk r13103
Now we have:
:rule_name()
:name_translation()
and for Nation_Type there is also:
:plural_translation()
Index: server/scripting/api_methods.h
===================================================================
--- server/scripting/api_methods.h (revision 13103)
+++ server/scripting/api_methods.h (arbetskopia)
@@ -27,5 +27,21 @@
bool api_methods_building_type_is_small_wonder(Building_Type *pbuilding);
bool api_methods_building_type_is_improvement(Building_Type *pbuilding);
+/* rule name and translated name methods */
+const char *api_methods_government_rule_name(Government *pgovernment);
+const char *api_methods_government_name_translation(Government *pgovernment);
+const char *api_methods_nation_type_rule_name(Nation_Type *pnation);
+const char *api_methods_nation_type_name_translation(Nation_Type *pnation);
+const char *api_methods_nation_type_plural_translation(Nation_Type
+ *pnation);
+const char *api_methods_building_type_rule_name(Building_Type *pbuilding);
+const char *api_methods_building_type_name_translation(Building_Type
+ *pbuilding);
+const char *api_methods_unit_type_rule_name(Unit_Type *punit_type);
+const char *api_methods_unit_type_name_translation(Unit_Type *punit_type);
+const char *api_methods_tech_type_rule_name(Tech_Type *ptech);
+const char *api_methods_tech_type_name_translation(Tech_Type *ptech);
+const char *api_methods_terrain_rule_name(Terrain *pterrain);
+const char *api_methods_terrain_name_translation(Terrain *pterrain);
#endif
Index: server/scripting/api.pkg
===================================================================
--- server/scripting/api.pkg (revision 13103)
+++ server/scripting/api.pkg (arbetskopia)
@@ -94,16 +94,28 @@
/* Class methods. */
+
+/* Player */
int api_methods_player_num_cities
@ methods_player_num_cities (Player *pplayer);
int api_methods_player_num_units
@ methods_player_num_units (Player *pplayer);
-bool api_methods_unit_type_has_flag
- @ methods_unit_type_has_flag (Unit_Type *punit_type, const char *flag);
-bool api_methods_unit_type_has_role
- @ methods_unit_type_has_role (Unit_Type *punit_type, const char *role);
+/* Government */
+const char *api_methods_government_rule_name
+ @ methods_government_rule_name (Government *pgovernment);
+const char *api_methods_government_name_translation
+ @ methods_government_name_translation (Government *pgovernment);
+/* Nation_Type */
+const char *api_methods_nation_type_rule_name
+ @ methods_nation_type_rule_name (Nation_Type *pnation);
+const char *api_methods_nation_type_name_translation
+ @ methods_nation_type_name_translation (Nation_Type *pnation);
+const char *api_methods_nation_type_plural_translation
+ @ methods_nation_type_plural_translation (Nation_Type *pnation);
+
+/* Building_Type */
bool api_methods_building_type_is_wonder
@ methods_building_type_is_wonder (Building_Type *pbuilding);
bool api_methods_building_type_is_great_wonder
@@ -112,8 +124,33 @@
@ methods_building_type_is_small_wonder (Building_Type *pbuilding);
bool api_methods_building_type_is_improvement
@ methods_building_type_is_improvement (Building_Type *pbuilding);
+const char *api_methods_building_type_rule_name
+ @ methods_building_type_rule_name (Building_Type *pbuilding);
+const char *api_methods_building_type_name_translation
+ @ methods_building_type_name_translation (Building_Type *pbuilding);
+/* Unit_Type */
+bool api_methods_unit_type_has_flag
+ @ methods_unit_type_has_flag (Unit_Type *punit_type, const char *flag);
+bool api_methods_unit_type_has_role
+ @ methods_unit_type_has_role (Unit_Type *punit_type, const char *role);
+const char *api_methods_unit_type_rule_name
+ @ methods_unit_type_rule_name (Unit_Type *punit_type);
+const char *api_methods_unit_type_name_translation
+ @ methods_unit_type_name_translation (Unit_Type *punit_type);
+/* Tech_Type */
+const char *api_methods_tech_type_rule_name
+ @ methods_tech_type_rule_name (Tech_Type *ptech);
+const char *api_methods_tech_type_name_translation
+ @ methods_tech_type_name_translation (Tech_Type *ptech);
+
+/* Terrain */
+const char *api_methods_terrain_rule_name
+ @ methods_terrain_rule_name (Terrain *pterrain);
+const char *api_methods_terrain_name_translation
+ @ methods_terrain_name_translation (Terrain *pterrain);
+
$[
-- Player methods.
function Player:is_human()
@@ -133,6 +170,28 @@
return find.city(self.owner, self.homecity_id)
end
+-- Government methods
+function Government:rule_name()
+ return methods_government_rule_name(self)
+end
+
+function Government:name_translation()
+ return methods_government_name_translation(self)
+end
+
+-- Nation_Type methods
+function Nation_Type:rule_name()
+ return methods_nation_type_rule_name(self)
+end
+
+function Nation_Type:name_translation()
+ return methods_nation_type_name_translation(self)
+end
+
+function Nation_Type:plural_translation()
+ return methods_nation_type_plural_translation(self)
+end
+
-- Building_Type methods.
function Building_Type:build_shield_cost()
return self.build_cost
@@ -154,6 +213,14 @@
return methods_building_type_is_improvement(self)
end
+function Building_Type:rule_name()
+ return methods_building_type_rule_name(self)
+end
+
+function Building_Type:name_translation()
+ return methods_building_type_name_translation(self)
+end
+
-- Unit_Type methods.
function Unit_Type:build_shield_cost()
return self.build_cost
@@ -166,6 +233,32 @@
function Unit_Type:has_role(role)
return methods_unit_type_has_role(self, role)
end
+
+function Unit_Type:rule_name()
+ return methods_unit_type_rule_name(self)
+end
+
+function Unit_Type:name_translation()
+ return methods_unit_type_name_translation(self)
+end
+
+-- Tech_Type methods
+function Tech_Type:rule_name()
+ return methods_tech_type_rule_name(self)
+end
+
+function Tech_Type:name_translation()
+ return methods_tech_type_name_translation(self)
+end
+
+-- Terrain methods
+function Terrain:rule_name()
+ return methods_terrain_rule_name(self)
+end
+
+function Terrain:name_translation()
+ return methods_terrain_name_translation(self)
+end
$]
/* Object find module. */
Index: server/scripting/api_methods.c
===================================================================
--- server/scripting/api_methods.c (revision 13103)
+++ server/scripting/api_methods.c (arbetskopia)
@@ -15,7 +15,13 @@
#include <config.h>
#endif
+#include "government.h"
+#include "improvement.h"
+#include "nation.h"
+#include "tech.h"
+#include "terrain.h"
#include "unitlist.h"
+#include "unittype.h"
#include "api_methods.h"
#include "script.h"
@@ -98,4 +104,107 @@
return is_improvement(pbuilding->index);
}
+/**************************************************************************
+ Return rule name for Government
+**************************************************************************/
+const char *api_methods_government_rule_name(Government *pgovernment)
+{
+ return government_rule_name(pgovernment);
+}
+/**************************************************************************
+ Return translated name for Government
+**************************************************************************/
+const char *api_methods_government_name_translation(Government *pgovernment)
+{
+ return government_name_translation(pgovernment);
+}
+
+/**************************************************************************
+ Return rule name for Nation_Type
+**************************************************************************/
+const char *api_methods_nation_type_rule_name(Nation_Type *pnation)
+{
+ return nation_rule_name(pnation);
+}
+
+/**************************************************************************
+ Return translated name for Nation_Type
+**************************************************************************/
+const char *api_methods_nation_type_name_translation(Nation_Type *pnation)
+{
+ return nation_name_translation(pnation);
+}
+
+/**************************************************************************
+ Return translated plural name for Nation_Type
+**************************************************************************/
+const char *api_methods_nation_type_plural_translation(Nation_Type *pnation)
+{
+ return nation_plural_translation(pnation);
+}
+
+/**************************************************************************
+ Return rule name for Building_Type
+**************************************************************************/
+const char *api_methods_building_type_rule_name(Building_Type *pbuilding)
+{
+ return improvement_rule_name(pbuilding->index);
+}
+
+/**************************************************************************
+ Return translated name for Building_Type
+**************************************************************************/
+const char *api_methods_building_type_name_translation(Building_Type
+ *pbuilding)
+{
+ return improvement_name_translation(pbuilding->index);
+}
+
+/**************************************************************************
+ Return rule name for Unit_Type
+**************************************************************************/
+const char *api_methods_unit_type_rule_name(Unit_Type *punit_type)
+{
+ return utype_rule_name(punit_type);
+}
+
+/**************************************************************************
+ Return translated name for Unit_Type
+**************************************************************************/
+const char *api_methods_unit_type_name_translation(Unit_Type *punit_type)
+{
+ return utype_name_translation(punit_type);
+}
+
+/**************************************************************************
+ Return rule name for Tech_Type
+**************************************************************************/
+const char *api_methods_tech_type_rule_name(Tech_Type *ptech)
+{
+ return advance_rule_name(ptech->index);
+}
+
+/**************************************************************************
+ Return translated name for Tech_Type
+**************************************************************************/
+const char *api_methods_tech_type_name_translation(Tech_Type *ptech)
+{
+ return advance_name_translation(ptech->index);
+}
+
+/**************************************************************************
+ Return rule name for Terrain
+**************************************************************************/
+const char *api_methods_terrain_rule_name(Terrain *pterrain)
+{
+ return terrain_rule_name(pterrain);
+}
+
+/**************************************************************************
+ Return translated name for Terrain
+**************************************************************************/
+const char *api_methods_terrain_name_translation(Terrain *pterrain)
+{
+ return terrain_name_translation(pterrain);
+}
_______________________________________________
Freeciv-dev mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-dev