BlueGit

blue-star tribegen

Files

tribegen / web / src / Events / IncreaseConsumptionEvent.php

IncreaseConsumptionEvent.php

more events, rivals
timfa Tim Falken · pushed by timfa · 9 months ago
52fdcbf6 History
IncreaseConsumptionEvent.php 1.8 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 15;
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 'had a growth spurt',
54 'was always hungry',
55 'consumed extra food',
56 'had an insatiable appetite this month',
57 'seemed particularly famished',
58 'ate with vigor',
59 ];
60
61 $reason = $reasons[array_rand($reasons)];
62
63 $variations = [
64 "{$nameA} {$reason}, consuming more food than usual.",
65 "This month, {$nameA} {$reason} and the food stores are diminished.",
66 "{$nameA} {$reason}, putting extra strain on the tribe's resources.",
67 "The tribe noticed {$nameA} {$reason}, draining more of their supplies.",
68 "{$nameA} {$reason}, and the food situation became slightly more dire.",
69 ];
70
71 $this->story = $variations[array_rand($variations)];
72 }
73}