mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-23 06:04:32 +01:00
island tanks
This commit is contained in:
19 files changed
+138
-222
No files matched your search
@@ -27,14 +27,4 @@ export abstract class AbstractBlitzKitAPI {
|
||||
abstract scripts(): Promise<BlitzScripts>;
|
||||
|
||||
abstract strings(locale: string): Promise<Strings>;
|
||||
|
||||
async tank(id: number) {
|
||||
const tanks = await this.tanks();
|
||||
return tanks.tanks[id];
|
||||
}
|
||||
|
||||
async model(id: number) {
|
||||
const models = await this.models();
|
||||
return models.models[id];
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@
|
||||
"react-dom": "^19.3.0",
|
||||
"react-error-boundary": "^6.1.3",
|
||||
"react-promise-suspense": "^0.3.4",
|
||||
"soapstone": "^1.0.1",
|
||||
"soapstone": "^1.1.0",
|
||||
"three": "^0.180.0",
|
||||
"three-stdlib": "^2.36.0",
|
||||
"transliteration": "^2.6.1",
|
||||
|
||||
@@ -19,7 +19,7 @@ const [skillDefinitions, tankDefinitions] = await Promise.all([
|
||||
|
||||
export const Page = withLocale(
|
||||
withErrorWrapper(() => {
|
||||
CompareEphemeral.useInitialization(
|
||||
CompareEphemeral.useInitialization(() =>
|
||||
createDefaultEnvironment(skillDefinitions),
|
||||
);
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ interface PageProps {
|
||||
export function Page({ embed, locale }: PageProps & LocaleAcceptorProps) {
|
||||
const config = embedConfigurations[embed];
|
||||
|
||||
EmbedState.useInitialization(extractEmbedConfigDefaults(config));
|
||||
EmbedState.useInitialization(() => extractEmbedConfigDefaults(config));
|
||||
|
||||
return (
|
||||
<LocaleProvider locale={locale}>
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ export function Page({ embed, locale }: PageProps & LocaleAcceptorProps) {
|
||||
return state;
|
||||
}, [embed]);
|
||||
|
||||
EmbedState.useInitialization(state);
|
||||
EmbedState.useInitialization(() => state);
|
||||
|
||||
return (
|
||||
<LocaleProvider locale={locale}>
|
||||
|
||||
@@ -20,7 +20,7 @@ export const Page = withLocale(
|
||||
withErrorWrapper(({ skeleton }: MaybeSkeletonComponentProps) => {
|
||||
const id = Number(ids[Math.floor(Math.random() * ids.length)]);
|
||||
|
||||
Guess.useInitialization(id);
|
||||
Guess.useInitialization(() => id);
|
||||
|
||||
return <Container skeleton={skeleton} />;
|
||||
}),
|
||||
@@ -30,7 +30,7 @@ function Container({ skeleton }: MaybeSkeletonComponentProps) {
|
||||
const id = Guess.use((state) => state.tank);
|
||||
const tank = tankDefinitions.tanks[id];
|
||||
|
||||
Tankopedia.useInitialization(tank);
|
||||
Tankopedia.useInitialization(() => tank);
|
||||
|
||||
useEffect(() => {
|
||||
Tankopedia.mutate((draft) => {
|
||||
|
||||
@@ -18,8 +18,8 @@ export const Page = withLocale(
|
||||
withErrorWrapper(({ skeleton }: MaybeSkeletonComponentProps) => {
|
||||
const initial = useRef(curateMixer());
|
||||
|
||||
Mixer.useInitialization(initial.current);
|
||||
Tankopedia.useInitialization(initial.current.hull);
|
||||
Mixer.useInitialization(() => initial.current);
|
||||
Tankopedia.useInitialization(() => initial.current.hull);
|
||||
|
||||
return (
|
||||
<div className={styles.wrapper}>
|
||||
|
||||
+27
-37
@@ -1,47 +1,37 @@
|
||||
.page {
|
||||
.sandbox {
|
||||
flex-grow: 1;
|
||||
display: flex;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-4);
|
||||
|
||||
.sandbox {
|
||||
flex-grow: 1;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-4);
|
||||
|
||||
@media (pointer: fine) {
|
||||
padding-top: var(--space-4);
|
||||
}
|
||||
@media (pointer: fine) {
|
||||
padding-top: var(--space-4);
|
||||
}
|
||||
}
|
||||
|
||||
.loadout {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-5);
|
||||
|
||||
background-color: var(--gray-2);
|
||||
|
||||
position: sticky;
|
||||
top: 0;
|
||||
|
||||
max-height: 100dvh;
|
||||
overflow-y: auto;
|
||||
|
||||
padding: var(--space-5);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
@media (pointer: coarse) {
|
||||
.sandbox,
|
||||
.loadout {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
background-color: var(--gray-2);
|
||||
|
||||
position: sticky;
|
||||
top: 0;
|
||||
|
||||
max-height: 100dvh;
|
||||
|
||||
.content {
|
||||
padding: var(--space-5);
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-5);
|
||||
}
|
||||
}
|
||||
|
||||
@media (pointer: coarse) {
|
||||
.sandbox,
|
||||
.loadout {
|
||||
&[data-tabbed="false"] {
|
||||
display: none;
|
||||
}
|
||||
&[data-tabbed="false"] {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
import { useMemo } from "react";
|
||||
import { api } from "../../../../../api/dynamic";
|
||||
import {
|
||||
Scroller,
|
||||
ScrollerOrientation,
|
||||
} from "../../../../../components/Scroller";
|
||||
import { ScrollerOrientation } from "../../../../../components/Scroller";
|
||||
import { ScrollerCurtains } from "../../../../../components/ScrollerCurtains";
|
||||
import type { ThicknessRange } from "../../../../../components/TankStaticArmor";
|
||||
import { TankopediaCharacteristics } from "../../../../../components/TankopediaCharacteristics";
|
||||
import { TankopediaGameModeAbilities } from "../../../../../components/TankopediaGameModeAbilities";
|
||||
@@ -14,88 +12,77 @@ import { TankopediaVideos } from "../../../../../components/TankopediaVideos";
|
||||
import { defaultEqualizer } from "../../../../../config/equalizer";
|
||||
import { withErrorWrapper } from "../../../../../hocs/withErrorWrapper";
|
||||
import { withLocale } from "../../../../../hocs/withLocale";
|
||||
import { useAwait } from "../../../../../hooks/useAwait";
|
||||
import { useCharacteristics } from "../../../../../hooks/useCharacteristics";
|
||||
import { Tankopedia, TankopediaTab } from "../../../../../stores/tankopedia";
|
||||
import styles from "./_index.module.css";
|
||||
|
||||
interface PageProps {
|
||||
interface TankProps {
|
||||
id: number;
|
||||
}
|
||||
|
||||
interface SandboxProps {
|
||||
tier: number;
|
||||
}
|
||||
|
||||
const tanks = await api.tanks();
|
||||
|
||||
export const Page = withErrorWrapper(
|
||||
withLocale<PageProps>(({ id }) => {
|
||||
const protagonistTank = useAwait(() => api.tank(id), `tank-${id}`);
|
||||
export const Sandbox = withErrorWrapper(
|
||||
withLocale<TankProps>(({ id }) => {
|
||||
const protagonistTank = tanks.tanks[id];
|
||||
|
||||
Tankopedia.useInitialization(protagonistTank);
|
||||
Tankopedia.useInitialization(() => protagonistTank);
|
||||
|
||||
const protagonist = Tankopedia.use((state) => state.protagonist);
|
||||
const equalize = Tankopedia.use((state) => state.environment.equalize);
|
||||
|
||||
const characteristics = useCharacteristics("protagonist");
|
||||
const antagonistCharacteristics = useCharacteristics("antagonist");
|
||||
|
||||
const thicknessRange = useMemo(() => {
|
||||
const entries = Object.values(tanks.tanks);
|
||||
const filtered = entries.filter(
|
||||
(thisTank) => thisTank.tier === protagonistTank.tier,
|
||||
);
|
||||
const value =
|
||||
(filtered.reduce((accumulator, thisTank) => {
|
||||
return (
|
||||
accumulator +
|
||||
thisTank.turrets.at(-1)!.guns.at(-1)!.shells[0].penetration!.near *
|
||||
((equalize ? thisTank.equalizer : undefined) ?? defaultEqualizer)
|
||||
.penetration
|
||||
);
|
||||
}, 0) /
|
||||
filtered.length) *
|
||||
(3 / 4);
|
||||
|
||||
return { value } satisfies ThicknessRange;
|
||||
}, [protagonist, equalize]);
|
||||
|
||||
return (
|
||||
<div className={styles.page}>
|
||||
<Sandbox tier={protagonistTank.tier} />
|
||||
<Loadout />
|
||||
<div className={styles.sandbox}>
|
||||
<TankopediaSandbox
|
||||
antagonistCharacteristics={antagonistCharacteristics}
|
||||
thicknessRange={thicknessRange}
|
||||
/>
|
||||
<TankopediaCharacteristics characteristics={characteristics} />
|
||||
<TankopediaGameModeAbilities />
|
||||
<TankopediaVideos />
|
||||
|
||||
<TankopediaTabs />
|
||||
</div>
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
function Loadout() {
|
||||
const tabbed = Tankopedia.use((state) => state.tab === TankopediaTab.Loadout);
|
||||
export const Loadout = withErrorWrapper(
|
||||
withLocale<TankProps>(({ id }) => {
|
||||
Tankopedia.useInitialization(() => tanks.tanks[id]);
|
||||
|
||||
return (
|
||||
<Scroller
|
||||
className={styles.loadout}
|
||||
data-tabbed={tabbed}
|
||||
orientation={ScrollerOrientation.Vertical}
|
||||
>
|
||||
<div className={styles.content}>
|
||||
const tabbed = Tankopedia.use(
|
||||
(state) => state.tab === TankopediaTab.Loadout,
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={styles.loadout} data-tabbed={tabbed}>
|
||||
<ScrollerCurtains orientation={ScrollerOrientation.Vertical} />
|
||||
<TankopediaLoadout />
|
||||
</div>
|
||||
</Scroller>
|
||||
);
|
||||
}
|
||||
|
||||
function Sandbox({ tier }: SandboxProps) {
|
||||
const protagonist = Tankopedia.use((state) => state.protagonist);
|
||||
const equalize = Tankopedia.use((state) => state.environment.equalize);
|
||||
|
||||
const characteristics = useCharacteristics("protagonist");
|
||||
const antagonistCharacteristics = useCharacteristics("antagonist");
|
||||
|
||||
const thicknessRange = useMemo(() => {
|
||||
const entries = Object.values(tanks.tanks);
|
||||
const filtered = entries.filter((thisTank) => thisTank.tier === tier);
|
||||
const value =
|
||||
(filtered.reduce((accumulator, thisTank) => {
|
||||
return (
|
||||
accumulator +
|
||||
thisTank.turrets.at(-1)!.guns.at(-1)!.shells[0].penetration!.near *
|
||||
((equalize ? thisTank.equalizer : undefined) ?? defaultEqualizer)
|
||||
.penetration
|
||||
);
|
||||
}, 0) /
|
||||
filtered.length) *
|
||||
(3 / 4);
|
||||
|
||||
return { value } satisfies ThicknessRange;
|
||||
}, [protagonist, equalize]);
|
||||
|
||||
return (
|
||||
<div className={styles.sandbox}>
|
||||
<TankopediaSandbox
|
||||
antagonistCharacteristics={antagonistCharacteristics}
|
||||
thicknessRange={thicknessRange}
|
||||
/>
|
||||
<TankopediaCharacteristics characteristics={characteristics} />
|
||||
<TankopediaGameModeAbilities />
|
||||
<TankopediaVideos />
|
||||
|
||||
<TankopediaTabs />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
);
|
||||
}),
|
||||
);
|
||||
@@ -1,12 +1,12 @@
|
||||
---
|
||||
import { api } from "../../../../../api/dynamic";
|
||||
import { mixStaticPaths } from "../../../../../astro/mixStaticPaths";
|
||||
import ColorScale from "../../../../../components/ColorScale.astro";
|
||||
import ColorRanks from "../../../../../components/ColorRanks.astro";
|
||||
import ColorScale from "../../../../../components/ColorScale.astro";
|
||||
import { tools } from "../../../../../constants/tools";
|
||||
import BaseLayout from "../../../../../layouts/BaseLayout.astro";
|
||||
import { getStaticPaths as _getStaticPaths } from "../index.astro";
|
||||
import { Page } from "./_index";
|
||||
import { Loadout, Sandbox } from "./_index";
|
||||
|
||||
export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => {
|
||||
const tanks = await api.tanks();
|
||||
@@ -25,6 +25,18 @@ const { id, locale } = Astro.props;
|
||||
<ColorScale color="green" />
|
||||
<ColorRanks />
|
||||
|
||||
<style>
|
||||
.page {
|
||||
flex-grow: 1;
|
||||
display: flex;
|
||||
|
||||
gap: var(--space-4);
|
||||
}
|
||||
</style>
|
||||
|
||||
<BaseLayout tool={tools.tanks} {locale} accent="violet">
|
||||
<Page {id} {locale} client:load />
|
||||
<div class="page">
|
||||
<Sandbox {id} {locale} client:load />
|
||||
<Loadout {id} {locale} client:load />
|
||||
</div>
|
||||
</BaseLayout>
|
||||
@@ -19,7 +19,7 @@ export interface CompareEphemeral {
|
||||
|
||||
export const CompareEphemeral = new Soapstone<
|
||||
CompareEphemeral,
|
||||
[TankEnvironment]
|
||||
TankEnvironment
|
||||
>((environment) => ({
|
||||
environment,
|
||||
syncShells: false,
|
||||
|
||||
@@ -100,6 +100,6 @@ export type EmbedConfigItem = (
|
||||
|
||||
export type EmbedStateStore = Record<string, EmbedConfigItem["default"]>;
|
||||
|
||||
export const EmbedState = new Soapstone<EmbedStateStore, [EmbedStateStore]>(
|
||||
export const EmbedState = new Soapstone<EmbedStateStore, EmbedStateStore>(
|
||||
(data) => data
|
||||
);
|
||||
@@ -8,7 +8,9 @@ import { embedText } from "./tokens";
|
||||
|
||||
export function useEmbedStateCurry<Config extends EmbedConfig>() {
|
||||
// TODO: find a way to initialize with the correct state preset
|
||||
EmbedState.useInitialization(extractEmbedConfigDefaults(breakdownConfig));
|
||||
EmbedState.useInitialization(() =>
|
||||
extractEmbedConfigDefaults(breakdownConfig),
|
||||
);
|
||||
|
||||
function useEmbedState<Key extends keyof Config>(key: Key) {
|
||||
return EmbedState.use((state) => {
|
||||
|
||||
@@ -21,7 +21,7 @@ export interface Guess {
|
||||
tiers: number[];
|
||||
}
|
||||
|
||||
export const Guess = new Soapstone<Guess, [number]>((tank) => ({
|
||||
export const Guess = new Soapstone<Guess, number>((tank) => ({
|
||||
tank,
|
||||
guessState: GuessState.NotGuessed,
|
||||
totalGuesses: 0,
|
||||
|
||||
@@ -18,4 +18,4 @@ export interface Mixer {
|
||||
};
|
||||
}
|
||||
|
||||
export const Mixer = new Soapstone<Mixer, [Mixer]>((data) => data);
|
||||
export const Mixer = new Soapstone<Mixer, Mixer>((data) => data);
|
||||
@@ -134,32 +134,30 @@ export enum TankopediaTab {
|
||||
|
||||
const skills = await api.skills();
|
||||
|
||||
export const Tankopedia = new Soapstone<Tankopedia, [TankDefinition]>(
|
||||
(tank) => ({
|
||||
disturbed: false,
|
||||
revealed: false,
|
||||
showControls: false,
|
||||
animate: true,
|
||||
export const Tankopedia = new Soapstone<Tankopedia, TankDefinition>((tank) => ({
|
||||
disturbed: false,
|
||||
revealed: false,
|
||||
showControls: false,
|
||||
animate: true,
|
||||
|
||||
tab: TankopediaTab.Sandbox,
|
||||
tab: TankopediaTab.Sandbox,
|
||||
|
||||
protagonist: createTankState(tank),
|
||||
antagonist: createTankState(tank),
|
||||
environment: createDefaultEnvironment(skills),
|
||||
protagonist: createTankState(tank),
|
||||
antagonist: createTankState(tank),
|
||||
environment: createDefaultEnvironment(skills),
|
||||
|
||||
relative_against: TankopediaRelativeAgainst.ClassAndTier,
|
||||
relative_against: TankopediaRelativeAgainst.ClassAndTier,
|
||||
|
||||
loaders: {
|
||||
display: {
|
||||
requested: TankopediaDisplay.Model,
|
||||
loaded: TankopediaDisplay.Model,
|
||||
},
|
||||
model: { requested: App.state.autoLoadModels, loaded: false },
|
||||
skin: { requested: undefined, loaded: undefined },
|
||||
attachment: { requested: undefined, loaded: undefined },
|
||||
loaders: {
|
||||
display: {
|
||||
requested: TankopediaDisplay.Model,
|
||||
loaded: TankopediaDisplay.Model,
|
||||
},
|
||||
model: { requested: App.state.autoLoadModels, loaded: false },
|
||||
skin: { requested: undefined, loaded: undefined },
|
||||
attachment: { requested: undefined, loaded: undefined },
|
||||
},
|
||||
|
||||
editStatic: false,
|
||||
xpMultiplier: 1,
|
||||
}),
|
||||
);
|
||||
editStatic: false,
|
||||
xpMultiplier: 1,
|
||||
}));
|
||||
Reference in new issue
Block a user