min age
@@ -1142,11 +1142,11 @@ class TribeGenApp
1142
1142
renderStorage ()
1143
1143
{
1144
1144
const foodDisplay = document.getElementById('foodDisplay');
1145
const monthsLeft = this.currentSave.food_months_remaining;
1146
if (monthsLeft !== undefined && monthsLeft !== null)
1145
const timeLeft = this.currentSave.food_time_remaining;
1146
if (timeLeft !== undefined && timeLeft !== null)
1147
1147
{
1148
const label = Number(monthsLeft) === 1 ? 'month' : 'months';
1149
foodDisplay.textContent = `Food: ${monthsLeft} ${label}`;
1148
const label = timeLeft;
1149
foodDisplay.textContent = `Food: ${label}`;
1150
1150
} else
1151
1151
{
1152
1152
foodDisplay.textContent = `Food: ${this.currentSave.food_count}`;
@@ -1142,11 +1142,11 @@ class TribeGenApp1142
renderStorage ()1142
renderStorage ()1143
{1143
{1144
const foodDisplay = document.getElementById('foodDisplay');1144
const foodDisplay = document.getElementById('foodDisplay');1145
const monthsLeft = this.currentSave.food_months_remaining;1145
const timeLeft = this.currentSave.food_time_remaining;1146
if (monthsLeft !== undefined && monthsLeft !== null)1146
if (timeLeft !== undefined && timeLeft !== null)1147
{1147
{1148
const label = Number(monthsLeft) === 1 ? 'month' : 'months';1148
const label = timeLeft;1149
foodDisplay.textContent = `Food: ${monthsLeft} ${label}`;1149
foodDisplay.textContent = `Food: ${label}`;1150
} else1150
} else1151
{1151
{1152
foodDisplay.textContent = `Food: ${this.currentSave.food_count}`;1152
foodDisplay.textContent = `Food: ${this.currentSave.food_count}`;@@ -73,6 +73,10 @@ class Tribe
73
73
$this->lastPlayed = $data['last_played'] ?? date('Y-m-d H:i:s');
74
74
$this->dataStore = $data['data_store'] ?? new stdClass();
75
75
}
76
77
if (is_array($this->dataStore)) {
78
$this->dataStore = (object) $this->dataStore;
79
}
76
80
}
77
81
78
82
$this->loadKobolds();
@@ -124,7 +128,7 @@ class Tribe
124
128
'current_month' => $this->currentMonth,
125
129
'current_season' => $this->currentSeason,
126
130
'food_count' => $this->foodCount,
127
'food_months_left' => $this->foodMonthsLeft($this->foodCount),
131
'food_time_left' => $this->foodTimeStr($this->foodCount),
128
132
'environment_id' => $this->environmentId,
129
133
'created_at' => $this->createdAt,
130
134
'last_played' => $this->lastPlayed,
@@ -315,6 +319,32 @@ class Tribe
315
319
return (int) floor($available / $foodPerMonth);
316
320
}
317
321
322
public function foodTimeStr($amount)
323
{
324
$months = $this->foodMonthsLeft($amount);
325
if ($months > 0) {
326
if ($months == 1)
327
return "1 month";
328
else
329
return "{$months} months";
330
}
331
332
$foodPerMonth = $this->calculateFoodNeeded();
333
if ($foodPerMonth <= 0) {
334
return "years";
335
}
336
337
$available = max(0, (float) $amount);
338
$days = (int) floor(($available / $foodPerMonth) * 30);
339
$weeks = intdiv($days, 7);
340
341
if ($weeks >= 1) {
342
return $weeks . " week" . ($weeks === 1 ? "" : "s");
343
}
344
345
return $days . " day" . ($days === 1 ? "" : "s");
346
}
347
318
348
/**
319
349
* Get food requirement for a specific kobold
320
350
*/
@@ -73,6 +73,10 @@ class Tribe73
$this->lastPlayed = $data['last_played'] ?? date('Y-m-d H:i:s');73
$this->lastPlayed = $data['last_played'] ?? date('Y-m-d H:i:s');74
$this->dataStore = $data['data_store'] ?? new stdClass();74
$this->dataStore = $data['data_store'] ?? new stdClass();75
}75
}76
77
if (is_array($this->dataStore)) {78
$this->dataStore = (object) $this->dataStore;79
}76
}80
}77
81
78
$this->loadKobolds();82
$this->loadKobolds();@@ -124,7 +128,7 @@ class Tribe124
'current_month' => $this->currentMonth,128
'current_month' => $this->currentMonth,125
'current_season' => $this->currentSeason,129
'current_season' => $this->currentSeason,126
'food_count' => $this->foodCount,130
'food_count' => $this->foodCount,127
'food_months_left' => $this->foodMonthsLeft($this->foodCount),131
'food_time_left' => $this->foodTimeStr($this->foodCount),128
'environment_id' => $this->environmentId,132
'environment_id' => $this->environmentId,129
'created_at' => $this->createdAt,133
'created_at' => $this->createdAt,130
'last_played' => $this->lastPlayed,134
'last_played' => $this->lastPlayed,@@ -315,6 +319,32 @@ class Tribe315
return (int) floor($available / $foodPerMonth);319
return (int) floor($available / $foodPerMonth);316
}320
}317
321
322
public function foodTimeStr($amount)323
{324
$months = $this->foodMonthsLeft($amount);325
if ($months > 0) {326
if ($months == 1)327
return "1 month";328
else329
return "{$months} months";330
}331
332
$foodPerMonth = $this->calculateFoodNeeded();333
if ($foodPerMonth <= 0) {334
return "years";335
}336
337
$available = max(0, (float) $amount);338
$days = (int) floor(($available / $foodPerMonth) * 30);339
$weeks = intdiv($days, 7);340
341
if ($weeks >= 1) {342
return $weeks . " week" . ($weeks === 1 ? "" : "s");343
}344
345
return $days . " day" . ($days === 1 ? "" : "s");346
}347
318
/**348
/**319
* Get food requirement for a specific kobold349
* Get food requirement for a specific kobold320
*/350
*/@@ -36,6 +36,8 @@ abstract class Event
36
36
37
37
abstract function getMaxParticipants();
38
38
39
abstract function getMinAge();
40
39
41
public function getStory()
40
42
{
41
43
return $this->story;
@@ -36,6 +36,8 @@ abstract class Event36
36
37
abstract function getMaxParticipants();37
abstract function getMaxParticipants();38
38
39
abstract function getMinAge();40
39
public function getStory()41
public function getStory()40
{42
{41
return $this->story;43
return $this->story;@@ -6,6 +6,11 @@ require_once __DIR__ . '/../../src/Classes/Kobold.php';
6
6
7
7
class ExplorationEvent extends Event
8
8
{
9
public function getMinAge()
10
{
11
return 14;
12
}
13
9
14
public function getMinParticipants()
10
15
{
11
16
return 1;
@@ -6,6 +6,11 @@ require_once __DIR__ . '/../../src/Classes/Kobold.php';6
6
7
class ExplorationEvent extends Event7
class ExplorationEvent extends Event8
{8
{9
public function getMinAge()10
{11
return 14;12
}13
9
public function getMinParticipants()14
public function getMinParticipants()10
{15
{11
return 1;16
return 1;@@ -5,6 +5,11 @@ require_once __DIR__ . '/../../src/Utilities/GameHelper.php';
5
5
6
6
class FarmingEvent extends Event
7
7
{
8
public function getMinAge()
9
{
10
return 10;
11
}
12
8
13
public function getMinParticipants()
9
14
{
10
15
return 2;
@@ -172,10 +177,10 @@ class FarmingEvent extends Event
172
177
$this->tribe->addFood($totalFood);
173
178
174
179
if ($months < 1)
175
$this->story .= "The tribe gained less than a month worth of food from the harvest.\n";
180
$this->story .= "The tribe gained only {$this->tribe->foodTimeStr($totalFood)} worth of food from the harvest.\n";
176
181
else {
177
182
if ($months == 1)
178
$this->story .= "The tribe gained a month worth of food from the harvest.\n";
183
$this->story .= "The tribe gained only a month worth of food from the harvest.\n";
179
184
else
180
185
$this->story .= "The tribe gained " . $months . " months worth of food from the harvest!\n";
181
186
}
@@ -5,6 +5,11 @@ require_once __DIR__ . '/../../src/Utilities/GameHelper.php';5
5
6
class FarmingEvent extends Event6
class FarmingEvent extends Event7
{7
{8
public function getMinAge()9
{10
return 10;11
}12
8
public function getMinParticipants()13
public function getMinParticipants()9
{14
{10
return 2;15
return 2;@@ -172,10 +177,10 @@ class FarmingEvent extends Event172
$this->tribe->addFood($totalFood);177
$this->tribe->addFood($totalFood);173
178
174
if ($months < 1)179
if ($months < 1)175
$this->story .= "The tribe gained less than a month worth of food from the harvest.\n";180
$this->story .= "The tribe gained only {$this->tribe->foodTimeStr($totalFood)} worth of food from the harvest.\n";176
else {181
else {177
if ($months == 1)182
if ($months == 1)178
$this->story .= "The tribe gained a month worth of food from the harvest.\n";183
$this->story .= "The tribe gained only a month worth of food from the harvest.\n";179
else184
else180
$this->story .= "The tribe gained " . $months . " months worth of food from the harvest!\n";185
$this->story .= "The tribe gained " . $months . " months worth of food from the harvest!\n";181
}186
}@@ -6,6 +6,11 @@ require_once __DIR__ . '/../../src/Utilities/GameHelper.php';
6
6
7
7
class HuntingEvent extends Event
8
8
{
9
public function getMinAge()
10
{
11
return 17;
12
}
13
9
14
public function getMinParticipants()
10
15
{
11
16
return 2;
@@ -64,7 +69,7 @@ class HuntingEvent extends Event
64
69
{
65
70
$this->story .= "Spring game was plentiful—rabbits and ground birds darted through the brush.\n";
66
71
67
$totalFood = $this->runHunt($hunters, 'small game', 2, 5, 1, 2);
72
$totalFood = $this->runHunt($hunters, 'small game', 5, 8, 1, 2);
68
73
69
74
if ($bestTracker->checkStat('intelligence') && rand(1, 100) <= 35) {
70
75
$herbs = GameHelper::loadItem('healing-herbs');
@@ -86,7 +91,7 @@ class HuntingEvent extends Event
86
91
{
87
92
$this->story .= "Summer trails led to boar and wild goats, but the heat was punishing.\n";
88
93
89
$totalFood = $this->runHunt($hunters, 'boar and goats', 4, 8, 1, 3);
94
$totalFood = $this->runHunt($hunters, 'boar and goats', 6, 12, 1, 3);
90
95
91
96
if ($bestFighter->checkStat('fighting') && rand(1, 100) <= 30) {
92
97
$bonus = rand(3, 6);
@@ -110,7 +115,7 @@ class HuntingEvent extends Event
110
115
$totalFood = $this->runHunt($hunters, 'deer', 5, 9, 2, 4);
111
116
112
117
if ($bestTracker->checkStat('intelligence') && rand(1, 100) <= 35) {
113
$bonus = rand(2, 6);
118
$bonus = rand(3, 8);
114
119
$totalFood += $bonus;
115
120
$this->story .= "{$bestTracker->getName()} followed fresh tracks to a second herd.\n";
116
121
}
@@ -127,7 +132,7 @@ class HuntingEvent extends Event
127
132
{
128
133
$this->story .= "Winter was harsh, and only lean game moved across the snow.\n";
129
134
130
$totalFood = $this->runHunt($hunters, 'winter game', 1, 4, 0, 1);
135
$totalFood = $this->runHunt($hunters, 'winter game', 2, 6, 0, 1);
131
136
132
137
if ($bestFighter->checkStat('fighting') && rand(1, 100) <= 25) {
133
138
$bonus = rand(2, 4);
@@ -192,7 +197,14 @@ class HuntingEvent extends Event
192
197
if ($totalFood > 0) {
193
198
$months = $this->tribe->foodMonthsLeft($totalFood);
194
199
$this->tribe->addFood($totalFood);
195
$this->story .= "The tribe gained {$months} months worth of food from the hunt.\n";
200
201
if ($months > 0) {
202
if ($months == 1)
203
$this->story .= "The tribe gained a month worth of food from the hunt.\n";
204
else
205
$this->story .= "The tribe gained {$months} months worth of food from the hunt.\n";
206
} else
207
$this->story .= "The hunt brought back {$this->tribe->foodTimeStr($totalFood)} worth of food.\n";
196
208
} else {
197
209
$this->story .= "The hunt brought back no usable food.\n";
198
210
}
@@ -6,6 +6,11 @@ require_once __DIR__ . '/../../src/Utilities/GameHelper.php';6
6
7
class HuntingEvent extends Event7
class HuntingEvent extends Event8
{8
{9
public function getMinAge()10
{11
return 17;12
}13
9
public function getMinParticipants()14
public function getMinParticipants()10
{15
{11
return 2;16
return 2;@@ -64,7 +69,7 @@ class HuntingEvent extends Event64
{69
{65
$this->story .= "Spring game was plentiful—rabbits and ground birds darted through the brush.\n";70
$this->story .= "Spring game was plentiful—rabbits and ground birds darted through the brush.\n";66
71
67
$totalFood = $this->runHunt($hunters, 'small game', 2, 5, 1, 2);72
$totalFood = $this->runHunt($hunters, 'small game', 5, 8, 1, 2);68
73
69
if ($bestTracker->checkStat('intelligence') && rand(1, 100) <= 35) {74
if ($bestTracker->checkStat('intelligence') && rand(1, 100) <= 35) {70
$herbs = GameHelper::loadItem('healing-herbs');75
$herbs = GameHelper::loadItem('healing-herbs');@@ -86,7 +91,7 @@ class HuntingEvent extends Event86
{91
{87
$this->story .= "Summer trails led to boar and wild goats, but the heat was punishing.\n";92
$this->story .= "Summer trails led to boar and wild goats, but the heat was punishing.\n";88
93
89
$totalFood = $this->runHunt($hunters, 'boar and goats', 4, 8, 1, 3);94
$totalFood = $this->runHunt($hunters, 'boar and goats', 6, 12, 1, 3);90
95
91
if ($bestFighter->checkStat('fighting') && rand(1, 100) <= 30) {96
if ($bestFighter->checkStat('fighting') && rand(1, 100) <= 30) {92
$bonus = rand(3, 6);97
$bonus = rand(3, 6);@@ -110,7 +115,7 @@ class HuntingEvent extends Event110
$totalFood = $this->runHunt($hunters, 'deer', 5, 9, 2, 4);115
$totalFood = $this->runHunt($hunters, 'deer', 5, 9, 2, 4);111
116
112
if ($bestTracker->checkStat('intelligence') && rand(1, 100) <= 35) {117
if ($bestTracker->checkStat('intelligence') && rand(1, 100) <= 35) {113
$bonus = rand(2, 6);118
$bonus = rand(3, 8);114
$totalFood += $bonus;119
$totalFood += $bonus;115
$this->story .= "{$bestTracker->getName()} followed fresh tracks to a second herd.\n";120
$this->story .= "{$bestTracker->getName()} followed fresh tracks to a second herd.\n";116
}121
}@@ -127,7 +132,7 @@ class HuntingEvent extends Event127
{132
{128
$this->story .= "Winter was harsh, and only lean game moved across the snow.\n";133
$this->story .= "Winter was harsh, and only lean game moved across the snow.\n";129
134
130
$totalFood = $this->runHunt($hunters, 'winter game', 1, 4, 0, 1);135
$totalFood = $this->runHunt($hunters, 'winter game', 2, 6, 0, 1);131
136
132
if ($bestFighter->checkStat('fighting') && rand(1, 100) <= 25) {137
if ($bestFighter->checkStat('fighting') && rand(1, 100) <= 25) {133
$bonus = rand(2, 4);138
$bonus = rand(2, 4);@@ -192,7 +197,14 @@ class HuntingEvent extends Event192
if ($totalFood > 0) {197
if ($totalFood > 0) {193
$months = $this->tribe->foodMonthsLeft($totalFood);198
$months = $this->tribe->foodMonthsLeft($totalFood);194
$this->tribe->addFood($totalFood);199
$this->tribe->addFood($totalFood);195
$this->story .= "The tribe gained {$months} months worth of food from the hunt.\n";200
201
if ($months > 0) {202
if ($months == 1)203
$this->story .= "The tribe gained a month worth of food from the hunt.\n";204
else205
$this->story .= "The tribe gained {$months} months worth of food from the hunt.\n";206
} else207
$this->story .= "The hunt brought back {$this->tribe->foodTimeStr($totalFood)} worth of food.\n";196
} else {208
} else {197
$this->story .= "The hunt brought back no usable food.\n";209
$this->story .= "The hunt brought back no usable food.\n";198
}210
}@@ -644,7 +644,7 @@ if ($method === 'POST') {
644
644
'current_season' => $tribe->getCurrentSeason(),
645
645
'environment_id' => $tribe->getEnvironmentId(),
646
646
'food_count' => $tribe->getFoodCount(),
647
'food_months_remaining' => $tribe->foodMonthsLeft($tribe->getFoodCount()),
647
'food_time_remaining' => $tribe->foodTimeStr($tribe->getFoodCount()),
648
648
'created_at' => $tribe->getCreatedAt(),
649
649
'last_played' => $tribe->getLastPlayed()
650
650
],
@@ -687,7 +687,8 @@ if ($method === 'POST') {
687
687
'cost' => $event->getCost(),
688
688
'available' => $event->isAvailable(),
689
689
'min_participants' => $event->getMinParticipants(),
690
'max_participants' => $event->getMaxParticipants()
690
'max_participants' => $event->getMaxParticipants(),
691
'min_age' => $event->getMinAge(),
691
692
];
692
693
}
693
694
@@ -644,7 +644,7 @@ if ($method === 'POST') {644
'current_season' => $tribe->getCurrentSeason(),644
'current_season' => $tribe->getCurrentSeason(),645
'environment_id' => $tribe->getEnvironmentId(),645
'environment_id' => $tribe->getEnvironmentId(),646
'food_count' => $tribe->getFoodCount(),646
'food_count' => $tribe->getFoodCount(),647
'food_months_remaining' => $tribe->foodMonthsLeft($tribe->getFoodCount()),647
'food_time_remaining' => $tribe->foodTimeStr($tribe->getFoodCount()),648
'created_at' => $tribe->getCreatedAt(),648
'created_at' => $tribe->getCreatedAt(),649
'last_played' => $tribe->getLastPlayed()649
'last_played' => $tribe->getLastPlayed()650
],650
],@@ -687,7 +687,8 @@ if ($method === 'POST') {687
'cost' => $event->getCost(),687
'cost' => $event->getCost(),688
'available' => $event->isAvailable(),688
'available' => $event->isAvailable(),689
'min_participants' => $event->getMinParticipants(),689
'min_participants' => $event->getMinParticipants(),690
'max_participants' => $event->getMaxParticipants()690
'max_participants' => $event->getMaxParticipants(),691
'min_age' => $event->getMinAge(),691
];692
];692
}693
}693
694