Add alternate mode of access to WFL map (currently only in FormulaAI)
This also hides the map's terrain from the string conversion.
This commit is contained in:
parent
153680400d
commit
7fb2c86c3b
2 changed files with 15 additions and 3 deletions
|
@ -66,7 +66,8 @@
|
|||
* Unit movetype functions (excluding resistance) can take a location instead of a terrain code, for convenience
|
||||
### WFL engine
|
||||
* New functions resistance_on(), vision_cost(), jamming_cost() that work in gameplay contexts (eg filters)
|
||||
* Unit object now has resistance, defense, movement_cost, vision_cost, jamming_cost, flying variables
|
||||
* Unit object now has resistance, defense, movement_cost, vision_cost, jamming_cost, flying
|
||||
* For FormulaAI, the game map object has an alternate access mode - `map.gamemap[loc(x,y)]`
|
||||
### WML engine
|
||||
* Support upkeep in StandardUnitFilter
|
||||
* [effect]apply_to=variation now supports heal_full
|
||||
|
|
|
@ -607,8 +607,6 @@ const gamemap& gamemap_callable::get_gamemap() const {
|
|||
|
||||
void gamemap_callable::get_inputs(formula_input_vector& inputs) const
|
||||
{
|
||||
add_input(inputs, "gamemap");
|
||||
add_input(inputs, "terrain");
|
||||
add_input(inputs, "w");
|
||||
add_input(inputs, "h");
|
||||
}
|
||||
|
@ -627,6 +625,19 @@ variant gamemap_callable::get_value(const std::string& key) const
|
|||
}
|
||||
}
|
||||
|
||||
return variant(vars);
|
||||
} else if(key == "gamemap") {
|
||||
int w = get_gamemap().w();
|
||||
int h = get_gamemap().h();
|
||||
|
||||
std::map<variant, variant> vars;
|
||||
for(int i = 0; i < w; i++) {
|
||||
for(int j = 0; j < h; j++) {
|
||||
const map_location loc(i, j);
|
||||
vars.emplace(std::make_shared<location_callable>(loc), std::make_shared<terrain_callable>(board_, loc));
|
||||
}
|
||||
}
|
||||
|
||||
return variant(vars);
|
||||
} else if(key == "w") {
|
||||
return variant(get_gamemap().w());
|
||||
|
|
Loading…
Add table
Reference in a new issue