BlueGit

blue-star tribegen

upd

timfa Tim Falken · pushed by timfa

Authored 2026-02-05 · 9 months ago

Hash
3298ef22953c170a69bfc60efc8dd2e854e2b182
Parent
7c42ecab
12 files changed +269 −21
web/assets/injuries/dehydrated.json added +15 −0
@@ -0,0 +1,15 @@
1 {
2 "injuryType": "Dehydrated",
3 "description": "Severe thirst and weakness from lack of water, leaving the kobold sluggish and unfocused.",
4 "category": "weather",
5 "severity": 4,
6 "statModifications": {
7 "vitality": -6,
8 "intelligence": -2,
9 "medicine": 0,
10 "crafting": -2,
11 "personality": -2,
12 "will": -4,
13 "fighting": -4
14 }
15 }
@@ -0,0 +1,15 @@
1{
2 "injuryType": "Dehydrated",
3 "description": "Severe thirst and weakness from lack of water, leaving the kobold sluggish and unfocused.",
4 "category": "weather",
5 "severity": 4,
6 "statModifications": {
7 "vitality": -6,
8 "intelligence": -2,
9 "medicine": 0,
10 "crafting": -2,
11 "personality": -2,
12 "will": -4,
13 "fighting": -4
14 }
15}
web/assets/injuries/heatstroke.json added +15 −0
@@ -0,0 +1,15 @@
1 {
2 "injuryType": "Heatstroke",
3 "description": "Overwhelmed by extreme heat, the kobold is weak, dizzy, and slow to react.",
4 "category": "weather",
5 "severity": 5,
6 "statModifications": {
7 "vitality": -8,
8 "intelligence": -3,
9 "medicine": 0,
10 "crafting": -3,
11 "personality": -2,
12 "will": -5,
13 "fighting": -6
14 }
15 }
@@ -0,0 +1,15 @@
1{
2 "injuryType": "Heatstroke",
3 "description": "Overwhelmed by extreme heat, the kobold is weak, dizzy, and slow to react.",
4 "category": "weather",
5 "severity": 5,
6 "statModifications": {
7 "vitality": -8,
8 "intelligence": -3,
9 "medicine": 0,
10 "crafting": -3,
11 "personality": -2,
12 "will": -5,
13 "fighting": -6
14 }
15}
web/src/Classes/Tribe.php +51 −11
@@ -832,9 +832,57 @@ class Tribe
832 832 if (!isset($this->dataStore)) {
833 833 $this->dataStore = new stdClass();
834 834 }
835 $this->dataStore->heatWaveActive = false;
835 $this->dataStore->heatWaveActive = max(0, (int) ($this->dataStore->heatWaveActive ?? 0) - 1);
836 $this->dataStore->draught = max(0, (int) ($this->dataStore->draught ?? 0) - 1);
836 837 $this->dataStore->floodedThisMonth = false;
837 $this->dataStore->draught = false;
838
839 $ongoingWeatherStory = '';
840 if ($this->dataStore->draught > 0) {
841 $droughtLines = [
842 "The drought continues, and the land remains cracked and dry.\n",
843 "No rain comes yet; the drought persists across the camp.\n",
844 "The drought has not broken, and the tribe endures another dry month.\n"
845 ];
846 $ongoingWeatherStory .= $droughtLines[array_rand($droughtLines)];
847 }
848 if ($this->dataStore->heatWaveActive > 0) {
849 $heatLines = [
850 "The heat wave continues, and the camp moves slowly under the oppressive sun.\n",
851 "The heat wave has not faded; the tribe bears another sweltering month.\n",
852 "Relief does not come, and the heat wave presses on.\n"
853 ];
854 $ongoingWeatherStory .= $heatLines[array_rand($heatLines)];
855 }
856
857 if ($this->dataStore->draught <= 0) {
858 foreach ($this->getKobolds() as $kobold) {
859 $injuries = $kobold->getInjuries();
860 foreach ($injuries as $injury) {
861 if (($injury['id'] ?? null) === 'dehydrated') {
862 $kobold->removeInjury('dehydrated');
863 }
864 }
865 }
866 }
867
868 foreach ($this->getKobolds() as $kobold) {
869 $injuries = $kobold->getInjuries();
870 $hasHeatstroke = false;
871 foreach ($injuries as $injury) {
872 if (($injury['id'] ?? null) === 'heatstroke') {
873 $hasHeatstroke = true;
874 break;
875 }
876 }
877
878 if ($hasHeatstroke) {
879 $vitality = (int) ($kobold->getStat('vitality') ?? 0);
880 $baselineFatigue = (int) ceil($vitality * 0.75);
881 if ($this->dataStore->heatWaveActive <= 0 || $kobold->getFatigue() <= $baselineFatigue) {
882 $kobold->removeInjury('heatstroke');
883 }
884 }
885 }
838 886
839 887 foreach ($this->kobolds as $kobold) {
840 888 $kobold->resetFatigue();
@@ -903,23 +951,15 @@ class Tribe
903 951 }
904 952
905 953 // Execute end-of-month events
906 $monthEventStory = '';
954 $monthEventStory = $ongoingWeatherStory;
907 955 $endOfMonthEvents = $this->getEndOfMonthEvents();
908 956
909 957 $hasFloodEvent = false;
910 $hasHeatWaveEvent = false;
911 958 foreach ($endOfMonthEvents as $event) {
912 959 $className = get_class($event);
913 960 if ($className === 'SmallFloodEvent' || $className === 'LargeFloodEvent') {
914 961 $hasFloodEvent = true;
915 962 }
916 if ($className === 'HeatWaveEvent') {
917 $hasHeatWaveEvent = true;
918 }
919 }
920
921 if ($hasHeatWaveEvent) {
922 $this->dataStore->heatWaveActive = true;
923 963 }
924 964
925 965 if ($hasFloodEvent) {
@@ -832,9 +832,57 @@ class Tribe
832 if (!isset($this->dataStore)) {
832 if (!isset($this->dataStore)) {
833 $this->dataStore = new stdClass();
833 $this->dataStore = new stdClass();
834 }
834 }
835 $this->dataStore->heatWaveActive = false;
835 $this->dataStore->heatWaveActive = max(0, (int) ($this->dataStore->heatWaveActive ?? 0) - 1);
836 $this->dataStore->draught = max(0, (int) ($this->dataStore->draught ?? 0) - 1);
836 $this->dataStore->floodedThisMonth = false;
837 $this->dataStore->floodedThisMonth = false;
837 $this->dataStore->draught = false;
838
839 $ongoingWeatherStory = '';
840 if ($this->dataStore->draught > 0) {
841 $droughtLines = [
842 "The drought continues, and the land remains cracked and dry.\n",
843 "No rain comes yet; the drought persists across the camp.\n",
844 "The drought has not broken, and the tribe endures another dry month.\n"
845 ];
846 $ongoingWeatherStory .= $droughtLines[array_rand($droughtLines)];
847 }
848 if ($this->dataStore->heatWaveActive > 0) {
849 $heatLines = [
850 "The heat wave continues, and the camp moves slowly under the oppressive sun.\n",
851 "The heat wave has not faded; the tribe bears another sweltering month.\n",
852 "Relief does not come, and the heat wave presses on.\n"
853 ];
854 $ongoingWeatherStory .= $heatLines[array_rand($heatLines)];
855 }
856
857 if ($this->dataStore->draught <= 0) {
858 foreach ($this->getKobolds() as $kobold) {
859 $injuries = $kobold->getInjuries();
860 foreach ($injuries as $injury) {
861 if (($injury['id'] ?? null) === 'dehydrated') {
862 $kobold->removeInjury('dehydrated');
863 }
864 }
865 }
866 }
867
868 foreach ($this->getKobolds() as $kobold) {
869 $injuries = $kobold->getInjuries();
870 $hasHeatstroke = false;
871 foreach ($injuries as $injury) {
872 if (($injury['id'] ?? null) === 'heatstroke') {
873 $hasHeatstroke = true;
874 break;
875 }
876 }
877
878 if ($hasHeatstroke) {
879 $vitality = (int) ($kobold->getStat('vitality') ?? 0);
880 $baselineFatigue = (int) ceil($vitality * 0.75);
881 if ($this->dataStore->heatWaveActive <= 0 || $kobold->getFatigue() <= $baselineFatigue) {
882 $kobold->removeInjury('heatstroke');
883 }
884 }
885 }
838
886
839 foreach ($this->kobolds as $kobold) {
887 foreach ($this->kobolds as $kobold) {
840 $kobold->resetFatigue();
888 $kobold->resetFatigue();
@@ -903,23 +951,15 @@ class Tribe
903 }
951 }
904
952
905 // Execute end-of-month events
953 // Execute end-of-month events
906 $monthEventStory = '';
954 $monthEventStory = $ongoingWeatherStory;
907 $endOfMonthEvents = $this->getEndOfMonthEvents();
955 $endOfMonthEvents = $this->getEndOfMonthEvents();
908
956
909 $hasFloodEvent = false;
957 $hasFloodEvent = false;
910 $hasHeatWaveEvent = false;
911 foreach ($endOfMonthEvents as $event) {
958 foreach ($endOfMonthEvents as $event) {
912 $className = get_class($event);
959 $className = get_class($event);
913 if ($className === 'SmallFloodEvent' || $className === 'LargeFloodEvent') {
960 if ($className === 'SmallFloodEvent' || $className === 'LargeFloodEvent') {
914 $hasFloodEvent = true;
961 $hasFloodEvent = true;
915 }
962 }
916 if ($className === 'HeatWaveEvent') {
917 $hasHeatWaveEvent = true;
918 }
919 }
920
921 if ($hasHeatWaveEvent) {
922 $this->dataStore->heatWaveActive = true;
923 }
963 }
924
964
925 if ($hasFloodEvent) {
965 if ($hasFloodEvent) {
web/src/Events/DroughtDehydrationEvent.php added +78 −0
@@ -0,0 +1,78 @@
1 <?php
2
3 require_once __DIR__ . '/../../src/Events/MonthEndEvent.php';
4
5 class DroughtDehydrationEvent extends MonthEndEvent
6 {
7 public function getMinAge()
8 {
9 return 0;
10 }
11
12 public function getMinParticipants()
13 {
14 return 1;
15 }
16
17 public function getMaxParticipants()
18 {
19 return 3;
20 }
21
22 public function getCost()
23 {
24 return 30;
25 }
26
27 public function isAvailable()
28 {
29 if (empty($this->tribe->dataStore->draught) || $this->tribe->dataStore->draught <= 0) {
30 return false;
31 }
32
33 $eligible = array_filter($this->tribe->getKobolds(), function ($kobold) {
34 foreach ($kobold->getInjuries() as $injury) {
35 if (($injury['id'] ?? null) === 'dehydrated') {
36 return false;
37 }
38 }
39 return $kobold->getAge() >= $this->getMinAge();
40 });
41
42 return !empty($eligible);
43 }
44
45 public function execute()
46 {
47 $eligible = array_values(array_filter($this->tribe->getKobolds(), function ($kobold) {
48 foreach ($kobold->getInjuries() as $injury) {
49 if (($injury['id'] ?? null) === 'dehydrated') {
50 return false;
51 }
52 }
53 return $kobold->getAge() >= $this->getMinAge();
54 }));
55
56 if (empty($eligible)) {
57 return;
58 }
59
60 shuffle($eligible);
61 $count = rand($this->getMinParticipants(), min($this->getMaxParticipants(), count($eligible)));
62 $targets = array_slice($eligible, 0, $count);
63
64 foreach ($targets as $kobold) {
65 $kobold->addInjury('dehydrated');
66 $kobold->save();
67 }
68
69 $names = implode(', ', array_map(fn($k) => $k->getName(), $targets));
70 $variations = [
71 "The drought wore on, and {$names} became dehydrated from the harsh conditions.",
72 "With the dry air and sparse water, {$names} fell ill with dehydration.",
73 "The drought took its toll; {$names} showed signs of dehydration by month's end."
74 ];
75
76 $this->story = $variations[array_rand($variations)];
77 }
78 }
@@ -0,0 +1,78 @@
1<?php
2
3require_once __DIR__ . '/../../src/Events/MonthEndEvent.php';
4
5class DroughtDehydrationEvent extends MonthEndEvent
6{
7 public function getMinAge()
8 {
9 return 0;
10 }
11
12 public function getMinParticipants()
13 {
14 return 1;
15 }
16
17 public function getMaxParticipants()
18 {
19 return 3;
20 }
21
22 public function getCost()
23 {
24 return 30;
25 }
26
27 public function isAvailable()
28 {
29 if (empty($this->tribe->dataStore->draught) || $this->tribe->dataStore->draught <= 0) {
30 return false;
31 }
32
33 $eligible = array_filter($this->tribe->getKobolds(), function ($kobold) {
34 foreach ($kobold->getInjuries() as $injury) {
35 if (($injury['id'] ?? null) === 'dehydrated') {
36 return false;
37 }
38 }
39 return $kobold->getAge() >= $this->getMinAge();
40 });
41
42 return !empty($eligible);
43 }
44
45 public function execute()
46 {
47 $eligible = array_values(array_filter($this->tribe->getKobolds(), function ($kobold) {
48 foreach ($kobold->getInjuries() as $injury) {
49 if (($injury['id'] ?? null) === 'dehydrated') {
50 return false;
51 }
52 }
53 return $kobold->getAge() >= $this->getMinAge();
54 }));
55
56 if (empty($eligible)) {
57 return;
58 }
59
60 shuffle($eligible);
61 $count = rand($this->getMinParticipants(), min($this->getMaxParticipants(), count($eligible)));
62 $targets = array_slice($eligible, 0, $count);
63
64 foreach ($targets as $kobold) {
65 $kobold->addInjury('dehydrated');
66 $kobold->save();
67 }
68
69 $names = implode(', ', array_map(fn($k) => $k->getName(), $targets));
70 $variations = [
71 "The drought wore on, and {$names} became dehydrated from the harsh conditions.",
72 "With the dry air and sparse water, {$names} fell ill with dehydration.",
73 "The drought took its toll; {$names} showed signs of dehydration by month's end."
74 ];
75
76 $this->story = $variations[array_rand($variations)];
77 }
78}
web/src/Events/DroughtEvent.php +12 −1
@@ -30,6 +30,10 @@ class DroughtEvent extends MonthEndEvent
30 30 return false;
31 31 }
32 32
33 if (!empty($this->tribe->dataStore->draught)) {
34 return false;
35 }
36
33 37 if (isset($this->tribe->dataStore) && isset($this->tribe->dataStore->floodedThisMonth) && $this->tribe->dataStore->floodedThisMonth) {
34 38 return false;
35 39 }
@@ -37,13 +41,20 @@ class DroughtEvent extends MonthEndEvent
37 41 return true;
38 42 }
39 43
44 private function getMonthsUntilNextSeason()
45 {
46 $monthOfYear = (($this->tribe->getCurrentMonth() - 1) % 12) + 1;
47 $monthInSeason = (($monthOfYear - 1) % 3) + 1;
48 return max(1, 3 - $monthInSeason + 1);
49 }
50
40 51 public function execute()
41 52 {
42 53 if (!isset($this->tribe->dataStore)) {
43 54 $this->tribe->dataStore = new stdClass();
44 55 }
45 56
46 $this->tribe->dataStore->draught = true;
57 $this->tribe->dataStore->draught = rand(1, $this->getMonthsUntilNextSeason());
47 58
48 59 $variations = [
49 60 "The heat lingered and the land cracked. No rain came, and the tribe marked the month as a drought, watching the streams grow thin.",
@@ -30,6 +30,10 @@ class DroughtEvent extends MonthEndEvent
30 return false;
30 return false;
31 }
31 }
32
32
33 if (!empty($this->tribe->dataStore->draught)) {
34 return false;
35 }
36
33 if (isset($this->tribe->dataStore) && isset($this->tribe->dataStore->floodedThisMonth) && $this->tribe->dataStore->floodedThisMonth) {
37 if (isset($this->tribe->dataStore) && isset($this->tribe->dataStore->floodedThisMonth) && $this->tribe->dataStore->floodedThisMonth) {
34 return false;
38 return false;
35 }
39 }
@@ -37,13 +41,20 @@ class DroughtEvent extends MonthEndEvent
37 return true;
41 return true;
38 }
42 }
39
43
44 private function getMonthsUntilNextSeason()
45 {
46 $monthOfYear = (($this->tribe->getCurrentMonth() - 1) % 12) + 1;
47 $monthInSeason = (($monthOfYear - 1) % 3) + 1;
48 return max(1, 3 - $monthInSeason + 1);
49 }
50
40 public function execute()
51 public function execute()
41 {
52 {
42 if (!isset($this->tribe->dataStore)) {
53 if (!isset($this->tribe->dataStore)) {
43 $this->tribe->dataStore = new stdClass();
54 $this->tribe->dataStore = new stdClass();
44 }
55 }
45
56
46 $this->tribe->dataStore->draught = true;
57 $this->tribe->dataStore->draught = rand(1, $this->getMonthsUntilNextSeason());
47
58
48 $variations = [
59 $variations = [
49 "The heat lingered and the land cracked. No rain came, and the tribe marked the month as a drought, watching the streams grow thin.",
60 "The heat lingered and the land cracked. No rain came, and the tribe marked the month as a drought, watching the streams grow thin.",
web/src/Events/ExplorationEvent.php +1 −1
@@ -82,7 +82,7 @@ class ExplorationEvent extends Event
82 82 $foodBonus = intval($avgIntelligence / 20); // Max +5 food from intelligence
83 83 $totalFood = $baseFood + $foodBonus;
84 84
85 if (!empty($this->tribe->dataStore->draught)) {
85 if (!empty($this->tribe->dataStore->draught) && $this->tribe->dataStore->draught > 0) {
86 86 $totalFood = (int) floor($totalFood / 2);
87 87 $this->story .= "The drought stunted the forage, cutting it down.\n";
88 88 }
@@ -82,7 +82,7 @@ class ExplorationEvent extends Event
82 $foodBonus = intval($avgIntelligence / 20); // Max +5 food from intelligence
82 $foodBonus = intval($avgIntelligence / 20); // Max +5 food from intelligence
83 $totalFood = $baseFood + $foodBonus;
83 $totalFood = $baseFood + $foodBonus;
84
84
85 if (!empty($this->tribe->dataStore->draught)) {
85 if (!empty($this->tribe->dataStore->draught) && $this->tribe->dataStore->draught > 0) {
86 $totalFood = (int) floor($totalFood / 2);
86 $totalFood = (int) floor($totalFood / 2);
87 $this->story .= "The drought stunted the forage, cutting it down.\n";
87 $this->story .= "The drought stunted the forage, cutting it down.\n";
88 }
88 }
web/src/Events/FarmingEvent.php +1 −1
@@ -175,7 +175,7 @@ class FarmingEvent extends Event
175 175 }
176 176
177 177
178 if (!empty($this->tribe->dataStore->draught)) {
178 if (!empty($this->tribe->dataStore->draught) && $this->tribe->dataStore->draught > 0) {
179 179 $totalFood = (int) floor($totalFood / 2);
180 180 $this->story .= "The drought wilted the crops, halving what could be gathered.\n";
181 181 }
@@ -175,7 +175,7 @@ class FarmingEvent extends Event
175 }
175 }
176
176
177
177
178 if (!empty($this->tribe->dataStore->draught)) {
178 if (!empty($this->tribe->dataStore->draught) && $this->tribe->dataStore->draught > 0) {
179 $totalFood = (int) floor($totalFood / 2);
179 $totalFood = (int) floor($totalFood / 2);
180 $this->story .= "The drought wilted the crops, halving what could be gathered.\n";
180 $this->story .= "The drought wilted the crops, halving what could be gathered.\n";
181 }
181 }
web/src/Events/HeatWaveEvent.php +13 −2
@@ -26,7 +26,18 @@ class HeatWaveEvent extends MonthEndEvent
26 26
27 27 public function isAvailable()
28 28 {
29 return $this->tribe->getCurrentSeason() === 'summer';
29 if ($this->tribe->getCurrentSeason() !== 'summer') {
30 return false;
31 }
32
33 return empty($this->tribe->dataStore->heatWaveActive);
34 }
35
36 private function getMonthsUntilNextSeason()
37 {
38 $monthOfYear = (($this->tribe->getCurrentMonth() - 1) % 12) + 1;
39 $monthInSeason = (($monthOfYear - 1) % 3) + 1;
40 return max(1, 3 - $monthInSeason + 1);
30 41 }
31 42
32 43 public function execute()
@@ -35,7 +46,7 @@ class HeatWaveEvent extends MonthEndEvent
35 46 $this->tribe->dataStore = new stdClass();
36 47 }
37 48
38 $this->tribe->dataStore->heatWaveActive = true;
49 $this->tribe->dataStore->heatWaveActive = rand(1, $this->getMonthsUntilNextSeason());
39 50
40 51 foreach ($this->tribe->getKobolds() as $kobold) {
41 52 $vitality = (int) ($kobold->getStat('vitality') ?? 0);
@@ -26,7 +26,18 @@ class HeatWaveEvent extends MonthEndEvent
26
26
27 public function isAvailable()
27 public function isAvailable()
28 {
28 {
29 return $this->tribe->getCurrentSeason() === 'summer';
29 if ($this->tribe->getCurrentSeason() !== 'summer') {
30 return false;
31 }
32
33 return empty($this->tribe->dataStore->heatWaveActive);
34 }
35
36 private function getMonthsUntilNextSeason()
37 {
38 $monthOfYear = (($this->tribe->getCurrentMonth() - 1) % 12) + 1;
39 $monthInSeason = (($monthOfYear - 1) % 3) + 1;
40 return max(1, 3 - $monthInSeason + 1);
30 }
41 }
31
42
32 public function execute()
43 public function execute()
@@ -35,7 +46,7 @@ class HeatWaveEvent extends MonthEndEvent
35 $this->tribe->dataStore = new stdClass();
46 $this->tribe->dataStore = new stdClass();
36 }
47 }
37
48
38 $this->tribe->dataStore->heatWaveActive = true;
49 $this->tribe->dataStore->heatWaveActive = rand(1, $this->getMonthsUntilNextSeason());
39
50
40 foreach ($this->tribe->getKobolds() as $kobold) {
51 foreach ($this->tribe->getKobolds() as $kobold) {
41 $vitality = (int) ($kobold->getStat('vitality') ?? 0);
52 $vitality = (int) ($kobold->getStat('vitality') ?? 0);
web/src/Events/HeatWaveHeatstrokeEvent.php added +78 −0
@@ -0,0 +1,78 @@
1 <?php
2
3 require_once __DIR__ . '/../../src/Events/MonthEndEvent.php';
4
5 class HeatWaveHeatstrokeEvent extends MonthEndEvent
6 {
7 public function getMinAge()
8 {
9 return 0;
10 }
11
12 public function getMinParticipants()
13 {
14 return 1;
15 }
16
17 public function getMaxParticipants()
18 {
19 return 3;
20 }
21
22 public function getCost()
23 {
24 return 35;
25 }
26
27 public function isAvailable()
28 {
29 if (empty($this->tribe->dataStore->heatWaveActive) || $this->tribe->dataStore->heatWaveActive <= 0) {
30 return false;
31 }
32
33 $eligible = array_filter($this->tribe->getKobolds(), function ($kobold) {
34 foreach ($kobold->getInjuries() as $injury) {
35 if (($injury['id'] ?? null) === 'heatstroke') {
36 return false;
37 }
38 }
39 return $kobold->getAge() >= $this->getMinAge();
40 });
41
42 return !empty($eligible);
43 }
44
45 public function execute()
46 {
47 $eligible = array_values(array_filter($this->tribe->getKobolds(), function ($kobold) {
48 foreach ($kobold->getInjuries() as $injury) {
49 if (($injury['id'] ?? null) === 'heatstroke') {
50 return false;
51 }
52 }
53 return $kobold->getAge() >= $this->getMinAge();
54 }));
55
56 if (empty($eligible)) {
57 return;
58 }
59
60 shuffle($eligible);
61 $count = rand($this->getMinParticipants(), min($this->getMaxParticipants(), count($eligible)));
62 $targets = array_slice($eligible, 0, $count);
63
64 foreach ($targets as $kobold) {
65 $kobold->addInjury('heatstroke');
66 $kobold->save();
67 }
68
69 $names = implode(', ', array_map(fn($k) => $k->getName(), $targets));
70 $variations = [
71 "The heat wave proved too much for {$names}, who suffered heatstroke.",
72 "Under the relentless sun, {$names} collapsed with heatstroke.",
73 "The scorching days left {$names} with heatstroke by the month's end."
74 ];
75
76 $this->story = $variations[array_rand($variations)];
77 }
78 }
@@ -0,0 +1,78 @@
1<?php
2
3require_once __DIR__ . '/../../src/Events/MonthEndEvent.php';
4
5class HeatWaveHeatstrokeEvent extends MonthEndEvent
6{
7 public function getMinAge()
8 {
9 return 0;
10 }
11
12 public function getMinParticipants()
13 {
14 return 1;
15 }
16
17 public function getMaxParticipants()
18 {
19 return 3;
20 }
21
22 public function getCost()
23 {
24 return 35;
25 }
26
27 public function isAvailable()
28 {
29 if (empty($this->tribe->dataStore->heatWaveActive) || $this->tribe->dataStore->heatWaveActive <= 0) {
30 return false;
31 }
32
33 $eligible = array_filter($this->tribe->getKobolds(), function ($kobold) {
34 foreach ($kobold->getInjuries() as $injury) {
35 if (($injury['id'] ?? null) === 'heatstroke') {
36 return false;
37 }
38 }
39 return $kobold->getAge() >= $this->getMinAge();
40 });
41
42 return !empty($eligible);
43 }
44
45 public function execute()
46 {
47 $eligible = array_values(array_filter($this->tribe->getKobolds(), function ($kobold) {
48 foreach ($kobold->getInjuries() as $injury) {
49 if (($injury['id'] ?? null) === 'heatstroke') {
50 return false;
51 }
52 }
53 return $kobold->getAge() >= $this->getMinAge();
54 }));
55
56 if (empty($eligible)) {
57 return;
58 }
59
60 shuffle($eligible);
61 $count = rand($this->getMinParticipants(), min($this->getMaxParticipants(), count($eligible)));
62 $targets = array_slice($eligible, 0, $count);
63
64 foreach ($targets as $kobold) {
65 $kobold->addInjury('heatstroke');
66 $kobold->save();
67 }
68
69 $names = implode(', ', array_map(fn($k) => $k->getName(), $targets));
70 $variations = [
71 "The heat wave proved too much for {$names}, who suffered heatstroke.",
72 "Under the relentless sun, {$names} collapsed with heatstroke.",
73 "The scorching days left {$names} with heatstroke by the month's end."
74 ];
75
76 $this->story = $variations[array_rand($variations)];
77 }
78}
web/src/Events/HuntingEvent.php +1 −1
@@ -195,7 +195,7 @@ class HuntingEvent extends Event
195 195 }
196 196
197 197 if ($totalFood > 0) {
198 if (!empty($this->tribe->dataStore->draught)) {
198 if (!empty($this->tribe->dataStore->draught) && $this->tribe->dataStore->draught > 0) {
199 199 $totalFood = (int) floor($totalFood / 2);
200 200 $this->story .= "The drought thinned the game, cutting the haul in half.\n";
201 201 }
@@ -195,7 +195,7 @@ class HuntingEvent extends Event
195 }
195 }
196
196
197 if ($totalFood > 0) {
197 if ($totalFood > 0) {
198 if (!empty($this->tribe->dataStore->draught)) {
198 if (!empty($this->tribe->dataStore->draught) && $this->tribe->dataStore->draught > 0) {
199 $totalFood = (int) floor($totalFood / 2);
199 $totalFood = (int) floor($totalFood / 2);
200 $this->story .= "The drought thinned the game, cutting the haul in half.\n";
200 $this->story .= "The drought thinned the game, cutting the haul in half.\n";
201 }
201 }
web/src/Events/SocialEvent.php +2 −2
@@ -105,7 +105,7 @@ class SocialEvent extends MonthEndEvent
105 105 $koboldA->dataStore->likes[$koboldB->getId()] = $aLikesB + 1;
106 106
107 107 $aSuccessVariations = [
108 "{$nameA} found themselves drawn to {$nameB}'s company this month, though {$nameB} seemed somewhat distracted and distant.",
108 "{$nameA} found {$koboldA->him()}self drawn to {$nameB}'s company this month, though {$nameB} seemed somewhat distracted and distant.",
109 109 "While {$nameB} was preoccupied with other matters, {$nameA} grew more appreciative of {$nameB}'s qualities and presence in the tribe.",
110 110 "{$nameA} made several attempts to connect with {$nameB}, and though the responses were lukewarm, {$nameA}'s fondness only grew.",
111 111 "As {$nameA} watched {$nameB} from afar, admiration bloomed—though {$nameB} remained largely unaware of the attention.",
@@ -123,7 +123,7 @@ class SocialEvent extends MonthEndEvent
123 123 $koboldB->dataStore->likes[$koboldA->getId()] = $bLikesA + 1;
124 124
125 125 $bSuccessVariations = [
126 "{$nameB} found themselves drawn to {$nameA}'s company this month, though {$nameA} seemed somewhat distracted and distant.",
126 "{$nameB} found {$koboldA->him()}self drawn to {$nameA}'s company this month, though {$nameA} seemed somewhat distracted and distant.",
127 127 "While {$nameA} was preoccupied with other matters, {$nameB} grew more appreciative of {$nameA}'s qualities and presence in the tribe.",
128 128 "{$nameB} made several attempts to connect with {$nameA}, and though the responses were lukewarm, {$nameB}'s fondness only grew.",
129 129 "As {$nameB} watched {$nameA} from afar, admiration bloomed—though {$nameA} remained largely unaware of the attention.",
@@ -105,7 +105,7 @@ class SocialEvent extends MonthEndEvent
105 $koboldA->dataStore->likes[$koboldB->getId()] = $aLikesB + 1;
105 $koboldA->dataStore->likes[$koboldB->getId()] = $aLikesB + 1;
106
106
107 $aSuccessVariations = [
107 $aSuccessVariations = [
108 "{$nameA} found themselves drawn to {$nameB}'s company this month, though {$nameB} seemed somewhat distracted and distant.",
108 "{$nameA} found {$koboldA->him()}self drawn to {$nameB}'s company this month, though {$nameB} seemed somewhat distracted and distant.",
109 "While {$nameB} was preoccupied with other matters, {$nameA} grew more appreciative of {$nameB}'s qualities and presence in the tribe.",
109 "While {$nameB} was preoccupied with other matters, {$nameA} grew more appreciative of {$nameB}'s qualities and presence in the tribe.",
110 "{$nameA} made several attempts to connect with {$nameB}, and though the responses were lukewarm, {$nameA}'s fondness only grew.",
110 "{$nameA} made several attempts to connect with {$nameB}, and though the responses were lukewarm, {$nameA}'s fondness only grew.",
111 "As {$nameA} watched {$nameB} from afar, admiration bloomed—though {$nameB} remained largely unaware of the attention.",
111 "As {$nameA} watched {$nameB} from afar, admiration bloomed—though {$nameB} remained largely unaware of the attention.",
@@ -123,7 +123,7 @@ class SocialEvent extends MonthEndEvent
123 $koboldB->dataStore->likes[$koboldA->getId()] = $bLikesA + 1;
123 $koboldB->dataStore->likes[$koboldA->getId()] = $bLikesA + 1;
124
124
125 $bSuccessVariations = [
125 $bSuccessVariations = [
126 "{$nameB} found themselves drawn to {$nameA}'s company this month, though {$nameA} seemed somewhat distracted and distant.",
126 "{$nameB} found {$koboldA->him()}self drawn to {$nameA}'s company this month, though {$nameA} seemed somewhat distracted and distant.",
127 "While {$nameA} was preoccupied with other matters, {$nameB} grew more appreciative of {$nameA}'s qualities and presence in the tribe.",
127 "While {$nameA} was preoccupied with other matters, {$nameB} grew more appreciative of {$nameA}'s qualities and presence in the tribe.",
128 "{$nameB} made several attempts to connect with {$nameA}, and though the responses were lukewarm, {$nameB}'s fondness only grew.",
128 "{$nameB} made several attempts to connect with {$nameA}, and though the responses were lukewarm, {$nameB}'s fondness only grew.",
129 "As {$nameB} watched {$nameA} from afar, admiration bloomed—though {$nameA} remained largely unaware of the attention.",
129 "As {$nameB} watched {$nameA} from afar, admiration bloomed—though {$nameA} remained largely unaware of the attention.",
web/src/Events/WalkDiscoveryEvent.php +2 −2
@@ -53,7 +53,7 @@ class WalkDiscoveryEvent extends MonthEndEvent
53 53 // Food discovery
54 54 $foodAmount = rand(3, 8);
55 55
56 if (!empty($this->tribe->dataStore->draught)) {
56 if (!empty($this->tribe->dataStore->draught) && $this->tribe->dataStore->draught > 0) {
57 57 $foodAmount = (int) floor($foodAmount / 2);
58 58 if ($foodAmount < 1) {
59 59 $foodAmount = 1;
@@ -74,7 +74,7 @@ class WalkDiscoveryEvent extends MonthEndEvent
74 74 ];
75 75
76 76 $this->story = $foodVariations[array_rand($foodVariations)];
77 if (!empty($this->tribe->dataStore->draught)) {
77 if (!empty($this->tribe->dataStore->draught) && $this->tribe->dataStore->draught > 0) {
78 78 $this->story .= " The drought kept the find small.";
79 79 }
80 80 } else {
@@ -53,7 +53,7 @@ class WalkDiscoveryEvent extends MonthEndEvent
53 // Food discovery
53 // Food discovery
54 $foodAmount = rand(3, 8);
54 $foodAmount = rand(3, 8);
55
55
56 if (!empty($this->tribe->dataStore->draught)) {
56 if (!empty($this->tribe->dataStore->draught) && $this->tribe->dataStore->draught > 0) {
57 $foodAmount = (int) floor($foodAmount / 2);
57 $foodAmount = (int) floor($foodAmount / 2);
58 if ($foodAmount < 1) {
58 if ($foodAmount < 1) {
59 $foodAmount = 1;
59 $foodAmount = 1;
@@ -74,7 +74,7 @@ class WalkDiscoveryEvent extends MonthEndEvent
74 ];
74 ];
75
75
76 $this->story = $foodVariations[array_rand($foodVariations)];
76 $this->story = $foodVariations[array_rand($foodVariations)];
77 if (!empty($this->tribe->dataStore->draught)) {
77 if (!empty($this->tribe->dataStore->draught) && $this->tribe->dataStore->draught > 0) {
78 $this->story .= " The drought kept the find small.";
78 $this->story .= " The drought kept the find small.";
79 }
79 }
80 } else {
80 } else {