event tweaks
@@ -795,6 +795,12 @@ class TribeGenApp
795
795
document.getElementById('itemModal').classList.add('hidden');
796
796
}
797
797
798
hideKoboldModal ()
799
{
800
const modal = document.getElementById('koboldModal');
801
modal.classList.add('hidden');
802
}
803
798
804
showKoboldModal (kobold)
799
805
{
800
806
const modal = document.getElementById('koboldModal');
@@ -904,7 +910,7 @@ class TribeGenApp
904
910
actions.className = 'injury-actions';
905
911
906
912
// malnourished has no cure button here
907
if (injury.category !== 'malnourished')
913
if (injury.category !== 'malnourished' && injury.category !== 'old-age')
908
914
{
909
915
// Get required medicine from server or calculate from cureMap
910
916
let required = injury.required_medicine || injury.requiredMedicine || null;
@@ -935,12 +941,14 @@ class TribeGenApp
935
941
const data = JSON.parse(dataText);
936
942
if (data.success)
937
943
{
944
this.hideKoboldModal();
938
945
typeText(document.getElementById('eventStory'), data.story);
939
946
this.showEventModal();
940
947
// Refresh game state
941
948
await this.loadGame(this.currentSave.id);
942
949
// reopen kobold modal after refresh
943
950
const refreshed = this.currentTribe.kobolds.find(k => k.id === kobold.id);
951
944
952
} else
945
953
{
946
954
alert(data.error || 'Failed to cure injury');
@@ -795,6 +795,12 @@ class TribeGenApp795
document.getElementById('itemModal').classList.add('hidden');795
document.getElementById('itemModal').classList.add('hidden');796
}796
}797
797
798
hideKoboldModal ()799
{800
const modal = document.getElementById('koboldModal');801
modal.classList.add('hidden');802
}803
798
showKoboldModal (kobold)804
showKoboldModal (kobold)799
{805
{800
const modal = document.getElementById('koboldModal');806
const modal = document.getElementById('koboldModal');@@ -904,7 +910,7 @@ class TribeGenApp904
actions.className = 'injury-actions';910
actions.className = 'injury-actions';905
911
906
// malnourished has no cure button here912
// malnourished has no cure button here907
if (injury.category !== 'malnourished')913
if (injury.category !== 'malnourished' && injury.category !== 'old-age')908
{914
{909
// Get required medicine from server or calculate from cureMap915
// Get required medicine from server or calculate from cureMap910
let required = injury.required_medicine || injury.requiredMedicine || null;916
let required = injury.required_medicine || injury.requiredMedicine || null;@@ -935,12 +941,14 @@ class TribeGenApp935
const data = JSON.parse(dataText);941
const data = JSON.parse(dataText);936
if (data.success)942
if (data.success)937
{943
{944
this.hideKoboldModal();938
typeText(document.getElementById('eventStory'), data.story);945
typeText(document.getElementById('eventStory'), data.story);939
this.showEventModal();946
this.showEventModal();940
// Refresh game state947
// Refresh game state941
await this.loadGame(this.currentSave.id);948
await this.loadGame(this.currentSave.id);942
// reopen kobold modal after refresh949
// reopen kobold modal after refresh943
const refreshed = this.currentTribe.kobolds.find(k => k.id === kobold.id);950
const refreshed = this.currentTribe.kobolds.find(k => k.id === kobold.id);951
944
} else952
} else945
{953
{946
alert(data.error || 'Failed to cure injury');954
alert(data.error || 'Failed to cure injury');@@ -368,18 +368,10 @@ class Kobold
368
368
369
369
public function getAgeProgress()
370
370
{
371
// Returns 0-1 indicating progress to next age tier
372
$ageTiers = [-1, 0, 4, 35, 60];
373
374
for ($i = 0; $i < count($ageTiers) - 1; $i++) {
375
$tierStart = $ageTiers[$i];
376
$tierEnd = $ageTiers[$i + 1];
377
378
if ($this->age >= $tierStart && $this->age < $tierEnd) {
379
$duration = $tierEnd - $tierStart;
380
$progress = ($this->age - $tierStart) / $duration;
381
return $progress;
382
}
371
if ($this->age < 17) {
372
return $this->age / 17;
373
} else if ($this->age > 40) {
374
return 1 - (40 / $this->age);
383
375
}
384
376
385
377
return 1;
@@ -393,10 +385,7 @@ class Kobold
393
385
394
386
$baseStat = $this->stats[$statName];
395
387
396
// Scale stats for non-adult kobolds
397
if ($this->getAgeCategory() === 'baby' || $this->getAgeCategory() === 'egg') {
398
$baseStat = (int) ($baseStat * $this->getAgeProgress());
399
}
388
$baseStat = (int) ($baseStat * $this->getAgeProgress());
400
389
401
390
return $baseStat;
402
391
}
@@ -368,18 +368,10 @@ class Kobold368
368
369
public function getAgeProgress()369
public function getAgeProgress()370
{370
{371
// Returns 0-1 indicating progress to next age tier371
if ($this->age < 17) {372
$ageTiers = [-1, 0, 4, 35, 60];372
return $this->age / 17;373
373
} else if ($this->age > 40) {374
for ($i = 0; $i < count($ageTiers) - 1; $i++) {374
return 1 - (40 / $this->age);375
$tierStart = $ageTiers[$i];376
$tierEnd = $ageTiers[$i + 1];377
378
if ($this->age >= $tierStart && $this->age < $tierEnd) {379
$duration = $tierEnd - $tierStart;380
$progress = ($this->age - $tierStart) / $duration;381
return $progress;382
}383
}375
}384
376
385
return 1;377
return 1;@@ -393,10 +385,7 @@ class Kobold393
385
394
$baseStat = $this->stats[$statName];386
$baseStat = $this->stats[$statName];395
387
396
// Scale stats for non-adult kobolds388
$baseStat = (int) ($baseStat * $this->getAgeProgress());397
if ($this->getAgeCategory() === 'baby' || $this->getAgeCategory() === 'egg') {398
$baseStat = (int) ($baseStat * $this->getAgeProgress());399
}400
389
401
return $baseStat;390
return $baseStat;402
}391
}@@ -33,11 +33,16 @@ class ExplorationEvent extends Event
33
33
throw new \Exception('No valid living kobolds found in participants list.');
34
34
}
35
35
36
$this->story .= "A group of " . count($explorers) . " intrepid explorers set out:\n";
37
foreach ($explorers as $explorer) {
38
$this->story .= "- " . $explorer->getName() . " (Intelligence: " . GameHelper::getStatLabel($explorer->getStat('intelligence')) . ")\n";
36
$this->story .= count($explorers) > 1 ?
37
"A group of " . count($explorers) . " intrepid explorers set out:\n"
38
: $explorers[0]->getName() . " sets out to explore.\n";
39
40
if (count($explorers) > 1) {
41
foreach ($explorers as $explorer) {
42
$this->story .= "- " . $explorer->getName() . "\n";
43
}
44
$this->story .= "\n";
39
45
}
40
$this->story .= "\n";
41
46
42
47
// Chance to find food (50% base)
43
48
$foodFound = rand(1, 100) <= 50;
@@ -47,6 +52,7 @@ class ExplorationEvent extends Event
47
52
$avgIntelligence = array_sum(array_map(function ($k) {
48
53
return $k->getStat('intelligence');
49
54
}, $explorers)) / count($explorers);
55
50
56
$foodBonus = intval($avgIntelligence / 20); // Max +5 food from intelligence
51
57
$totalFood = $baseFood + $foodBonus;
52
58
@@ -70,7 +76,7 @@ class ExplorationEvent extends Event
70
76
$this->story .= $injuredKobold->getName() . " broke a leg!\n";
71
77
}
72
78
73
$stickFound = rand(1, 100) <= 20;
79
$stickFound = rand(1, 100) <= 200;
74
80
if ($stickFound) {
75
81
$bestKobold = GameHelper::findBestKoboldForStat($explorers, "crafting");
76
82
@@ -80,13 +86,11 @@ class ExplorationEvent extends Event
80
86
$boneItem = GameHelper::loadItem('bone-setting');
81
87
if ($boneItem) {
82
88
$this->tribe->addToStorage($boneItem);
83
$this->story .= "The explorers also salvaged a Bone-setting kit and brought it back to storage.\n";
89
$this->story .= "{$bestKobold->getName()} finds a nice stick and fashions it into a Splint the tribe can use to treat fractures.\n";
84
90
}
91
} else {
92
$this->story .= "{$bestKobold->getName()} finds a stick suitable to be a splint, but it breaks as {$bestKobold->he()} tries to craft it.\n";
85
93
}
86
else
87
{
88
$this->story .= "$bestKobold->getName() finds a stick suitable to be a splint, but it breaks as $bestKobold->he() tries to craft it.\n";
89
}
90
94
}
91
95
$this->story .= "\nThe exploration party returned to the tribe with their findings.";
92
96
@@ -33,11 +33,16 @@ class ExplorationEvent extends Event33
throw new \Exception('No valid living kobolds found in participants list.');33
throw new \Exception('No valid living kobolds found in participants list.');34
}34
}35
35
36
$this->story .= "A group of " . count($explorers) . " intrepid explorers set out:\n";36
$this->story .= count($explorers) > 1 ?37
foreach ($explorers as $explorer) {37
"A group of " . count($explorers) . " intrepid explorers set out:\n"38
$this->story .= "- " . $explorer->getName() . " (Intelligence: " . GameHelper::getStatLabel($explorer->getStat('intelligence')) . ")\n";38
: $explorers[0]->getName() . " sets out to explore.\n";39
40
if (count($explorers) > 1) {41
foreach ($explorers as $explorer) {42
$this->story .= "- " . $explorer->getName() . "\n";43
}44
$this->story .= "\n";39
}45
}40
$this->story .= "\n";41
46
42
// Chance to find food (50% base)47
// Chance to find food (50% base)43
$foodFound = rand(1, 100) <= 50;48
$foodFound = rand(1, 100) <= 50;@@ -47,6 +52,7 @@ class ExplorationEvent extends Event47
$avgIntelligence = array_sum(array_map(function ($k) {52
$avgIntelligence = array_sum(array_map(function ($k) {48
return $k->getStat('intelligence');53
return $k->getStat('intelligence');49
}, $explorers)) / count($explorers);54
}, $explorers)) / count($explorers);55
50
$foodBonus = intval($avgIntelligence / 20); // Max +5 food from intelligence56
$foodBonus = intval($avgIntelligence / 20); // Max +5 food from intelligence51
$totalFood = $baseFood + $foodBonus;57
$totalFood = $baseFood + $foodBonus;52
58
@@ -70,7 +76,7 @@ class ExplorationEvent extends Event70
$this->story .= $injuredKobold->getName() . " broke a leg!\n";76
$this->story .= $injuredKobold->getName() . " broke a leg!\n";71
}77
}72
78
73
$stickFound = rand(1, 100) <= 20;79
$stickFound = rand(1, 100) <= 200;74
if ($stickFound) {80
if ($stickFound) {75
$bestKobold = GameHelper::findBestKoboldForStat($explorers, "crafting");81
$bestKobold = GameHelper::findBestKoboldForStat($explorers, "crafting");76
82
@@ -80,13 +86,11 @@ class ExplorationEvent extends Event80
$boneItem = GameHelper::loadItem('bone-setting');86
$boneItem = GameHelper::loadItem('bone-setting');81
if ($boneItem) {87
if ($boneItem) {82
$this->tribe->addToStorage($boneItem);88
$this->tribe->addToStorage($boneItem);83
$this->story .= "The explorers also salvaged a Bone-setting kit and brought it back to storage.\n";89
$this->story .= "{$bestKobold->getName()} finds a nice stick and fashions it into a Splint the tribe can use to treat fractures.\n";84
}90
}91
} else {92
$this->story .= "{$bestKobold->getName()} finds a stick suitable to be a splint, but it breaks as {$bestKobold->he()} tries to craft it.\n";85
}93
}86
else87
{88
$this->story .= "$bestKobold->getName() finds a stick suitable to be a splint, but it breaks as $bestKobold->he() tries to craft it.\n";89
}90
}94
}91
$this->story .= "\nThe exploration party returned to the tribe with their findings.";95
$this->story .= "\nThe exploration party returned to the tribe with their findings.";92
96
@@ -288,8 +288,8 @@ class GameHelper
288
288
289
289
for ($k = 0; $k < count($kobolds); $k++) {
290
290
$kobold = $kobolds[$k];
291
if ($kobold->stats[$skillId] > $highest) {
292
$highest = $kobold->stats[$skillId];
291
if ($kobold->getStat($skillId) > $highest) {
292
$highest = $kobold->getStat($skillId);
293
293
$selected = $kobold;
294
294
}
295
295
}
@@ -288,8 +288,8 @@ class GameHelper288
288
289
for ($k = 0; $k < count($kobolds); $k++) {289
for ($k = 0; $k < count($kobolds); $k++) {290
$kobold = $kobolds[$k];290
$kobold = $kobolds[$k];291
if ($kobold->stats[$skillId] > $highest) {291
if ($kobold->getStat($skillId) > $highest) {292
$highest = $kobold->stats[$skillId];292
$highest = $kobold->getStat($skillId);293
$selected = $kobold;293
$selected = $kobold;294
}294
}295
}295
}