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:
2026-03-03 22:24:17 +01:00
commit e031c9a1d2
155 changed files with 22334 additions and 0 deletions

View File

@@ -0,0 +1,102 @@
/**
* Auto-mode profiles: 50 specialisations in 5 families.
* Used by player auto mode and bot zoos (bots still use legacy random fast/slow/balanced).
* Params: spendThreshold (multiplier on cost to allow spend), upgradeChance (01), sellChance (01, bots only).
*/
/** @typedef {{ id: number, familyId: number, spendThreshold: number, upgradeChance: number, sellChance: number, labelKey: string, prioritiesKey: string, risksKey: string }} AutoModeProfile */
/** Families 15: Conservateurs, Éleveurs, Commerçants, Expansionnistes, Scientifiques. */
export const AUTO_MODE_FAMILY_IDS = [1, 2, 3, 4, 5];
/** Profile id range per family: 110, 1120, 2130, 3140, 4150. */
const FAMILY_RANGES = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50]];
/** Legacy profile name to default profile id (balanced=25, fast=33, slow=7). */
export const LEGACY_PROFILE_TO_ID = { balanced: 25, fast: 33, slow: 7 };
/**
* All 50 profiles. Params tuned per family.
* @type {AutoModeProfile[]}
*/
const PROFILES = [];
function buildProfiles() {
for (let familyId = 1; familyId <= 5; familyId++) {
const [minId, maxId] = FAMILY_RANGES[familyId - 1];
for (let id = minId; id <= maxId; id++) {
const i = (id - minId) / (maxId - minId);
const spendThreshold = 0.5 + i * 2;
const upgradeChance = 0.05 + i * 0.5;
const sellChance = familyId === 2 ? 0.02 + i * 0.08 : familyId === 3 ? 0.08 + i * 0.12 : 0.02 + i * 0.1;
PROFILES.push({
id,
familyId,
spendThreshold: Math.round(spendThreshold * 100) / 100,
upgradeChance: Math.round(upgradeChance * 100) / 100,
sellChance: Math.round(sellChance * 100) / 100,
labelKey: `autoProfile.specialisation.${id}`,
prioritiesKey: `autoProfile.priorities.${id}`,
risksKey: `autoProfile.risks.${id}`,
});
}
}
}
buildProfiles();
/**
* Resolve effective profile id from state (autoModeProfileId or legacy autoModeProfile).
* @param {{ autoModeProfileId?: number, autoModeProfile?: string }} state
* @returns {number}
*/
export function getEffectiveProfileId(state) {
const id = state.autoModeProfileId;
if (id !== null && id !== undefined && id >= 1 && id <= 50) return id;
const legacy = state.autoModeProfile;
if (legacy === "fast" || legacy === "slow" || legacy === "balanced") return LEGACY_PROFILE_TO_ID[legacy];
return LEGACY_PROFILE_TO_ID.balanced;
}
/**
* Get profile by id (150). Returns default balanced params if not found.
* @param {number} profileId
* @returns {AutoModeProfile}
*/
export function getProfileById(profileId) {
const p = PROFILES.find((x) => x.id === profileId);
if (p) return p;
const def = PROFILES.find((x) => x.id === 25);
return def ?? PROFILES[0];
}
/**
* Params for use in bot/player auto logic.
* @param {number} profileId
* @returns {{ spendThreshold: number, upgradeChance: number, sellChance: number }}
*/
export function getProfileParams(profileId) {
const p = getProfileById(profileId);
return {
spendThreshold: p.spendThreshold,
upgradeChance: p.upgradeChance,
sellChance: p.sellChance,
};
}
/**
* All profiles in the given family (15).
* @param {number} familyId
* @returns {AutoModeProfile[]}
*/
export function getProfilesByFamily(familyId) {
return PROFILES.filter((p) => p.familyId === familyId);
}
/** All 50 profiles.
* @returns {AutoModeProfile[]}
*/
export function getAllProfiles() {
return [...PROFILES];
}
export { FAMILY_RANGES };