2017 © Pedro Peláez
 

library rockpaperscissorsspocklizard

Based on a game created by Sam Kass and Karen Bryla and made popular by "Big Bang Theory"

image

jarrett/rockpaperscissorsspocklizard

Based on a game created by Sam Kass and Karen Bryla and made popular by "Big Bang Theory"

  • Thursday, September 7, 2017
  • by jarrett
  • Repository
  • 1 Watchers
  • 0 Stars
  • 18 Installations
  • HTML
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Build Status Code Coverage Scrutinizer Code Quality SensioLabsInsight, (*1)

RockPaperScissorsSpockLizard Game (in PHP)

A PHP class implementation of Rock Paper Scissors Spock Lizard as created by Sam Kass and Karen Bryla and popularized by "Big Bang Theory.", (*2)

Add as many players (or bots) as you want. Then play them all against each other at the same time!, (*3)

Packagist can be found here: jarrett/rockpaperscissorsspocklizard, (*4)

Getting Started

Install via composer:, (*5)

composer install jarrett/rockpaperscissorsspocklizard

and require composer autoloader, (*6)

require 'vendor/autoload.php';

Basic Example:

use Jarrett\RockPaperScissorsSpockLizard;
use Jarrett\RockPaperScissorsSpockLizard\Player;

// ...

$player = new Player();
$player->move('rock');

$bot = new Player();
$bot->isBot(true);

$game = new RockPaperScissorsSpockLizard();
$game->addPlayers($player, $bot)
     ->play();

$outcome = $game->getOutcomes();    

2 Player Example:

use Jarrett\RockPaperScissorsSpockLizard;
use Jarrett\RockPaperScissorsSpockLizard\Player;

// ...

$player1 = new Player();
$player1->move('rock');

$player2 = new Player();
$player2->move('scissors');

$game = new RockpaperScissorsSpockLizard();
$game->setRounds(3)
     ->addPlayers($player1, $player2);
     ->play();

$outcome = $this->getOutcomes()

5 Player Example:

use Jarrett\RockPaperScissorsSpockLizard;
use Jarrett\RockPaperScissorsSpockLizard\Player;

// ...

// human
$player1 = new Player();
$player1->move('rock');

// human
$player2 = new Player();
$player2->move('paper');

// and 3 bots
$player3 = new Player();
$player4 = new Player();
$player5 = new Player();

$game = new RockpaperScissorsSpockLizard();
$game->addPlayers($player1, $player2, $player3, $player4, $player5)
     ->play();

// returns an array containing all wins, ties, and losses
$outcomes = $this->getOutcomes()

... or just throw the player instantiation directly into the addPlayers() method, (*7)

$game = new RockpaperScissorsSpockLizard();
$game->addPlayers($player1, $player2, (new Player), (new Player), (new Player))
         ->play();

Class Method Reference:

Player( string $player_name )

move( string $move)

Set your move, (*8)

setName()

Set player name. Can also be passed via the constructor. Generic "Player 1, 2, 3" will be used if name is empty., (*9)

getName()

Get player name., (*10)

getMoveHistory()

Get player's move history, (*11)

getLastMove()

Get player's last move, (*12)

RockPaperScissorsSpockLizard()

play()

Play the round, (*13)

restart()

Restarts the game, (*14)

setRounds( string $number, bool $lock = false)

Set the number of rounds for this game. Default is 1 if not specified., (*15)

Parameters
$number integer
  • The maximum number of rounds before a winner is chosen
$lock bool
  • If true, don't allow the number of rounds to change for this game
  • If _false_ (default), the maximum number of rounds can be changed during the game, even after a winner is determined.

getRounds()

Returns all round results., (*16)

getOutcome()

Returns last round outcome., (*17)

addPlayer()

Add player to the game., (*18)

addPlayers()

Add multiple players to the game., (*19)

getPlayers()

Return players for game., (*20)

getTotalPlayers()

Returns the number of players playing, (*21)

getRoundWinner()

Returns the player who won the last round., (*22)

getOutcomes()

Returns the outcomes for all players., (*23)

getWinners()

Returns the player who won the game., (*24)

The Versions

07/09 2017

dev-master

9999999-dev

Based on a game created by Sam Kass and Karen Bryla and made popular by "Big Bang Theory"

  Sources   Download

GPL-3.0

The Development Requires

by Jarrett Barnett

07/09 2017

1.1.4-stable

1.1.4.0

Based on a game created by Sam Kass and Karen Bryla and made popular by "Big Bang Theory"

  Sources   Download

GPL-3.0

The Development Requires

by Jarrett Barnett

30/08 2017

1.1.3-stable

1.1.3.0

Based on a game created by Sam Kass and Karen Bryla and made popular by "Big Bang Theory"

  Sources   Download

GPL-3.0

The Development Requires

by Jarrett Barnett

30/08 2017

1.1.3

1.1.3.0

Based on a game created by Sam Kass and Karen Bryla and made popular by "Big Bang Theory"

  Sources   Download

GPL-3.0

The Development Requires

by Jarrett Barnett

29/08 2017

1.1.2-stable

1.1.2.0

Based on a game created by Sam Kass and Karen Bryla and made popular by "Big Bang Theory"

  Sources   Download

The Development Requires

by Jarrett Barnett

29/08 2017

1.1.1-stable

1.1.1.0

Based on a game created by Sam Kass and Karen Bryla and made popular by "Big Bang Theory"

  Sources   Download

The Development Requires

by Jarrett Barnett

29/08 2017

1.1.0-stable

1.1.0.0

Based on a game created by Sam Kass and Karen Bryla and made popular by "Big Bang Theory"

  Sources   Download

The Development Requires

by Jarrett Barnett

29/08 2017

1.0.0

1.0.0.0

Based on a game created by Sam Kass and Karen Bryla and made popular by "Big Bang Theory"

  Sources   Download

The Development Requires

by Jarrett Barnett