[Wesnoth-commits] r10200 - in /trunk/src: game_events.cpp gamestatus.cpp gamestatus.hpp (February 19, 2006 - 23:13)

Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Headers

 

Author: xan
Date: Sun Feb 19 23:12:22 2006
New Revision: 10200

URL: http://svn.gna.org/viewcvs/wesnoth?rev=10200&view=rev
Log:
Add [modify_turns] to [event]. Takes 'value' and 'add' as keys.

Modified:
    trunk/src/game_events.cpp
    trunk/src/gamestatus.cpp
    trunk/src/gamestatus.hpp

Modified: trunk/src/game_events.cpp
URL: http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=10200&r1=10199&r2=10200&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Sun Feb 19 23:12:22 2006
@@ -494,6 +494,18 @@
 			state_of_game->get_variable(var_name+".name") = (*teams)[team_index].name();
 			state_of_game->get_variable(var_name+".team_name") = (*teams)[team_index].team_name();
 		}
+	}
+	else if(cmd == "modify_turns") {
+		const std::string& value = cfg["value"];
+		const bool modify = cfg["add"] != "yes";
+		
+		wassert(status_ptr != NULL);
+		if(modify) {
+			status_ptr->modify_turns(value);
+		} else {
+			status_ptr->add_turns(lexical_cast_default<int>(value,0));
+		}
+		
 	}
 	//command to store gold into a variable
 	else if(cmd == "store_gold") {

Modified: trunk/src/gamestatus.cpp
URL: http://svn.gna.org/viewcvs/wesnoth/trunk/src/gamestatus.cpp?rev=10200&r1=10199&r2=10200&view=diff
==============================================================================
--- trunk/src/gamestatus.cpp (original)
+++ trunk/src/gamestatus.cpp Sun Feb 19 23:12:22 2006
@@ -280,6 +280,15 @@
 {
 	return numTurns_;
 }
+void gamestatus::modify_turns(const std::string& mod)
+{
+	numTurns_ = maximum<int>(utils::apply_modifier(numTurns_,mod,0),-1);
+}
+void gamestatus::add_turns(int num)
+{
+	numTurns_ = maximum<int>(numTurns_ + num,-1);
+}
+
 
 bool gamestatus::next_turn()
 {

Modified: trunk/src/gamestatus.hpp
URL: http://svn.gna.org/viewcvs/wesnoth/trunk/src/gamestatus.hpp?rev=10200&r1=10199&r2=10200&view=diff
==============================================================================
--- trunk/src/gamestatus.hpp (original)
+++ trunk/src/gamestatus.hpp Sun Feb 19 23:12:22 2006
@@ -62,6 +62,8 @@
 	const time_of_day& get_time_of_day(int illuminated, const gamemap::location& loc, int n_turn) const;
 	size_t turn() const;
 	int number_of_turns() const;
+	void modify_turns(const std::string& mod);
+	void add_turns(int num);
 
 	//function to move to the next turn. Returns true iff time
 	//has expired.



Related Mails




Powered by MHonArc, Updated Mon Feb 20 00:00:24 2006