Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ XO
[![Build Status](https://travis-ci.org/saimaz/XO.svg?branch=master)](https://travis-ci.org/saimaz/XO)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/saimaz/XO/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/saimaz/XO/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/saimaz/XO/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/saimaz/XO/?branch=master)



Kaip paleisti žaisti vieną prieš kitą:
app/console xo:fight 'player1' 'Drunk Player' -g 1000

./console xo:fight -g 10000 'Drunk player' 'Expert player'
./console xo:fight -g 10000 'Expert player' 'Drunk player'
21 changes: 21 additions & 0 deletions src/XO/Player/Dardar/ActionsInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
namespace XO\Player\Dardar;

interface ActionsInterface
{
const KILL = 'kill';

const ATTACK = 'attack';

const DEFEND = 'defend';

const RANDOM = 'random';

public function defend();

public function attack();

public function kill();

public function isTurn($move);
}
60 changes: 60 additions & 0 deletions src/XO/Player/Dardar/Move/Move.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace XO\Player\Dardar\Move;

class Move implements MoveInterface
{
protected $x;

protected $y;

public function __construct($y, $x)
{
$this->setX($x);
$this->setY($y);
}

/**
* @return array
*/
public function getMove()
{
return array($this->x, $this->y);
}

/**
* Returns a natural array with not swapped values
* @return array
*/
public function getNaturalMove()
{
return array($this->y, $this->x);
}

/**
* @param mixed $x
*
* @throws \InvalidArgumentException
*/
public function setX($x)
{
if (!is_int($x)) {
throw new \InvalidArgumentException('X cannot be set! ' . $x);
}
$this->x = $x;
}


/**
* @param $y
*
* @throws \InvalidArgumentException
*/
public function setY($y)
{
if (!is_int($y)) {
throw new \InvalidArgumentException('Y cannot be set! ' . $y);
}
$this->y = $y;
}
}
10 changes: 10 additions & 0 deletions src/XO/Player/Dardar/Move/MoveInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php


namespace XO\Player\Dardar\Move;


interface MoveInterface
{
public function getMove();
}
10 changes: 10 additions & 0 deletions src/XO/Player/Dardar/Move/MoveNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php


namespace XO\Player\Dardar\Move;


class MoveNotFoundException extends \Exception
{

}
12 changes: 12 additions & 0 deletions src/XO/Player/Dardar/Move/NullMove.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php


namespace XO\Player\Dardar\Move;

class NullMove implements MoveInterface
{
public function getMove()
{
throw new MoveNotFoundException('This move is invalid.');
}
}
Loading