From 9d2bb1fc03fe9541bbfe07d66b049bcca01972c6 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Mon, 11 Jul 2016 21:04:16 +0200 Subject: [PATCH] . --- src/arenas/tron/Direction.php | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/arenas/tron/Direction.php b/src/arenas/tron/Direction.php index 83039a4..381f25a 100644 --- a/src/arenas/tron/Direction.php +++ b/src/arenas/tron/Direction.php @@ -5,5 +5,38 @@ class Direction private static $bottom = 1; private static $left = 2; private static $right = 3; - + + private $value; + + public function __construct(){ + $this->value = 0; + } + public function __toString(){ + switch ($this->value){ + case Direction::$top: + return "y+"; + break; + case Direction::$bottom: + return "y-"; + break; + case Direction::$left: + return "x-"; + break; + case Direction::$right: + return "x+"; + break; + } + } + public function opposite(){ + $opposites = array( + Direction::$top => Direction::$bottom, + Direction::$bottom => Direction::$top, + Direction::$left => Direction::$right, + Direction::$right => Direction::$left + ); + + $opposite = new Direction(); + $opposite->value = $opposites[$this->value]; + + } } \ No newline at end of file