BlueGit

blue-star tribegen

FARMING DONE

also egg happening done

timfa Tim · pushed by timfa

Authored 2026-01-29 · 9 months ago

Hash
d1e9b1cbad7f81de1e392d1d650c9563c689b688
Parent
8bb1fbc6
4 files changed +30 −10
web/assets/injuries/malnourished.json added +15 −0
@@ -0,0 +1,15 @@
1 {
2 "injuryType": "Malnourished",
3 "description": "This kobold did not receive enough food and is suffering from malnutrition.",
4 "category": "malnourished",
5 "severity": 5,
6 "statModifications": {
7 "vitality": -10,
8 "intelligence": 0,
9 "medicine": 0,
10 "crafting": -1,
11 "personality": -3,
12 "will": -5,
13 "fighting": -8
14 }
15 }
@@ -0,0 +1,15 @@
1{
2 "injuryType": "Malnourished",
3 "description": "This kobold did not receive enough food and is suffering from malnutrition.",
4 "category": "malnourished",
5 "severity": 5,
6 "statModifications": {
7 "vitality": -10,
8 "intelligence": 0,
9 "medicine": 0,
10 "crafting": -1,
11 "personality": -3,
12 "will": -5,
13 "fighting": -8
14 }
15}
web/js/app.js +13 −3
@@ -596,12 +596,16 @@ class TribeGenApp
596 596 const row = document.createElement('div');
597 597 row.className = `participant-row ${eligible ? 'eligible' : 'ineligible'}`;
598 598
599 const fatigueValue = Number(kobold.fatigue || 0);
600 const vitalityValue = Number(kobold.stats?.vitality || 0);
601 const fatigueLabel = kobold.fatigue_label || this.getFatigueLabel(fatigueValue, vitalityValue);
602
599 603 if (eligible)
600 604 {
601 605 row.innerHTML = `
602 606 <label>
603 607 <input type="checkbox" class="participant-checkbox" data-id="${kobold.id}">
604 <strong>${kobold.name}</strong> (${kobold.ageCategory != "egg" ? `${kobold.age}y - ${kobold.ageCategory}` : 'egg'})
608 <strong>${kobold.name}</strong> (${kobold.ageCategory != "egg" ? fatigueLabel : 'egg'})
605 609 </label>
606 610 `;
607 611 const cb = row.querySelector('.participant-checkbox');
@@ -610,7 +614,7 @@ class TribeGenApp
610 614 {
611 615 row.innerHTML = `
612 616 <div class="participant-disabled">
613 <span>${kobold.name} (${kobold.ageCategory != "egg" ? `${kobold.age}y - ${kobold.ageCategory}` : 'egg'})</span>
617 <span>${kobold.name} (${kobold.ageCategory != "egg" ? fatigueLabel : 'egg'})</span>
614 618 <span class="disabled-reason">${reason}</span>
615 619 </div>
616 620 `;
@@ -1085,6 +1089,7 @@ class TribeGenApp
1085 1089 document.getElementById('itemModalName').textContent = item.name;
1086 1090 document.getElementById('itemModalDescription').textContent = item.description || 'No description';
1087 1091
1092 this.hideKoboldModal();
1088 1093 // Show stat modifications (handle both camelCase and snake_case)
1089 1094 const statMods = document.getElementById('itemModalStatMods');
1090 1095 statMods.innerHTML = '';
@@ -1114,7 +1119,12 @@ class TribeGenApp
1114 1119 const returnBtn = document.createElement('button');
1115 1120 returnBtn.className = 'secondary';
1116 1121 returnBtn.textContent = 'Return to Storage';
1117 returnBtn.addEventListener('click', () => this.returnItemToStorage(item, kobold));
1122 returnBtn.addEventListener('click', () =>
1123 {
1124 this.hideKoboldModal();
1125 this.returnItemToStorage(item, kobold);
1126 });
1127
1118 1128 actions.appendChild(returnBtn);
1119 1129
1120 1130 modal.classList.remove('hidden');
@@ -596,12 +596,16 @@ class TribeGenApp
596 const row = document.createElement('div');
596 const row = document.createElement('div');
597 row.className = `participant-row ${eligible ? 'eligible' : 'ineligible'}`;
597 row.className = `participant-row ${eligible ? 'eligible' : 'ineligible'}`;
598
598
599 const fatigueValue = Number(kobold.fatigue || 0);
600 const vitalityValue = Number(kobold.stats?.vitality || 0);
601 const fatigueLabel = kobold.fatigue_label || this.getFatigueLabel(fatigueValue, vitalityValue);
602
599 if (eligible)
603 if (eligible)
600 {
604 {
601 row.innerHTML = `
605 row.innerHTML = `
602 <label>
606 <label>
603 <input type="checkbox" class="participant-checkbox" data-id="${kobold.id}">
607 <input type="checkbox" class="participant-checkbox" data-id="${kobold.id}">
604 <strong>${kobold.name}</strong> (${kobold.ageCategory != "egg" ? `${kobold.age}y - ${kobold.ageCategory}` : 'egg'})
608 <strong>${kobold.name}</strong> (${kobold.ageCategory != "egg" ? fatigueLabel : 'egg'})
605 </label>
609 </label>
606 `;
610 `;
607 const cb = row.querySelector('.participant-checkbox');
611 const cb = row.querySelector('.participant-checkbox');
@@ -610,7 +614,7 @@ class TribeGenApp
610 {
614 {
611 row.innerHTML = `
615 row.innerHTML = `
612 <div class="participant-disabled">
616 <div class="participant-disabled">
613 <span>${kobold.name} (${kobold.ageCategory != "egg" ? `${kobold.age}y - ${kobold.ageCategory}` : 'egg'})</span>
617 <span>${kobold.name} (${kobold.ageCategory != "egg" ? fatigueLabel : 'egg'})</span>
614 <span class="disabled-reason">${reason}</span>
618 <span class="disabled-reason">${reason}</span>
615 </div>
619 </div>
616 `;
620 `;
@@ -1085,6 +1089,7 @@ class TribeGenApp
1085 document.getElementById('itemModalName').textContent = item.name;
1089 document.getElementById('itemModalName').textContent = item.name;
1086 document.getElementById('itemModalDescription').textContent = item.description || 'No description';
1090 document.getElementById('itemModalDescription').textContent = item.description || 'No description';
1087
1091
1092 this.hideKoboldModal();
1088 // Show stat modifications (handle both camelCase and snake_case)
1093 // Show stat modifications (handle both camelCase and snake_case)
1089 const statMods = document.getElementById('itemModalStatMods');
1094 const statMods = document.getElementById('itemModalStatMods');
1090 statMods.innerHTML = '';
1095 statMods.innerHTML = '';
@@ -1114,7 +1119,12 @@ class TribeGenApp
1114 const returnBtn = document.createElement('button');
1119 const returnBtn = document.createElement('button');
1115 returnBtn.className = 'secondary';
1120 returnBtn.className = 'secondary';
1116 returnBtn.textContent = 'Return to Storage';
1121 returnBtn.textContent = 'Return to Storage';
1117 returnBtn.addEventListener('click', () => this.returnItemToStorage(item, kobold));
1122 returnBtn.addEventListener('click', () =>
1123 {
1124 this.hideKoboldModal();
1125 this.returnItemToStorage(item, kobold);
1126 });
1127
1118 actions.appendChild(returnBtn);
1128 actions.appendChild(returnBtn);
1119
1129
1120 modal.classList.remove('hidden');
1130 modal.classList.remove('hidden');
web/src/Events/FarmingEvent.php +2 −2
@@ -54,7 +54,7 @@ class FarmingEvent extends Event
54 54 for ($i = 0; $i < count($explorers); $i++) {
55 55 $farmer = $explorers[$i];
56 56
57 if (!$farmer->checkStat('will')) {
57 if (!$farmer->checkStat('will') && rand(1, 100) <= 30) {
58 58 $farmer->addInjury("smallCut");
59 59 $this->story .= "{$farmer->getName()} had an accident plowing the field, cutting {$farmer->his()} leg with the hoe.\n";
60 60 break;
@@ -64,7 +64,7 @@ class FarmingEvent extends Event
64 64 for ($i = 0; $i < count($explorers); $i++) {
65 65 $farmer = $explorers[$i];
66 66
67 if ($farmer->checkStat('intelligence')) {
67 if ($farmer->checkStat('intelligence') && rand(1, 100) <= 40) {
68 68 $herbs = GameHelper::loadItem('healing-herbs');
69 69 $this->tribe->addToStorage($herbs, rand(1, 3));
70 70 $this->story .= "{$farmer->getName()} managed to grow some useful healing herbs while tending the crops.\n";
@@ -54,7 +54,7 @@ class FarmingEvent extends Event
54 for ($i = 0; $i < count($explorers); $i++) {
54 for ($i = 0; $i < count($explorers); $i++) {
55 $farmer = $explorers[$i];
55 $farmer = $explorers[$i];
56
56
57 if (!$farmer->checkStat('will')) {
57 if (!$farmer->checkStat('will') && rand(1, 100) <= 30) {
58 $farmer->addInjury("smallCut");
58 $farmer->addInjury("smallCut");
59 $this->story .= "{$farmer->getName()} had an accident plowing the field, cutting {$farmer->his()} leg with the hoe.\n";
59 $this->story .= "{$farmer->getName()} had an accident plowing the field, cutting {$farmer->his()} leg with the hoe.\n";
60 break;
60 break;
@@ -64,7 +64,7 @@ class FarmingEvent extends Event
64 for ($i = 0; $i < count($explorers); $i++) {
64 for ($i = 0; $i < count($explorers); $i++) {
65 $farmer = $explorers[$i];
65 $farmer = $explorers[$i];
66
66
67 if ($farmer->checkStat('intelligence')) {
67 if ($farmer->checkStat('intelligence') && rand(1, 100) <= 40) {
68 $herbs = GameHelper::loadItem('healing-herbs');
68 $herbs = GameHelper::loadItem('healing-herbs');
69 $this->tribe->addToStorage($herbs, rand(1, 3));
69 $this->tribe->addToStorage($herbs, rand(1, 3));
70 $this->story .= "{$farmer->getName()} managed to grow some useful healing herbs while tending the crops.\n";
70 $this->story .= "{$farmer->getName()} managed to grow some useful healing herbs while tending the crops.\n";
web/src/api/game.php +0 −5
@@ -154,7 +154,6 @@ if ($method === 'POST') {
154 154 $reflection = new ReflectionClass($target);
155 155 if ($reflection->hasProperty('items')) {
156 156 $prop = $reflection->getProperty('items');
157 $prop->setAccessible(true);
158 157 $prop->setValue($target, $newItems);
159 158 }
160 159
@@ -220,7 +219,6 @@ if ($method === 'POST') {
220 219 $ref = new ReflectionClass($target);
221 220 if ($ref->hasProperty('items')) {
222 221 $prop = $ref->getProperty('items');
223 $prop->setAccessible(true);
224 222 $items = $prop->getValue($target) ?? [];
225 223 $items[] = $found;
226 224 $prop->setValue($target, $items);
@@ -231,7 +229,6 @@ if ($method === 'POST') {
231 229 $refT = new ReflectionClass($tribe);
232 230 if ($refT->hasProperty('storage')) {
233 231 $p = $refT->getProperty('storage');
234 $p->setAccessible(true);
235 232 $p->setValue($tribe, array_values($newStorage));
236 233 }
237 234
@@ -292,7 +289,6 @@ if ($method === 'POST') {
292 289 $ref = new ReflectionClass($target);
293 290 if ($ref->hasProperty('items')) {
294 291 $p = $ref->getProperty('items');
295 $p->setAccessible(true);
296 292 $p->setValue($target, $newItems);
297 293 }
298 294 }
@@ -303,7 +299,6 @@ if ($method === 'POST') {
303 299 $refT = new ReflectionClass($tribe);
304 300 if ($refT->hasProperty('storage')) {
305 301 $p = $refT->getProperty('storage');
306 $p->setAccessible(true);
307 302 $p->setValue($tribe, $storage);
308 303 }
309 304
@@ -154,7 +154,6 @@ if ($method === 'POST') {
154 $reflection = new ReflectionClass($target);
154 $reflection = new ReflectionClass($target);
155 if ($reflection->hasProperty('items')) {
155 if ($reflection->hasProperty('items')) {
156 $prop = $reflection->getProperty('items');
156 $prop = $reflection->getProperty('items');
157 $prop->setAccessible(true);
158 $prop->setValue($target, $newItems);
157 $prop->setValue($target, $newItems);
159 }
158 }
160
159
@@ -220,7 +219,6 @@ if ($method === 'POST') {
220 $ref = new ReflectionClass($target);
219 $ref = new ReflectionClass($target);
221 if ($ref->hasProperty('items')) {
220 if ($ref->hasProperty('items')) {
222 $prop = $ref->getProperty('items');
221 $prop = $ref->getProperty('items');
223 $prop->setAccessible(true);
224 $items = $prop->getValue($target) ?? [];
222 $items = $prop->getValue($target) ?? [];
225 $items[] = $found;
223 $items[] = $found;
226 $prop->setValue($target, $items);
224 $prop->setValue($target, $items);
@@ -231,7 +229,6 @@ if ($method === 'POST') {
231 $refT = new ReflectionClass($tribe);
229 $refT = new ReflectionClass($tribe);
232 if ($refT->hasProperty('storage')) {
230 if ($refT->hasProperty('storage')) {
233 $p = $refT->getProperty('storage');
231 $p = $refT->getProperty('storage');
234 $p->setAccessible(true);
235 $p->setValue($tribe, array_values($newStorage));
232 $p->setValue($tribe, array_values($newStorage));
236 }
233 }
237
234
@@ -292,7 +289,6 @@ if ($method === 'POST') {
292 $ref = new ReflectionClass($target);
289 $ref = new ReflectionClass($target);
293 if ($ref->hasProperty('items')) {
290 if ($ref->hasProperty('items')) {
294 $p = $ref->getProperty('items');
291 $p = $ref->getProperty('items');
295 $p->setAccessible(true);
296 $p->setValue($target, $newItems);
292 $p->setValue($target, $newItems);
297 }
293 }
298 }
294 }
@@ -303,7 +299,6 @@ if ($method === 'POST') {
303 $refT = new ReflectionClass($tribe);
299 $refT = new ReflectionClass($tribe);
304 if ($refT->hasProperty('storage')) {
300 if ($refT->hasProperty('storage')) {
305 $p = $refT->getProperty('storage');
301 $p = $refT->getProperty('storage');
306 $p->setAccessible(true);
307 $p->setValue($tribe, $storage);
302 $p->setValue($tribe, $storage);
308 }
303 }
309
304