diff --git a/src/app/tools/embed/customize/[embed]/components/Boolean.tsx b/src/app/tools/embed/[embed]/customize/components/Boolean.tsx similarity index 100% rename from src/app/tools/embed/customize/[embed]/components/Boolean.tsx rename to src/app/tools/embed/[embed]/customize/components/Boolean.tsx diff --git a/src/app/tools/embed/customize/[embed]/components/Color/components/ColorControllerRaw.tsx b/src/app/tools/embed/[embed]/customize/components/Color/components/ColorControllerRaw.tsx similarity index 100% rename from src/app/tools/embed/customize/[embed]/components/Color/components/ColorControllerRaw.tsx rename to src/app/tools/embed/[embed]/customize/components/Color/components/ColorControllerRaw.tsx diff --git a/src/app/tools/embed/customize/[embed]/components/Color/index.tsx b/src/app/tools/embed/[embed]/customize/components/Color/index.tsx similarity index 100% rename from src/app/tools/embed/customize/[embed]/components/Color/index.tsx rename to src/app/tools/embed/[embed]/customize/components/Color/index.tsx diff --git a/src/app/tools/embed/customize/[embed]/components/Enum.tsx b/src/app/tools/embed/[embed]/customize/components/Enum.tsx similarity index 100% rename from src/app/tools/embed/customize/[embed]/components/Enum.tsx rename to src/app/tools/embed/[embed]/customize/components/Enum.tsx diff --git a/src/app/tools/embed/customize/[embed]/components/Radius.tsx b/src/app/tools/embed/[embed]/customize/components/Radius.tsx similarity index 100% rename from src/app/tools/embed/customize/[embed]/components/Radius.tsx rename to src/app/tools/embed/[embed]/customize/components/Radius.tsx diff --git a/src/app/tools/embed/customize/[embed]/components/RichText.tsx b/src/app/tools/embed/[embed]/customize/components/RichText.tsx similarity index 100% rename from src/app/tools/embed/customize/[embed]/components/RichText.tsx rename to src/app/tools/embed/[embed]/customize/components/RichText.tsx diff --git a/src/app/tools/embed/customize/[embed]/components/Size.tsx b/src/app/tools/embed/[embed]/customize/components/Size.tsx similarity index 100% rename from src/app/tools/embed/customize/[embed]/components/Size.tsx rename to src/app/tools/embed/[embed]/customize/components/Size.tsx diff --git a/src/app/tools/embed/customize/[embed]/components/SizeWithout0.tsx b/src/app/tools/embed/[embed]/customize/components/SizeWithout0.tsx similarity index 100% rename from src/app/tools/embed/customize/[embed]/components/SizeWithout0.tsx rename to src/app/tools/embed/[embed]/customize/components/SizeWithout0.tsx diff --git a/src/app/tools/embed/customize/[embed]/components/Slider.tsx b/src/app/tools/embed/[embed]/customize/components/Slider.tsx similarity index 95% rename from src/app/tools/embed/customize/[embed]/components/Slider.tsx rename to src/app/tools/embed/[embed]/customize/components/Slider.tsx index d8d3607ce..d1f6c612b 100644 --- a/src/app/tools/embed/customize/[embed]/components/Slider.tsx +++ b/src/app/tools/embed/[embed]/customize/components/Slider.tsx @@ -26,7 +26,7 @@ export function Slider({ ]} onValueChange={([value]) => { mutateEmbedState((draft) => { - draft[configKey] = `${value}`; + draft[configKey] = value; }); }} /> diff --git a/src/app/tools/embed/customize/[embed]/components/Text.tsx b/src/app/tools/embed/[embed]/customize/components/Text.tsx similarity index 100% rename from src/app/tools/embed/customize/[embed]/components/Text.tsx rename to src/app/tools/embed/[embed]/customize/components/Text.tsx diff --git a/src/app/tools/embed/customize/[embed]/layout.tsx b/src/app/tools/embed/[embed]/customize/layout.tsx similarity index 100% rename from src/app/tools/embed/customize/[embed]/layout.tsx rename to src/app/tools/embed/[embed]/customize/layout.tsx diff --git a/src/app/tools/embed/customize/[embed]/page.tsx b/src/app/tools/embed/[embed]/customize/page.tsx similarity index 81% rename from src/app/tools/embed/customize/[embed]/page.tsx rename to src/app/tools/embed/[embed]/customize/page.tsx index 148ba64b4..8a51f70fb 100644 --- a/src/app/tools/embed/customize/[embed]/page.tsx +++ b/src/app/tools/embed/[embed]/customize/page.tsx @@ -7,6 +7,8 @@ import { ReactNode, useEffect, useRef, useState } from 'react'; import { NAVBAR_HEIGHT } from '../../../../../components/Navbar'; import PageWrapper from '../../../../../components/PageWrapper'; import { imgur } from '../../../../../core/blitzkit/imgur'; +import * as App from '../../../../../stores/app'; +import * as EmbedState from '../../../../../stores/embedState'; import { EmbedConfig } from '../../../../../stores/embedState'; import { EmbedItemType } from '../../../../../stores/embedState/constants'; import { configurations, previews } from '../../configurations'; @@ -29,6 +31,8 @@ export default function Page({ }: { params: { embed: keyof typeof configurations }; }) { + const embedStateStore = EmbedState.useStore(); + const appStore = App.useStore(); const config = configurations[params.embed] as EmbedConfig; const Preview = previews[params.embed]; const [backgroundImage, setBackgroundImage] = useState(imgur('SO13zur')); @@ -59,13 +63,41 @@ export default function Page({ - diff --git a/src/app/tools/embed/[embed]/host/page.tsx b/src/app/tools/embed/[embed]/host/page.tsx new file mode 100644 index 000000000..0000f1fb2 --- /dev/null +++ b/src/app/tools/embed/[embed]/host/page.tsx @@ -0,0 +1,28 @@ +'use client'; + +import { Code, Text } from '@radix-ui/themes'; +import PageWrapper from '../../../../../components/PageWrapper'; +import { configurations } from '../../configurations'; + +export interface EmbedPreviewControllerProps { + configKey: string; +} + +export default function Page({ + params, + searchParams, +}: { + params: { embed: keyof typeof configurations }; + searchParams: { state: string }; +}) { + return ( + + {params.embed} + + + +
{JSON.stringify(JSON.parse(searchParams['state']), null, 2)}
+
+
+ ); +} diff --git a/src/core/statistics/compositeStats/constants.ts b/src/core/statistics/compositeStats/constants.ts index 116a133bb..8c7e03fda 100644 --- a/src/core/statistics/compositeStats/constants.ts +++ b/src/core/statistics/compositeStats/constants.ts @@ -18,6 +18,11 @@ export const blitzStatsKeys = [ 'xp', ] as const; +export const blitzkitStatsKeys = [ + ...blitzStatsKeys, + 'battle_life_time', +] as const; + export const blitzPlayerStatsKeys = [ ...blitzStatsKeys, 'max_frags_tank_id', @@ -25,7 +30,7 @@ export const blitzPlayerStatsKeys = [ ] as const; export const compositeStatsKeysBase = [ - ...blitzStatsKeys, + ...blitzkitStatsKeys, 'damage_ratio', 'kills_to_death_ratio', 'accuracy', @@ -55,6 +60,11 @@ const normalizedBlitzStatsKeys = [ 'xp', ] satisfies (typeof blitzStatsKeys)[number][]; +const normalizedBlitzkitStatsKeys = [ + ...normalizedBlitzStatsKeys, + 'battle_life_time', +] satisfies (typeof blitzkitStatsKeys)[number][]; + const cumulativeBlitzStatsKeys = [ 'battles', 'capture_points', @@ -75,8 +85,13 @@ const cumulativeBlitzStatsKeys = [ 'xp', ] satisfies (typeof blitzStatsKeys)[number][]; +const cumulativeBlitzkitStatsKeys = [ + ...cumulativeBlitzStatsKeys, + 'battle_life_time', +] satisfies (typeof blitzkitStatsKeys)[number][]; + const normalizedCompositeStatsKeys = [ - ...normalizedBlitzStatsKeys, + ...normalizedBlitzkitStatsKeys, // 'damage_ratio', is a dimensionless ratio // 'kills_to_death_ratio', also a dimensionless ratio // 'accuracy', dimensionless ratio @@ -87,7 +102,7 @@ const normalizedCompositeStatsKeys = [ ] satisfies (typeof compositeStatsKeysBase)[number][]; const cumulativeCompositeStatsKeys = [ - ...cumulativeBlitzStatsKeys, + ...cumulativeBlitzkitStatsKeys, 'damage_ratio', 'kills_to_death_ratio', 'accuracy', @@ -105,6 +120,9 @@ export const compositeStatsKeys = [ type BlitzStatsKey = (typeof blitzStatsKeys)[number]; export type BlitzStats = Record; +type BlitzkitStatsKey = (typeof blitzkitStatsKeys)[number]; +export type BlitzkitStats = Record; + type BlitzPlayerStatsKey = (typeof blitzPlayerStatsKeys)[number]; export type BlitzPlayerStats = Record; @@ -145,6 +163,7 @@ export const compositeStatsFormatting: { }, normalized_wins: { fixed: 0, unit: '%', coefficient: 100, preview: 0.72 }, normalized_xp: { fixed: 0, preview: 982, localeFormat: true }, + normalized_battle_life_time: { fixed: 1, preview: 4.6, coefficient: 1 / 60 }, cumulative_accuracy: { fixed: 0, unit: '%', coefficient: 100, preview: 0.91 }, cumulative_battles: { fixed: 0, preview: 12 }, @@ -172,4 +191,10 @@ export const compositeStatsFormatting: { cumulative_wins: { fixed: 0, preview: 8 }, cumulative_xp: { fixed: 0, preview: 19403, localeFormat: true }, cumulative_wn8: { fixed: 0, preview: 3103, localeFormat: true }, + cumulative_battle_life_time: { + fixed: 0, + preview: 109, + coefficient: 1 / 60, + localeFormat: true, + }, }; diff --git a/src/core/statistics/compositeStats/index.ts b/src/core/statistics/compositeStats/index.ts index 3887cd5aa..58f7d0d5e 100644 --- a/src/core/statistics/compositeStats/index.ts +++ b/src/core/statistics/compositeStats/index.ts @@ -1,12 +1,12 @@ import calculateWN8 from '../calculateWN8'; import { - BlitzStats, + BlitzkitStats, CompositeStats, compositeStatsFormatting, CompositeStatsKey, } from './constants'; -export function compositeStats(stats: BlitzStats, average: BlitzStats) { +export function compositeStats(stats: BlitzkitStats, average: BlitzkitStats) { return { normalized_damage_dealt: stats.damage_dealt / stats.battles, normalized_damage_received: stats.damage_received / stats.battles, @@ -21,6 +21,7 @@ export function compositeStats(stats: BlitzStats, average: BlitzStats) { normalized_win_and_survived: stats.win_and_survived / stats.battles, normalized_wins: stats.wins / stats.battles, normalized_xp: stats.xp / stats.battles, + normalized_battle_life_time: stats.battle_life_time / stats.battles, cumulative_accuracy: stats.hits / stats.shots, cumulative_battles: stats.battles, @@ -44,6 +45,7 @@ export function compositeStats(stats: BlitzStats, average: BlitzStats) { cumulative_wins: stats.wins, cumulative_xp: stats.xp, cumulative_wn8: calculateWN8(average, stats), + cumulative_battle_life_time: stats.battle_life_time, } satisfies CompositeStats; } diff --git a/src/lang/en-US.json b/src/lang/en-US.json index 69f241fd1..69a209ce9 100644 --- a/src/lang/en-US.json +++ b/src/lang/en-US.json @@ -99,6 +99,7 @@ "normalized_win_and_survived": "Winning and surviving rate", "normalized_wins": "Winrate", "normalized_xp": "XP", + "normalized_battle_life_time": "Battle time", "cumulative_accuracy": "Accuracy", "cumulative_battles": "Battles", @@ -120,7 +121,8 @@ "cumulative_win_and_survived": "Won and survived battles", "cumulative_wins": "Wins", "cumulative_xp": "Total XP", - "cumulative_wn8": "WN8" + "cumulative_wn8": "WN8", + "cumulative_battle_life_time": "Total battle time" } },