From 51b864f9208f1f2f2cba815f0c4c8b317d93a4ba Mon Sep 17 00:00:00 2001 From: Ronald Rey Date: Sat, 30 Dec 2023 15:35:54 -0400 Subject: [PATCH 1/2] feat; Add Sprint --- .prettierrc | 5 +++++ src/Action.js | 32 +++++++++++++++++++++++++++----- src/App.js | 14 +++++++++----- src/constants.js | 1 + 4 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 .prettierrc create mode 100644 src/constants.js diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..cc0728a --- /dev/null +++ b/.prettierrc @@ -0,0 +1,5 @@ +{ + "useTabs": true, + "semi": false, + "trailingComma": "all" +} diff --git a/src/Action.js b/src/Action.js index 2a79457..66dcd06 100644 --- a/src/Action.js +++ b/src/Action.js @@ -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 @@ -21,7 +22,7 @@ const gcdOverrides = new Set([ 16485, //kaeshi goken 16486, //kaeshi setsugekka 2259, //ten - 18805, + 18805, 2261, //chi 18806, 2263, //jin @@ -51,7 +52,22 @@ const gcdOverrides = new Set([ const ogcdOverrides = new Set([ 3559, //bard WM 116, //bard AP - 114 //bard MB + 114, //bard MB + 3, // 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() @@ -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) diff --git a/src/App.js b/src/App.js index 06f9b11..2b248ee 100644 --- a/src/App.js +++ b/src/App.js @@ -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"]) @@ -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 diff --git a/src/constants.js b/src/constants.js new file mode 100644 index 0000000..25abd51 --- /dev/null +++ b/src/constants.js @@ -0,0 +1 @@ +export const SPRINT_ACTION_ID = 3 From b8fe828573e0ac3e8db54ee7e09c62905818e7e8 Mon Sep 17 00:00:00 2001 From: Ronald Rey Date: Sat, 30 Dec 2023 16:02:31 -0400 Subject: [PATCH 2/2] use SPRINT_ACTION_ID in ogcdoverrides --- src/Action.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Action.js b/src/Action.js index 66dcd06..14be992 100644 --- a/src/Action.js +++ b/src/Action.js @@ -53,7 +53,7 @@ const ogcdOverrides = new Set([ 3559, //bard WM 116, //bard AP 114, //bard MB - 3, // Sprint + SPRINT_ACTION_ID, // Sprint ]) const actionOverrides = new Map([