new [store_turns] tag to store the number of turns remaining

This commit is contained in:
Patrick Parker 2007-04-07 21:32:52 +00:00
parent 79275acd6e
commit 3ccd7b3b15
2 changed files with 11 additions and 1 deletions

View file

@ -68,6 +68,7 @@ Version 1.3.1+svn:
* WML engine
* new [own_village] condition to check if someone own a particular village
* new [store_villages] tag to store village locations
* new [store_turns] tag to store the number of turns remaining
* all [store_*] tags get a default variable name
* use complex variable substitution almost everywhere
* new key for [set_variable], literal=, to avoid variable substitution

View file

@ -744,7 +744,16 @@ bool event_handler::handle_event_command(const queued_event& event_info,
status_ptr->add_turns(-status_ptr->number_of_turns());
status_ptr->add_turns(lexical_cast_default<int>(value,50));
}
}
else if(cmd == "store_turns") {
std::string var_name = cfg["variable"];
if(var_name.empty()) {
var_name = cmd.substr(cmd.find_first_of('_') + 1);
}
wassert(state_of_game != NULL);
wassert(status_ptr != NULL);
int turns = status_ptr->number_of_turns();
state_of_game->get_variable(var_name) = lexical_cast_default<std::string>(turns,"");
}
//moving a 'unit' - i.e. a dummy unit that is just moving for