-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Support for (most) 1.8 maps (#7631)
* Add: Support XML tag aliases, support "attatchment" mispelling This initial round of updates allows for basic support of 1.8 maps, they will load after this update. * Add support to load (most) 1.8 maps - Add conversion code to match attachments spelled either as 'attatchment' or as 'attachment - Add annotation @RenameOnNextMajorRelease to help us know which items we can rename and to what when save game compatibility can be broken. - Add ignore for properties: "takeUnitControl" and "giveUnitControl" Add conversion logic for: - isParatroop -> isAirTransportable - isInfantry & isMechanized -> isLandTransportable - Battleship|Units repair at beginning|end of round -> Units Repair at beginning|end of round - 'occupiedTerrOf' -> 'originalOwner' - 'victoryCity=false' -> 'victoryCity=0' - 'isImpassible' -> 'isImpassable' - 'turns' -> 'rounds'
- Loading branch information
1 parent
22811dc
commit 9c05bae
Showing
22 changed files
with
3,394 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
game-core/src/main/java/games/strategy/engine/data/gameparser/LegacyPropertyMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package games.strategy.engine.data.gameparser; | ||
|
||
import games.strategy.triplea.Constants; | ||
import lombok.experimental.UtilityClass; | ||
|
||
/** | ||
* This converts property names and values that were used in older map XMLs and updates those values | ||
* to their newer versions. This is useful to allow the game code to only use the newer names and | ||
* values while still being able to load older maps. | ||
*/ | ||
@UtilityClass | ||
class LegacyPropertyMapper { | ||
|
||
static String mapLegacyOptionName(final String optionName) { | ||
if (optionName.equalsIgnoreCase("isParatroop")) { | ||
return "isAirTransportable"; | ||
} else if (optionName.equalsIgnoreCase("isInfantry") | ||
|| optionName.equalsIgnoreCase("isMechanized")) { | ||
return "isLandTransportable"; | ||
} else if (optionName.equalsIgnoreCase("occupiedTerrOf")) { | ||
return Constants.ORIGINAL_OWNER; | ||
} else if (optionName.equalsIgnoreCase("isImpassible")) { | ||
return "isImpassable"; | ||
} else if (optionName.equalsIgnoreCase("turns")) { | ||
return "rounds"; | ||
} | ||
return optionName; | ||
} | ||
|
||
public String mapLegacyOptionValue(final String optionName, final String optionValue) { | ||
if (optionName.equalsIgnoreCase("victoryCity")) { | ||
if (optionValue.equalsIgnoreCase("true")) { | ||
return "1"; | ||
} else if (optionValue.equalsIgnoreCase("false")) { | ||
return "0"; | ||
} else { | ||
return optionValue; | ||
} | ||
} | ||
return optionValue; | ||
} | ||
|
||
public String mapPropertyName(final String propertyName) { | ||
if (propertyName.equalsIgnoreCase("Battleships repair at end of round") | ||
|| propertyName.equalsIgnoreCase("Units repair at end of round")) { | ||
return Constants.TWO_HIT_BATTLESHIPS_REPAIR_END_OF_TURN; | ||
} else if (propertyName.equalsIgnoreCase("Battleships repair at beginning of round") | ||
|| propertyName.equalsIgnoreCase("Units repair at beginning of round")) { | ||
return Constants.TWO_HIT_BATTLESHIPS_REPAIR_BEGINNING_OF_TURN; | ||
} | ||
|
||
return propertyName; | ||
} | ||
|
||
static boolean ignoreOptionName(final String name) { | ||
return name.equalsIgnoreCase("takeUnitControl") || name.equalsIgnoreCase("giveUnitControl"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.