예제 #1
0
 /**
  * Reference:
  *     ## Impassable wood
  *     @1 Hero number 1
  *     [] Tavern
  *     $- Gold mine (neutral)
  *     $1 Gold mine (belonging to hero 1)
  *
  * @param string $chars
  * @return Tile
  */
 private static function readTile(Position $pos, $chars)
 {
     static $TILE_CLASSES = array('  ' => 'Vindinium\\Board\\EmptyTile', '##' => 'Vindinium\\Board\\Wood', '[]' => 'Vindinium\\Board\\Tavern', '$-' => 'Vindinium\\Board\\GoldMine');
     if ($Tile = Arrays::get($TILE_CLASSES, $chars)) {
         return new $Tile($pos);
     }
     $heroId = (int) substr($chars, 1);
     if ('@' === $chars[0]) {
         return new Avatar($pos, $heroId);
     }
     if ('$' === $chars[0]) {
         return new GoldMine($pos, $heroId);
     }
     throw new \InvalidArgumentException("Invalid tile: '{$chars}'");
 }
예제 #2
0
파일: Hero.php 프로젝트: eridal/vindinium
 /**
  * @internal
  */
 protected function init(array $data)
 {
     $this->userId = Arrays::get($data, 'userId');
     $this->elo = (int) Arrays::get($data, 'elo');
 }