Documentation ¶
Index ¶
- func GetNextChar(character string, maxCharacters uint) byte
- func MatchFound(coordinates string, stringOfCoords string) bool
- type BattleModel
- func (m *BattleModel) Accept(player2ID, boardID, battleID int) (int, error)
- func (m *BattleModel) CheckBoardOwner(playerID, battleID, boardID int) bool
- func (m *BattleModel) CheckChallenger(player1ID, battleID, player2BoardID int) bool
- func (m *BattleModel) CheckTurn(battleID, playerID int) (int, string)
- func (m *BattleModel) Create(player1ID, player1BoardID, player2ID int, secretTurn string) (int, error)
- func (m *BattleModel) Get(playerID, battleID int) (*models.Battle, error)
- func (m *BattleModel) GetChallenger(currentPlayerID int) (int, error)
- func (m *BattleModel) GetChallenges(rowid int) ([]*models.Battle, error)
- func (m *BattleModel) GetOpen(rowid, battleID int) ([]*models.Battle, error)
- func (m *BattleModel) GetTurn(battleID int) (int, error)
- func (m *BattleModel) UpdateChallenge(player1 int, player2 int, player2Accepted bool, battleID int) error
- func (m *BattleModel) UpdateTurn(player1 int, player2 int, nextTurn int, battleID int, secretTurn []byte) error
- type BoardModel
- func (m *BoardModel) ChooseBoard(rowid, boardID int, action string) (int, error)
- func (m *BoardModel) Create(rowid int, boardName string) (int, error)
- func (m *BoardModel) GetInfo(playerID, boardID int) (*models.Board, error)
- func (m *BoardModel) GetPositions(rowid int) ([]*models.Position, error)
- func (m *BoardModel) Insert(playerID int, boardID int, shipName string, arrayOfCoords []string) (int, error)
- func (m *BoardModel) List(rowid int) ([]*models.Board, error)
- func (m *BoardModel) Update(rowid int, boardName string, playerID int) (int, error)
- type PlayerModel
- func (m *PlayerModel) Authenticate(screenName, password string) (int, error)
- func (m *PlayerModel) Get(rowid int) (*models.Player, error)
- func (m *PlayerModel) Insert(screenName string, emailAddress string, password string) (int, error)
- func (m *PlayerModel) List(rowid int, status string) ([]*models.Player, error)
- func (m *PlayerModel) Update(id int, emailAddress string) (int, error)
- func (m *PlayerModel) UpdateLogin(id int, loggedIn bool) (int, error)
- type PositionModel
- func (m *PositionModel) CheckWinner(playerID, battleID int) (bool, error)
- func (m *PositionModel) Get(id int) (*models.Position, error)
- func (m *PositionModel) Insert(boardID int, battleshipID int, playerID int, coordX int, coordY int, ...) (int, error)
- func (m *PositionModel) List(boardID, playerID int) ([]*models.Position, error)
- func (m *PositionModel) Update(playerID int, playerTakingTheirTurn int, battleID int, boardID int, coordX int, ...) (string, string, bool, error)
- type ShipModel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetNextChar ¶
return the next alphabet character but stop at maxCharacters
func MatchFound ¶
Types ¶
type BattleModel ¶
func (*BattleModel) Accept ¶
func (m *BattleModel) Accept(player2ID, boardID, battleID int) (int, error)
Accept a challenge (battle)
func (*BattleModel) CheckBoardOwner ¶
func (m *BattleModel) CheckBoardOwner(playerID, battleID, boardID int) bool
GetBoardOwner - Ensure the player is the owner of this board and this board is part of this battle
func (*BattleModel) CheckChallenger ¶
func (m *BattleModel) CheckChallenger(player1ID, battleID, player2BoardID int) bool
Check that the person logged in should be updating this battle
func (*BattleModel) CheckTurn ¶
func (m *BattleModel) CheckTurn(battleID, playerID int) (int, string)
Just ask the database whose turn it is - The database will return a secret key representing player1 or player2
func (*BattleModel) Create ¶
func (m *BattleModel) Create(player1ID, player1BoardID, player2ID int, secretTurn string) (int, error)
Create a new Battle - record the challenger (player1) and the challengee (player2)
func (*BattleModel) Get ¶
func (m *BattleModel) Get(playerID, battleID int) (*models.Battle, error)
Get - return a single battle; this is for the battle board
func (*BattleModel) GetChallenger ¶
func (m *BattleModel) GetChallenger(currentPlayerID int) (int, error)
GetChallenger - See if there are any challengers out there
func (*BattleModel) GetChallenges ¶
func (m *BattleModel) GetChallenges(rowid int) ([]*models.Battle, error)
GetAll - Get all active battles or challenges (this could be combined with GetOpen below)
func (*BattleModel) GetOpen ¶
func (m *BattleModel) GetOpen(rowid, battleID int) ([]*models.Battle, error)
GetOpen - Get a list of open challenges
func (*BattleModel) GetTurn ¶
func (m *BattleModel) GetTurn(battleID int) (int, error)
Just ask the database whose turn it is - The database will return a secret key representing player1 or player2
func (*BattleModel) UpdateChallenge ¶
func (m *BattleModel) UpdateChallenge(player1 int, player2 int, player2Accepted bool, battleID int) error
Update challenge - opponent has accepted
func (*BattleModel) UpdateTurn ¶
func (m *BattleModel) UpdateTurn(player1 int, player2 int, nextTurn int, battleID int, secretTurn []byte) error
Update turn - other player's turn
type BoardModel ¶
func (*BoardModel) ChooseBoard ¶
func (m *BoardModel) ChooseBoard(rowid, boardID int, action string) (int, error)
Choose Board - I can't store the boardID in my session so...
update the database and keep one "selected" board at any given point in time
func (*BoardModel) Create ¶
func (m *BoardModel) Create(rowid int, boardName string) (int, error)
Create a board if one with the same name doesn't already exist (belonging to this user)
func (*BoardModel) GetInfo ¶
func (m *BoardModel) GetInfo(playerID, boardID int) (*models.Board, error)
Get board info - name of board
func (*BoardModel) GetPositions ¶
func (m *BoardModel) GetPositions(rowid int) ([]*models.Position, error)
Get positions on board
type PlayerModel ¶
func (*PlayerModel) Authenticate ¶
func (m *PlayerModel) Authenticate(screenName, password string) (int, error)
authenticate player
func (*PlayerModel) Get ¶
func (m *PlayerModel) Get(rowid int) (*models.Player, error)
get player information
func (*PlayerModel) Update ¶
func (m *PlayerModel) Update(id int, emailAddress string) (int, error)
update player
func (*PlayerModel) UpdateLogin ¶
func (m *PlayerModel) UpdateLogin(id int, loggedIn bool) (int, error)
update login
type PositionModel ¶
func (*PositionModel) CheckWinner ¶
func (m *PositionModel) CheckWinner(playerID, battleID int) (bool, error)
Check the Battles board to see if one of the players has 5 sunken ships
func (*PositionModel) List ¶
func (m *PositionModel) List(boardID, playerID int) ([]*models.Position, error)
func (*PositionModel) Update ¶
func (m *PositionModel) Update(playerID int, playerTakingTheirTurn int, battleID int, boardID int, coordX int, coordY, secretTurn string) (string, string, bool, error)
Update positions pinColor - Query player, battle, board, and coordinates - Return the pinColor and shipType (if sunk) - Update whose turn it is