BlueGit

blue-star tribegen

Files

tribegen / web / src / Events / IllnessEvent.php

IllnessEvent.php

fix errors
timfa Tim · pushed by timfa · 9 months ago
e130a216 History
IllnessEvent.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 IllnessEvent extends MonthEndEvent
7{
8 public function getMinAge()
9 {
10 return 5;
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 60;
26 }
27
28 public function isAvailable()
29 {
30 return true;
31 }
32
33 public function execute()
34 {
35 $this->story = '';
36
37 $eligible = $this->tribe->getAliveKobolds();
38 if (empty($eligible)) {
39 return;
40 }
41
42 $kobold = $eligible[array_rand($eligible)];
43
44 // Disease types that can be randomly acquired
45 $diseases = [
46 ['type' => 'smallCut', 'name' => 'small cut'],
47 ['type' => 'sunburn', 'name' => 'sunburn'],
48 ];
49
50 $disease = $diseases[array_rand($diseases)];
51
52 $kobold->addInjury($disease['type']);
53
54 $nameA = $kobold->getName();
55
56 $illnessVariations = [
57 "{$nameA} developed a {$disease['name']} this month and is feeling poorly.",
58 "Misfortune struck {$nameA}, who came down with a {$disease['name']}.",
59 "{$nameA} is suffering from a {$disease['name']} and needs rest.",
60 "A {$disease['name']} has plagued {$nameA} throughout the month.",
61 "{$nameA} was afflicted with a {$disease['name']} and is quite uncomfortable.",
62 "The elements were unkind to {$nameA}, leaving {$kobold->him()} with a {$disease['name']}.",
63 "{$nameA} has been dealing with a {$disease['name']} that emerged this month.",
64 ];
65
66 $this->story = $illnessVariations[array_rand($illnessVariations)];
67
68 $kobold->save();
69 }
70}