C# Class MBC.Core.Game.Match

Exibir arquivo Open project: aiclub/Mohawk_Battleship Class Usage Examples

Public Methods

Method Description
AddPlayer ( Player plr ) : bool

Adds a player to the match.

AddTeam ( Team newTeam ) : bool

Adds a team to the match.

Match ( Configuration config ) : System

Creates a match with parameters loaded from a configuration.

Play ( ) : void

Moves the match progress forward at a standard pace.

PlayerDisqualified ( Player plr, string reason ) : bool

Signals a disqualification event against a player for a specific reason.

PlayerLost ( Player plr ) : bool

Marks a player as a loser in the current round and increases their losing score. Player must be active in order to lose, otherwise this method returns false.

PlayerSetShips ( Player plr, IList ships ) : bool

Sets the ships that are assigned to a player.

PlayerShot ( Player plr, Shot shot ) : bool

Use when a player shoots.

PlayerShot ( Player plr, Shot shot, Ship shipHit ) : bool

Use when a player shoots and hits a ship.

PlayerTeamAssign ( Player plr, Team newTeam ) : bool

Assign a player to a team.

PlayerTimeout ( Player plr, ControllerTimeoutException ex ) : void

Call when a player has timed out.

PlayerWin ( Player plr ) : void

Call when a player has won a round.

RemovePlayer ( Player plr ) : bool

Call when a player is to be removed from the match.

RemoveTeam ( Team remTeam ) : bool

Call when a team is to be removed from the match.

ShipsValid ( Player player ) : bool

Checks if a player's ship are placed, and are valid within the parameters of the match.

Stop ( ) : void

Stops progression of the match.

Protected Methods

Method Description
IsShotValid ( Shot shot ) : bool

Determines whether or not a given shot is valid within the parameters of the match.

PlayLogic ( ) : bool
PlayerMessage ( Player plr, string msg ) : void

Call when a player is outputting a message.

PlayerShipDestroyed ( Player plr, Ship destroyedShip ) : void

Call when a ship from a player has been destroyed.

SetParameters ( Configuration conf ) : void

Changes the match parameters to reflect the configuration given.

Private Methods

Method Description
AppendEvent ( MBC.Core.Events.Event ev ) : void

Appends an event to the list of events of the match, with a proper timestamp.

ApplyParameters ( Configuration conf ) : void

Applies a configuration to the match.

EndRound ( ) : void

Notifies the end of a round.

MatchEnd ( ) : bool

Called when the match ends.

NewRound ( ) : void

Notifies a new round beginning.

NotifyParamsChanged ( ) : void

Notifies match parameter changes.

Method Details

AddPlayer() public method

Adds a player to the match.
public AddPlayer ( Player plr ) : bool
plr Player
return bool

AddTeam() public method

Adds a team to the match.
public AddTeam ( Team newTeam ) : bool
newTeam Team
return bool

IsShotValid() protected method

Determines whether or not a given shot is valid within the parameters of the match.
protected IsShotValid ( Shot shot ) : bool
shot Shot
return bool

Match() public method

Creates a match with parameters loaded from a configuration.
public Match ( Configuration config ) : System
config Configuration
return System

Play() public method

Moves the match progress forward at a standard pace.
public Play ( ) : void
return void

PlayLogic() protected method

protected PlayLogic ( ) : bool
return bool

PlayerDisqualified() public method

Signals a disqualification event against a player for a specific reason.
public PlayerDisqualified ( Player plr, string reason ) : bool
plr Player
reason string
return bool

PlayerLost() public method

Marks a player as a loser in the current round and increases their losing score. Player must be active in order to lose, otherwise this method returns false.
public PlayerLost ( Player plr ) : bool
plr Player
return bool

PlayerMessage() protected method

Call when a player is outputting a message.
protected PlayerMessage ( Player plr, string msg ) : void
plr Player
msg string
return void

PlayerSetShips() public method

Sets the ships that are assigned to a player.
public PlayerSetShips ( Player plr, IList ships ) : bool
plr Player
ships IList
return bool

PlayerShipDestroyed() protected method

Call when a ship from a player has been destroyed.
protected PlayerShipDestroyed ( Player plr, Ship destroyedShip ) : void
plr Player
destroyedShip Ship
return void

PlayerShot() public method

Use when a player shoots.
public PlayerShot ( Player plr, Shot shot ) : bool
plr Player
shot Shot
return bool

PlayerShot() public method

Use when a player shoots and hits a ship.
public PlayerShot ( Player plr, Shot shot, Ship shipHit ) : bool
plr Player
shot Shot
shipHit Ship
return bool

PlayerTeamAssign() public method

Assign a player to a team.
public PlayerTeamAssign ( Player plr, Team newTeam ) : bool
plr Player
newTeam Team
return bool

PlayerTimeout() public method

Call when a player has timed out.
public PlayerTimeout ( Player plr, ControllerTimeoutException ex ) : void
plr Player
ex MBC.Core.Threading.ControllerTimeoutException
return void

PlayerWin() public method

Call when a player has won a round.
public PlayerWin ( Player plr ) : void
plr Player
return void

RemovePlayer() public method

Call when a player is to be removed from the match.
public RemovePlayer ( Player plr ) : bool
plr Player
return bool

RemoveTeam() public method

Call when a team is to be removed from the match.
public RemoveTeam ( Team remTeam ) : bool
remTeam Team
return bool

SetParameters() protected method

Changes the match parameters to reflect the configuration given.
protected SetParameters ( Configuration conf ) : void
conf Configuration
return void

ShipsValid() public method

Checks if a player's ship are placed, and are valid within the parameters of the match.
public ShipsValid ( Player player ) : bool
player Player
return bool

Stop() public method

Stops progression of the match.
public Stop ( ) : void
return void