diff options
Diffstat (limited to 'diplomacy/web/src/gui/utils/province.js')
-rw-r--r-- | diplomacy/web/src/gui/utils/province.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/diplomacy/web/src/gui/utils/province.js b/diplomacy/web/src/gui/utils/province.js index fe54a82..8e26c4b 100644 --- a/diplomacy/web/src/gui/utils/province.js +++ b/diplomacy/web/src/gui/utils/province.js @@ -114,4 +114,22 @@ export class Province { isWater() { return this.type === ProvinceType.WATER; } + + _id(id) { + return `_${id.toLowerCase()}`; + } + + getID(identifiers) { + let id = this._id(this.name); + if (!identifiers[id]) { + for (let alias of this.aliases) { + id = this._id(alias); + if (identifiers[id]) + break; + } + } + if (!identifiers[id] && this.isCoast()) + id = this.parent.getID(identifiers); + return id; + } } |