Add [modify_turns] to [event]. Takes 'value' and 'add' as keys.

This commit is contained in:
Dominic Bolin 2006-02-19 22:12:22 +00:00
parent e5d244c030
commit 8b834318c1
3 changed files with 23 additions and 0 deletions

View file

@ -495,6 +495,18 @@ bool event_handler::handle_event_command(const queued_event& event_info,
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") {
WRN_NG << "[store_gold] tag is now deprecated; use [store_side] instead.\n";

View file

@ -280,6 +280,15 @@ int gamestatus::number_of_turns() const
{
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()
{

View file

@ -62,6 +62,8 @@ public:
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.