SUF: Accept range-lists for integer keys (level, defense, recall_cost, movement_cost)
Also, add vision_cost and jamming_cost keys Closes #1778
This commit is contained in:
parent
37b6610e11
commit
73f1541e81
2 changed files with 76 additions and 8 deletions
|
@ -44,6 +44,8 @@ Version 1.13.8+dev:
|
|||
* Fix [scroll] with omitted x or y
|
||||
* Fix [story] not showing if all parts are conditional
|
||||
* Fix some hotkeys not working (issues #1737 and #1769)
|
||||
* New vision_cost and jamming_cost keys in SUF
|
||||
* Integer SUF keys (eg level) now accept a list of ranges
|
||||
|
||||
Version 1.13.8:
|
||||
* Campaigns:
|
||||
|
|
|
@ -487,20 +487,86 @@ bool basic_unit_filter_impl::internal_matches_filter(const unit & u, const map_l
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!vcfg["recall_cost"].blank() && vcfg["recall_cost"].to_int(-1) != u.recall_cost()) {
|
||||
return false;
|
||||
if (!vcfg["recall_cost"].blank()) {
|
||||
bool match_found = false;
|
||||
for(auto cost : utils::parse_ranges(vcfg["recall_cost"])) {
|
||||
if(cost.first <= u.recall_cost() && u.recall_cost() <= cost.second) {
|
||||
match_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!match_found) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!vcfg["level"].blank() && vcfg["level"].to_int(-1) != u.level()) {
|
||||
return false;
|
||||
if(!vcfg["level"].blank()) {
|
||||
bool match_found = false;
|
||||
for(auto lvl : utils::parse_ranges(vcfg["level"])) {
|
||||
if(lvl.first <= u.level() && u.level() <= lvl.second) {
|
||||
match_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!match_found) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!vcfg["defense"].blank() && vcfg["defense"].to_int(-1) != u.defense_modifier(fc_.get_disp_context().map().get_terrain(loc))) {
|
||||
return false;
|
||||
if(!vcfg["defense"].blank()) {
|
||||
bool match_found = false;
|
||||
int actual_defense = u.defense_modifier(fc_.get_disp_context().map().get_terrain(loc));
|
||||
for(auto def : utils::parse_ranges(vcfg["defense"])) {
|
||||
if(def.first <= actual_defense && actual_defense <= def.second) {
|
||||
match_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!match_found) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!vcfg["movement_cost"].blank() && vcfg["movement_cost"].to_int(-1) != u.movement_cost(fc_.get_disp_context().map().get_terrain(loc))) {
|
||||
return false;
|
||||
if(!vcfg["movement_cost"].blank()) {
|
||||
bool match_found = false;
|
||||
int actual_cost = u.movement_cost(fc_.get_disp_context().map().get_terrain(loc));
|
||||
for(auto cost : utils::parse_ranges(vcfg["movement_cost"])) {
|
||||
if(cost.first <= actual_cost && actual_cost <= cost.second) {
|
||||
match_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!match_found) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!vcfg["vision_cost"].blank()) {
|
||||
bool match_found = false;
|
||||
int actual_cost = u.vision_cost(fc_.get_disp_context().map().get_terrain(loc));
|
||||
for(auto cost : utils::parse_ranges(vcfg["vision_cost"])) {
|
||||
if(cost.first <= actual_cost && actual_cost <= cost.second) {
|
||||
match_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!match_found) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!vcfg["jamming_cost"].blank()) {
|
||||
bool match_found = false;
|
||||
int actual_cost = u.jamming_cost(fc_.get_disp_context().map().get_terrain(loc));
|
||||
for(auto cost : utils::parse_ranges(vcfg["jamming_cost"])) {
|
||||
if(cost.first <= actual_cost && actual_cost <= cost.second) {
|
||||
match_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!match_found) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Now start with the new WML based comparison.
|
||||
|
|
Loading…
Add table
Reference in a new issue