phase 12 koncxana

This commit is contained in:
2025-12-08 14:16:24 +01:00
parent f3d476e843
commit 81a7895c10
11 changed files with 547 additions and 39 deletions

View File

@@ -1,44 +1,144 @@
class LegacySystem {
constructor(scene) {
this.scene = scene;
this.worldAge = 0; // Days passed
this.generation = 1;
this.currentAge = 18; // Protagonist age
this.family = {
partner: null,
children: []
// AGE & GENERATION
this.generation = 1;
this.birthDay = 1; // Global Day count when current char was born
this.currentAge = 18; // Start at 18
// FAMILY
this.isMarried = false;
this.spouseName = null;
this.childName = null;
this.childAge = 0;
// FRACTIONS / REPUTATION
this.reputation = {
survivors: 0, // Human NPCs
mutants: -50, // Starts hostile
zombies: 0 // Handled by Hybrid Skill, but we can track here too
};
console.log('⏳ LegacySystem: Initialized (Gen ' + this.generation + ')');
// Listen for Day Change logic
this.scene.events.on('update', (time, delta) => this.update(time, delta));
}
// Call daily
advanceDay() {
this.worldAge++;
// Age Logic
if (this.worldAge % 365 === 0) {
this.currentAge++;
console.log('🎂 Birthday! Now age:', this.currentAge);
update(time, delta) {
if (!this.scene.weatherSystem) return;
const currentDay = this.scene.weatherSystem.dayCount;
// Calculate Age
// 1 Year = 28 Days (4 seasons * 7 days).
const daysAlive = Math.max(0, currentDay - this.birthDay);
const yearsAlive = Math.floor(daysAlive / 28);
// Don't spam update
if (this.currentAge !== 18 + yearsAlive) {
this.currentAge = 18 + yearsAlive;
this.scene.events.emit('update-age-ui', { gen: this.generation, age: this.currentAge });
}
// Child Growth
if (this.childName && currentDay % 28 === 0) {
// Child ages up logic could go here
}
}
marry(npcId) {
this.family.partner = npcId;
console.log('💍 Married to:', npcId);
}
// --- REPUTATION ---
modifyReputation(fraction, amount) {
if (this.reputation[fraction] !== undefined) {
this.reputation[fraction] += amount;
// Clamp -100 to 100
this.reputation[fraction] = Phaser.Math.Clamp(this.reputation[fraction], -100, 100);
haveChild(name) {
if (this.family.children.length < 2) {
this.family.children.push({ name: name, age: 0 });
console.log('👶 New Child:', name);
if (this.scene.player) {
this.scene.events.emit('show-floating-text', {
x: this.scene.player.sprite.x,
y: this.scene.player.sprite.y - 60,
text: `Reputation (${fraction}): ${amount > 0 ? '+' : ''}${amount}`,
color: amount > 0 ? '#00FF00' : '#FF0000'
});
}
}
}
dieAndInherit(heirIndex) {
console.log('⚰️ Character Died. Passing legacy...');
// --- MARRIAGE ---
propose(npc) {
if (this.isMarried) {
this.showText("You are already married!");
return;
}
// Logic: Need Ring and High Rep
const hasRing = this.scene.inventorySystem && this.scene.inventorySystem.hasItem('gold_coin'); // Placeholder: use Gold Coin as "Ring" for now
// Or better: Let's create 'ring' item? For now, Gold Coins (50?).
// Let's require 50 Gold Coins for now? Or specific item?
// Let's assume inventory checks are done before calling this, or simple check here.
const highRep = this.reputation.survivors >= 50;
// Temp logic: Always succeed if rep > 0 for testing?
if (highRep) {
this.isMarried = true;
this.spouseName = npc.name || "Villager";
this.showText(`You married ${this.spouseName}!`);
} else {
this.showText("They refused... (Need 50 Rep)");
}
}
haveChild() {
if (!this.isMarried) return;
if (this.childName) return;
this.childName = "Baby Jr.";
this.childAge = 0;
this.showText("A child is born!");
}
// --- INHERITANCE / DEATH ---
triggerInheritance() {
console.log('💀 TRIGGERING INHERITANCE...');
// 1. Increment Generation
this.generation++;
this.currentAge = 18; // Reset age for heir
// TODO: Transfer inventory and stats
// 2. Reset Player Stats
if (this.scene.weatherSystem) {
this.birthDay = this.scene.weatherSystem.dayCount; // Born today
}
this.currentAge = 18; // Reset age
this.isMarried = false;
this.spouseName = null;
this.childName = null; // Clean slate (child became protagonist)
// 3. Clear transient reputation, but keep a bit?
// Inheritance bonus: Keep 20% of rep?
this.reputation.survivors = Math.floor(this.reputation.survivors * 0.2);
this.reputation.mutants = Math.floor(this.reputation.mutants * 0.2) - 40; // Still suspicious
this.showText(`Step Id: 760
Generation ${this.generation} Begins!`, '#FFD700');
// Heal
if (this.scene.player) {
this.scene.player.hp = this.scene.player.maxHp;
this.scene.player.isDead = false;
this.scene.player.sprite.setTint(0xffffff);
this.scene.player.sprite.setAlpha(1);
}
}
showText(msg, color = '#FFFFFF') {
const player = this.scene.player;
if (player) {
this.scene.events.emit('show-floating-text', {
x: player.sprite.x, y: player.sprite.y - 50, text: msg, color: color
});
}
}
}