From 86f7080f2a09b4c3aa7934f19324b1c05f8faf7a Mon Sep 17 00:00:00 2001 From: andy5995 Date: Tue, 12 Oct 2021 22:08:54 -0500 Subject: [PATCH] update for a25 A lot of warnings still, depending on biomes, some maps won't load at all. --- ChangeLog | 4 ++ README.md | 9 ++++ gui/common/!!!badmod_patchApplyN.js | 37 -------------- gui/common/mod~badmod.js | 25 ---------- .../NetMessages/GameRegisterStanza~badmod.js | 9 ---- gui/gamesetup/gamesetup~badmod.js | 48 ------------------- gui/maps/MapFilters_badmod_2.js | 7 +++ maps/random/bad_hyrcanian_shores.json | 1 + maps/random/badcontinent.json | 1 + maps/random/badmainland.json | 3 +- maps/random/badmainland_fixed.json | 3 +- maps/random/balancedHelpers/food.js | 2 +- maps/random/britannic_road.json | 1 + maps/random/cross.json | 1 + maps/random/slopes.json | 1 + maps/random/wrench.json | 1 + maps/random/wrench_fixed.json | 1 + mod.json | 10 ++-- 18 files changed, 37 insertions(+), 127 deletions(-) create mode 100644 ChangeLog delete mode 100644 gui/common/!!!badmod_patchApplyN.js delete mode 100644 gui/common/mod~badmod.js delete mode 100644 gui/gamesetup/NetMessages/GameRegisterStanza~badmod.js delete mode 100644 gui/gamesetup/gamesetup~badmod.js create mode 100644 gui/maps/MapFilters_badmod_2.js diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..a22807f --- /dev/null +++ b/ChangeLog @@ -0,0 +1,4 @@ +2021-10-12 + + * Update for 0ad a25 (Some maps still don't work depending on the biome set) + * v0.25.0999 released diff --git a/README.md b/README.md index 5ddfc8c..f13141a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ +### Balanced Maps 2 + +Fork of [Balanced Maps](https://github.com/badosu/badmod) + +Please report any issues by opening a ticket on +https://github.com/0ad-matters/balanced_maps_2 or by submitting a [pull +request](https://guides.github.com/introduction/flow/). + ### Credits - Valihrant for extensive playtesting, map concepts and feedback @@ -5,3 +13,4 @@ - Feldfeld for original random food generator, britannic road, wood generator and discussions - elexis for extensive technical help - nani for technical help and autociv +- badosu for maintaining the original Balanced Maps project diff --git a/gui/common/!!!badmod_patchApplyN.js b/gui/common/!!!badmod_patchApplyN.js deleted file mode 100644 index d956bca..0000000 --- a/gui/common/!!!badmod_patchApplyN.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @param {Object} [prefix] - * @param {String} method - * @param {Function} patch - */ -function autociv_patchApplyN() -{ - let prefix, method, patch; - if (arguments.length < 2) - { - let error = new Error("Insufficient arguments to patch: " + method); - warn(error.message) - warn(error.stack) - } - if (arguments.length == 2) - { - prefix = global; - method = arguments[0]; - patch = arguments[1]; - } - else - { - prefix = arguments[0]; - method = arguments[1]; - patch = arguments[2]; - } - - if (!(method in prefix)) - { - let error = new Error("Function not defined: " + method); - warn(error.message) - warn(error.stack) - return; - } - - prefix[method] = new Proxy(prefix[method], { apply: patch }); -} diff --git a/gui/common/mod~badmod.js b/gui/common/mod~badmod.js deleted file mode 100644 index a9c4504..0000000 --- a/gui/common/mod~badmod.js +++ /dev/null @@ -1,25 +0,0 @@ -global["balancedMapsCompatibilityMatcher"] = new RegExp('^0\\.20(\\.|$)', 'i'); - -autociv_patchApplyN("hasSameMods", function (target, that, args) -{ - let mod = ([name, version]) => !/^FGod.*/i.test(name); - return target.apply(that, args.map(mods => mods.filter(mod))); -}) - -autociv_patchApplyN("hasSameMods", function (target, that, args) -{ - let mod = ([name, version]) => !/^AutoCiv.*/i.test(name); - return target.apply(that, args.map(mods => mods.filter(mod))); -}) - -autociv_patchApplyN("hasSameMods", function (target, that, args) -{ - let nameFilter = (name) => !/^balanced[-_]maps.*/i.test(name); - let compatibilityFilter = ([name, version]) => (nameFilter(name) || global["balancedMapsCompatibilityMatcher"].test(version)); - - if (args[0].every(compatibilityFilter)) { - return target.apply(that, args.map(mods => mods.filter(nameFilter))); - } else { - return target.apply(that, args); - } -}) diff --git a/gui/gamesetup/NetMessages/GameRegisterStanza~badmod.js b/gui/gamesetup/NetMessages/GameRegisterStanza~badmod.js deleted file mode 100644 index 8452275..0000000 --- a/gui/gamesetup/NetMessages/GameRegisterStanza~badmod.js +++ /dev/null @@ -1,9 +0,0 @@ -GameRegisterStanza = new Proxy(GameRegisterStanza, { - construct: function (target, args) - { - let instance = new target(...args); - let mod = ([name, version]) => !/^balanced[-_]maps.*/i.test(name); - instance.mods = JSON.stringify(JSON.parse(instance.mods).filter(mod)); - return instance; - } -}); diff --git a/gui/gamesetup/gamesetup~badmod.js b/gui/gamesetup/gamesetup~badmod.js deleted file mode 100644 index 4e9df43..0000000 --- a/gui/gamesetup/gamesetup~badmod.js +++ /dev/null @@ -1,48 +0,0 @@ -function badmod_patchModFilter() -{ - if (!global["getFilteredMods"]) - global["getFilteredMods"] = function(gameData) { return Engine.GetEngineInfo().mods }; - - // Generate with `ls maps/random/*.js | sed -r 's/(\w|\/)+_triggers.js//g' | sed -r 's/.js//g' | sed -r '/^$/d' | paste -sd "," - | sed -r "s/,/\",\"/g" | sed -r "s/^|$/\"/g"` - if (!global["balancedMaps"]) - global["balancedMaps"] = [ - "maps/random/badcontinent", - "maps/random/bad_hyrcanian_shores", - "maps/random/badmainland_fixed", - "maps/random/badmainland", - "maps/random/britannic_road", - "maps/random/cross", - "maps/random/slopes", - "maps/random/wrench_fixed", - "maps/random/wrench" - ]; - - function isBalancedMap(mapName) { - return global["balancedMaps"].indexOf(mapName) > -1; - } - - autociv_patchApplyN("getFilteredMods", function (target, that, args) - { - let mod = ([name, version]) => !/^FGod.*/i.test(name); - return target.apply(that, args).filter(mod); - }); - - autociv_patchApplyN("getFilteredMods", function (target, that, args) - { - let mod = ([name, version]) => !/^AutoCiv.*/i.test(name); - return target.apply(that, args).filter(mod); - }); - - autociv_patchApplyN("getFilteredMods", function (target, that, args) - { - let mod = ([name, version]) => (!/^balanced[-_]maps.*/i.test(name) || isBalancedMap(args[0].map)); - - return target.apply(that, args).filter(mod); - }); -} - -autociv_patchApplyN("init", function (target, that, args) -{ - target.apply(that, args); - badmod_patchModFilter(); -}) diff --git a/gui/maps/MapFilters_badmod_2.js b/gui/maps/MapFilters_badmod_2.js new file mode 100644 index 0000000..c3f4c22 --- /dev/null +++ b/gui/maps/MapFilters_badmod_2.js @@ -0,0 +1,7 @@ +MapFilters.prototype.Filters.push( + { + "Name": "Balanced Maps 2", + "Title": "badmod", + "Description": "Balanced Maps 2", + "Match": ["badmod"] + }); diff --git a/maps/random/bad_hyrcanian_shores.json b/maps/random/bad_hyrcanian_shores.json index 3a0b552..c3dc56f 100644 --- a/maps/random/bad_hyrcanian_shores.json +++ b/maps/random/bad_hyrcanian_shores.json @@ -4,6 +4,7 @@ "Script" : "bad_hyrcanian_shores.js", "Description" : "Each player starts in a coastal area between forested hills and the Caspian Sea. Resources are distributed evenly to players.", "Preview" : "badhyrcanian.png", + "Keywords": ["badmod"], "CircularMap" : true } } diff --git a/maps/random/badcontinent.json b/maps/random/badcontinent.json index 07aa1ec..e770106 100644 --- a/maps/random/badcontinent.json +++ b/maps/random/badcontinent.json @@ -5,6 +5,7 @@ "Description" : "All players starts on a continent surrounded by water. Resources are distributed evenly between players.", "Preview" : "continent.png", "SupportedBiomes": "generic/", + "Keywords": ["badmod"], "CircularMap" : true } } diff --git a/maps/random/badmainland.json b/maps/random/badmainland.json index 5b30f67..a46c5e5 100644 --- a/maps/random/badmainland.json +++ b/maps/random/badmainland.json @@ -3,8 +3,9 @@ "Name" : "Balanced Mainland", "Script" : "badmainland.js", "Description" : "A typical map without any water. Resources are distributed evenly between players.", - "Preview" : "mainland_temperate.png", + "Preview" : "mainland.png", "SupportedBiomes": "generic/", + "Keywords": ["badmod"], "CircularMap" : true } } diff --git a/maps/random/badmainland_fixed.json b/maps/random/badmainland_fixed.json index 8b5745b..9b1f709 100644 --- a/maps/random/badmainland_fixed.json +++ b/maps/random/badmainland_fixed.json @@ -3,8 +3,9 @@ "Name" : "Balanced Mainland (fixed)", "Script" : "badmainland_fixed.js", "Description" : "A typical map without any water. Resources are distributed evenly between players. Positions defined by players", - "Preview" : "mainland_temperate.png", + "Preview" : "mainland.png", "SupportedBiomes": "generic/", + "Keywords": ["badmod"], "CircularMap" : true } } diff --git a/maps/random/balancedHelpers/food.js b/maps/random/balancedHelpers/food.js index deff307..3610954 100644 --- a/maps/random/balancedHelpers/food.js +++ b/maps/random/balancedHelpers/food.js @@ -35,7 +35,7 @@ const balancedFoodConfig = { placer: placeFoodDesert, initialFood: () => randIntInclusive(4, 30), }, - 'generic/snowy': { + 'generic/arctic': { placer: placeFoodSnowy, initialFood: () => randIntInclusive(3, 30), evenInitialFood: true, diff --git a/maps/random/britannic_road.json b/maps/random/britannic_road.json index a0c38f2..92f1846 100644 --- a/maps/random/britannic_road.json +++ b/maps/random/britannic_road.json @@ -4,6 +4,7 @@ "Script" : "britannic_road.js", "Description" : "Britannic Road", "Preview" : "britannic_road.png", + "Keywords": ["badmod"], "CircularMap" : true } } diff --git a/maps/random/cross.json b/maps/random/cross.json index cc2bb53..11900c8 100644 --- a/maps/random/cross.json +++ b/maps/random/cross.json @@ -5,6 +5,7 @@ "Description" : "Players start with lake behind the base with plenty of fishing.", "Preview" : "cross.png", "SupportedBiomes": "generic/", + "Keywords": ["badmod"], "CircularMap" : true } } diff --git a/maps/random/slopes.json b/maps/random/slopes.json index 049a1d0..950a742 100644 --- a/maps/random/slopes.json +++ b/maps/random/slopes.json @@ -5,6 +5,7 @@ "Description" : "Teams are placed in opposite sides, surrounded by plateaus with plenty of wood and fish from lakes.", "Preview" : "slopes.png", "SupportedBiomes": "generic/", + "Keywords": ["badmod"], "CircularMap" : false } } diff --git a/maps/random/wrench.json b/maps/random/wrench.json index 8ed6d4b..b86e0cc 100644 --- a/maps/random/wrench.json +++ b/maps/random/wrench.json @@ -5,6 +5,7 @@ "Description" : "Players start side by side, protected by mountains. Extra minerals on border.", "Preview" : "wrench.png", "SupportedBiomes": "generic/", + "Keywords": ["badmod"], "CircularMap" : true } } diff --git a/maps/random/wrench_fixed.json b/maps/random/wrench_fixed.json index e2e28ac..d687b47 100644 --- a/maps/random/wrench_fixed.json +++ b/maps/random/wrench_fixed.json @@ -5,6 +5,7 @@ "Description" : "Players start side by side, protected by mountains, extra minerals on border. Positions defined by players", "Preview" : "wrench.png", "SupportedBiomes": "generic/", + "Keywords": ["badmod"], "CircularMap" : true } } diff --git a/mod.json b/mod.json index daa976d..7df8ffa 100644 --- a/mod.json +++ b/mod.json @@ -1,9 +1,9 @@ { - "name": "balanced-maps", - "version": "0.21.0", - "label": "Balanced maps", + "name": "balanced-maps-2", + "version": "0.25.0999", + "label": "Balanced maps 2", "description": "A collection of balanced maps.", - "dependencies": ["0ad=0.0.24"], - "url": "https://github.com/badosu/badmod", + "dependencies": ["0ad=0.0.25"], + "url": "https://github.com/0ad-matters/badmod", "type": "maps" }