Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Sprint #80

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"useTabs": true,
"semi": false,
"trailingComma": "all"
}
32 changes: 27 additions & 5 deletions src/Action.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react"
import "./css/Action.css"
import { SPRINT_ACTION_ID } from "./constants"

const gcdOverrides = new Set([
15997, //standard step
Expand All @@ -21,7 +22,7 @@ const gcdOverrides = new Set([
16485, //kaeshi goken
16486, //kaeshi setsugekka
2259, //ten
18805,
18805,
2261, //chi
18806,
2263, //jin
Expand Down Expand Up @@ -51,7 +52,22 @@ const gcdOverrides = new Set([
const ogcdOverrides = new Set([
3559, //bard WM
116, //bard AP
114 //bard MB
114, //bard MB
SPRINT_ACTION_ID, // Sprint
])

const actionOverrides = new Map([
// Sprint's actual api data has an innaccurate icon.
// https://xivapi.com/Action/3?columns=Icon,Name,ActionCategoryTargetID
// https://xivapi.com/i/000000/000405.png
[
SPRINT_ACTION_ID,
{
ActionCategoryTargetID: 10,
Icon: "/i/000000/000104.png",
Name: "Sprint",
},
],
])

const actionMap = new Map()
Expand All @@ -68,9 +84,15 @@ export default function Action({ actionId, additionalClasses }) {

let current = true
void (async () => {
const data = await (await fetch(`https://xivapi.com/Action/${actionId}?columns=Icon,Name,ActionCategoryTargetID`, {
mode: "cors"
})).json()
const localData = actionOverrides.get(actionId)
const data =
localData ||
(await (
await fetch(
`https://xivapi.com/Action/${actionId}?columns=Icon,Name,ActionCategoryTargetID`,
{ mode: "cors" },
)
).json())
if (current) {
actionMap.set(actionId, data)
setApiData(data)
Expand Down
14 changes: 9 additions & 5 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "./css/App.css"
import Action from "./Action"
import RotationContainer from "./Rotation"
import ReactDOM from "react-dom"
import { SPRINT_ACTION_ID } from "./constants"

const handleCodes = new Set(["00", "01", "02", "21", "22", "33"])

Expand Down Expand Up @@ -81,12 +82,15 @@ export default function App() {

const action = parseInt(logParameter3, 16)

if ( //sanity check the tea sis period wig snapped
((action < 9 || action > 30000) && //is not a combat action
(action < 100001 || action > 100300)) || //and is not a crafting action
(logTimestamp === lastTimestamp && action === lastAction) //or this action is a bug/duplicate
)
const isCombatAction =
(action >= 9 && action <= 30000) || action === SPRINT_ACTION_ID
const isCraftingAction = action >= 100001 && action <= 100300
const isBugOrDuplicate =
logTimestamp === lastTimestamp && action === lastAction

if ((!isCombatAction && !isCraftingAction) || isBugOrDuplicate) {
return
}

if (Date.now() - Date.parse(lastTimestamp) > 120000) openNewEncounter() //last action > 120s ago

Expand Down
1 change: 1 addition & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const SPRINT_ACTION_ID = 3