Skip to content

Commit

Permalink
Display items as oGCDs (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
reyronald authored Jan 16, 2024
1 parent 1732f7a commit aa088c9
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/Action.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ export default function Action({ actionId, ability, additionalClasses }) {
: `https://xivapi.com/Item/${itemId}?columns=Name,Icon,IconHD,IconID`

const localData = actionOverrides.get(actionId)
const data = localData || (await (await fetch(url, { mode: "cors" })).json())
const data =
localData || (await (await fetch(url, { mode: "cors" })).json())

if (current) {
actionMap.set(actionId, data)
Expand All @@ -108,22 +109,31 @@ export default function Action({ actionId, ability, additionalClasses }) {
return null
}

const isItem = getIsItem(ability)
const isGCD =
!isItem &&
(gcdOverrides.has(actionId) ||
(!ogcdOverrides.has(actionId) && apiData.ActionCategoryTargetID !== 4))

return (
<img
className={
gcdOverrides.has(actionId) ||
(!ogcdOverrides.has(actionId) && apiData.ActionCategoryTargetID !== 4)
? `gcd ${additionalClasses}`
: `ogcd ${additionalClasses}`
isGCD ? `gcd ${additionalClasses}` : `ogcd ${additionalClasses}`
}
src={`https://xivapi.com/${apiData.Icon}`}
alt={apiData.Name || ""}
/>
)
}

function getIsItem(ability) {
const isIt = ability.startsWith("item_")
return isIt
}

function getItemId(ability) {
if (!ability.startsWith("item_")) return null
const isItem = getIsItem(ability)
if (!isItem) return null

const hex = ability.replace("item_", "")
const bigId = parseInt(hex, 16)
Expand Down

0 comments on commit aa088c9

Please sign in to comment.