easier to expand
@@ -396,6 +396,22 @@ class Tribe
396
396
return $this->foodCount;
397
397
}
398
398
399
public function modifyFoodGain(&$amount)
400
{
401
$reason = null;
402
403
if ($amount <= 0) {
404
return $reason;
405
}
406
407
if (!empty($this->dataStore->draught) && $this->dataStore->draught > 0) {
408
$amount = (int) floor($amount / 2);
409
$reason = 'draught';
410
}
411
412
return $reason;
413
}
414
399
415
/**
400
416
* Calculate total food needed for all alive kobolds for one month
401
417
*/
@@ -396,6 +396,22 @@ class Tribe396
return $this->foodCount;396
return $this->foodCount;397
}397
}398
398
399
public function modifyFoodGain(&$amount)400
{401
$reason = null;402
403
if ($amount <= 0) {404
return $reason;405
}406
407
if (!empty($this->dataStore->draught) && $this->dataStore->draught > 0) {408
$amount = (int) floor($amount / 2);409
$reason = 'draught';410
}411
412
return $reason;413
}414
399
/**415
/**400
* Calculate total food needed for all alive kobolds for one month416
* Calculate total food needed for all alive kobolds for one month401
*/417
*/@@ -82,9 +82,11 @@ 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) && $this->tribe->dataStore->draught > 0) {
86
$totalFood = (int) floor($totalFood / 2);
85
$reason = $this->tribe->modifyFoodGain($totalFood);
86
if ($reason === 'draught') {
87
87
$this->story .= "The drought stunted the forage, cutting it down.\n";
88
} elseif ($reason === 'heatWave') {
89
$this->story .= "The heat sapped the harvest, cutting it down.\n";
88
90
}
89
91
90
92
$this->tribe->addFood($totalFood);
@@ -82,9 +82,11 @@ class ExplorationEvent extends Event82
$foodBonus = intval($avgIntelligence / 20); // Max +5 food from intelligence82
$foodBonus = intval($avgIntelligence / 20); // Max +5 food from intelligence83
$totalFood = $baseFood + $foodBonus;83
$totalFood = $baseFood + $foodBonus;84
84
85
if (!empty($this->tribe->dataStore->draught) && $this->tribe->dataStore->draught > 0) {85
$reason = $this->tribe->modifyFoodGain($totalFood);86
$totalFood = (int) floor($totalFood / 2);86
if ($reason === 'draught') {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
} elseif ($reason === 'heatWave') {89
$this->story .= "The heat sapped the harvest, cutting it down.\n";88
}90
}89
91
90
$this->tribe->addFood($totalFood);92
$this->tribe->addFood($totalFood);@@ -175,9 +175,11 @@ class FarmingEvent extends Event
175
175
}
176
176
177
177
178
if (!empty($this->tribe->dataStore->draught) && $this->tribe->dataStore->draught > 0) {
179
$totalFood = (int) floor($totalFood / 2);
178
$reason = $this->tribe->modifyFoodGain($totalFood);
179
if ($reason === 'draught') {
180
180
$this->story .= "The drought wilted the crops, halving what could be gathered.\n";
181
} elseif ($reason === 'heatWave') {
182
$this->story .= "The heat wilted the crops, halving what could be gathered.\n";
181
183
}
182
184
$months = $this->tribe->foodMonthsLeft($totalFood);
183
185
$this->tribe->addFood($totalFood);
@@ -175,9 +175,11 @@ class FarmingEvent extends Event175
}175
}176
176
177
177
178
if (!empty($this->tribe->dataStore->draught) && $this->tribe->dataStore->draught > 0) {178
$reason = $this->tribe->modifyFoodGain($totalFood);179
$totalFood = (int) floor($totalFood / 2);179
if ($reason === 'draught') {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
} elseif ($reason === 'heatWave') {182
$this->story .= "The heat wilted the crops, halving what could be gathered.\n";181
}183
}182
$months = $this->tribe->foodMonthsLeft($totalFood);184
$months = $this->tribe->foodMonthsLeft($totalFood);183
$this->tribe->addFood($totalFood);185
$this->tribe->addFood($totalFood);@@ -195,9 +195,11 @@ class HuntingEvent extends Event
195
195
}
196
196
197
197
if ($totalFood > 0) {
198
if (!empty($this->tribe->dataStore->draught) && $this->tribe->dataStore->draught > 0) {
199
$totalFood = (int) floor($totalFood / 2);
198
$reason = $this->tribe->modifyFoodGain($totalFood);
199
if ($reason === 'draught') {
200
200
$this->story .= "The drought thinned the game, cutting the haul in half.\n";
201
} elseif ($reason === 'heatWave') {
202
$this->story .= "The heat slowed the hunters, cutting the haul in half.\n";
201
203
}
202
204
$months = $this->tribe->foodMonthsLeft($totalFood);
203
205
$this->tribe->addFood($totalFood);
@@ -195,9 +195,11 @@ class HuntingEvent extends Event195
}195
}196
196
197
if ($totalFood > 0) {197
if ($totalFood > 0) {198
if (!empty($this->tribe->dataStore->draught) && $this->tribe->dataStore->draught > 0) {198
$reason = $this->tribe->modifyFoodGain($totalFood);199
$totalFood = (int) floor($totalFood / 2);199
if ($reason === 'draught') {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
} elseif ($reason === 'heatWave') {202
$this->story .= "The heat slowed the hunters, cutting the haul in half.\n";201
}203
}202
$months = $this->tribe->foodMonthsLeft($totalFood);204
$months = $this->tribe->foodMonthsLeft($totalFood);203
$this->tribe->addFood($totalFood);205
$this->tribe->addFood($totalFood);@@ -53,11 +53,9 @@ class WalkDiscoveryEvent extends MonthEndEvent
53
53
// Food discovery
54
54
$foodAmount = rand(3, 8);
55
55
56
if (!empty($this->tribe->dataStore->draught) && $this->tribe->dataStore->draught > 0) {
57
$foodAmount = (int) floor($foodAmount / 2);
58
if ($foodAmount < 1) {
59
$foodAmount = 1;
60
}
56
$reason = $this->tribe->modifyFoodGain($foodAmount);
57
if ($foodAmount < 1) {
58
$foodAmount = 1;
61
59
}
62
60
$this->tribe->addFood($foodAmount);
63
61
@@ -74,8 +72,10 @@ class WalkDiscoveryEvent extends MonthEndEvent
74
72
];
75
73
76
74
$this->story = $foodVariations[array_rand($foodVariations)];
77
if (!empty($this->tribe->dataStore->draught) && $this->tribe->dataStore->draught > 0) {
75
if ($reason === 'draught') {
78
76
$this->story .= " The drought kept the find small.";
77
} elseif ($reason === 'heatWave') {
78
$this->story .= " The heat kept the find small.";
79
79
}
80
80
} else {
81
81
// Item discovery
@@ -53,11 +53,9 @@ class WalkDiscoveryEvent extends MonthEndEvent53
// Food discovery53
// Food discovery54
$foodAmount = rand(3, 8);54
$foodAmount = rand(3, 8);55
55
56
if (!empty($this->tribe->dataStore->draught) && $this->tribe->dataStore->draught > 0) {56
$reason = $this->tribe->modifyFoodGain($foodAmount);57
$foodAmount = (int) floor($foodAmount / 2);57
if ($foodAmount < 1) {58
if ($foodAmount < 1) {58
$foodAmount = 1;59
$foodAmount = 1;60
}61
}59
}62
$this->tribe->addFood($foodAmount);60
$this->tribe->addFood($foodAmount);63
61
@@ -74,8 +72,10 @@ class WalkDiscoveryEvent extends MonthEndEvent74
];72
];75
73
76
$this->story = $foodVariations[array_rand($foodVariations)];74
$this->story = $foodVariations[array_rand($foodVariations)];77
if (!empty($this->tribe->dataStore->draught) && $this->tribe->dataStore->draught > 0) {75
if ($reason === 'draught') {78
$this->story .= " The drought kept the find small.";76
$this->story .= " The drought kept the find small.";77
} elseif ($reason === 'heatWave') {78
$this->story .= " The heat kept the find small.";79
}79
}80
} else {80
} else {81
// Item discovery81
// Item discovery