|
| 1 | +<?php |
| 2 | + |
| 3 | +class Narration |
| 4 | +{ |
| 5 | + public function pick_narration($narrations) |
| 6 | + { |
| 7 | + if (count($narrations) == 1) { |
| 8 | + return $narrations[0]; |
| 9 | + } else if (count($narrations) > 1) { |
| 10 | + return $narrations[rand(0, count($narrations) - 1)]; |
| 11 | + } else { |
| 12 | + return "ERROR"; |
| 13 | + } |
| 14 | + } |
| 15 | + |
| 16 | + public function start() |
| 17 | + { |
| 18 | + return $this->pick_narration($this->start_narrations); |
| 19 | + } |
| 20 | + |
| 21 | + public function round() |
| 22 | + { |
| 23 | + if (!$this->round_narrated) { |
| 24 | + $this->round_narrated = true; |
| 25 | + return $this->pick_narration($this->round_narration_start); |
| 26 | + } |
| 27 | + return $this->pick_narration($this->round_narrations); |
| 28 | + } |
| 29 | + |
| 30 | + public function won() |
| 31 | + { |
| 32 | + return $this->pick_narration($this->won_narrations); |
| 33 | + } |
| 34 | + |
| 35 | + public function lost() |
| 36 | + { |
| 37 | + return $this->pick_narration($this->lost_narrations); |
| 38 | + } |
| 39 | + |
| 40 | + public function draw() |
| 41 | + { |
| 42 | + return $this->pick_narration($this->draw_narrations); |
| 43 | + } |
| 44 | + |
| 45 | + // gameplay utterances are inscribed below. |
| 46 | + |
| 47 | + private $start_narrations = array( |
| 48 | + "Our great hero, Orderus, enters into battle with a wild beast....", |
| 49 | + [ |
| 50 | + "Once upon a time, there was a great hero named Orderus.", |
| 51 | + "After more than a hundred years of battles with all kinds of monsters,", |
| 52 | + "he encountered a wild beast while walking the evergreen forests of Emagia.", |
| 53 | + ], |
| 54 | + ); |
| 55 | + |
| 56 | + private $round_narrated = false; |
| 57 | + private $round_narration_start = array( |
| 58 | + "Orderus is encountered by a wild beast!", |
| 59 | + [ |
| 60 | + "As Orderus stands in uffish thought, the Jabberwocky--", |
| 61 | + "Oh, wait; it's just a generic wild beast.", |
| 62 | + "Anyway, the wild beast, with eyes of flame,", |
| 63 | + "comes whiffling through the tulgey wood,", |
| 64 | + "and burbles as it comes!", |
| 65 | + ], |
| 66 | + ); |
| 67 | + private $round_narrations = array( |
| 68 | + "Another skirmish ensues.", |
| 69 | + "They go at it again.", |
| 70 | + "Once again, they fight!", |
| 71 | + "The battle continues.", |
| 72 | + "They clash...", |
| 73 | + ); |
| 74 | + |
| 75 | + private $won_narrations = array( |
| 76 | + "The game hath ended, but it is not the end, for Orderus hath once again emerged as victor.", |
| 77 | + "Huzzah! Orderus has vanquished the foe yet again!", |
| 78 | + "And once again, the battle is done, and Orderus lives to face the next glorious battle.", |
| 79 | + "And the winner is...Orderus! But, of course.", |
| 80 | + "Orderus won; the wild beast is toast.", |
| 81 | + ); |
| 82 | + |
| 83 | + private $lost_narrations = array( |
| 84 | + "Alas, Orderus is no more, for he has finally met his tragic demise. The game is thus over.", |
| 85 | + "'Tis a sad day. Orderus was no match for this particular wild beat--or perhaps he was tired.", |
| 86 | + "Against all expectations, Orderus is in fact done for.", |
| 87 | + "Orderus lost, but the wild beast is at least reasonably battered.", |
| 88 | + "Orderus, by the treacherous paw of the wild beast, has been rendered out of order.", |
| 89 | + ); |
| 90 | + |
| 91 | + private $draw_narrations = array( |
| 92 | + "'Tis strange, but the battle appeareth to be a draw.", |
| 93 | + ); |
| 94 | +} |
0 commit comments