Skip to content

Commit

Permalink
Slightly different way of echo-ing in Event.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Baker committed May 12, 2016
1 parent 1122207 commit 016fd99
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions event.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,35 @@ class Event {
public function draw(Player $player, array $tiles) {
Assert::type($tiles, Tile);
$hand = new Hand($tiles);
echo "{$player} draws {$hand}";
$this->p("{$player} draws {$hand}");
if (count($tiles) < $player->hand()->size()) {
echo ", hand is {$player->hand()}";
$this->p(", hand is {$player->hand()}");
}
echo "\n\n";
$this->l()->l();
}

public function move(Player $player, Move $move, $score, Board $board, Scores $scores) {
if (count($move->placements()) > 0) {
echo "{$player} plays {$move} for {$score}\n";
echo "\n{$board}";
echo "\n{$scores}";
$this->l("{$player} plays {$move} for {$score}");
$this->l()->p($board);
$this->l()->p($scores);
} else {
echo "{$player} changes his letters.\n";
$this->l("$player changes his letters. Hand is {$player->hand()}");
}
echo "\n";
$this->l();
}

public function __call($f, array $args) {
echo "$f\n";
$this->l("$f");
}

private function p($s) {
echo $s;
return $this;
}

private function l($s = '') {
echo "$s\n";
return $this;
}
}

0 comments on commit 016fd99

Please sign in to comment.