mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
fix: hosting
This commit is contained in:
1 parent
31666c9bb6
commit
acf36ec461
16 files changed
+98
-9
No files matched your search
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -26,7 +26,7 @@ export function Slider({
|
||||
]}
|
||||
onValueChange={([value]) => {
|
||||
mutateEmbedState((draft) => {
|
||||
draft[configKey] = `${value}`;
|
||||
draft[configKey] = value;
|
||||
});
|
||||
}}
|
||||
/>
|
||||
File renamed without changes.
File renamed without changes.
+34
-2
@@ -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({
|
||||
<Flex mb="4" gap="2">
|
||||
<Button
|
||||
onClick={() => {
|
||||
console.log(`${location.origin}/embed/${params.embed}/host`);
|
||||
const { wargaming } = appStore.getState().logins;
|
||||
|
||||
if (!wargaming) return;
|
||||
|
||||
const state = embedStateStore.getState();
|
||||
const initial = embedStateStore.getInitialState();
|
||||
const shallowState: EmbedState.EmbedState = {};
|
||||
|
||||
Object.entries(state).forEach(([key, value]) => {
|
||||
if (value !== initial[key]) {
|
||||
shallowState[key] = value;
|
||||
}
|
||||
});
|
||||
|
||||
const searchParams = new URLSearchParams({
|
||||
id: `${wargaming.id}`,
|
||||
state: JSON.stringify(shallowState),
|
||||
});
|
||||
|
||||
navigator.clipboard.writeText(
|
||||
`${location.origin}/tools/embed/${params.embed}/host?${searchParams.toString()}`,
|
||||
);
|
||||
}}
|
||||
>
|
||||
<CopyIcon />
|
||||
Copy URL
|
||||
</Button>
|
||||
<Button variant="outline">
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
navigator.clipboard.writeText(
|
||||
'body { margin: 0; background-color: transparent; overflow: hidden; }',
|
||||
);
|
||||
}}
|
||||
>
|
||||
<CopyIcon />
|
||||
Copy CSS
|
||||
</Button>
|
||||
@@ -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 (
|
||||
<PageWrapper>
|
||||
<Text>{params.embed}</Text>
|
||||
|
||||
<Text></Text>
|
||||
<Code color="gray">
|
||||
<pre>{JSON.stringify(JSON.parse(searchParams['state']), null, 2)}</pre>
|
||||
</Code>
|
||||
</PageWrapper>
|
||||
);
|
||||
}
|
||||
@@ -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<BlitzStatsKey, number>;
|
||||
|
||||
type BlitzkitStatsKey = (typeof blitzkitStatsKeys)[number];
|
||||
export type BlitzkitStats = Record<BlitzkitStatsKey, number>;
|
||||
|
||||
type BlitzPlayerStatsKey = (typeof blitzPlayerStatsKeys)[number];
|
||||
export type BlitzPlayerStats = Record<BlitzPlayerStatsKey, number>;
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
};
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -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"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in new issue
Block a user