Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/unit_actions.js
Show First 20 Lines • Show All 605 Lines • ▼ Show 20 Lines | "getActionInfo": function(entState, targetState) | ||||
"trader": entState.id, | "trader": entState.id, | ||||
"target": targetState.id | "target": targetState.id | ||||
}); | }); | ||||
if (!tradingDetails) | if (!tradingDetails) | ||||
return false; | return false; | ||||
let tooltip; | let tooltip; | ||||
switch (tradingDetails.type) | switch (tradingDetails.type) | ||||
Lint: ESLintBear (default-case): `Expected a default case.` | |||||
{ | { | ||||
case "is first": | case "is first": | ||||
tooltip = translate("Origin trade market.") + "\n"; | tooltip = translate("Origin trade market.") + "\n"; | ||||
if (tradingDetails.hasBothMarkets) | if (tradingDetails.hasBothMarkets) | ||||
tooltip += sprintf(translate("Gain: %(gain)s"), { | tooltip += sprintf(translate("Gain: %(gain)s"), { | ||||
"gain": getTradingTooltip(tradingDetails.gain) | "gain": getTradingTooltip(tradingDetails.gain) | ||||
}); | }); | ||||
else | else | ||||
▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Lines | "actionCheck": function(target, selection) | ||||
"cursor": "action-guard", | "cursor": "action-guard", | ||||
"target": target, | "target": target, | ||||
"firstAbleEntity": actionInfo.entity | "firstAbleEntity": actionInfo.entity | ||||
}; | }; | ||||
}, | }, | ||||
"specificness": 40, | "specificness": 40, | ||||
}, | }, | ||||
"collect-treasure": | |||||
{ | |||||
"execute": function(target, action, selection, queued) | |||||
{ | |||||
Engine.PostNetworkCommand({ | |||||
"type": "collect-treasure", | |||||
"entities": selection, | |||||
"target": action.target, | |||||
"queued": queued, | |||||
"formation": g_AutoFormation.getNull() | |||||
}); | |||||
Engine.GuiInterfaceCall("PlaySound", { | |||||
"name": "order_collect_treasure", | |||||
"entity": action.firstAbleEntity | |||||
}); | |||||
return true; | |||||
}, | |||||
"getActionInfo": function(entState, targetState) | |||||
{ | |||||
if (!entState.treasureCollecter || | |||||
!targetState || !targetState.treasure) | |||||
return false; | |||||
return { | |||||
"possible": true, | |||||
"cursor": "action-collect-treasure" | |||||
}; | |||||
}, | |||||
"actionCheck": function(target, selection) | |||||
{ | |||||
let actionInfo = getActionInfo("collect-treasure", target, selection); | |||||
return actionInfo.possible && { | |||||
"type": "collect-treasure", | |||||
"cursor": actionInfo.cursor, | |||||
"target": target, | |||||
"firstAbleEntity": actionInfo.entity | |||||
}; | |||||
}, | |||||
"specificness": 1, | |||||
}, | |||||
"remove-guard": | "remove-guard": | ||||
{ | { | ||||
"execute": function(target, action, selection, queued) | "execute": function(target, action, selection, queued) | ||||
{ | { | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "remove-guard", | "type": "remove-guard", | ||||
"entities": selection, | "entities": selection, | ||||
"target": action.target, | "target": action.target, | ||||
▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | "getActionInfo": function(entState, targetState) | ||||
if (targetState.garrisonHolder.occupiedSlots >= | if (targetState.garrisonHolder.occupiedSlots >= | ||||
targetState.garrisonHolder.capacity) | targetState.garrisonHolder.capacity) | ||||
tooltip = coloredText(tooltip, "orange"); | tooltip = coloredText(tooltip, "orange"); | ||||
} | } | ||||
else if (targetState && targetState.resourceSupply) | else if (targetState && targetState.resourceSupply) | ||||
{ | { | ||||
let resourceType = targetState.resourceSupply.type; | let resourceType = targetState.resourceSupply.type; | ||||
if (resourceType.generic == "treasure") | |||||
cursor = "action-gather-" + resourceType.generic; | |||||
else | |||||
cursor = "action-gather-" + resourceType.specific; | cursor = "action-gather-" + resourceType.specific; | ||||
data.command = "gather-near-position"; | data.command = "gather-near-position"; | ||||
data.resourceType = resourceType; | data.resourceType = resourceType; | ||||
data.resourceTemplate = targetState.template; | data.resourceTemplate = targetState.template; | ||||
if (!targetState.speed) | if (!targetState.speed) | ||||
{ | { | ||||
data.command = "gather"; | data.command = "gather"; | ||||
data.target = targetState.id; | data.target = targetState.id; | ||||
} | } | ||||
} | } | ||||
else if (targetState && targetState.treasure) | |||||
{ | |||||
cursor = "action-collect-treasure"; | |||||
data.command = "collect-treasure"; | |||||
data.target = targetState.id; | |||||
} | |||||
else if (entState.market && targetState && targetState.market && | else if (entState.market && targetState && targetState.market && | ||||
entState.id != targetState.id && | entState.id != targetState.id && | ||||
(!entState.market.naval || targetState.market.naval) && | (!entState.market.naval || targetState.market.naval) && | ||||
!playerCheck(entState, targetState, ["Enemy"])) | !playerCheck(entState, targetState, ["Enemy"])) | ||||
{ | { | ||||
// Find a trader (if any) that this structure can train. | // Find a trader (if any) that this structure can train. | ||||
let trader; | let trader; | ||||
if (entState.production && entState.production.entities.length) | if (entState.production && entState.production.entities.length) | ||||
▲ Show 20 Lines • Show All 673 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Expected a default case.