mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Enable eslint rule 'no-case-declarations'
Enable recommended rule 'no-case-declarations' [1] and manually fix violations. [1] https://eslint.org/docs/latest/rules/no-case-declarations Ref: #8068 Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
parent
cb2717faba
commit
57e72b01ae
7 changed files with 29 additions and 9 deletions
|
|
@ -38,6 +38,7 @@ class AutoStartHost
|
|||
switch (message.type)
|
||||
{
|
||||
case "players":
|
||||
{
|
||||
this.playerAssignments = message.newAssignments;
|
||||
Engine.SendNetworkReady(2);
|
||||
let max = 0;
|
||||
|
|
@ -48,6 +49,7 @@ class AutoStartHost
|
|||
Engine.AssignNetworkPlayer(++max, uid);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "ready":
|
||||
this.playerAssignments[message.guid].status = message.status;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -251,11 +251,13 @@ function resizeGUIObjectToCaption(object, align, margin = {})
|
|||
objectSize.left = object.size.right - width;
|
||||
break;
|
||||
case "center":
|
||||
{
|
||||
const oldWidth = object.size.right - object.size.left;
|
||||
const widthDiff = width - oldWidth;
|
||||
objectSize.right = object.size.right + (widthDiff / 2);
|
||||
objectSize.left = object.size.left - (widthDiff / 2);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -523,6 +523,7 @@ function handleInputBeforeGui(ev, hoveredObject)
|
|||
switch (inputState)
|
||||
{
|
||||
case INPUT_BANDBOXING:
|
||||
{
|
||||
const bandbox = Engine.GetGUIObjectByName("bandbox");
|
||||
switch (ev.type)
|
||||
{
|
||||
|
|
@ -570,6 +571,7 @@ function handleInputBeforeGui(ev, hoveredObject)
|
|||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
case INPUT_UNIT_POSITION:
|
||||
switch (ev.type)
|
||||
|
|
@ -662,6 +664,7 @@ function handleInputBeforeGui(ev, hoveredObject)
|
|||
switch (ev.type)
|
||||
{
|
||||
case "mousemotion":
|
||||
{
|
||||
placementSupport.wallEndPosition = Engine.GetTerrainAtScreenPoint(ev.x, ev.y);
|
||||
|
||||
// Update the structure placement preview, and by extension, the list of snapping candidate entities for both (!)
|
||||
|
|
@ -686,7 +689,7 @@ function handleInputBeforeGui(ev, hoveredObject)
|
|||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
case "mousebuttondown":
|
||||
if (ev.button == SDL_BUTTON_LEFT)
|
||||
{
|
||||
|
|
@ -730,6 +733,7 @@ function handleInputBeforeGui(ev, hoveredObject)
|
|||
switch (ev.type)
|
||||
{
|
||||
case "mousemotion":
|
||||
{
|
||||
if (g_DragStart.distanceTo(ev) >= Math.square(getMaxDragDelta()))
|
||||
// Rotate in the direction of the cursor.
|
||||
placementSupport.angle = placementSupport.position.horizAngleTo(Engine.GetTerrainAtScreenPoint(ev.x, ev.y));
|
||||
|
|
@ -754,7 +758,7 @@ function handleInputBeforeGui(ev, hoveredObject)
|
|||
|
||||
updateBuildingPlacementPreview();
|
||||
return false;
|
||||
|
||||
}
|
||||
case "mousebuttonup":
|
||||
if (ev.button == SDL_BUTTON_LEFT)
|
||||
{
|
||||
|
|
@ -828,6 +832,7 @@ function handleInputAfterGui(ev)
|
|||
switch (ev.type)
|
||||
{
|
||||
case "mousemotion":
|
||||
{
|
||||
const ent = Engine.PickEntityAtPoint(ev.x, ev.y);
|
||||
if (ent != INVALID_ENTITY)
|
||||
g_Selection.setHighlightList([ent]);
|
||||
|
|
@ -835,7 +840,7 @@ function handleInputAfterGui(ev)
|
|||
g_Selection.setHighlightList([]);
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
case "mousebuttondown":
|
||||
if (Engine.HotkeyIsPressed("session.flare") && !g_IsReplay)
|
||||
{
|
||||
|
|
@ -891,6 +896,7 @@ function handleInputAfterGui(ev)
|
|||
switch (ev.type)
|
||||
{
|
||||
case "mousemotion":
|
||||
{
|
||||
const ent = Engine.PickEntityAtPoint(ev.x, ev.y);
|
||||
if (ent != INVALID_ENTITY)
|
||||
g_Selection.setHighlightList([ent]);
|
||||
|
|
@ -898,7 +904,7 @@ function handleInputAfterGui(ev)
|
|||
g_Selection.setHighlightList([]);
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
case "mousebuttondown":
|
||||
if (ev.button == SDL_BUTTON_LEFT && preSelectedAction != ACTION_NONE)
|
||||
{
|
||||
|
|
@ -932,6 +938,7 @@ function handleInputAfterGui(ev)
|
|||
switch (ev.type)
|
||||
{
|
||||
case "mousemotion":
|
||||
{
|
||||
if (g_DragStart.distanceTo(ev) >= getMaxDragDelta())
|
||||
{
|
||||
inputState = INPUT_BANDBOXING;
|
||||
|
|
@ -944,7 +951,7 @@ function handleInputAfterGui(ev)
|
|||
else
|
||||
g_Selection.setHighlightList([]);
|
||||
return false;
|
||||
|
||||
}
|
||||
case "mousebuttonup":
|
||||
if (ev.button == SDL_BUTTON_LEFT)
|
||||
{
|
||||
|
|
@ -1124,7 +1131,7 @@ function handleInputAfterGui(ev)
|
|||
return false;
|
||||
|
||||
case "hotkeydown":
|
||||
|
||||
{
|
||||
const rotation_step = Math.PI / 12; // 24 clicks make a full rotation
|
||||
|
||||
switch (ev.hotkey)
|
||||
|
|
@ -1140,7 +1147,7 @@ function handleInputAfterGui(ev)
|
|||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1629,6 +1636,7 @@ function performGroup(action, groupId)
|
|||
case "snap":
|
||||
case "select":
|
||||
case "add":
|
||||
{
|
||||
const toSelect = [];
|
||||
g_Groups.update();
|
||||
for (const ent in g_Groups.groups[groupId].ents)
|
||||
|
|
@ -1647,6 +1655,7 @@ function performGroup(action, groupId)
|
|||
Engine.CameraMoveTo(position.x, position.z);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "save":
|
||||
case "breakUp":
|
||||
g_Groups.groups[groupId].reset();
|
||||
|
|
|
|||
|
|
@ -295,6 +295,7 @@ PETRA.GarrisonManager.prototype.keepGarrisoned = function(ent, holder, around)
|
|||
case PETRA.GarrisonManager.TYPE_TRADE: // trader garrisoned in ship
|
||||
return true;
|
||||
case PETRA.GarrisonManager.TYPE_PROTECTION: // hurt unit for healing or infantry for defense
|
||||
{
|
||||
if (holder.buffHeal() && ent.isHealable() && ent.healthLevel() < this.Config.garrisonHealthLevel.high)
|
||||
return true;
|
||||
const capture = ent.capturePoints();
|
||||
|
|
@ -315,6 +316,7 @@ PETRA.GarrisonManager.prototype.keepGarrisoned = function(ent, holder, around)
|
|||
if (PETRA.isSiegeUnit(ent))
|
||||
return around.meleeSiege;
|
||||
return holder.buffHeal() && ent.needsHeal();
|
||||
}
|
||||
case PETRA.GarrisonManager.TYPE_DECAY:
|
||||
return ent.captureStrength() && this.decayingStructures.has(holder.id());
|
||||
case PETRA.GarrisonManager.TYPE_EMERGENCY: // f.e. hero in regicide mode
|
||||
|
|
|
|||
|
|
@ -152,11 +152,12 @@ PopulationCapManager.prototype.OnGlobalPlayerDefeated = function(msg)
|
|||
switch(this.popCapType)
|
||||
{
|
||||
case CAPTYPE_TEAM_POPULATION:
|
||||
{
|
||||
const team = QueryPlayerIDInterface(msg.playerId, IID_Diplomacy).GetTeam();
|
||||
if (team != -1)
|
||||
this.RedistributeTeamPopCap(team);
|
||||
break;
|
||||
|
||||
}
|
||||
case CAPTYPE_WORLD_POPULATION:
|
||||
this.RedistributeWorldPopCap();
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -35,12 +35,14 @@ function Cheat(input)
|
|||
return;
|
||||
}
|
||||
case "convertunit":
|
||||
{
|
||||
if (isNaN(input.parameter))
|
||||
return;
|
||||
const playerID = (input.parameter > -1 && QueryPlayerIDInterface(input.parameter) || cmpPlayer).GetPlayerID();
|
||||
for (const ent of input.selected)
|
||||
Engine.QueryInterface(ent, IID_Ownership)?.SetOwner(playerID);
|
||||
return;
|
||||
}
|
||||
case "killunits":
|
||||
for (const ent of input.selected)
|
||||
{
|
||||
|
|
@ -188,6 +190,7 @@ function Cheat(input)
|
|||
Cheat({ "player": input.player, "action": "changephase", "selected": input.selected });
|
||||
return;
|
||||
case "playRetro":
|
||||
{
|
||||
const play = input.parameter.toLowerCase() != "off";
|
||||
cmpGuiInterface.PushNotification({
|
||||
"type": "play-tracks",
|
||||
|
|
@ -196,7 +199,7 @@ function Cheat(input)
|
|||
"players": [input.player]
|
||||
});
|
||||
return;
|
||||
|
||||
}
|
||||
default:
|
||||
warn("Cheat '" + input.action + "' is not implemented");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ const configEslintRecommended = {
|
|||
"for-direction": "warn",
|
||||
"getter-return": "warn",
|
||||
"no-async-promise-executor": "warn",
|
||||
"no-case-declarations": "warn",
|
||||
"no-class-assign": "warn",
|
||||
"no-compare-neg-zero": "warn",
|
||||
"no-cond-assign": "warn",
|
||||
|
|
|
|||
Loading…
Reference in a new issue