Author: cazfi
Date: Wed Jan 13 22:51:37 2016
New Revision: 31462

URL: http://svn.gna.org/viewcvs/freeciv?rev=31462&view=rev
Log:
Added functions is_happy(), is_unhappy(), is_celebrating(), is_gov_center(), 
and is_capital()
to lua API.

Original implementations by J. M. Gorbach <gorb>

See patch #6804

Modified:
    branches/S2_6/common/scriptcore/api_game_methods.c
    branches/S2_6/common/scriptcore/api_game_methods.h
    branches/S2_6/common/scriptcore/tolua_game.pkg

Modified: branches/S2_6/common/scriptcore/api_game_methods.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/scriptcore/api_game_methods.c?rev=31462&r1=31461&r2=31462&view=diff
==============================================================================
--- branches/S2_6/common/scriptcore/api_game_methods.c  (original)
+++ branches/S2_6/common/scriptcore/api_game_methods.c  Wed Jan 13 22:51:37 2016
@@ -222,7 +222,62 @@
 }
 
 /*****************************************************************************
-  Return rule name for Government
+  Return TRUE iff city happy
+*****************************************************************************/
+bool api_methods_is_city_happy(lua_State *L, City *pcity)
+{
+  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_SELF(L, pcity, FALSE);
+
+  return city_happy(pcity);
+}
+
+/*****************************************************************************
+  Return TRUE iff city is unhappy
+*****************************************************************************/
+bool api_methods_is_city_unhappy(lua_State *L, City *pcity)
+{
+  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_SELF(L, pcity, FALSE);
+
+  return city_unhappy(pcity);
+}
+
+/*****************************************************************************
+  Return TRUE iff city is celebrating
+*****************************************************************************/
+bool api_methods_is_city_celebrating(lua_State *L, City *pcity)
+{
+  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_SELF(L, pcity, FALSE);
+
+  return city_celebrating(pcity);
+}
+
+/*****************************************************************************
+  Return TRUE iff city is government center
+*****************************************************************************/
+bool api_methods_is_gov_center(lua_State *L, City *pcity)
+{
+  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_SELF(L, pcity, FALSE);
+
+  return is_gov_center(pcity);
+}
+
+/*****************************************************************************
+  Return TRUE if city is capital
+*****************************************************************************/
+bool api_methods_is_capital(lua_State *L, City *pcity)
+{
+  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_SELF(L, pcity, FALSE);
+
+  return is_capital(pcity);
+}
+
+/*****************************************************************************
+   Return rule name for Government
 *****************************************************************************/
 const char *api_methods_government_rule_name(lua_State *L,
                                              Government *pgovernment)
@@ -281,7 +336,6 @@
 
   return nation_plural_translation(pnation);
 }
-
 
 /*****************************************************************************
   Return TRUE iff player has wonder

Modified: branches/S2_6/common/scriptcore/api_game_methods.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/scriptcore/api_game_methods.h?rev=31462&r1=31461&r2=31462&view=diff
==============================================================================
--- branches/S2_6/common/scriptcore/api_game_methods.h  (original)
+++ branches/S2_6/common/scriptcore/api_game_methods.h  Wed Jan 13 22:51:37 2016
@@ -37,9 +37,8 @@
                                               Building_Type *pbuilding);
 const char *api_methods_building_type_rule_name(lua_State *L,
                                                 Building_Type *pbuilding);
-const char
-  *api_methods_building_type_name_translation(lua_State *L,
-                                              Building_Type *pbuilding);
+const char *api_methods_building_type_name_translation(lua_State *L,
+                                                       Building_Type 
*pbuilding);
 
 /* City */
 bool api_methods_city_has_building(lua_State *L, City *pcity,
@@ -50,6 +49,12 @@
 int api_methods_city_inspire_partisans(lua_State *L, City *self, Player 
*inspirer);
 
 int api_methods_city_culture_get(lua_State *L, City *pcity);
+
+bool api_methods_is_city_happy(lua_State *L, City *pcity);
+bool api_methods_is_city_unhappy(lua_State *L, City *pcity);
+bool api_methods_is_city_celebrating(lua_State *L, City *pcity);
+bool api_methods_is_gov_center(lua_State *L, City *pcity);
+bool api_methods_is_capital(lua_State *L, City *pcity);
 
 /* Government */
 const char *api_methods_government_rule_name(lua_State *L,
@@ -62,9 +67,8 @@
                                               Nation_Type *pnation);
 const char *api_methods_nation_type_name_translation(lua_State *L,
                                                      Nation_Type *pnation);
-const char
-  *api_methods_nation_type_plural_translation(lua_State *L,
-                                              Nation_Type *pnation);
+const char *api_methods_nation_type_plural_translation(lua_State *L,
+                                                       Nation_Type *pnation);
 
 /* Player */
 bool api_methods_player_has_wonder(lua_State *L, Player *pplayer,

Modified: branches/S2_6/common/scriptcore/tolua_game.pkg
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/scriptcore/tolua_game.pkg?rev=31462&r1=31461&r2=31462&view=diff
==============================================================================
--- branches/S2_6/common/scriptcore/tolua_game.pkg      (original)
+++ branches/S2_6/common/scriptcore/tolua_game.pkg      Wed Jan 13 22:51:37 2016
@@ -185,6 +185,17 @@
 
   int api_methods_city_culture_get
     @ culture(lua_State *L, City *self);
+
+  bool api_methods_is_city_happy
+    @ is_happy(lua_State *L, City *self);
+  bool api_methods_is_city_unhappy
+    @ is_unhappy(lua_State *L, City *self);
+  bool api_methods_is_city_celebrating
+    @ is_celebrating(lua_State *L, City *self);
+  bool api_methods_is_gov_center
+    @ is_gov_center(lua_State *L, City *self);
+  bool api_methods_is_capital
+    @ is_capital(lua_State *L, City *self);
 }
 
 $[


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to