From: <tz...@us...> - 2009-03-22 20:01:05
|
Revision: 2929 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2929&view=rev Author: tzlaine Date: 2009-03-22 20:01:03 +0000 (Sun, 22 Mar 2009) Log Message: ----------- Fix for PythonUniverseWrapper accidentally left out of my previous ship hulls and parts commit. Modified Paths: -------------- trunk/FreeOrion/python/PythonUniverseWrapper.cpp Modified: trunk/FreeOrion/python/PythonUniverseWrapper.cpp =================================================================== --- trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2009-03-22 19:18:24 UTC (rev 2928) +++ trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2009-03-22 20:01:03 UTC (rev 2929) @@ -196,7 +196,6 @@ .add_property("designedByEmpireID", make_function(&ShipDesign::DesignedByEmpire, return_value_policy<return_by_value>())) .add_property("designedOnTurn", make_function(&ShipDesign::DesignedOnTurn, return_value_policy<return_by_value>())) .add_property("starlaneSpeed", make_function(&ShipDesign::StarlaneSpeed, return_value_policy<return_by_value>())) - .add_property("battleSpeed", make_function(&ShipDesign::Speed, return_value_policy<return_by_value>())) .add_property("defense", make_function(&ShipDesign::Defense, return_value_policy<return_by_value>())) .add_property("speed", make_function(&ShipDesign::Speed, return_value_policy<return_by_value>())) .add_property("attack", make_function(&ShipDesign::Attack, return_value_policy<return_by_value>())) |
From: <geo...@us...> - 2010-08-28 16:25:53
|
Revision: 3770 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=3770&view=rev Author: geoffthemedio Date: 2010-08-28 16:25:46 +0000 (Sat, 28 Aug 2010) Log Message: ----------- Changed Python API for Universe::ShortestPath and Universe::LeastJumpsPath to take references to Universe instead of pointers, in the hope of making the functions usable in Python. Modified Paths: -------------- trunk/FreeOrion/python/PythonUniverseWrapper.cpp Modified: trunk/FreeOrion/python/PythonUniverseWrapper.cpp =================================================================== --- trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2010-08-28 02:55:59 UTC (rev 3769) +++ trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2010-08-28 16:25:46 UTC (rev 3770) @@ -75,24 +75,22 @@ void (Universe::*UpdateMeterEstimatesVoidFunc)(void) = &Universe::UpdateMeterEstimates; - std::vector<int> LeastJumpsPath(const Universe* universe, int start_sys, int end_sys, int empire_id) { - std::pair<std::list<int>, int> path = universe->LeastJumpsPath(start_sys, end_sys, empire_id); + std::vector<int> LeastJumpsPath(const Universe& universe, int start_sys, int end_sys, int empire_id) { + std::pair<std::list<int>, int> path = universe.LeastJumpsPath(start_sys, end_sys, empire_id); std::vector<int> retval; std::copy(path.first.begin(), path.first.end(), std::back_inserter(retval)); return retval; } + boost::function<std::vector<int>(const Universe&, int, int, int)> LeastJumpsFunc = &LeastJumpsPath; - boost::function<std::vector<int>(const Universe*, int, int, int)> LeastJumpsFunc = &LeastJumpsPath; - - std::vector<int> ShortestPath(const Universe* universe, int start_sys, int end_sys, int empire_id) { - std::pair<std::list<int>, int> path = universe->ShortestPath(start_sys, end_sys, empire_id); + std::vector<int> ShortestPath(const Universe& universe, int start_sys, int end_sys, int empire_id) { + std::pair<std::list<int>, int> path = universe.ShortestPath(start_sys, end_sys, empire_id); std::vector<int> retval; std::copy(path.first.begin(), path.first.end(), std::back_inserter(retval)); return retval; } + boost::function<std::vector<int>(const Universe&, int, int, int)> ShortestPathFunc = &ShortestPath; - boost::function<std::vector<int>(const Universe*, int, int, int)> ShortestPathFunc = &ShortestPath; - const Meter* (UniverseObject::*ObjectGetMeter)(MeterType) const = &UniverseObject::GetMeter; boost::function<double(const UniverseObject*, MeterType)> InitialCurrentMeterValueFromObject = @@ -165,13 +163,13 @@ .def("leastJumpsPath", make_function( LeastJumpsFunc, return_value_policy<return_by_value>(), - boost::mpl::vector<std::vector<int>, const Universe*, int, int, int>() + boost::mpl::vector<std::vector<int>, const Universe&, int, int, int>() )) .def("shortestPath", make_function( ShortestPathFunc, return_value_policy<return_by_value>(), - boost::mpl::vector<std::vector<int>, const Universe*, int, int, int>() + boost::mpl::vector<std::vector<int>, const Universe&, int, int, int>() )) .def("dump", &DumpObjects) |
From: <geo...@us...> - 2011-10-26 02:16:22
|
Revision: 4441 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=4441&view=rev Author: geoffthemedio Date: 2011-10-26 02:16:15 +0000 (Wed, 26 Oct 2011) Log Message: ----------- Exposed Universe's linearDistance, jumpDistance, and systemsConnected functions in Python API. Modified Paths: -------------- trunk/FreeOrion/python/PythonUniverseWrapper.cpp Modified: trunk/FreeOrion/python/PythonUniverseWrapper.cpp =================================================================== --- trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2011-10-25 20:12:50 UTC (rev 4440) +++ trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2011-10-26 02:16:15 UTC (rev 4441) @@ -195,18 +195,36 @@ .def("updateMeterEstimates", UpdateMeterEstimatesVoidFunc) - .def("leastJumpsPath", make_function( - LeastJumpsFunc, + .def("linearDistance", make_function( + LinearDistanceFunc, return_value_policy<return_by_value>(), - boost::mpl::vector<std::vector<int>, const Universe&, int, int, int>() + boost::mpl::vector<double, const Universe&, int, int>() )) + .def("jumpDistance", make_function( + JumpDistanceFunc, + return_value_policy<return_by_value>(), + boost::mpl::vector<int, const Universe&, int, int>() + )) + .def("shortestPath", make_function( ShortestPathFunc, return_value_policy<return_by_value>(), boost::mpl::vector<std::vector<int>, const Universe&, int, int, int>() )) + .def("leastJumpsPath", make_function( + LeastJumpsFunc, + return_value_policy<return_by_value>(), + boost::mpl::vector<std::vector<int>, const Universe&, int, int, int>() + )) + + .def("systemsConnected", make_function( + SystemsConnectedFunc, + return_value_policy<return_by_value>(), + boost::mpl::vector<bool, const Universe&, int, int>() + )) + .def("dump", &DumpObjects) ; |
From: <geo...@us...> - 2011-12-11 23:11:55
|
Revision: 4517 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=4517&view=rev Author: geoffthemedio Date: 2011-12-11 23:11:48 +0000 (Sun, 11 Dec 2011) Log Message: ----------- Exposed to Python the ShipDesign properties canInvade, isArmed, and isMonster. Modified Paths: -------------- trunk/FreeOrion/python/PythonUniverseWrapper.cpp Modified: trunk/FreeOrion/python/PythonUniverseWrapper.cpp =================================================================== --- trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2011-12-10 15:41:26 UTC (rev 4516) +++ trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2011-12-11 23:11:48 UTC (rev 4517) @@ -301,6 +301,9 @@ .add_property("defense", make_function(&ShipDesign::Defense, return_value_policy<return_by_value>())) .add_property("attack", make_function(&ShipDesign::Attack, return_value_policy<return_by_value>())) .add_property("canColonize", make_function(&ShipDesign::CanColonize, return_value_policy<return_by_value>())) + .add_property("canInvade", make_function(&ShipDesign::HasTroops, return_value_policy<return_by_value>())) + .add_property("isArmed", make_function(&ShipDesign::IsArmed, return_value_policy<return_by_value>())) + .add_property("isMonster", make_function(&ShipDesign::IsMonster, return_value_policy<return_by_value>())) .add_property("productionCost", make_function(&ShipDesign::ProductionCost, return_value_policy<return_by_value>())) .add_property("productionTime", make_function(&ShipDesign::ProductionTime, return_value_policy<return_by_value>())) .add_property("perTurnCost", make_function(&ShipDesign::PerTurnCost, return_value_policy<return_by_value>())) |
From: <geo...@us...> - 2012-09-25 06:50:31
|
Revision: 5267 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=5267&view=rev Author: geoffthemedio Date: 2012-09-25 06:50:20 +0000 (Tue, 25 Sep 2012) Log Message: ----------- Added producedByEmpireID property to ships and buildings, and orderedScrapped property to buildings in Python API. Modified Paths: -------------- trunk/FreeOrion/python/PythonUniverseWrapper.cpp Modified: trunk/FreeOrion/python/PythonUniverseWrapper.cpp =================================================================== --- trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2012-09-25 06:39:30 UTC (rev 5266) +++ trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2012-09-25 06:50:20 UTC (rev 5267) @@ -305,6 +305,7 @@ .add_property("design", make_function(&Ship::Design, return_value_policy<reference_existing_object>())) .add_property("designID", &Ship::DesignID) .add_property("fleetID", &Ship::FleetID) + .add_property("producedByEmpireID", &Ship::ProducedByEmpireID) .add_property("isMonster", &Ship::IsMonster) .add_property("isArmed", &Ship::IsArmed) .add_property("canColonize", &Ship::CanColonize) @@ -370,8 +371,9 @@ ////////////////// class_<Building, bases<UniverseObject>, noncopyable>("building", no_init) .add_property("buildingTypeName", make_function(&Building::BuildingTypeName, return_value_policy<copy_const_reference>())) - //.add_property("operating", &Building::Operating) .add_property("planetID", make_function(&Building::PlanetID, return_value_policy<return_by_value>())) + .add_property("producedByEmpireID", &Building::ProducedByEmpireID) + .add_property("orderedScrapped", &Building::OrderedScrapped) ; ////////////////// @@ -426,6 +428,7 @@ .add_property("allObjectIDs", make_function(&System::FindObjectIDs<UniverseObject>, return_value_policy<return_by_value>())) .add_property("planetIDs", make_function(&System::FindObjectIDs<Planet>, return_value_policy<return_by_value>())) .add_property("fleetIDs", make_function(&System::FindObjectIDs<Fleet>, return_value_policy<return_by_value>())) + .add_property("lastTurnBattleHere", &System::LastTurnBattleHere) ; ////////////////// |
From: <geo...@us...> - 2012-10-16 07:15:27
|
Revision: 5303 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=5303&view=rev Author: geoffthemedio Date: 2012-10-16 07:15:20 +0000 (Tue, 16 Oct 2012) Log Message: ----------- Tweaked version of update to Python API by Dilvish, to expose BuildingType cost and times as functions instead of properties. Modified Paths: -------------- trunk/FreeOrion/python/PythonUniverseWrapper.cpp Modified: trunk/FreeOrion/python/PythonUniverseWrapper.cpp =================================================================== --- trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2012-10-15 18:42:56 UTC (rev 5302) +++ trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2012-10-16 07:15:20 UTC (rev 5303) @@ -257,16 +257,16 @@ // Container Wrappers // //////////////////////// class_<std::map<int, int> >("IntIntMap") - .def(boost::python::map_indexing_suite<std::map<int, int>, true >()) + .def(boost::python::map_indexing_suite<std::map<int, int>, true >()) ; class_<std::map<int, double> >("IntDblMap") - .def(boost::python::map_indexing_suite<std::map<int, double>,true >()) + .def(boost::python::map_indexing_suite<std::map<int, double>,true >()) ; class_<std::map<int, Visibility> >("IntVisibilityMap") - .def(boost::python::map_indexing_suite<std::map<int, Visibility>,true >()) + .def(boost::python::map_indexing_suite<std::map<int, Visibility>,true >()) ; class_<std::map<Visibility,int> >("VisibilityIntMap") - .def(boost::python::map_indexing_suite<std::map<Visibility,int>,true >()) + .def(boost::python::map_indexing_suite<std::map<Visibility,int>,true >()) ; //////////////////// @@ -476,7 +476,6 @@ ; def("getHullType", &GetHullType, return_value_policy<reference_existing_object>()); - ////////////////// // Building // ////////////////// @@ -493,16 +492,14 @@ class_<BuildingType, noncopyable>("buildingType", no_init) .add_property("name", make_function(&BuildingType::Name, return_value_policy<copy_const_reference>())) .add_property("description", make_function(&BuildingType::Description, return_value_policy<copy_const_reference>())) - .add_property("productionCost", &BuildingType::ProductionCost) - .add_property("productionTime", &BuildingType::ProductionTime) + .def("productionCost", &BuildingType::ProductionCost) + .def("productionTime", &BuildingType::ProductionTime) + .def("perTurnCost", &BuildingType::PerTurnCost) .add_property("maintenanceCost", &BuildingType::MaintenanceCost) - .add_property("perTurnCost", &BuildingType::PerTurnCost) .def("captureResult", &BuildingType::GetCaptureResult) .def("canBeProduced", &BuildingType::ProductionLocation) //(int empire_id, int location_id) ; def("getBuildingType", &GetBuildingType, return_value_policy<reference_existing_object>()); - - //////////////////// // ResourceCenter // //////////////////// |
From: <geo...@us...> - 2012-10-26 20:05:04
|
Revision: 5338 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=5338&view=rev Author: geoffthemedio Date: 2012-10-26 20:04:58 +0000 (Fri, 26 Oct 2012) Log Message: ----------- -Remove some, I think, unnecessary duplication of code in Python AI interface that handles visible vs. all ever known objects, as this is already done (in the clients) in the called object-getter functions. -Also made all the Python AI interface FindObjectIDs functions work the same re: free function instead of universe member FindObjectIDs calls. Not sure if this will cause any problems with local changes (ie. creating new fleets client-side) not showing up in the returned list of objects, so may need to tweak this code. Modified Paths: -------------- trunk/FreeOrion/python/PythonUniverseWrapper.cpp Modified: trunk/FreeOrion/python/PythonUniverseWrapper.cpp =================================================================== --- trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2012-10-26 06:21:18 UTC (rev 5337) +++ trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2012-10-26 20:04:58 UTC (rev 5338) @@ -19,60 +19,26 @@ namespace { void DumpObjects(const Universe& universe) { Logger().debugStream() << universe.Objects().Dump(); } - const UniverseObject* GetUniverseObjectP(const Universe& universe, int id) { - //Logger().debugStream() << "GetUniverseObjectP(universe, " << id << ")"; - const UniverseObject* retval = universe.Objects().Object(id); - if (!retval) - retval = ::GetUniverseObject(id); - return retval; - } - const Fleet* GetFleetP(const Universe& universe, int id) { - //Logger().debugStream() << "GetFleetP(universe, " << id << ")"; - const Fleet* retval = universe.Objects().Object<Fleet>(id); - if (!retval) - retval = ::GetFleet(id); - return retval; - } - const Ship* GetShipP(const Universe& universe, int id) { - //Logger().debugStream() << "GetShipP(universe, " << id << ")"; - const Ship* retval = universe.Objects().Object<Ship>(id); - if (!retval) - retval = ::GetShip(id); - return retval; - } - const Planet* GetPlanetP(const Universe& universe, int id) { - //Logger().debugStream() << "GetPlanetP(universe, " << id << ")"; - const Planet* retval = universe.Objects().Object<Planet>(id); - if (!retval) - retval = ::GetPlanet(id); - return retval; - } - const System* GetSystemP(const Universe& universe, int id) { - //Logger().debugStream() << "GetSystemP(universe, " << id << ")"; - const System* retval = universe.Objects().Object<System>(id); - if (!retval) - retval = ::GetSystem(id); - return retval; - } - const Field* GetFieldP(const Universe& universe, int id) { - //Logger().debugStream() << "GetFieldP(universe, " << id << ")"; - const Field* retval = universe.Objects().Object<Field>(id); - if (!retval) - retval = ::GetField(id); - return retval; - } - const Building* GetBuildingP(const Universe& universe, int id) { - //Logger().debugStream() << "GetBuildingP(universe, " << id << ")"; - const Building* retval = universe.Objects().Object<Building>(id); - if (!retval) - retval = ::GetBuilding(id); - return retval; - } + const UniverseObject* GetUniverseObjectP(const Universe& universe, int id) + { return ::GetUniverseObject(id); } + const Fleet* GetFleetP(const Universe& universe, int id) + { return ::GetFleet(id); } + const Ship* GetShipP(const Universe& universe, int id) + { return ::GetShip(id); } + const Planet* GetPlanetP(const Universe& universe, int id) + { return ::GetPlanet(id); } + const System* GetSystemP(const Universe& universe, int id) + { return ::GetSystem(id); } + const Field* GetFieldP(const Universe& universe, int id) + { return ::GetField(id); } + const Building* GetBuildingP(const Universe& universe, int id) + { return ::GetBuilding(id); } + std::vector<int> ObjectIDs(const Universe& universe) - { return universe.Objects().FindObjectIDs(); } + { return Objects().FindObjectIDs(); } std::vector<int> FleetIDs(const Universe& universe) - { return universe.Objects().FindObjectIDs<Fleet>(); } + { return Objects().FindObjectIDs<Fleet>(); } std::vector<int> SystemIDs(const Universe& universe) { return Objects().FindObjectIDs<System>(); } std::vector<int> FieldIDs(const Universe& universe) @@ -80,7 +46,7 @@ std::vector<int> PlanetIDs(const Universe& universe) { return Objects().FindObjectIDs<Planet>(); } std::vector<int> ShipIDs(const Universe& universe) - { return universe.Objects().FindObjectIDs<Ship>(); } + { return Objects().FindObjectIDs<Ship>(); } std::vector<int> BuildingIDs(const Universe& universe) { return Objects().FindObjectIDs<Building>(); } |
From: <geo...@us...> - 2012-11-19 10:07:01
|
Revision: 5441 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=5441&view=rev Author: geoffthemedio Date: 2012-11-19 10:06:50 +0000 (Mon, 19 Nov 2012) Log Message: ----------- grooming Modified Paths: -------------- trunk/FreeOrion/python/PythonUniverseWrapper.cpp Modified: trunk/FreeOrion/python/PythonUniverseWrapper.cpp =================================================================== --- trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2012-11-19 09:26:49 UTC (rev 5440) +++ trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2012-11-19 10:06:50 UTC (rev 5441) @@ -93,7 +93,7 @@ } boost::function<std::vector<int>(const Universe&, int, int, int)> LeastJumpsFunc = &LeastJumpsPath; - bool SystemsConnectedP(const Universe& universe, int system1_id, int system2_id, int empire_id=ALL_EMPIRES) { + bool SystemsConnectedP(const Universe& universe, int system1_id, int system2_id, int empire_id=ALL_EMPIRES) { //Logger().debugStream() << "SystemsConnected!(" << system1_id << ", " << system2_id << ")"; try { bool retval = universe.SystemsConnected(system1_id, system2_id, empire_id); @@ -105,7 +105,7 @@ } boost::function<bool(const Universe&, int, int, int)> SystemsConnectedFunc = &SystemsConnectedP; - std::vector<int> ImmediateNeighborsP(const Universe& universe, int system1_id, int empire_id = ALL_EMPIRES) { + std::vector<int> ImmediateNeighborsP(const Universe& universe, int system1_id, int empire_id = ALL_EMPIRES) { std::multimap<double, int> lanemap; std::vector<int> retval; try { @@ -119,7 +119,7 @@ } boost::function<std::vector<int> (const Universe&, int, int)> ImmediateNeighborsFunc = &ImmediateNeighborsP; - std::map<int,double> SystemNeighborsMapP(const Universe& universe, int system1_id, int empire_id = ALL_EMPIRES) { + std::map<int,double> SystemNeighborsMapP(const Universe& universe, int system1_id, int empire_id = ALL_EMPIRES) { std::multimap<double, int> lanemap; std::map<int,double> retval; try { @@ -133,7 +133,7 @@ } boost::function<std::map<int,double> (const Universe&, int, int)> SystemNeighborsMapFunc = &SystemNeighborsMapP; - int VisibilityP(const Universe& universe, int object_id, int empire_id = ALL_EMPIRES) { + int VisibilityP(const Universe& universe, int object_id, int empire_id = ALL_EMPIRES) { int retval; //std::vector<int> retval; try { @@ -145,7 +145,7 @@ } boost::function<int (const Universe&, int, int)> VisibilityFunc = &VisibilityP; - std::vector<int> VisibilityTurnsP(const Universe& universe, int object_id, int empire_id = ALL_EMPIRES) { + std::vector<int> VisibilityTurnsP(const Universe& universe, int object_id, int empire_id = ALL_EMPIRES) { Universe::VisibilityTurnMap vismap; std::vector<int> retval; //std::vector<int> retval; @@ -166,7 +166,7 @@ const std::map<MeterType, Meter>& (UniverseObject::*ObjectMeters)(void) const = &UniverseObject::Meters; - std::vector<std::string> ObjectSpecials(const UniverseObject& object) { + std::vector<std::string> ObjectSpecials(const UniverseObject& object) { std::vector<std::string> retval; for (std::map<std::string, int>::const_iterator it = object.Specials().begin(); it != object.Specials().end(); ++it) @@ -236,9 +236,9 @@ .def(boost::python::map_indexing_suite<std::map<int, Visibility>,true >()) ; class_<std::map<Visibility,int> >("VisibilityIntMap") - .def(boost::python::map_indexing_suite<std::map<Visibility,int>,true >()) + .def(boost::python::map_indexing_suite<std::map<Visibility, int>, true>()) ; - + //////////////////// // Universe // //////////////////// |
From: <geo...@us...> - 2013-02-24 20:22:48
|
Revision: 5800 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=5800&view=rev Author: geoffthemedio Date: 2013-02-24 20:22:40 +0000 (Sun, 24 Feb 2013) Log Message: ----------- Exposed Species::CanProduceShips to Python API. Modified Paths: -------------- trunk/FreeOrion/python/PythonUniverseWrapper.cpp Modified: trunk/FreeOrion/python/PythonUniverseWrapper.cpp =================================================================== --- trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2013-02-24 15:24:40 UTC (rev 5799) +++ trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2013-02-24 20:22:40 UTC (rev 5800) @@ -581,6 +581,7 @@ .add_property("description", make_function(&Species::Description, return_value_policy<copy_const_reference>())) .add_property("homeworlds", make_function(&Species::Homeworlds, return_value_policy<copy_const_reference>())) .add_property("canColonize", make_function(&Species::CanColonize, return_value_policy<return_by_value>())) + .add_property("canProduceShips", make_function(&Species::CanProduceShips,return_value_policy<return_by_value>())) .add_property("tags", make_function(&Species::Tags, return_value_policy<return_by_value>())) // TODO: const std::vector<FocusType>& Species::Foci() .def("getPlanetEnvironment", &Species::GetPlanetEnvironment) |
From: <dil...@us...> - 2015-02-19 01:08:28
|
Revision: 7964 http://sourceforge.net/p/freeorion/code/7964 Author: dilvish-fo Date: 2015-02-19 01:08:21 +0000 (Thu, 19 Feb 2015) Log Message: ----------- eliminated some unneeded attributes in the AI interface ShipDesign wrapper. Modified Paths: -------------- trunk/FreeOrion/python/PythonUniverseWrapper.cpp Modified: trunk/FreeOrion/python/PythonUniverseWrapper.cpp =================================================================== --- trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2015-02-19 00:36:12 UTC (rev 7963) +++ trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2015-02-19 01:08:21 UTC (rev 7964) @@ -190,7 +190,8 @@ boost::function<std::vector<int> (const ShipDesign&)> DirectFireStatsFunc = &DirectFireStatsP; const std::vector<std::string>& (ShipDesign::*PartsVoid)(void) const = &ShipDesign::Parts; - std::vector<std::string> (ShipDesign::*PartsSlotType)(ShipSlotType) const = &ShipDesign::Parts; + // The following (PartsSlotType) is not currently used, but left as an example for this kind of wrapper + //std::vector<std::string> (ShipDesign::*PartsSlotType)(ShipSlotType) const = &ShipDesign::Parts; std::vector<ShipSlotType> HullSlots(const HullType& hull) { std::vector<ShipSlotType> retval; @@ -417,7 +418,6 @@ class_<ShipDesign, noncopyable>("shipDesign", no_init) .add_property("id", make_function(&ShipDesign::ID, return_value_policy<return_by_value>())) .def("name", make_function(&ShipDesign::Name, return_value_policy<copy_const_reference>())) - .add_property("description", make_function(&ShipDesign::Description, return_value_policy<copy_const_reference>())) .add_property("designedOnTurn", make_function(&ShipDesign::DesignedOnTurn, return_value_policy<return_by_value>())) .add_property("battleSpeed", make_function(&ShipDesign::BattleSpeed, return_value_policy<return_by_value>())) .add_property("starlaneSpeed", make_function(&ShipDesign::StarlaneSpeed, return_value_policy<return_by_value>())) @@ -440,7 +440,6 @@ boost::mpl::vector<std::vector<int>, const ShipDesign&>() )) - .def("partsInSlotType", PartsSlotType, return_value_policy<return_by_value>()) .def("productionLocationForEmpire", &ShipDesign::ProductionLocation) ; def("validShipDesign", ValidDesignHullAndParts); |
From: <geo...@us...> - 2015-03-02 18:32:37
|
Revision: 7993 http://sourceforge.net/p/freeorion/code/7993 Author: geoffthemedio Date: 2015-03-02 18:32:30 +0000 (Mon, 02 Mar 2015) Log Message: ----------- Added some meter type containers to Python API, hopefully fixing some gamestate getters. Modified Paths: -------------- trunk/FreeOrion/python/PythonUniverseWrapper.cpp Modified: trunk/FreeOrion/python/PythonUniverseWrapper.cpp =================================================================== --- trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2015-03-01 21:18:26 UTC (rev 7992) +++ trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2015-03-02 18:32:30 UTC (rev 7993) @@ -254,7 +254,19 @@ class_<std::vector<ShipSlotType> >("ShipSlotVec") .def(boost::python::vector_indexing_suite<std::vector<ShipSlotType>, true>()) ; + class_<std::map<MeterType, Meter> >("MeterTypeMeterMap") + .def(boost::python::map_indexing_suite<std::map<MeterType, Meter>, true>()) + ; + // typedef std::map<std::pair<MeterType, std::string>, Meter> PartMeterMap; + class_<std::pair<MeterType, std::string> >("MeterTypeStringPair") + .add_property("meterType", &std::pair<MeterType, std::string>::first) + .add_property("string", &std::pair<MeterType, std::string>::second) + ; + class_<Ship::PartMeterMap>("MeterTypeStringPairMeterMap") + .def(boost::python::map_indexing_suite<Ship::PartMeterMap, true>()) + ; + //////////////////// // Universe // //////////////////// |
From: <geo...@us...> - 2015-03-03 11:55:02
|
Revision: 7998 http://sourceforge.net/p/freeorion/code/7998 Author: geoffthemedio Date: 2015-03-03 11:55:00 +0000 (Tue, 03 Mar 2015) Log Message: ----------- -Added some dump functions to PythonUniverseWrapper.cpp -Attempted to expose some Meter containers and Meter class, probably not functional Modified Paths: -------------- trunk/FreeOrion/python/PythonUniverseWrapper.cpp Modified: trunk/FreeOrion/python/PythonUniverseWrapper.cpp =================================================================== --- trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2015-03-03 11:17:48 UTC (rev 7997) +++ trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2015-03-03 11:55:00 UTC (rev 7998) @@ -153,7 +153,7 @@ } return retval; } - boost::function<std::map<int,double> (const Universe&, int, int)> SystemNeighborsMapFunc = &SystemNeighborsMapP; + boost::function<std::map<int, double> (const Universe&, int, int)> SystemNeighborsMapFunc = &SystemNeighborsMapP; const Meter* (UniverseObject::*ObjectGetMeter)(MeterType) const = &UniverseObject::GetMeter; const std::map<MeterType, Meter>& @@ -262,10 +262,18 @@ .add_property("meterType", &std::pair<MeterType, std::string>::first) .add_property("string", &std::pair<MeterType, std::string>::second) ; - class_<Ship::PartMeterMap>("MeterTypeStringPairMeterMap") - .def(boost::python::map_indexing_suite<Ship::PartMeterMap, true>()) + class_<Ship::PartMeterMap>("ShipPartMeterMap") + .def(boost::python::map_indexing_suite<Ship::PartMeterMap>()) ; + /////////////// + // Meter // + /////////////// + class_<Meter, noncopyable>("meter", no_init) + .add_property("current", &Meter::Current) + .add_property("initial", &Meter::Initial) + .add_property("dump", &Meter::Dump) + ; //////////////////// // Universe // @@ -376,6 +384,7 @@ .def("hasTag", &UniverseObject::HasTag) .add_property("meters", make_function(ObjectMeters, return_internal_reference<>())) .def("getMeter", make_function(ObjectGetMeter, return_internal_reference<>())) + .add_property("dump", &UniverseObject::Dump) ; /////////////////// @@ -453,6 +462,7 @@ )) .def("productionLocationForEmpire", &ShipDesign::ProductionLocation) + .add_property("dump", &ShipDesign::Dump) ; def("validShipDesign", ValidDesignHullAndParts); def("validShipDesign", ValidDesignDesign); @@ -508,6 +518,7 @@ .def("perTurnCost", &BuildingType::PerTurnCost) .def("captureResult", &BuildingType::GetCaptureResult) .def("canBeProduced", &BuildingType::ProductionLocation) //(int empire_id, int location_id) + .add_property("dump", &BuildingType::Dump) ; def("getBuildingType", &GetBuildingType, return_value_policy<reference_existing_object>()); //////////////////// @@ -582,6 +593,7 @@ class_<FieldType, noncopyable>("fieldType", no_init) .add_property("name", make_function(&FieldType::Name, return_value_policy<copy_const_reference>())) .add_property("description", make_function(&FieldType::Description, return_value_policy<copy_const_reference>())) + .add_property("dump", &FieldType::Dump) ; def("getFieldType", &GetFieldType, return_value_policy<reference_existing_object>()); @@ -592,6 +604,7 @@ class_<Special, noncopyable>("special", no_init) .add_property("name", make_function(&Special::Name, return_value_policy<copy_const_reference>())) .add_property("description", make_function(&Special::Description, return_value_policy<copy_const_reference>())) + .add_property("dump", &Special::Dump) ; def("getSpecial", &GetSpecial, return_value_policy<reference_existing_object>()); @@ -609,6 +622,7 @@ .add_property("tags", make_function(&Species::Tags, return_value_policy<return_by_value>())) // TODO: const std::vector<FocusType>& Species::Foci() .def("getPlanetEnvironment", &Species::GetPlanetEnvironment) + .add_property("dump", &Species::Dump) ; def("getSpecies", &GetSpecies, return_value_policy<reference_existing_object>()); } |
From: <dil...@us...> - 2015-03-12 03:41:30
|
Revision: 8024 http://sourceforge.net/p/freeorion/code/8024 Author: dilvish-fo Date: 2015-03-12 03:41:23 +0000 (Thu, 12 Mar 2015) Log Message: ----------- python interface minor adjustment re wormholes and planet axial tilt Modified Paths: -------------- trunk/FreeOrion/python/PythonUniverseWrapper.cpp Modified: trunk/FreeOrion/python/PythonUniverseWrapper.cpp =================================================================== --- trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2015-03-12 02:59:24 UTC (rev 8023) +++ trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2015-03-12 03:41:23 UTC (rev 8024) @@ -556,7 +556,7 @@ .add_property("InitialOrbitalPosition", &Planet::InitialOrbitalPosition) .def("OrbitalPositionOnTurn", &Planet::OrbitalPositionOnTurn) .add_property("RotationalPeriod", &Planet::RotationalPeriod) - .add_property("AxialTilt", &Planet::AxialTilt) + //.add_property("AxialTilt", &Planet::AxialTilt) .add_property("buildingIDs", make_function(&Planet::BuildingIDs, return_internal_reference<>())) ; @@ -566,10 +566,10 @@ class_<System, bases<UniverseObject>, noncopyable>("system", no_init) .add_property("starType", &System::GetStarType) .add_property("numStarlanes", &System::NumStarlanes) - .add_property("numWormholes", &System::NumWormholes) + .add_property("numWormholes", &System::NumWormholes, "Currently unused.") .def("HasStarlaneToSystemID", &System::HasStarlaneTo) - .def("HasWormholeToSystemID", &System::HasWormholeTo) - .add_property("starlanesWormholes", make_function(&System::StarlanesWormholes, return_value_policy<return_by_value>())) + .def("HasWormholeToSystemID", &System::HasWormholeTo, "Currently unused.") + .add_property("starlanesWormholes", make_function(&System::StarlanesWormholes, return_value_policy<return_by_value>()), "Currently unused.") .add_property("planetIDs", make_function(&System::PlanetIDs, return_value_policy<return_by_value>())) .add_property("buildingIDs", make_function(&System::BuildingIDs, return_value_policy<return_by_value>())) .add_property("fleetIDs", make_function(&System::FleetIDs, return_value_policy<return_by_value>())) |