BlueGit

blue-star tribegen

Files

tribegen / web / src / Events / IncreaseConsumptionEvent.php

IncreaseConsumptionEvent.php

fix errors
timfa Tim · pushed by timfa · 9 months ago
e130a216 History
IncreaseConsumptionEvent.php 1.7 KiB Download Raw
1<?php
2
3require_once __DIR__ . '/../../src/Events/MonthEndEvent.php';
4require_once __DIR__ . '/../../src/Classes/Kobold.php';
5
6class IncreaseConsumptionEvent extends MonthEndEvent
7{
8 public function getMinAge()
9 {
10 return 10;
11 }
12
13 public function getMinParticipants()
14 {
15 return 1;
16 }
17
18 public function getMaxParticipants()
19 {
20 return 1;
21 }
22
23 public function getCost()
24 {
25 return 85;
26 }
27
28 public function isAvailable()
29 {
30 return true;
31 }
32
33 public function execute()
34 {
35 $this->story = '';
36
37 $eligible = array_filter($this->tribe->getAliveKobolds(), fn($k) => $k->getAge() >= $this->getMinAge());
38 $eligible = array_values($eligible);
39
40 if (empty($eligible)) {
41 return;
42 }
43
44 $kobold = $eligible[array_rand($eligible)];
45
46 $foodCost = rand(2, 5);
47 $this->tribe->removeFood($foodCost);
48
49 $nameA = $kobold->getName();
50
51 $reasons = [
52 'grew a significant appetite',
53 'was always hungry',
54 'had an insatiable appetite this month',
55 'seemed particularly famished',
56 'ate with vigor',
57 ];
58
59 $reason = $reasons[array_rand($reasons)];
60
61 $variations = [
62 "{$nameA} {$reason}, consuming more food than usual.",
63 "This month, {$nameA} {$reason} and the food stores are diminished.",
64 "{$nameA} {$reason}, putting extra strain on the tribe's resources.",
65 "The tribe noticed {$nameA} {$reason}, draining more of their supplies.",
66 "{$nameA} {$reason}, and the food situation became slightly more dire.",
67 ];
68
69 $this->story = $variations[array_rand($variations)];
70 }
71}