Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/unit_actions.js
Show First 20 Lines • Show All 629 Lines • ▼ Show 20 Lines | "garrison": | ||||
}, | }, | ||||
"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"])) | ||||
return false; | return false; | ||||
let tooltip = sprintf(translate("Current garrison: %(garrisoned)s/%(capacity)s"), { | let tooltip = sprintf(translate("Current garrison: %(garrisoned)s/%(capacity)s"), { | ||||
"garrisoned": targetState.garrisonHolder.garrisonedEntitiesCount, | "garrisoned": targetState.garrisonHolder.garrisonedSlots, | ||||
"capacity": targetState.garrisonHolder.capacity | "capacity": targetState.garrisonHolder.capacity | ||||
}); | }); | ||||
let extraCount = 0; | let extraCount = entState.canGarrison.size; | ||||
if (entState.garrisonHolder) | if (entState.garrisonHolder) | ||||
extraCount += entState.garrisonHolder.garrisonedEntitiesCount; | extraCount += entState.garrisonHolder.garrisonedSlots; | ||||
if (targetState.garrisonHolder.garrisonedEntitiesCount + extraCount >= targetState.garrisonHolder.capacity) | if (targetState.garrisonHolder.garrisonedSlots + extraCount > targetState.garrisonHolder.capacity) | ||||
tooltip = coloredText(tooltip, "orange"); | tooltip = coloredText(tooltip, "orange"); | ||||
if (!MatchesClassList(entState.identity.classes, targetState.garrisonHolder.allowedClasses)) | if (!MatchesClassList(entState.identity.classes, targetState.garrisonHolder.allowedClasses)) | ||||
return false; | return false; | ||||
return { | return { | ||||
"possible": true, | "possible": true, | ||||
"tooltip": tooltip | "tooltip": tooltip | ||||
▲ Show 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | "getActionInfo": function(entState, targetState) | ||||
else if (targetState.garrisonHolder && | else if (targetState.garrisonHolder && | ||||
playerCheck(entState, targetState, ["Player", "MutualAlly"])) | playerCheck(entState, targetState, ["Player", "MutualAlly"])) | ||||
{ | { | ||||
data.command = "garrison"; | data.command = "garrison"; | ||||
data.target = targetState.id; | data.target = targetState.id; | ||||
cursor = "action-garrison"; | cursor = "action-garrison"; | ||||
tooltip = sprintf(translate("Current garrison: %(garrisoned)s/%(capacity)s"), { | tooltip = sprintf(translate("Current garrison: %(garrisoned)s/%(capacity)s"), { | ||||
"garrisoned": targetState.garrisonHolder.garrisonedEntitiesCount, | "garrisoned": targetState.garrisonHolder.garrisonedSlots, | ||||
"capacity": targetState.garrisonHolder.capacity | "capacity": targetState.garrisonHolder.capacity | ||||
}); | }); | ||||
if (targetState.garrisonHolder.garrisonedEntitiesCount >= | if (targetState.garrisonHolder.garrisonedSlots >= | ||||
targetState.garrisonHolder.capacity) | targetState.garrisonHolder.capacity) | ||||
tooltip = coloredText(tooltip, "orange"); | tooltip = coloredText(tooltip, "orange"); | ||||
} | } | ||||
else if (targetState.resourceSupply) | else if (targetState.resourceSupply) | ||||
{ | { | ||||
let resourceType = targetState.resourceSupply.type; | let resourceType = targetState.resourceSupply.type; | ||||
if (resourceType.generic == "treasure") | if (resourceType.generic == "treasure") | ||||
cursor = "action-gather-" + resourceType.generic; | cursor = "action-gather-" + resourceType.generic; | ||||
▲ Show 20 Lines • Show All 677 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator