From 7bb02a2afee76f3b638d8be6dcc92ffaaa530bda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manw=C3=AB?= Date: Sat, 6 Jan 2024 13:04:46 -0300 Subject: [PATCH] new log fixes --- .../onLabel/MatchGameRoomStateChangedEvent.ts | 2 ++ src/components/action-log-v2/LineAbility.tsx | 4 +-- src/components/action-log-v2/LineAttack.tsx | 4 +-- src/components/action-log-v2/LineCast.tsx | 2 +- src/components/action-log-v2/LineConceded.tsx | 4 ++- .../action-log-v2/LineCountered.tsx | 2 +- .../action-log-v2/LineDamageDealt.tsx | 2 +- .../action-log-v2/LineDestroyed.tsx | 2 +- src/components/action-log-v2/LineDiscard.tsx | 2 +- src/components/action-log-v2/LineDraw.tsx | 2 +- src/components/action-log-v2/LineExile.tsx | 2 +- .../action-log-v2/LineModifiedLife.tsx | 19 ++++++++++++ src/components/action-log-v2/LinePlay.tsx | 2 +- src/components/action-log-v2/LineTimedOut.tsx | 4 ++- src/components/action-log-v2/LineTurnInfo.tsx | 10 +++++-- src/components/action-log-v2/LineWon.tsx | 4 ++- src/components/action-log-v2/LineZonePut.tsx | 2 +- .../action-log-v2/LineZoneReturn.tsx | 2 +- src/components/action-log-v2/index.tsx | 5 ++++ src/components/action-log-v2/types.ts | 1 + src/components/views/history/MatchView.tsx | 2 +- src/info.json | 2 +- src/scss/actionLog.scss | 29 ++++++++++++++++++- 23 files changed, 88 insertions(+), 22 deletions(-) create mode 100644 src/components/action-log-v2/LineModifiedLife.tsx diff --git a/src/background/onLabel/MatchGameRoomStateChangedEvent.ts b/src/background/onLabel/MatchGameRoomStateChangedEvent.ts index 60178f1..d88507c 100644 --- a/src/background/onLabel/MatchGameRoomStateChangedEvent.ts +++ b/src/background/onLabel/MatchGameRoomStateChangedEvent.ts @@ -87,6 +87,8 @@ export default function onLabelMatchGameRoomStateChangedEvent( // Now only when a match begins if (gameRoom.stateType == "MatchGameRoomStateType_Playing") { + globalStore.currentActionLog.lines = []; + globalStore.currentActionLog.players = []; actionLog({ seat: -1, type: "START", diff --git a/src/components/action-log-v2/LineAbility.tsx b/src/components/action-log-v2/LineAbility.tsx index 8115185..5eb3703 100644 --- a/src/components/action-log-v2/LineAbility.tsx +++ b/src/components/action-log-v2/LineAbility.tsx @@ -5,11 +5,11 @@ import { ActionLogLineProps } from "./types"; export default function LineAbility(props: ActionLogLineProps) { const { line } = props; - if (line.type !== "ZONE_PUT") return <>; + if (line.type !== "ABILITY") return <>; return ( <> -
+
's  {line.abilityId ? : "ability"} diff --git a/src/components/action-log-v2/LineAttack.tsx b/src/components/action-log-v2/LineAttack.tsx index a9bf7cb..af58d32 100644 --- a/src/components/action-log-v2/LineAttack.tsx +++ b/src/components/action-log-v2/LineAttack.tsx @@ -8,9 +8,9 @@ export default function LineAttack(props: ActionLogLineProps) { if (line.type !== "ATTACK") return <>; return ( -
+
{getPlayerBySeat(line.seat, players)} -  attacked with   +  attacked with  {line.grpIds.map((grpId, index) => { const len = line.grpIds.length; return ( diff --git a/src/components/action-log-v2/LineCast.tsx b/src/components/action-log-v2/LineCast.tsx index d045ac5..7be0bb6 100644 --- a/src/components/action-log-v2/LineCast.tsx +++ b/src/components/action-log-v2/LineCast.tsx @@ -11,7 +11,7 @@ export default function LineCast(props: ActionLogLineProps) { return ( <> -
+
{playerName} cast  {line.grpId ? : "a spell"}
diff --git a/src/components/action-log-v2/LineConceded.tsx b/src/components/action-log-v2/LineConceded.tsx index 9e79905..708054d 100644 --- a/src/components/action-log-v2/LineConceded.tsx +++ b/src/components/action-log-v2/LineConceded.tsx @@ -10,7 +10,9 @@ export default function LineConceded(props: ActionLogLineProps) { return ( <> -
{playerName} conceded.
+
+ {playerName} conceded. +
); } diff --git a/src/components/action-log-v2/LineCountered.tsx b/src/components/action-log-v2/LineCountered.tsx index 623e12d..e8528b8 100644 --- a/src/components/action-log-v2/LineCountered.tsx +++ b/src/components/action-log-v2/LineCountered.tsx @@ -9,7 +9,7 @@ export default function LineCountered(props: ActionLogLineProps) { return ( <> -
+
{line.abilityId ? ( <> diff --git a/src/components/action-log-v2/LineDamageDealt.tsx b/src/components/action-log-v2/LineDamageDealt.tsx index 86146b9..8bf2884 100644 --- a/src/components/action-log-v2/LineDamageDealt.tsx +++ b/src/components/action-log-v2/LineDamageDealt.tsx @@ -9,7 +9,7 @@ export default function LineDamageDealt(props: ActionLogLineProps) { return ( <> -
+
 dealt {line.amount} damage to  {line.targetType === "PLAYER" ? ( diff --git a/src/components/action-log-v2/LineDestroyed.tsx b/src/components/action-log-v2/LineDestroyed.tsx index 2f86d52..566ea0a 100644 --- a/src/components/action-log-v2/LineDestroyed.tsx +++ b/src/components/action-log-v2/LineDestroyed.tsx @@ -9,7 +9,7 @@ export default function LineDestroyed(props: ActionLogLineProps) { return ( <> -
+
{line.abilityId ? ( <> diff --git a/src/components/action-log-v2/LineDiscard.tsx b/src/components/action-log-v2/LineDiscard.tsx index 3f538b2..1a2b8cc 100644 --- a/src/components/action-log-v2/LineDiscard.tsx +++ b/src/components/action-log-v2/LineDiscard.tsx @@ -11,7 +11,7 @@ export default function LineDiscard(props: ActionLogLineProps) { return ( <> -
+
{playerName} discarded  {line.grpId ? : "a card"}
diff --git a/src/components/action-log-v2/LineDraw.tsx b/src/components/action-log-v2/LineDraw.tsx index 9310076..b587a49 100644 --- a/src/components/action-log-v2/LineDraw.tsx +++ b/src/components/action-log-v2/LineDraw.tsx @@ -11,7 +11,7 @@ export default function LineDraw(props: ActionLogLineProps) { return ( <> -
+
{playerName} drew  {line.grpId ? : "a card"}
diff --git a/src/components/action-log-v2/LineExile.tsx b/src/components/action-log-v2/LineExile.tsx index cc6eaea..a799c4c 100644 --- a/src/components/action-log-v2/LineExile.tsx +++ b/src/components/action-log-v2/LineExile.tsx @@ -9,7 +9,7 @@ export default function LineExile(props: ActionLogLineProps) { return ( <> -
+
{line.abilityId ? ( <> diff --git a/src/components/action-log-v2/LineModifiedLife.tsx b/src/components/action-log-v2/LineModifiedLife.tsx new file mode 100644 index 0000000..a293e9e --- /dev/null +++ b/src/components/action-log-v2/LineModifiedLife.tsx @@ -0,0 +1,19 @@ +import getPlayerBySeat from "./getPlayerBySeat"; +import { ActionLogLineProps } from "./types"; + +export default function LineModifiedLife(props: ActionLogLineProps) { + const { line, players } = props; + + if (line.type !== "MODIFIED_LIFE") return <>; + + const playerName = getPlayerBySeat(line.seat || 0, players); + + return ( + <> +
+ {playerName} {line.delta < 0 ? "lost" : "gained"}  + {Math.abs(line.delta)} life ({line.total}). +
+ + ); +} diff --git a/src/components/action-log-v2/LinePlay.tsx b/src/components/action-log-v2/LinePlay.tsx index e8ca4b3..5f7855d 100644 --- a/src/components/action-log-v2/LinePlay.tsx +++ b/src/components/action-log-v2/LinePlay.tsx @@ -11,7 +11,7 @@ export default function LinePlay(props: ActionLogLineProps) { return ( <> -
+
{playerName} played  {line.grpId ? : "a land"}
diff --git a/src/components/action-log-v2/LineTimedOut.tsx b/src/components/action-log-v2/LineTimedOut.tsx index 7d91f52..1e71a00 100644 --- a/src/components/action-log-v2/LineTimedOut.tsx +++ b/src/components/action-log-v2/LineTimedOut.tsx @@ -10,7 +10,9 @@ export default function LineTimedOut(props: ActionLogLineProps) { return ( <> -
{playerName} timed out.
+
+ {playerName} timed out. +
); } diff --git a/src/components/action-log-v2/LineTurnInfo.tsx b/src/components/action-log-v2/LineTurnInfo.tsx index 69d5291..dc6ac98 100644 --- a/src/components/action-log-v2/LineTurnInfo.tsx +++ b/src/components/action-log-v2/LineTurnInfo.tsx @@ -1,3 +1,4 @@ +import { toMMSS } from "../../utils/dateTo"; import getPlayerBySeat from "./getPlayerBySeat"; import { ActionLogLineProps } from "./types"; @@ -11,15 +12,20 @@ const phasesMap: Record = { }; export default function LineTurnInfo(props: ActionLogLineProps) { - const { line, players } = props; + const { line, players, timeStart } = props; if (line.type !== "TURN_INFO") return <>; + const timeDiff = toMMSS(Math.round((line.timestamp - timeStart) / 1000)); + return ( <> {line.subType === "BEGIN" && (
-
Turn {line.turnNumber}
+
+ Turn {line.turnNumber} + +{timeDiff} +
{getPlayerBySeat(line.activePlayer || 0, players)}
diff --git a/src/components/action-log-v2/LineWon.tsx b/src/components/action-log-v2/LineWon.tsx index 9503d34..2c2880a 100644 --- a/src/components/action-log-v2/LineWon.tsx +++ b/src/components/action-log-v2/LineWon.tsx @@ -10,7 +10,9 @@ export default function LineWin(props: ActionLogLineProps) { return ( <> -
{playerName} won!
+
+ {playerName} won! +
); } diff --git a/src/components/action-log-v2/LineZonePut.tsx b/src/components/action-log-v2/LineZonePut.tsx index f30976f..99527c6 100644 --- a/src/components/action-log-v2/LineZonePut.tsx +++ b/src/components/action-log-v2/LineZonePut.tsx @@ -9,7 +9,7 @@ export default function LineZonePut(props: ActionLogLineProps) { return ( <> -
+
{line.abilityId ? ( <> diff --git a/src/components/action-log-v2/LineZoneReturn.tsx b/src/components/action-log-v2/LineZoneReturn.tsx index 28ceee7..b094165 100644 --- a/src/components/action-log-v2/LineZoneReturn.tsx +++ b/src/components/action-log-v2/LineZoneReturn.tsx @@ -9,7 +9,7 @@ export default function LineZoneReturn(props: ActionLogLineProps) { return ( <> -
+
{line.abilityId ? ( <> diff --git a/src/components/action-log-v2/index.tsx b/src/components/action-log-v2/index.tsx index e0de845..93a94fe 100644 --- a/src/components/action-log-v2/index.tsx +++ b/src/components/action-log-v2/index.tsx @@ -8,6 +8,7 @@ import LineDestroyed from "./LineDestroyed"; import LineDiscard from "./LineDiscard"; import LineDraw from "./LineDraw"; import LineExile from "./LineExile"; +import LineModifiedLife from "./LineModifiedLife"; import LinePlay from "./LinePlay"; import LineTimedOut from "./LineTimedOut"; import LineTurnInfo from "./LineTurnInfo"; @@ -66,6 +67,9 @@ function getLineComponent(type: ActionLogLineType) { case "ABILITY": lineComponent = LineAbility; break; + case "MODIFIED_LIFE": + lineComponent = LineModifiedLife; + break; case "DAMAGE_DEALT": lineComponent = LineDamageDealt; break; @@ -109,6 +113,7 @@ export default function ActionLog(props: ActionLogProps): JSX.Element { ); diff --git a/src/components/action-log-v2/types.ts b/src/components/action-log-v2/types.ts index 56d286f..33ae3c5 100644 --- a/src/components/action-log-v2/types.ts +++ b/src/components/action-log-v2/types.ts @@ -199,4 +199,5 @@ export type ActionLogV2 = { export interface ActionLogLineProps { line: ActionLogLine; players: ActionLogPlayer[]; + timeStart: number; } diff --git a/src/components/views/history/MatchView.tsx b/src/components/views/history/MatchView.tsx index d62325e..b797ba5 100644 --- a/src/components/views/history/MatchView.tsx +++ b/src/components/views/history/MatchView.tsx @@ -436,7 +436,7 @@ export default function MatchView(): JSX.Element {