mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
Fix eslint indent rule
eslint --no-config-lookup --fix --rule 'indent: ["warn", "tab", { "outerIIFEBody": 0, }]'
Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
@@ -2,7 +2,7 @@ function TestScript1_Init() {}
|
||||
|
||||
TestScript1_Init.prototype.Init = function() {
|
||||
var param = this.template;
|
||||
// print("# ",uneval(param),"\n");
|
||||
// print("# ",uneval(param),"\n");
|
||||
if (param)
|
||||
this.x = (+param.x) + (+param.y._string) + (+param.y.z['@w']) + (+param.y.z.a);
|
||||
else
|
||||
|
||||
@@ -78,31 +78,31 @@ function parseCmdLineArgs(settings, cmdLineArgs)
|
||||
{
|
||||
switch (cmdLineArgs['autostart-visibility'])
|
||||
{
|
||||
case 'revealed':
|
||||
settings.mapExploration.setAllied(true);
|
||||
settings.mapExploration.setExplored(true);
|
||||
settings.mapExploration.setRevealed(true);
|
||||
break;
|
||||
case 'explored':
|
||||
settings.mapExploration.setAllied(false);
|
||||
settings.mapExploration.setExplored(true);
|
||||
settings.mapExploration.setRevealed(false);
|
||||
break;
|
||||
case 'hidden':
|
||||
settings.mapExploration.setAllied(false);
|
||||
settings.mapExploration.setExplored(false);
|
||||
settings.mapExploration.setRevealed(false);
|
||||
break;
|
||||
case 'allied':
|
||||
settings.mapExploration.setAllied(true);
|
||||
settings.mapExploration.setExplored(false);
|
||||
settings.mapExploration.setRevealed(false);
|
||||
break;
|
||||
case 'allied-explored':
|
||||
settings.mapExploration.setAllied(true);
|
||||
settings.mapExploration.setExplored(true);
|
||||
settings.mapExploration.setRevealed(false);
|
||||
break;
|
||||
case 'revealed':
|
||||
settings.mapExploration.setAllied(true);
|
||||
settings.mapExploration.setExplored(true);
|
||||
settings.mapExploration.setRevealed(true);
|
||||
break;
|
||||
case 'explored':
|
||||
settings.mapExploration.setAllied(false);
|
||||
settings.mapExploration.setExplored(true);
|
||||
settings.mapExploration.setRevealed(false);
|
||||
break;
|
||||
case 'hidden':
|
||||
settings.mapExploration.setAllied(false);
|
||||
settings.mapExploration.setExplored(false);
|
||||
settings.mapExploration.setRevealed(false);
|
||||
break;
|
||||
case 'allied':
|
||||
settings.mapExploration.setAllied(true);
|
||||
settings.mapExploration.setExplored(false);
|
||||
settings.mapExploration.setRevealed(false);
|
||||
break;
|
||||
case 'allied-explored':
|
||||
settings.mapExploration.setAllied(true);
|
||||
settings.mapExploration.setExplored(true);
|
||||
settings.mapExploration.setRevealed(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -419,12 +419,12 @@ function getGameDescription(initAttributes, mapCache)
|
||||
titles.push({
|
||||
"label": translate("Rated game"),
|
||||
"value": ratingDescription
|
||||
});
|
||||
});
|
||||
else if (g_IsNetworked && Engine.HasXmppClient())
|
||||
titles.push({
|
||||
"label": translate("Rated game"),
|
||||
"value": initAttributes.settings.RatingEnabled === true ? ratingDescription : translateWithContext("game setup option", "disabled")
|
||||
});
|
||||
});
|
||||
|
||||
return titles.map(title => sprintf(translate("%(label)s %(details)s"), {
|
||||
"label": coloredText(title.label, g_DescriptionHighlight),
|
||||
|
||||
@@ -98,17 +98,17 @@ function getMismatchMessage(mismatchType, clientMismatchInfo, serverMismatchInfo
|
||||
{
|
||||
switch (mismatchType)
|
||||
{
|
||||
case "engine": return sprintf(translate("Different engine versions detected client version: %(clientMismatch)s server version: %(serverMismatch)s"), {
|
||||
"clientMismatch": clientMismatchInfo,
|
||||
"serverMismatch": serverMismatchInfo
|
||||
});
|
||||
case "mod": return sprintf(translate("Different mods enabled, or mods enabled in a different order. Client mod: '%(clientMismatch)s' Server mod: '%(serverMismatch)s'"), {
|
||||
"clientMismatch": clientMismatchInfo,
|
||||
"serverMismatch": serverMismatchInfo
|
||||
});
|
||||
default: return sprintf(translate("Unrecognized handshake mismatch type: %(mismatchType)s"), {
|
||||
"mismatchType": mismatchType
|
||||
});
|
||||
case "engine": return sprintf(translate("Different engine versions detected client version: %(clientMismatch)s server version: %(serverMismatch)s"), {
|
||||
"clientMismatch": clientMismatchInfo,
|
||||
"serverMismatch": serverMismatchInfo
|
||||
});
|
||||
case "mod": return sprintf(translate("Different mods enabled, or mods enabled in a different order. Client mod: '%(clientMismatch)s' Server mod: '%(serverMismatch)s'"), {
|
||||
"clientMismatch": clientMismatchInfo,
|
||||
"serverMismatch": serverMismatchInfo
|
||||
});
|
||||
default: return sprintf(translate("Unrecognized handshake mismatch type: %(mismatchType)s"), {
|
||||
"mismatchType": mismatchType
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1248,14 +1248,14 @@ function getTemplateViewerOnClickTooltip()
|
||||
*/
|
||||
function abbreviateLargeNumbers(number)
|
||||
{
|
||||
if (number >= 1e6)
|
||||
return Math.floor(number / 1e6) + translateWithContext("One letter abbreviation for million", 'M');
|
||||
if (number >= 1e6)
|
||||
return Math.floor(number / 1e6) + translateWithContext("One letter abbreviation for million", 'M');
|
||||
|
||||
if (number >= 1e5)
|
||||
return Math.floor(number / 1e3) + translateWithContext("One letter abbreviation for thousand", 'k');
|
||||
if (number >= 1e5)
|
||||
return Math.floor(number / 1e3) + translateWithContext("One letter abbreviation for thousand", 'k');
|
||||
|
||||
if (number >= 1e4)
|
||||
return (number / 1e3).toFixed(1).replace(/\.0$/, '') + translateWithContext("One letter abbreviation for thousand", 'k');
|
||||
if (number >= 1e4)
|
||||
return (number / 1e3).toFixed(1).replace(/\.0$/, '') + translateWithContext("One letter abbreviation for thousand", 'k');
|
||||
|
||||
return number;
|
||||
return number;
|
||||
}
|
||||
|
||||
@@ -92,8 +92,8 @@ class GameSettingsController
|
||||
if (initData?.gameSettings)
|
||||
this.persistentMatchSettings.enabled = !!initData.gameSettings?.usePersistence;
|
||||
const settings = initData?.gameSettings || this.persistentMatchSettings.loadFile();
|
||||
if (settings)
|
||||
this.parseSettings(settings, true);
|
||||
if (settings)
|
||||
this.parseSettings(settings, true);
|
||||
}
|
||||
} catch(err) {
|
||||
error("There was an error loading game settings. You may need to disable persistent match settings.");
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ class GameSettingControlManager
|
||||
this.gameSettingControls[victoryCondition.Name] =
|
||||
new VictoryConditionCheckbox(
|
||||
victoryCondition, this, getCategory(victoryCondition.Name), undefined,
|
||||
setupWindow, isSavedGame);
|
||||
setupWindow, isSavedGame);
|
||||
|
||||
this.playerSettingControlManagers = Array.from(
|
||||
new Array(g_MaxPlayers),
|
||||
|
||||
@@ -120,8 +120,8 @@ class HotkeysPage
|
||||
{
|
||||
let hotkey = hotkeyList.list_data[hotkeyList.hovered];
|
||||
hotkeyList.tooltip = this.metadata.hotkeys[hotkey]?.desc ?
|
||||
translateWithContext("hotkey metadata", this.metadata.hotkeys[hotkey]?.desc) :
|
||||
translate(this.UnavailableTooltipString);
|
||||
translateWithContext("hotkey metadata", this.metadata.hotkeys[hotkey]?.desc) :
|
||||
translate(this.UnavailableTooltipString);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,20 +10,20 @@ class MapBrowserPageControls
|
||||
|
||||
this.setupButtons();
|
||||
|
||||
const alignmentHelper = new AlignmentHelper("max");
|
||||
const labelMargin = 5;
|
||||
const alignmentHelper = new AlignmentHelper("max");
|
||||
const labelMargin = 5;
|
||||
|
||||
this.mapBrowserSearchBoxLabel = Engine.GetGUIObjectByName("mapBrowserSearchBoxLabel");
|
||||
this.mapBrowserSearchBoxControl = Engine.GetGUIObjectByName("mapBrowserSearchBoxControl");
|
||||
alignmentHelper.setObject(this.mapBrowserSearchBoxControl, "left", this.mapBrowserSearchBoxLabel.size.right + labelMargin);
|
||||
alignmentHelper.setObject(this.mapBrowserSearchBoxControl, "left", this.mapBrowserSearchBoxLabel.size.right + labelMargin);
|
||||
|
||||
this.mapBrowserMapTypeLabel = Engine.GetGUIObjectByName("mapBrowserMapTypeLabel");
|
||||
this.mapBrowserMapTypeControl = Engine.GetGUIObjectByName("mapBrowserMapTypeControl");
|
||||
alignmentHelper.setObject(this.mapBrowserMapTypeControl, "left", this.mapBrowserMapTypeLabel.size.right + labelMargin);
|
||||
alignmentHelper.setObject(this.mapBrowserMapTypeControl, "left", this.mapBrowserMapTypeLabel.size.right + labelMargin);
|
||||
|
||||
this.mapBrowserMapFilterLabel = Engine.GetGUIObjectByName("mapBrowserMapFilterLabel");
|
||||
this.mapBrowserMapFilterControl = Engine.GetGUIObjectByName("mapBrowserMapFilterControl");
|
||||
alignmentHelper.setObject(this.mapBrowserMapFilterControl, "left", this.mapBrowserMapFilterLabel.size.right + labelMargin);
|
||||
alignmentHelper.setObject(this.mapBrowserMapFilterControl, "left", this.mapBrowserMapFilterLabel.size.right + labelMargin);
|
||||
}
|
||||
|
||||
setupButtons()
|
||||
@@ -68,16 +68,16 @@ class MapBrowserPageControls
|
||||
}
|
||||
|
||||
static Captions =
|
||||
{
|
||||
"close":
|
||||
{
|
||||
"close":
|
||||
{
|
||||
"caption": translate("Close"),
|
||||
"tooltip": translate("%(hotkey)s: Close map browser.")
|
||||
},
|
||||
"cancel":
|
||||
"cancel":
|
||||
{
|
||||
"caption": translate("Cancel"),
|
||||
"tooltip": translate("%(hotkey)s: Close map browser and discard the selection.")
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -130,11 +130,11 @@ var g_OptionType = {
|
||||
sprintf(
|
||||
option.min !== undefined && option.max !== undefined ?
|
||||
translateWithContext("option number", "Min: %(min)s, Max: %(max)s") :
|
||||
option.min !== undefined && option.max === undefined ?
|
||||
translateWithContext("option number", "Min: %(min)s") :
|
||||
option.min === undefined && option.max !== undefined ?
|
||||
translateWithContext("option number", "Max: %(max)s") :
|
||||
"",
|
||||
option.min !== undefined && option.max === undefined ?
|
||||
translateWithContext("option number", "Min: %(min)s") :
|
||||
option.min === undefined && option.max !== undefined ?
|
||||
translateWithContext("option number", "Max: %(max)s") :
|
||||
"",
|
||||
{
|
||||
"min": option.min,
|
||||
"max": option.max
|
||||
|
||||
@@ -36,8 +36,8 @@ var g_MainMenuItems = [
|
||||
"caption": translate("Tips and Tricks"),
|
||||
"tooltip": translate("Discover simple tips, tricks, and game mechanics."),
|
||||
"onPress": Engine.OpenChildPage.bind(null, "page_tips.xml", {
|
||||
"tipScrolling": true
|
||||
})
|
||||
"tipScrolling": true
|
||||
})
|
||||
},
|
||||
{
|
||||
"caption": translate("Structure Tree"),
|
||||
@@ -197,24 +197,24 @@ var g_MainMenuItems = [
|
||||
"caption": translate("Join Game"),
|
||||
"tooltip": translate("Joining an existing multiplayer game."),
|
||||
"onPress": Engine.OpenChildPage.bind(null, "page_gamesetup_mp.xml", {
|
||||
"multiplayerGameType": "join"
|
||||
})
|
||||
"multiplayerGameType": "join"
|
||||
})
|
||||
},
|
||||
{
|
||||
"caption": translate("Host New Game"),
|
||||
"tooltip": translate("Host a new multiplayer game."),
|
||||
"onPress": Engine.OpenChildPage.bind(null, "page_gamesetup_mp.xml", {
|
||||
"multiplayerGameType": "host",
|
||||
"loadSavedGame": false
|
||||
})
|
||||
"multiplayerGameType": "host",
|
||||
"loadSavedGame": false
|
||||
})
|
||||
},
|
||||
{
|
||||
"caption": translate("Host Saved Game"),
|
||||
"tooltip": translate("Continue playing a game from a savegame."),
|
||||
"onPress": Engine.OpenChildPage.bind(null, "page_gamesetup_mp.xml", {
|
||||
"multiplayerGameType": "host",
|
||||
"loadSavedGame": true
|
||||
})
|
||||
"multiplayerGameType": "host",
|
||||
"loadSavedGame": true
|
||||
})
|
||||
},
|
||||
{
|
||||
"caption": translate("Replays"),
|
||||
|
||||
@@ -6,10 +6,10 @@ class CivInfoPage extends ReferencePage
|
||||
|
||||
this.civSelection = new CivSelectDropdown(this.civData);
|
||||
if (!this.civSelection.hasCivs())
|
||||
{
|
||||
this.closePage();
|
||||
return;
|
||||
}
|
||||
{
|
||||
this.closePage();
|
||||
return;
|
||||
}
|
||||
this.civSelection.registerHandler(this.selectCiv.bind(this));
|
||||
|
||||
this.CivEmblem = Engine.GetGUIObjectByName("civEmblem");
|
||||
|
||||
@@ -11,9 +11,9 @@ class EntityBox
|
||||
static setViewerOnPress(guiObject, templateName, civCode)
|
||||
{
|
||||
let viewerFunc = Engine.OpenChildPage.bind(null, "page_viewer.xml", {
|
||||
"templateName": templateName,
|
||||
"civ": civCode
|
||||
});
|
||||
"templateName": templateName,
|
||||
"civ": civCode
|
||||
});
|
||||
guiObject.onPress = viewerFunc;
|
||||
guiObject.onPressRight = viewerFunc;
|
||||
}
|
||||
|
||||
@@ -115,9 +115,9 @@ class DiplomacyColors
|
||||
// Players see colors depending on diplomacy
|
||||
this.displayedPlayerColors[i] =
|
||||
g_ViewedPlayer == i ? this.getDiplomacyColor("self") :
|
||||
g_Players[g_ViewedPlayer].isAlly[i] ? this.getDiplomacyColor("ally") :
|
||||
g_Players[g_ViewedPlayer].isNeutral[i] ? this.getDiplomacyColor("neutral") :
|
||||
this.getDiplomacyColor("enemy");
|
||||
g_Players[g_ViewedPlayer].isAlly[i] ? this.getDiplomacyColor("ally") :
|
||||
g_Players[g_ViewedPlayer].isNeutral[i] ? this.getDiplomacyColor("neutral") :
|
||||
this.getDiplomacyColor("enemy");
|
||||
|
||||
this.displayedPlayerColors[0] = g_Players[0].color;
|
||||
}
|
||||
|
||||
@@ -94,9 +94,9 @@ class Menu
|
||||
|
||||
let maxOffset =
|
||||
this.endPosition + (
|
||||
this.isOpen ?
|
||||
-this.menuButtonPanel.size.bottom :
|
||||
+this.menuButtonPanel.size.top);
|
||||
this.isOpen ?
|
||||
-this.menuButtonPanel.size.bottom :
|
||||
+this.menuButtonPanel.size.top);
|
||||
|
||||
|
||||
if (maxOffset <= 0)
|
||||
|
||||
@@ -46,10 +46,10 @@ class ChatAddressees
|
||||
|
||||
let addressees = this.AddresseeTypes.filter(
|
||||
addresseeType => addresseeType.isSelectable()).map(
|
||||
addresseeType => ({
|
||||
"label": translateWithContext("chat addressee", addresseeType.label),
|
||||
"cmd": addresseeType.command
|
||||
}));
|
||||
addresseeType => ({
|
||||
"label": translateWithContext("chat addressee", addresseeType.label),
|
||||
"cmd": addresseeType.command
|
||||
}));
|
||||
|
||||
// Add playernames for private messages
|
||||
let guids = sortGUIDsByPlayerID();
|
||||
|
||||
+3
-3
@@ -54,9 +54,9 @@ DiplomacyDialogPlayerControl.prototype.DiplomacyPlayerText = class
|
||||
this.playerID == g_ViewedPlayer ? "" :
|
||||
g_Players[this.playerID].isAlly[g_ViewedPlayer] ?
|
||||
translate(this.Ally) :
|
||||
g_Players[this.playerID].isNeutral[g_ViewedPlayer] ?
|
||||
translate(this.Neutral) :
|
||||
translate(this.Enemy);
|
||||
g_Players[this.playerID].isNeutral[g_ViewedPlayer] ?
|
||||
translate(this.Neutral) :
|
||||
translate(this.Enemy);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1502,8 +1502,8 @@ function addTrainingToQueue(selection, trainEntType, playerState)
|
||||
}
|
||||
|
||||
if (decrement || Engine.GuiInterfaceCall("GetNeededResources", {
|
||||
"cost": multiplyEntityCosts(template, getBatchTrainingSize())
|
||||
}))
|
||||
"cost": multiplyEntityCosts(template, getBatchTrainingSize())
|
||||
}))
|
||||
return;
|
||||
|
||||
inputState = INPUT_BATCHTRAINING;
|
||||
|
||||
@@ -379,7 +379,7 @@ function updateTutorial(notification)
|
||||
let notificationText =
|
||||
notification.instructions.reduce((instructions, item) =>
|
||||
instructions + (typeof item == "string" ? translate(item) : colorizeHotkey(translate(item.text), item.hotkey)),
|
||||
"");
|
||||
"");
|
||||
|
||||
Engine.GetGUIObjectByName("tutorialText").caption = g_TutorialMessages.concat(setStringTags(notificationText, g_TutorialNewMessageTags)).join("\n");
|
||||
g_TutorialMessages.push(notificationText);
|
||||
|
||||
@@ -102,9 +102,9 @@ class CounterManager
|
||||
"order":
|
||||
this.selectedOrder == 0 ?
|
||||
translate("Unordered") :
|
||||
this.selectedOrder == 1 ?
|
||||
translate("Descending") :
|
||||
translate("Ascending")
|
||||
this.selectedOrder == 1 ?
|
||||
translate("Descending") :
|
||||
translate("Ascending")
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -523,22 +523,22 @@ function initGUILabels()
|
||||
Engine.GetGUIObjectByName("summaryText").caption =
|
||||
g_GameData.gui.isInGame ?
|
||||
translate("Current Scores") :
|
||||
g_GameData.gui.isReplay ?
|
||||
translate("Scores at the end of the game.") :
|
||||
g_GameData.gui.disconnected ?
|
||||
translate("You have been disconnected.") :
|
||||
!assignedState ?
|
||||
translate("You have left the game.") :
|
||||
assignedState.state == "won" ?
|
||||
translate("You have won the battle!") :
|
||||
assignedState.state == "defeated" ?
|
||||
translate("You have been defeated…") :
|
||||
translate("You have abandoned the game.");
|
||||
g_GameData.gui.isReplay ?
|
||||
translate("Scores at the end of the game.") :
|
||||
g_GameData.gui.disconnected ?
|
||||
translate("You have been disconnected.") :
|
||||
!assignedState ?
|
||||
translate("You have left the game.") :
|
||||
assignedState.state == "won" ?
|
||||
translate("You have won the battle!") :
|
||||
assignedState.state == "defeated" ?
|
||||
translate("You have been defeated…") :
|
||||
translate("You have abandoned the game.");
|
||||
|
||||
Engine.GetGUIObjectByName("timeElapsed").caption = sprintf(
|
||||
translate("Game time elapsed: %(time)s"), {
|
||||
"time": timeToString(g_GameData.sim.timeElapsed)
|
||||
});
|
||||
});
|
||||
|
||||
let mapType = g_Settings.MapTypes.find(type => type.Name == g_GameData.sim.mapSettings.mapType);
|
||||
let mapSize = g_Settings.MapSizes.find(size => size.Tiles == g_GameData.sim.mapSettings.Size || 0);
|
||||
|
||||
@@ -75,7 +75,7 @@ function* GenerateMap(mapSettings) {
|
||||
throw new Error("Too many teams for " + pattern + ", use circle or make two teams.");
|
||||
pattern = "circle";
|
||||
}
|
||||
startAngle = 1.600;
|
||||
startAngle = 1.600;
|
||||
}
|
||||
if ((pattern === "circle")){
|
||||
startAngle = 2.600;
|
||||
@@ -119,53 +119,53 @@ function* GenerateMap(mapSettings) {
|
||||
undefined);
|
||||
|
||||
placePlayerBases({
|
||||
"PlayerPlacement": [playerIDs, playerPosition],
|
||||
"PlayerTileClass": clPlayer,
|
||||
"BaseResourceClass": clBaseResource,
|
||||
"CityPatch": {
|
||||
"outerTerrain": tRoadWild,
|
||||
"innerTerrain": tRoad
|
||||
},
|
||||
"StartingAnimal": {
|
||||
},
|
||||
"Berries": {
|
||||
"template": oFruitBush
|
||||
},
|
||||
"Mines": {
|
||||
"types": [
|
||||
{ "template": oMetalLarge },
|
||||
{ "template": oStoneLarge }
|
||||
]
|
||||
},
|
||||
"Trees": {
|
||||
"template": oTree1,
|
||||
"count": 2
|
||||
},
|
||||
"Decoratives": {
|
||||
"template": aGrassShort
|
||||
}
|
||||
"PlayerPlacement": [playerIDs, playerPosition],
|
||||
"PlayerTileClass": clPlayer,
|
||||
"BaseResourceClass": clBaseResource,
|
||||
"CityPatch": {
|
||||
"outerTerrain": tRoadWild,
|
||||
"innerTerrain": tRoad
|
||||
},
|
||||
"StartingAnimal": {
|
||||
},
|
||||
"Berries": {
|
||||
"template": oFruitBush
|
||||
},
|
||||
"Mines": {
|
||||
"types": [
|
||||
{ "template": oMetalLarge },
|
||||
{ "template": oStoneLarge }
|
||||
]
|
||||
},
|
||||
"Trees": {
|
||||
"template": oTree1,
|
||||
"count": 2
|
||||
},
|
||||
"Decoratives": {
|
||||
"template": aGrassShort
|
||||
}
|
||||
});
|
||||
|
||||
yield 30;
|
||||
|
||||
for (let m = 0; m < randIntInclusive(20, 34); ++m)
|
||||
{
|
||||
let elevRand = randIntInclusive(4, 12);
|
||||
createArea(
|
||||
new ChainPlacer(
|
||||
7,
|
||||
15,
|
||||
Math.floor(scaleByMapSize(15, 20)),
|
||||
Infinity,
|
||||
new Vector2D(fractionToTiles(randFloat(0, 1)), fractionToTiles(randFloat(0, 1))),
|
||||
0,
|
||||
[Math.floor(fractionToTiles(0.01))]),
|
||||
[
|
||||
new LayeredPainter([tHill,tMainTerrain], [Math.floor(elevRand / 3), 40]),
|
||||
new SmoothElevationPainter(ELEVATION_SET, elevRand, Math.floor(elevRand / 3)),
|
||||
new TileClassPainter(clHill)
|
||||
],
|
||||
[avoidClasses(clPlayer, 16),stayClasses(clLand, 28)]);
|
||||
let elevRand = randIntInclusive(4, 12);
|
||||
createArea(
|
||||
new ChainPlacer(
|
||||
7,
|
||||
15,
|
||||
Math.floor(scaleByMapSize(15, 20)),
|
||||
Infinity,
|
||||
new Vector2D(fractionToTiles(randFloat(0, 1)), fractionToTiles(randFloat(0, 1))),
|
||||
0,
|
||||
[Math.floor(fractionToTiles(0.01))]),
|
||||
[
|
||||
new LayeredPainter([tHill,tMainTerrain], [Math.floor(elevRand / 3), 40]),
|
||||
new SmoothElevationPainter(ELEVATION_SET, elevRand, Math.floor(elevRand / 3)),
|
||||
new TileClassPainter(clHill)
|
||||
],
|
||||
[avoidClasses(clPlayer, 16),stayClasses(clLand, 28)]);
|
||||
}
|
||||
|
||||
const nonMountainPosition = Vector2D.add(mapCenter, new Vector2D(0, fractionToTiles(0.10)).rotate(startAngle).rotate(Math.PI)).round();
|
||||
@@ -260,10 +260,10 @@ function* GenerateMap(mapSettings) {
|
||||
|
||||
g_Map.log("Creating sparse hills stone mines");
|
||||
createBalancedStoneMines(
|
||||
oStoneSmall,
|
||||
oStoneSmall,
|
||||
clRock,
|
||||
[stayClasses(clLand, 8), avoidClasses(clForest, 1, clPlayer, 16, clMountain, 8, clRock, 10)]
|
||||
oStoneSmall,
|
||||
oStoneSmall,
|
||||
clRock,
|
||||
[stayClasses(clLand, 8), avoidClasses(clForest, 1, clPlayer, 16, clMountain, 8, clRock, 10)]
|
||||
);
|
||||
|
||||
g_Map.log("Creating sparse hills metal mines");
|
||||
|
||||
@@ -308,7 +308,7 @@ Trigger.prototype.UpdateCelticRitual = function()
|
||||
|
||||
let animations = ritualAnimations[
|
||||
cmpIdentity.HasClass("Healer") ? "healer" :
|
||||
cmpIdentity.HasClass("Female") ? "female" : "male"];
|
||||
cmpIdentity.HasClass("Female") ? "female" : "male"];
|
||||
|
||||
let cmpVisual = Engine.QueryInterface(ent, IID_Visual);
|
||||
if (!cmpVisual)
|
||||
|
||||
@@ -108,42 +108,42 @@ function* GenerateMap(mapSettings)
|
||||
yield 20;
|
||||
|
||||
|
||||
for (let m = 0; m < randIntInclusive(40, 90); ++m) {
|
||||
let elevRand = randIntInclusive(6, 12);
|
||||
createArea(
|
||||
new ChainPlacer(
|
||||
12,
|
||||
28,
|
||||
Math.floor(scaleByMapSize(5, 30)),
|
||||
Infinity,
|
||||
new Vector2D(fractionToTiles(randFloat(0, 1)), fractionToTiles(randFloat(0, 1))),
|
||||
0,
|
||||
[Math.floor(fractionToTiles(0.01))]),
|
||||
[
|
||||
new LayeredPainter([tHill, tMainTerrain, tCliff], [Math.floor(elevRand / 5), 40]),
|
||||
new SmoothElevationPainter(ELEVATION_SET, elevRand, randIntInclusive(18, 35)),
|
||||
new TileClassPainter(clHill)
|
||||
],
|
||||
[avoidClasses(clPlayer, 34, clHill, 8)]);
|
||||
}
|
||||
for (let m = 0; m < randIntInclusive(60, 100); ++m) {
|
||||
const elevRand = randIntInclusive(14, 36);
|
||||
createArea(
|
||||
new ChainPlacer(
|
||||
10,
|
||||
20,
|
||||
Math.floor(scaleByMapSize(8, 15)),
|
||||
Infinity,
|
||||
new Vector2D(fractionToTiles(randFloat(0, 1)), fractionToTiles(randFloat(0, 1))),
|
||||
0,
|
||||
[Math.floor(fractionToTiles(0.01))]),
|
||||
[
|
||||
new LayeredPainter([tCliff, tHill,tMainTerrain], [Math.floor(elevRand / 8), 40]),
|
||||
new SmoothElevationPainter(ELEVATION_SET, elevRand, randIntInclusive(18, 25)),
|
||||
new TileClassPainter(clHill)
|
||||
],
|
||||
[avoidClasses(clBaseResource, 2, clPlayer, 30), stayClasses(clHill, 1)]);
|
||||
}
|
||||
for (let m = 0; m < randIntInclusive(40, 90); ++m) {
|
||||
let elevRand = randIntInclusive(6, 12);
|
||||
createArea(
|
||||
new ChainPlacer(
|
||||
12,
|
||||
28,
|
||||
Math.floor(scaleByMapSize(5, 30)),
|
||||
Infinity,
|
||||
new Vector2D(fractionToTiles(randFloat(0, 1)), fractionToTiles(randFloat(0, 1))),
|
||||
0,
|
||||
[Math.floor(fractionToTiles(0.01))]),
|
||||
[
|
||||
new LayeredPainter([tHill, tMainTerrain, tCliff], [Math.floor(elevRand / 5), 40]),
|
||||
new SmoothElevationPainter(ELEVATION_SET, elevRand, randIntInclusive(18, 35)),
|
||||
new TileClassPainter(clHill)
|
||||
],
|
||||
[avoidClasses(clPlayer, 34, clHill, 8)]);
|
||||
}
|
||||
for (let m = 0; m < randIntInclusive(60, 100); ++m) {
|
||||
const elevRand = randIntInclusive(14, 36);
|
||||
createArea(
|
||||
new ChainPlacer(
|
||||
10,
|
||||
20,
|
||||
Math.floor(scaleByMapSize(8, 15)),
|
||||
Infinity,
|
||||
new Vector2D(fractionToTiles(randFloat(0, 1)), fractionToTiles(randFloat(0, 1))),
|
||||
0,
|
||||
[Math.floor(fractionToTiles(0.01))]),
|
||||
[
|
||||
new LayeredPainter([tCliff, tHill,tMainTerrain], [Math.floor(elevRand / 8), 40]),
|
||||
new SmoothElevationPainter(ELEVATION_SET, elevRand, randIntInclusive(18, 25)),
|
||||
new TileClassPainter(clHill)
|
||||
],
|
||||
[avoidClasses(clBaseResource, 2, clPlayer, 30), stayClasses(clHill, 1)]);
|
||||
}
|
||||
|
||||
const [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1));
|
||||
createDefaultForests(
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
function setupBiome_aegean()
|
||||
{
|
||||
[g_Gaia.tree1, g_Gaia.tree2] = pickRandom([[
|
||||
"gaia/tree/cypress_wild",
|
||||
"gaia/tree/pine_maritime_short",
|
||||
"gaia/tree/cretan_date_palm_tall"
|
||||
]]);
|
||||
"gaia/tree/cypress_wild",
|
||||
"gaia/tree/pine_maritime_short",
|
||||
"gaia/tree/cretan_date_palm_tall"
|
||||
]]);
|
||||
|
||||
g_Gaia.tree3 = pickRandom([
|
||||
"gaia/tree/olive",
|
||||
|
||||
@@ -9,8 +9,8 @@ function setupBiome_nubia()
|
||||
]);
|
||||
|
||||
g_Gaia.tree3 = pickRandom([
|
||||
"gaia/tree/baobab_4_dead",
|
||||
"gaia/tree/baobab_3_mature"
|
||||
"gaia/tree/baobab_4_dead",
|
||||
"gaia/tree/baobab_3_mature"
|
||||
]);
|
||||
|
||||
[g_Gaia.tree4, g_Gaia.tree5] = pickRandom([
|
||||
|
||||
@@ -273,7 +273,7 @@ function createVolcano(position, tileClass, terrainTexture, lavaTextures, smoke,
|
||||
clLava,
|
||||
position),
|
||||
0,
|
||||
stayClasses(tileClass, 1));
|
||||
stayClasses(tileClass, 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -575,7 +575,7 @@ function partitionPlayers(playerIDs)
|
||||
east.length > west.length ?
|
||||
[east, west.concat(team)] :
|
||||
[east.concat(team), west],
|
||||
[[], []]);
|
||||
[[], []]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -619,18 +619,18 @@ function playerPlacementByPattern(patternName, distance = undefined, groupedDist
|
||||
|
||||
switch (patternName)
|
||||
{
|
||||
case "circle":
|
||||
return playerPlacementCircle(distance, angle, center).slice(0, 2);
|
||||
case "river":
|
||||
return playerPlacementRiver(angle, distance, center);
|
||||
case "groupedLines":
|
||||
return placeLine(getTeamsArray(), distance, groupedDistance, angle);
|
||||
case "stronghold":
|
||||
return placeStronghold(getTeamsArray(), distance, groupedDistance, angle);
|
||||
case "randomGroup":
|
||||
return playerPlacementRandom(getPlayerIDs(), undefined);
|
||||
default:
|
||||
throw new Error("Unknown placement pattern: " + patternName);
|
||||
case "circle":
|
||||
return playerPlacementCircle(distance, angle, center).slice(0, 2);
|
||||
case "river":
|
||||
return playerPlacementRiver(angle, distance, center);
|
||||
case "groupedLines":
|
||||
return placeLine(getTeamsArray(), distance, groupedDistance, angle);
|
||||
case "stronghold":
|
||||
return placeStronghold(getTeamsArray(), distance, groupedDistance, angle);
|
||||
case "randomGroup":
|
||||
return playerPlacementRandom(getPlayerIDs(), undefined);
|
||||
default:
|
||||
throw new Error("Unknown placement pattern: " + patternName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,11 +56,11 @@ function getObstructionSize(templateName, margin = 0)
|
||||
obstruction.Static ?
|
||||
new Vector2D(obstruction.Static["@depth"], obstruction.Static["@width"]) :
|
||||
// Used for gates, should consider the position too
|
||||
obstruction.Obstructions ?
|
||||
new Vector2D(
|
||||
Object.keys(obstruction.Obstructions).reduce((depth, key) => Math.max(depth, +obstruction.Obstructions[key]["@depth"]), 0),
|
||||
Object.keys(obstruction.Obstructions).reduce((width, key) => width + +obstruction.Obstructions[key]["@width"], 0)) :
|
||||
new Vector2D(0, 0);
|
||||
obstruction.Obstructions ?
|
||||
new Vector2D(
|
||||
Object.keys(obstruction.Obstructions).reduce((depth, key) => Math.max(depth, +obstruction.Obstructions[key]["@depth"]), 0),
|
||||
Object.keys(obstruction.Obstructions).reduce((width, key) => width + +obstruction.Obstructions[key]["@width"], 0)) :
|
||||
new Vector2D(0, 0);
|
||||
|
||||
return obstructionSize.div(TERRAIN_TILE_SIZE).add(new Vector2D(2, 2).mult(margin));
|
||||
}
|
||||
|
||||
@@ -14,10 +14,10 @@ function HeightPlacer(mode, minElevation, maxElevation)
|
||||
{
|
||||
this.withinHeightRange =
|
||||
mode == Elevation_ExcludeMin_ExcludeMax ? position => g_Map.getHeight(position) > minElevation && g_Map.getHeight(position) < maxElevation :
|
||||
mode == Elevation_IncludeMin_ExcludeMax ? position => g_Map.getHeight(position) >= minElevation && g_Map.getHeight(position) < maxElevation :
|
||||
mode == Elevation_ExcludeMin_IncludeMax ? position => g_Map.getHeight(position) > minElevation && g_Map.getHeight(position) <= maxElevation :
|
||||
mode == Elevation_IncludeMin_IncludeMax ? position => g_Map.getHeight(position) >= minElevation && g_Map.getHeight(position) <= maxElevation :
|
||||
undefined;
|
||||
mode == Elevation_IncludeMin_ExcludeMax ? position => g_Map.getHeight(position) >= minElevation && g_Map.getHeight(position) < maxElevation :
|
||||
mode == Elevation_ExcludeMin_IncludeMax ? position => g_Map.getHeight(position) > minElevation && g_Map.getHeight(position) <= maxElevation :
|
||||
mode == Elevation_IncludeMin_IncludeMax ? position => g_Map.getHeight(position) >= minElevation && g_Map.getHeight(position) <= maxElevation :
|
||||
undefined;
|
||||
|
||||
if (!this.withinHeightRange)
|
||||
throw new Error("Invalid HeightPlacer mode: " + mode);
|
||||
|
||||
@@ -1090,24 +1090,24 @@ function findClearLine(bluffArea, angle)
|
||||
let y;
|
||||
switch (angle)
|
||||
{
|
||||
case 0:
|
||||
offset = new Vector2D(-1, -1);
|
||||
y = corners.max.y;
|
||||
break;
|
||||
case 1:
|
||||
offset = new Vector2D(1, -1);
|
||||
y = corners.max.y;
|
||||
break;
|
||||
case 2:
|
||||
offset = new Vector2D(1, 1);
|
||||
y = corners.min.y;
|
||||
break;
|
||||
case 3:
|
||||
offset = new Vector2D(-1, 1);
|
||||
y = corners.min.y;
|
||||
break;
|
||||
default:
|
||||
throw new Error("Unknown angle " + angle);
|
||||
case 0:
|
||||
offset = new Vector2D(-1, -1);
|
||||
y = corners.max.y;
|
||||
break;
|
||||
case 1:
|
||||
offset = new Vector2D(1, -1);
|
||||
y = corners.max.y;
|
||||
break;
|
||||
case 2:
|
||||
offset = new Vector2D(1, 1);
|
||||
y = corners.min.y;
|
||||
break;
|
||||
case 3:
|
||||
offset = new Vector2D(-1, 1);
|
||||
y = corners.min.y;
|
||||
break;
|
||||
default:
|
||||
throw new Error("Unknown angle " + angle);
|
||||
}
|
||||
|
||||
let clearLine;
|
||||
|
||||
@@ -106,7 +106,7 @@ Trigger.prototype.WonderVictoryStartTimer = function(ent, player)
|
||||
"players": [player],
|
||||
"translateMessage": true
|
||||
},
|
||||
wonderDuration)
|
||||
wonderDuration)
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Trigger.prototype.SpawnAndAttack = function()
|
||||
{
|
||||
var intruders = TriggerHelper.SpawnUnitsFromTriggerPoints(
|
||||
pickRandom(["B", "C"]), "units/rome/champion_infantry_swordsman_02", this.attackSize, 0);
|
||||
pickRandom(["B", "C"]), "units/rome/champion_infantry_swordsman_02", this.attackSize, 0);
|
||||
|
||||
for (var origin in intruders)
|
||||
{
|
||||
|
||||
@@ -88,7 +88,7 @@ m.SharedScript.prototype.init = function(state, deserialization)
|
||||
error("AI shared component inconsistent sizes: map=" + this.mapSize + " while territory=" + this.territoryMap.width);
|
||||
this.territoryMap.cellSize = this.mapSize / this.territoryMap.width;
|
||||
|
||||
/*
|
||||
/*
|
||||
let landPassMap = new Uint8Array(this.passabilityMap.data.length);
|
||||
let waterPassMap = new Uint8Array(this.passabilityMap.data.length);
|
||||
let obstructionMaskLand = this.passabilityClasses["default-terrain-only"];
|
||||
|
||||
@@ -459,7 +459,7 @@ PETRA.DefenseManager.prototype.assignDefenders = function(gameState)
|
||||
if (!armiesNeeding[a].army.foeEntities.some(eEnt => {
|
||||
let eEntID = gameState.getEntityById(eEnt);
|
||||
return ent.canAttackTarget(eEntID, PETRA.allowCapture(gameState, ent, eEntID));
|
||||
}))
|
||||
}))
|
||||
continue;
|
||||
|
||||
let dist = API3.SquareVectorDistance(ent.position(), armiesNeeding[a].army.foePosition);
|
||||
|
||||
@@ -328,8 +328,8 @@ BuildingAI.prototype.FireArrows = function()
|
||||
}
|
||||
|
||||
// Add targets to a list.
|
||||
let targets = [];
|
||||
let addTarget = function(target)
|
||||
let targets = [];
|
||||
let addTarget = function(target)
|
||||
{
|
||||
const pref = (cmpAttack.GetPreference(target) ?? 49);
|
||||
targets.push({"entityId": target, "preference": pref});
|
||||
@@ -347,15 +347,15 @@ BuildingAI.prototype.FireArrows = function()
|
||||
for (let target of this.targetUnits)
|
||||
addTarget(target);
|
||||
// Sort targets by preference and then by proximity.
|
||||
targets.sort( (a,b) => {
|
||||
targets.sort( (a,b) => {
|
||||
if (a.preference > b.preference)
|
||||
return 1;
|
||||
else if (a.preference < b.preference)
|
||||
return -1;
|
||||
else if (PositionHelper.DistanceBetweenEntities(this.entity, a.entityId) > PositionHelper.DistanceBetweenEntities(this.entity, b.entityId))
|
||||
return 1;
|
||||
return -1;
|
||||
});
|
||||
return -1;
|
||||
});
|
||||
}
|
||||
else
|
||||
targets = this.focusTargets;
|
||||
@@ -367,10 +367,10 @@ BuildingAI.prototype.FireArrows = function()
|
||||
const range = cmpAttack.GetRange(attackType);
|
||||
const yOrigin = cmpAttack.GetAttackYOrigin(attackType);
|
||||
|
||||
let firedArrows = 0;
|
||||
let firedArrows = 0;
|
||||
let targetIndex = 0;
|
||||
while (firedArrows < arrowsToFire && targetIndex < targets.length)
|
||||
{
|
||||
{
|
||||
|
||||
let selectedTarget = targets[targetIndex].entityId;
|
||||
if (this.CheckTargetVisible(selectedTarget) && cmpObstructionManager.IsInTargetParabolicRange(
|
||||
|
||||
@@ -114,7 +114,7 @@ Identity.prototype.Deserialize = function (data)
|
||||
this.name = data.name;
|
||||
};
|
||||
|
||||
Identity.prototype.Serialize = function()
|
||||
Identity.prototype.Serialize = function()
|
||||
{
|
||||
const result = {
|
||||
"phenotype": this.phenotype,
|
||||
|
||||
@@ -22,7 +22,7 @@ Engine.LoadHelperScript("ValueModification.js");
|
||||
Engine.LoadComponentScript("interfaces/ModifiersManager.js");
|
||||
|
||||
let applyModifierOverride = (key, val, ent) => {
|
||||
return val;
|
||||
return val;
|
||||
}
|
||||
|
||||
AddMock(SYSTEM_ENTITY, IID_ModifiersManager, {
|
||||
@@ -32,8 +32,8 @@ AddMock(SYSTEM_ENTITY, IID_ModifiersManager, {
|
||||
});
|
||||
|
||||
const cmpLoot = ConstructComponent(30, "Loot", {
|
||||
"xp": 35,
|
||||
"metal": 10
|
||||
"xp": 35,
|
||||
"metal": 10
|
||||
});
|
||||
|
||||
TS_ASSERT_EQUALS(cmpLoot.GetResources().xp, undefined);
|
||||
@@ -43,8 +43,8 @@ TS_ASSERT_UNEVAL_EQUALS(cmpLoot.GetResources(), { "food": 0, "metal": 10, "stone
|
||||
TS_ASSERT_EQUALS(cmpLoot.GetXp(), 35);
|
||||
|
||||
const cmpLootNoXp = ConstructComponent(30, "Loot", {
|
||||
"metal": 10,
|
||||
"wood": 20
|
||||
"metal": 10,
|
||||
"wood": 20
|
||||
});
|
||||
|
||||
TS_ASSERT_EQUALS(cmpLootNoXp.GetResources().xp, undefined);
|
||||
@@ -55,13 +55,13 @@ TS_ASSERT_UNEVAL_EQUALS(cmpLootNoXp.GetResources(), { "food": 0, "metal": 10, "s
|
||||
TS_ASSERT_EQUALS(cmpLootNoXp.GetXp(), 0);
|
||||
|
||||
applyModifierOverride = (key, val, ent) => {
|
||||
return key == "Loot/xp" ? 100 : val;
|
||||
return key == "Loot/xp" ? 100 : val;
|
||||
}
|
||||
|
||||
TS_ASSERT_EQUALS(cmpLootNoXp.GetXp(), 100);
|
||||
|
||||
applyModifierOverride = (key, val, ent) => {
|
||||
return key == "Loot/wood" ? 100 : val;
|
||||
return key == "Loot/wood" ? 100 : val;
|
||||
}
|
||||
|
||||
TS_ASSERT_EQUALS(cmpLootNoXp.GetResources().wood, 100);
|
||||
|
||||
@@ -13,7 +13,7 @@ const ownMarket = 6;
|
||||
const otherMarket = 7;
|
||||
|
||||
AddMock(SYSTEM_ENTITY, IID_PlayerManager, {
|
||||
"GetPlayerByID": (i) => i
|
||||
"GetPlayerByID": (i) => i
|
||||
});
|
||||
|
||||
const cmpTrader = ConstructComponent(trader, "Trader", {
|
||||
|
||||
@@ -579,7 +579,7 @@ var g_Commands = {
|
||||
// Only the owner of the garrisonHolder may unload entities from any owners
|
||||
if (!IsOwnedByPlayer(player, garrisonHolder) && !data.controlAllUnits
|
||||
&& player != +cmd.owner)
|
||||
continue;
|
||||
continue;
|
||||
|
||||
if (!cmpGarrisonHolder.UnloadTemplate(cmd.template, cmd.owner, cmd.all))
|
||||
notifyUnloadFailure(player, garrisonHolder);
|
||||
|
||||
Reference in New Issue
Block a user