feat(jogo): expediente dos mortos, jogo de zumbis em primeira pessoa
Etapa 1 inteira (logica com 100% de cobertura, cena 3D, toque, sons, bancada de desempenho, e2e) e a base da etapa 2 (mapa novo no Tiled, texturas, imagens dos itens, sons conferidos, golpe recortado e medido). Pagina /jogo fora do menu e do sitemap ate a medicao no celular.
This commit is contained in:
1 parent
c7d09d63d4
commit
67b32fcab3
118 files changed
+16730
No files matched your search
@@ -0,0 +1,60 @@
|
||||
import { problemaPorId, problemasDaArea } from "./problemas";
|
||||
import { sortearInteiro } from "./rng";
|
||||
import type { Dificuldade, NaFila, TipoZumbi } from "./tipos";
|
||||
import { DIFICULDADES, HORDAS } from "./valores";
|
||||
|
||||
export function tamanhoDaHorda(
|
||||
indice: number,
|
||||
dificuldade: Dificuldade,
|
||||
): number {
|
||||
if (indice !== 0 && indice !== 1 && indice !== 2) {
|
||||
throw new Error(`Índice de horda inválido: ${indice}`);
|
||||
}
|
||||
return Math.max(
|
||||
1,
|
||||
Math.round(HORDAS.tamanhos[indice] * DIFICULDADES[dificuldade].quantidade),
|
||||
);
|
||||
}
|
||||
|
||||
export function escolherHordas(
|
||||
p: { rng: number },
|
||||
problemaId: string,
|
||||
): string[] {
|
||||
const problema = problemaPorId(problemaId);
|
||||
if (!problema) throw new Error(`Problema desconhecido: ${problemaId}`);
|
||||
const outros = problemasDaArea(problema.area)
|
||||
.map((candidato) => candidato.id)
|
||||
.filter((id) => id !== problemaId);
|
||||
const escolhidos: string[] = [];
|
||||
for (let i = 0; i < 3; i++) {
|
||||
escolhidos.push(...outros.splice(sortearInteiro(p, outros.length), 1));
|
||||
}
|
||||
return [...escolhidos, problemaId];
|
||||
}
|
||||
|
||||
function tipoDaPosicao(indice: number, posicao: number): TipoZumbi {
|
||||
if (indice === 0) return "comum";
|
||||
if (indice === 1) return posicao % 2 === 0 ? "comum" : "rapido";
|
||||
const resto = posicao % 5;
|
||||
if (resto < 2) return "comum";
|
||||
return resto < 4 ? "rapido" : "blindado";
|
||||
}
|
||||
|
||||
export function montarFila(
|
||||
indice: number,
|
||||
problemaId: string,
|
||||
dificuldade: Dificuldade,
|
||||
): NaFila[] {
|
||||
if (indice === 3) {
|
||||
const tipos: TipoZumbi[] = [
|
||||
"chefao",
|
||||
...Array<TipoZumbi>(HORDAS.escoltaDoChefao).fill("comum"),
|
||||
];
|
||||
return tipos.map((tipo) => ({ tipo, problemaId }));
|
||||
}
|
||||
const total = tamanhoDaHorda(indice, dificuldade);
|
||||
return Array.from({ length: total }, (_, posicao) => ({
|
||||
tipo: tipoDaPosicao(indice, posicao),
|
||||
problemaId,
|
||||
}));
|
||||
}
|
||||
Reference in new issue
Block a user