-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
Signed-off-by: GrumpyMurloc <[email protected]>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,22 @@ public function fire() | |
return; | ||
} | ||
|
||
$this->gameManager->sendMessageToChannel($this->game, ":rain_cloud: It is raining. It is a cold rain, and the freezing drops chill you to the bone." ); | ||
|
||
$weather= $this->game->weather; | ||
if ($weather!= null){ | ||
if($weather==1){ | ||
$this->gameManager->sendMessageToChannel($this->game, ":rain_cloud: It is raining. It is a cold rain, and the freezing drops chill you to the bone." ); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
} | ||
// Cloudy | ||
else if($weather==2){ | ||
$this->gameManager->sendMessageToChannel($this->game, ":cloud: The cloud embrace the sky and cover the sun letting only a few glimmer of light"); | ||
} | ||
// Sunny | ||
else{ | ||
$this->gameManager->sendMessageToChannel($this->game, ":sunny: The warm sun is shining. Its brightness almost blinds you. You take a moment to appreciate its embrace."); | ||
} | ||
} | ||
else{ | ||
$this->gameManager->sendMessageToChannel($this->game,"No Game Running"); | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
chrisgillis
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php namespace Slackwolf\Game\Formatter; | ||
|
||
use Slackwolf\Game\Game; | ||
use Slackwolf\Game\GameState; | ||
|
||
/** | ||
* Defines the WeatherFormatter class. | ||
*/ | ||
class WeatherFormatter | ||
{ | ||
|
||
/** | ||
* @param $game | ||
* | ||
* @return string | ||
*/ | ||
public static function format(Game $game) | ||
{ | ||
// Send message according to GameState and weather | ||
$state= $game->state; | ||
|
||
if($state== GameState::FIRST_NIGHT){ | ||
if($game->weather==1){ | ||
$msg= ":moon: :rain_cloud: The rain comes down in torrents as the village sleeps, unaware of the horror the lurks outside in the wet. It is the middle of the night."; | ||
} | ||
else if($game->weather==1){ | ||
$msg= ":moon: :cloud: The cloud covered the sky blocking even the few glimmering light pass. "; | ||
} | ||
else{ | ||
$msg= "The village sleeps, unaware of the horror the lurks outside in the dark. It is the middle of the night."; | ||
} | ||
|
||
} | ||
if($state== GameState::DAY){ | ||
if($game->weather==1){ | ||
$msg= ":sunrise: The sun rises and the villagers awake. It is still raining, but it slows somewhat, allowing momentary respite from the cold, wet hell that we all live in."; | ||
} | ||
else if($game->weather==1){ | ||
$msg= ":cloud: There is no sky today, only a thick layer of cloud blocking the sky. The air was cooler, announcing rain in the day to come."; | ||
} | ||
else{ | ||
$msg= ":sunny: The morning came and the sun, high in the sky, gave hope that one day this madness will end."; | ||
} | ||
} | ||
if($state== GameState::NIGHT){ | ||
if($game->weather==1){ | ||
$msg= ":moon: :zzz: The sun sets, and the hard rain makes it difficult to hear anything outside. Villagers bar their doors, take long pulls of :beer:, and try not to think of what might lurk beyond the feeble candlelight."; | ||
} | ||
else if($game->weather==1){ | ||
$msg= ":moon: :fog: A thick fog covered the village blocking all of the light. The Villagers bar their door waiting without rest until sunrise."; | ||
} | ||
else{ | ||
$msg= ":full_moon: The sun set, and the moon lights up the sky giving a glimmer of hope. The Villagers bar their doors waiting in fear until sunrise."; | ||
} | ||
} | ||
|
||
return $msg; | ||
This comment has been minimized.
Sorry, something went wrong.
chrisgillis
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ class Game | |
public $wolvesVoted; | ||
public $witchHealed; | ||
public $witchPoisoned; | ||
public $weather; | ||
|
||
/** | ||
* @param $id | ||
|
@@ -606,4 +607,14 @@ public function setWitchPoisonedUserId($id) { | |
$this->witchPoisonedUserId = $id; | ||
} | ||
|
||
|
||
public function setWeather(){ | ||
// Randomize the weather 1=rain, 2= cloudy, 3=sunny | ||
// Might be better using string instead of int. | ||
$this->weather= rand(1,3); | ||
This comment has been minimized.
Sorry, something went wrong.
chrisgillis
|
||
|
||
} | ||
public function getWeather(){ | ||
return $this->weather; | ||
} | ||
} |
These integers for the state of the weather might be better as defined constants.
define('RAINING', 1);
for example.You can take this a step further by instead creating an enum.
You can then access them like so:
$weather == Weather::Rainy