Initial commit
**Motivations:** - Initialisation du versionning git pour le projet **Root causes:** - N/A (Nouveau projet) **Correctifs:** - N/A **Evolutions:** - Structure initiale du projet - Ajout du .gitignore **Pages affectées:** - Tous les fichiers
This commit is contained in:
66
web/js/default-grid-layout.js
Normal file
66
web/js/default-grid-layout.js
Normal file
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Shared default zoo grid layout: row 1 building cells and 3 starter couples (row 2).
|
||||
* Used by state.js (defaultState) and prestige.js (doPrestige).
|
||||
*/
|
||||
|
||||
import { LootTables } from "./loot-tables.js";
|
||||
import { fillAnimalBlock } from "./placement.js";
|
||||
|
||||
/** Row 1 layout: (col, kind). Columns 1–6. */
|
||||
const ROW1_LAYOUT = [
|
||||
[1, "research"],
|
||||
[2, "billeterie"],
|
||||
[3, "nursery"],
|
||||
[4, "reception"],
|
||||
[5, "food"],
|
||||
[6, "school"],
|
||||
];
|
||||
|
||||
/**
|
||||
* Build default cells for row 1 (research, billeterie, nursery, reception, food, school).
|
||||
* @returns {Record<string, { kind: string, level: number }>}
|
||||
*/
|
||||
export function buildDefaultRow1Cells() {
|
||||
const cells = {};
|
||||
for (const [col, kind] of ROW1_LAYOUT) {
|
||||
cells[`${col}_1`] = { kind, level: 1 };
|
||||
}
|
||||
return cells;
|
||||
}
|
||||
|
||||
/** Default animal ids for the 3 starter couples (one per biome: Meadow, Ocean, Mountain). */
|
||||
export const STARTER_ANIMAL_IDS_BY_BIOME = ["c0_r0", "c5_r0", "c10_r0"];
|
||||
|
||||
/** Positions for the 6 starter animals (row 2, columns 1–6). */
|
||||
export const STARTER_ANIMAL_POSITIONS = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2]];
|
||||
|
||||
/**
|
||||
* Place 3 breeding couples (6 animals) on the grid. Mutates state.grid.cells.
|
||||
* @param {import("./types.js").GameState} state
|
||||
*/
|
||||
export function addStarterAnimals(state) {
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
let idx = 0;
|
||||
for (const animalId of STARTER_ANIMAL_IDS_BY_BIOME) {
|
||||
const def = LootTables.Animals[animalId];
|
||||
if (def !== null && def !== undefined) {
|
||||
const w = def.cellsWide ?? 1;
|
||||
const h = def.cellsHigh ?? 1;
|
||||
for (let pair = 0; pair < 2 && idx < STARTER_ANIMAL_POSITIONS.length; pair++, idx++) {
|
||||
const [x, y] = STARTER_ANIMAL_POSITIONS[idx];
|
||||
fillAnimalBlock(state, x, y, {
|
||||
kind: "animal",
|
||||
id: animalId,
|
||||
mutation: "none",
|
||||
level: 1,
|
||||
placedAt: now,
|
||||
lastVisitedAt: now,
|
||||
lastFedAt: now,
|
||||
cellsWide: w,
|
||||
cellsHigh: h,
|
||||
fromOtherZoo: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user