PHP Class Slackwolf\Game\Game

Show file Open project: chrisgillis/slackwolf Class Usage Examples

Public Properties

Property Type Description
$dayEnded
$hunterNeedsToShoot
$nightEnded
$seerSeen
$state
$witchHealed
$witchPoisoned
$wolvesVoted

Public Methods

Method Description
__construct ( $id, array $users, Slackwolf\Game\RoleStrategy\RoleStrategyInterface $roleStrategy )
addLobbyPlayer ( User $user ) : boolean If the lobby is open, adds a user to it.
assignRoles ( ) Assigns each user in the game to a role.
changeState ( $state )
clearPlayerVote ( $voterId )
clearVotes ( )
getDeadPlayers ( ) : User[] An array containing all the users that have been killed.
getGuardedUserId ( ) : mixed
getId ( ) : string
getLastGuardedUserId ( ) : mixed
getLivingPlayers ( ) : User[] An array containing all users that are still alive.
getLobbyPlayers ( ) : User[]
getNumRole ( $roleType ) : integer
getOriginalNumRole ( $roleType ) : integer
getOriginalPlayers ( ) : User[]
getOriginalPlayersOfRole ( $roleType ) : User[]
getPlayerById ( $id ) : User | boolean
getPlayersOfRole ( $roleType ) : User[]
getRoleStrategy ( ) : Slackwolf\Game\RoleStrategy\RoleStrategyInterface
getState ( ) : integer
getVillageTeam ( ) : User[]
getVotes ( ) : array
getWerewolves ( ) : User[]
getWitchHealed ( ) : mixed
getWitchHealedUserId ( ) : mixed
getWitchHealingPotion ( ) : integer
getWitchPoisonPotion ( ) : integer
getWitchPoisoned ( ) : mixed
getWitchPoisonedUserId ( ) : mixed
getWolvesVoted ( ) : mixed
hasPlayerVoted ( $voterId ) : boolean
isOver ( ) : boolean
isPlayerAlive ( $playerId ) : boolean Whether or not the player is alive.
killPlayer ( $player_id ) Kills the specified player.
removeLobbyPlayer ( $player_id ) : boolean Removes a user from the game lobby.
seerSeen ( ) : mixed
setDayEnded ( boolean $val )
setGuardedUserId ( $id )
setHunterNeedsToShoot ( boolean $val )
setLastGuardedUserId ( $id )
setNightEnded ( boolean $val )
setSeerSeen ( $seen )
setWitchHealed ( $healed )
setWitchHealedUserId ( $id )
setWitchHealingPotion ( $val )
setWitchPoisonPotion ( $val )
setWitchPoisoned ( $poisoned )
setWitchPoisonedUserId ( $id )
setWolvesVoted ( mixed $wolvesVoted )
vote ( $voterId, $voteForId )
votingFinished ( ) : boolean
whoWon ( ) : mixed

Method Details

__construct() public method

public __construct ( $id, array $users, Slackwolf\Game\RoleStrategy\RoleStrategyInterface $roleStrategy )
$id
$users array
$roleStrategy Slackwolf\Game\RoleStrategy\RoleStrategyInterface

addLobbyPlayer() public method

If the lobby is open, adds a user to it.
public addLobbyPlayer ( User $user ) : boolean
$user Slack\User The user to add to the lobby.
return boolean If successful, returns TRUE, otherwise, FALSE.

assignRoles() public method

Assigns each user in the game to a role.
public assignRoles ( )

changeState() public method

public changeState ( $state )
$state

clearPlayerVote() public method

public clearPlayerVote ( $voterId )
$voterId

clearVotes() public method

public clearVotes ( )

getDeadPlayers() public method

An array containing all the users that have been killed.
public getDeadPlayers ( ) : User[]
return Slack\User[] Users who have been killed.

getGuardedUserId() public method

public getGuardedUserId ( ) : mixed
return mixed

getId() public method

public getId ( ) : string
return string The game's ID, matches the channel ID.

getLastGuardedUserId() public method

public getLastGuardedUserId ( ) : mixed
return mixed

getLivingPlayers() public method

An array containing all users that are still alive.
public getLivingPlayers ( ) : User[]
return Slack\User[] Users who are currently alive.

getLobbyPlayers() public method

public getLobbyPlayers ( ) : User[]
return Slack\User[] An array of the lobby members.

getNumRole() public method

public getNumRole ( $roleType ) : integer
return integer

getOriginalNumRole() public method

public getOriginalNumRole ( $roleType ) : integer
return integer

getOriginalPlayers() public method

public getOriginalPlayers ( ) : User[]
return Slack\User[]

getOriginalPlayersOfRole() public method

public getOriginalPlayersOfRole ( $roleType ) : User[]
return Slack\User[]

getPlayerById() public method

public getPlayerById ( $id ) : User | boolean
$id
return Slack\User | boolean

getPlayersOfRole() public method

public getPlayersOfRole ( $roleType ) : User[]
return Slack\User[]

getRoleStrategy() public method

public getRoleStrategy ( ) : Slackwolf\Game\RoleStrategy\RoleStrategyInterface
return Slackwolf\Game\RoleStrategy\RoleStrategyInterface The game's strategy type.

getState() public method

public getState ( ) : integer
return integer The state of the game.

getVillageTeam() public method

public getVillageTeam ( ) : User[]
return Slack\User[]

getVotes() public method

public getVotes ( ) : array
return array

getWerewolves() public method

public getWerewolves ( ) : User[]
return Slack\User[]

getWitchHealed() public method

public getWitchHealed ( ) : mixed
return mixed

getWitchHealedUserId() public method

public getWitchHealedUserId ( ) : mixed
return mixed

getWitchHealingPotion() public method

public getWitchHealingPotion ( ) : integer
return integer

getWitchPoisonPotion() public method

public getWitchPoisonPotion ( ) : integer
return integer

getWitchPoisoned() public method

public getWitchPoisoned ( ) : mixed
return mixed

getWitchPoisonedUserId() public method

public getWitchPoisonedUserId ( ) : mixed
return mixed

getWolvesVoted() public method

public getWolvesVoted ( ) : mixed
return mixed

hasPlayerVoted() public method

public hasPlayerVoted ( $voterId ) : boolean
$voterId
return boolean

isOver() public method

public isOver ( ) : boolean
return boolean

isPlayerAlive() public method

Whether or not the player is alive.
public isPlayerAlive ( $playerId ) : boolean
$playerId The Slack user ID.
return boolean TRUE if player is alive and in game, otherwise FALSE.

killPlayer() public method

Kills the specified player.
public killPlayer ( $player_id )
$player_id The player to kill.

removeLobbyPlayer() public method

Removes a user from the game lobby.
public removeLobbyPlayer ( $player_id ) : boolean
$player_id The user to remove from the lobby.
return boolean If successful, returns TRUE, otherwise, FALSE.

seerSeen() public method

public seerSeen ( ) : mixed
return mixed

setDayEnded() public method

public setDayEnded ( boolean $val )
$val boolean

setGuardedUserId() public method

public setGuardedUserId ( $id )
$id

setHunterNeedsToShoot() public method

public setHunterNeedsToShoot ( boolean $val )
$val boolean

setLastGuardedUserId() public method

public setLastGuardedUserId ( $id )
$id

setNightEnded() public method

public setNightEnded ( boolean $val )
$val boolean

setSeerSeen() public method

public setSeerSeen ( $seen )
$seen

setWitchHealed() public method

public setWitchHealed ( $healed )
$healed

setWitchHealedUserId() public method

public setWitchHealedUserId ( $id )
$id

setWitchHealingPotion() public method

public setWitchHealingPotion ( $val )
$val

setWitchPoisonPotion() public method

public setWitchPoisonPotion ( $val )
$val

setWitchPoisoned() public method

public setWitchPoisoned ( $poisoned )
$poisoned

setWitchPoisonedUserId() public method

public setWitchPoisonedUserId ( $id )
$id

setWolvesVoted() public method

public setWolvesVoted ( mixed $wolvesVoted )
$wolvesVoted mixed

vote() public method

public vote ( $voterId, $voteForId )
$voterId
$voteForId

votingFinished() public method

public votingFinished ( ) : boolean
return boolean

whoWon() public method

public whoWon ( ) : mixed
return mixed

Property Details

$dayEnded public property

public $dayEnded

$hunterNeedsToShoot public property

public $hunterNeedsToShoot

$nightEnded public property

public $nightEnded

$seerSeen public property

public $seerSeen

$state public property

public $state

$witchHealed public property

public $witchHealed

$witchPoisoned public property

public $witchPoisoned

$wolvesVoted public property

public $wolvesVoted