Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/unit_actions.js
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | "execute": function(target, action, selection, queued) | ||||
"z": target.z, | "z": target.z, | ||||
"queued": queued | "queued": queued | ||||
}); | }); | ||||
DrawTargetMarker(target); | DrawTargetMarker(target); | ||||
Engine.GuiInterfaceCall("PlaySound", { | Engine.GuiInterfaceCall("PlaySound", { | ||||
"name": "order_walk", | "name": "order_walk", | ||||
"entity": selection[0] | "entity": selection.find(ent => this.actionCheck(null, [ent])) | ||||
}); | }); | ||||
return true; | return true; | ||||
}, | }, | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
{ | { | ||||
return { "possible": true }; | return { "possible": true }; | ||||
}, | }, | ||||
Show All 34 Lines | "execute": function(target, action, selection, queued) | ||||
"targetClasses": targetClasses, | "targetClasses": targetClasses, | ||||
"queued": queued | "queued": queued | ||||
}); | }); | ||||
DrawTargetMarker(target); | DrawTargetMarker(target); | ||||
Engine.GuiInterfaceCall("PlaySound", { | Engine.GuiInterfaceCall("PlaySound", { | ||||
"name": "order_walk", | "name": "order_walk", | ||||
"entity": selection[0] | "entity": selection.find(ent => getActionInfo("attack-move", null, [ent]).possible) | ||||
}); | }); | ||||
return true; | return true; | ||||
}, | }, | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
{ | { | ||||
return { "possible": true }; | return { "possible": true }; | ||||
}, | }, | ||||
Show All 21 Lines | "execute": function(target, action, selection, queued) | ||||
"entities": selection, | "entities": selection, | ||||
"target": action.target, | "target": action.target, | ||||
"allowCapture": true, | "allowCapture": true, | ||||
"queued": queued | "queued": queued | ||||
}); | }); | ||||
Engine.GuiInterfaceCall("PlaySound", { | Engine.GuiInterfaceCall("PlaySound", { | ||||
"name": "order_attack", | "name": "order_attack", | ||||
"entity": selection[0] | "entity": selection.find(ent => this.actionCheck(action.target, [ent])) | ||||
}); | }); | ||||
return true; | return true; | ||||
}, | }, | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
{ | { | ||||
if (!entState.attack || !targetState.hitpoints) | if (!entState.attack || !targetState.hitpoints) | ||||
return false; | return false; | ||||
Show All 29 Lines | "execute": function(target, action, selection, queued) | ||||
"entities": selection, | "entities": selection, | ||||
"target": action.target, | "target": action.target, | ||||
"queued": queued, | "queued": queued, | ||||
"allowCapture": false | "allowCapture": false | ||||
}); | }); | ||||
Engine.GuiInterfaceCall("PlaySound", { | Engine.GuiInterfaceCall("PlaySound", { | ||||
"name": "order_attack", | "name": "order_attack", | ||||
"entity": selection[0] | "entity": selection.find(ent => this.actionCheck(action.target, [ent])) | ||||
}); | }); | ||||
return true; | return true; | ||||
}, | }, | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
{ | { | ||||
if (!entState.attack || !targetState.hitpoints) | if (!entState.attack || !targetState.hitpoints) | ||||
return false; | return false; | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | "execute": function(target, action, selection, queued) | ||||
"target": action.target, | "target": action.target, | ||||
"targetClasses": { "attack": g_PatrolTargets }, | "targetClasses": { "attack": g_PatrolTargets }, | ||||
"queued": queued, | "queued": queued, | ||||
"allowCapture": false | "allowCapture": false | ||||
}); | }); | ||||
DrawTargetMarker(target); | DrawTargetMarker(target); | ||||
Engine.GuiInterfaceCall("PlaySound", { "name": "order_patrol", "entity": selection[0] }); | Engine.GuiInterfaceCall("PlaySound", { | ||||
"name": "order_patrol", | |||||
"entity": selection.find(ent => getActionInfo("patrol", action.target, [ent])) | |||||
}); | |||||
return true; | return true; | ||||
}, | }, | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
{ | { | ||||
if (!entState.unitAI || !entState.unitAI.canPatrol) | if (!entState.unitAI || !entState.unitAI.canPatrol) | ||||
return false; | return false; | ||||
return { "possible": true }; | return { "possible": true }; | ||||
Show All 31 Lines | "execute": function(target, action, selection, queued) | ||||
"type": "heal", | "type": "heal", | ||||
"entities": selection, | "entities": selection, | ||||
"target": action.target, | "target": action.target, | ||||
"queued": queued | "queued": queued | ||||
}); | }); | ||||
Engine.GuiInterfaceCall("PlaySound", { | Engine.GuiInterfaceCall("PlaySound", { | ||||
"name": "order_heal", | "name": "order_heal", | ||||
"entity": selection[0] | "entity": selection.find(ent => this.actionCheck(action.target, [ent])) | ||||
}); | }); | ||||
return true; | return true; | ||||
}, | }, | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
{ | { | ||||
if (!entState.heal || | if (!entState.heal || | ||||
!hasClass(targetState, "Unit") || !targetState.needsHeal || | !hasClass(targetState, "Unit") || !targetState.needsHeal || | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | "execute": function(target, action, selection, queued) | ||||
"entities": selection, | "entities": selection, | ||||
"target": action.target, | "target": action.target, | ||||
"autocontinue": true, | "autocontinue": true, | ||||
"queued": queued | "queued": queued | ||||
}); | }); | ||||
Engine.GuiInterfaceCall("PlaySound", { | Engine.GuiInterfaceCall("PlaySound", { | ||||
"name": action.foundation ? "order_build" : "order_repair", | "name": action.foundation ? "order_build" : "order_repair", | ||||
"entity": selection[0] | "entity": selection.find(ent => this.actionCheck(action.target, [ent])) | ||||
}); | }); | ||||
return true; | return true; | ||||
}, | }, | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
{ | { | ||||
if (!entState.builder || | if (!entState.builder || | ||||
!targetState.needsRepair && !targetState.foundation || | !targetState.needsRepair && !targetState.foundation || | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | "execute": function(target, action, selection, queued) | ||||
"type": "gather", | "type": "gather", | ||||
"entities": selection, | "entities": selection, | ||||
"target": action.target, | "target": action.target, | ||||
"queued": queued | "queued": queued | ||||
}); | }); | ||||
Engine.GuiInterfaceCall("PlaySound", { | Engine.GuiInterfaceCall("PlaySound", { | ||||
"name": "order_gather", | "name": "order_gather", | ||||
"entity": selection[0] | "entity": selection.find(ent => this.actionCheck(action.target, [ent])) | ||||
}); | }); | ||||
return true; | return true; | ||||
}, | }, | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
{ | { | ||||
if (!targetState.resourceSupply) | if (!targetState.resourceSupply) | ||||
return false; | return false; | ||||
Show All 31 Lines | "execute": function(target, action, selection, queued) | ||||
"type": "returnresource", | "type": "returnresource", | ||||
"entities": selection, | "entities": selection, | ||||
"target": action.target, | "target": action.target, | ||||
"queued": queued | "queued": queued | ||||
}); | }); | ||||
Engine.GuiInterfaceCall("PlaySound", { | Engine.GuiInterfaceCall("PlaySound", { | ||||
"name": "order_gather", | "name": "order_gather", | ||||
"entity": selection[0] | "entity": selection.find(ent => this.actionCheck(action.target, [ent])) | ||||
}); | }); | ||||
return true; | return true; | ||||
}, | }, | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
{ | { | ||||
if (!targetState.resourceDropsite) | if (!targetState.resourceDropsite) | ||||
return false; | return false; | ||||
Show All 31 Lines | "actionCheck": function(target, selection) | ||||
"target": target | "target": target | ||||
}; | }; | ||||
}, | }, | ||||
"specificness": 2, | "specificness": 2, | ||||
}, | }, | ||||
"cancel-setup-trade-route": | "cancel-setup-trade-route": | ||||
{ | { | ||||
"execute":function(target, action, selection, queued) | "execute":function(target, action, selection, queued) | ||||
Lint: ESLintBear (key-spacing): `Missing space before value for key 'execute'.` | |||||
{ | { | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "cancel-setup-trade-route", | "type": "cancel-setup-trade-route", | ||||
"entities": selection, | "entities": selection, | ||||
"target": action.target, | "target": action.target, | ||||
"queued": queued | "queued": queued | ||||
}); | }); | ||||
Show All 28 Lines | "actionCheck": function(target, selection) | ||||
if (!actionInfo.possible) | if (!actionInfo.possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "cancel-setup-trade-route", | "type": "cancel-setup-trade-route", | ||||
"cursor": "action-cancel-setup-trade-route", | "cursor": "action-cancel-setup-trade-route", | ||||
"tooltip": actionInfo.tooltip, | "tooltip": actionInfo.tooltip, | ||||
"target": target | "target": target | ||||
} | } | ||||
Lint: ESLintBear (semi) Missing semicolon. Lint: ESLintBear (semi): `Missing semicolon.` | |||||
Lint: JSHintBear Missing semicolon. Lint: JSHintBear: `Missing semicolon.` | |||||
}, | }, | ||||
"specificness": 2, | "specificness": 2, | ||||
}, | }, | ||||
"setup-trade-route": | "setup-trade-route": | ||||
{ | { | ||||
"execute": function(target, action, selection, queued) | "execute": function(target, action, selection, queued) | ||||
{ | { | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "setup-trade-route", | "type": "setup-trade-route", | ||||
"entities": selection, | "entities": selection, | ||||
"target": action.target, | "target": action.target, | ||||
"source": null, | "source": null, | ||||
"route": null, | "route": null, | ||||
"queued": queued | "queued": queued | ||||
}); | }); | ||||
Engine.GuiInterfaceCall("PlaySound", { | Engine.GuiInterfaceCall("PlaySound", { | ||||
"name": "order_trade", | "name": "order_trade", | ||||
"entity": selection[0] | "entity": selection.find(ent => this.actionCheck(action.target, [ent])) | ||||
}); | }); | ||||
return true; | return true; | ||||
}, | }, | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
{ | { | ||||
if (targetState.foundation || !entState.trader || !targetState.market || | if (targetState.foundation || !entState.trader || !targetState.market || | ||||
playerCheck(entState, targetState, ["Enemy"]) || | playerCheck(entState, targetState, ["Enemy"]) || | ||||
!(targetState.market.land && hasClass(entState, "Organic") || | !(targetState.market.land && hasClass(entState, "Organic") || | ||||
targetState.market.naval && hasClass(entState, "Ship"))) | targetState.market.naval && hasClass(entState, "Ship"))) | ||||
return false; | return false; | ||||
let tradingDetails = Engine.GuiInterfaceCall("GetTradingDetails", { | let tradingDetails = Engine.GuiInterfaceCall("GetTradingDetails", { | ||||
"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. 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 64 Lines • ▼ Show 20 Lines | "execute": function(target, action, selection, queued) | ||||
"type": "garrison", | "type": "garrison", | ||||
"entities": selection, | "entities": selection, | ||||
"target": action.target, | "target": action.target, | ||||
"queued": queued | "queued": queued | ||||
}); | }); | ||||
Engine.GuiInterfaceCall("PlaySound", { | Engine.GuiInterfaceCall("PlaySound", { | ||||
"name": "order_garrison", | "name": "order_garrison", | ||||
"entity": selection[0] | "entity": selection.find(ent => getActionInfo("garrison", action.target, [ent]).possible) | ||||
}); | }); | ||||
return true; | return true; | ||||
}, | }, | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
{ | { | ||||
if (!entState.canGarrison || !targetState.garrisonHolder || | if (!entState.canGarrison || !targetState.garrisonHolder || | ||||
!playerCheck(entState, targetState, ["Player", "MutualAlly"])) | !playerCheck(entState, targetState, ["Player", "MutualAlly"])) | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | "execute": function(target, action, selection, queued) | ||||
"type": "guard", | "type": "guard", | ||||
"entities": selection, | "entities": selection, | ||||
"target": action.target, | "target": action.target, | ||||
"queued": queued | "queued": queued | ||||
}); | }); | ||||
Engine.GuiInterfaceCall("PlaySound", { | Engine.GuiInterfaceCall("PlaySound", { | ||||
"name": "order_guard", | "name": "order_guard", | ||||
"entity": selection[0] | "entity": selection.find(ent => getActionInfo("guard", action.target, [ent]).possible) | ||||
}); | }); | ||||
return true; | return true; | ||||
}, | }, | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
{ | { | ||||
if (!targetState.guard || entState.id == targetState.id || | if (!targetState.guard || entState.id == targetState.id || | ||||
!playerCheck(entState, targetState, ["Player", "Ally"]) || | !playerCheck(entState, targetState, ["Player", "Ally"]) || | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | "execute": function(target, action, selection, queued) | ||||
"type": "remove-guard", | "type": "remove-guard", | ||||
"entities": selection, | "entities": selection, | ||||
"target": action.target, | "target": action.target, | ||||
"queued": queued | "queued": queued | ||||
}); | }); | ||||
Engine.GuiInterfaceCall("PlaySound", { | Engine.GuiInterfaceCall("PlaySound", { | ||||
"name": "order_guard", | "name": "order_guard", | ||||
"entity": selection[0] | "entity": selection.find(ent => getActionInfo("remove-guard", action.target, [ent]).possible && someGuarding([ent])) | ||||
Not Done Inline ActionsOne might argue that all commands should get an actionCheck. Especially if you need to check more than just getActionInfo(...).possible bb: One might argue that all commands should get an `actionCheck`. Especially if you need to check… | |||||
Not Done Inline ActionsI think the problem with an actionCheck is that the action can then be triggered by mouse-pointing only. Freagarach: I think the problem with an `actionCheck` is that the action can then be triggered by mouse… | |||||
}); | }); | ||||
return true; | return true; | ||||
}, | }, | ||||
"hotkeyActionCheck": function(target, selection) | "hotkeyActionCheck": function(target, selection) | ||||
{ | { | ||||
if (!Engine.HotkeyIsPressed("session.guard") || | if (!Engine.HotkeyIsPressed("session.guard") || | ||||
!getActionInfo("remove-guard", target, selection).possible || | !getActionInfo("remove-guard", target, selection).possible || | ||||
▲ Show 20 Lines • Show All 835 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Missing space before value for key 'execute'.