Documentation ¶
Index ¶
- Constants
- type Enterprise
- type Klingon
- type Message
- type MoveableObject
- type Object
- type Player
- type Quadrant
- func (q *Quadrant) AcceptInput()
- func (q *Quadrant) AddMessage(t string)
- func (q *Quadrant) DisplayMessages()
- func (q *Quadrant) DisplayQuadrant()
- func (q *Quadrant) DisplayState()
- func (q *Quadrant) DisplayStatus()
- func (q *Quadrant) HandleKeyForState(key tcell.EventKey)
- func (q *Quadrant) IsPlayerDead() bool
- func (q *Quadrant) MoveObject(m MoveableObject, direction int)
- func (q *Quadrant) Update()
- func (q *Quadrant) UpdateState(newState int)
- func (q *Quadrant) UpdateTorpedoes()
- type Star
- type Starbase
- type Torpedo
Constants ¶
const ( Dir1 Dir2 Dir3 Dir4 Dir5 Dir6 Dir7 Dir8 Dir9 )
Direction constants
const ( Normal = iota Weapons Shields Sensors Computer WeaponsPhasers WeaponsTorpedoes )
State of interface - which option currently selected
const ( EnergyToMove = 10 TorpedoDamage = 500 )
Game constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Enterprise ¶
type Enterprise struct { X int Y int QuadrantX int QuadrantY int Energy int Shields int Torpedoes int }
Enterprise : Information relating to the player ship
func NewEnterprise ¶
func NewEnterprise(xloc int, yloc int) *Enterprise
NewEnterprise creates a new Enterprise
func (Enterprise) GetShields ¶
func (e Enterprise) GetShields() int
GetShields returns the object's shield strength
func (*Enterprise) IsPlayer ¶
func (e *Enterprise) IsPlayer() bool
IsPlayer indicates if this is the player object or not
func (Enterprise) Location ¶
func (e Enterprise) Location() (int, int)
Location returns the location of the Enterprise
func (*Enterprise) TakeDamage ¶
func (e *Enterprise) TakeDamage(damage int)
TakeDamage reduces damage to Enterprise
type Klingon ¶
Klingon for the Enterprise to blow up
func (Klingon) GetShields ¶
GetShields returns the object's shield strength
func (*Klingon) TakeDamage ¶
TakeDamage does damage to klingon
type MoveableObject ¶
MoveableObject is the interface for all moveable objects
type Object ¶
type Object interface { Name() string Location() (int, int) TakeDamage(damage int) GetShields() int }
Object interface to generize all objects in sector
type Player ¶
type Player interface { MoveableObject IsPlayer() bool }
Player interface to test if object is player
type Quadrant ¶
type Quadrant struct { X int Y int Objects [10][10]Object Player *Enterprise StartingNumberOfKlingons int NumberOfKlingons int StartingNumberOfStarbases int NumberOfStarbases int NumberOfStars int Scanned bool Game game.Game UIState int AwaitingInput bool CurrentInput string Messages []Message // contains filtered or unexported fields }
Quadrant : All the information related to a single Quadrant
func NewQuadrant ¶
func NewQuadrant(parentGame game.Game, x int, y int, numKlingons int, numStars int, numBases int) *Quadrant
NewQuadrant creates a new quadrant, populated with items
func (*Quadrant) AcceptInput ¶
func (q *Quadrant) AcceptInput()
AcceptInput accepts whatever the player has typed for input
func (*Quadrant) AddMessage ¶
AddMessage adds a message to the messages display Will be removed in 5 turns (stardate + 0.5)
func (*Quadrant) DisplayMessages ¶
func (q *Quadrant) DisplayMessages()
DisplayMessages displays all the messages in order, removing any greater than 0.5 Stardates old
func (*Quadrant) DisplayQuadrant ¶
func (q *Quadrant) DisplayQuadrant()
DisplayQuadrant draws the Quadrant map
func (*Quadrant) DisplayState ¶
func (q *Quadrant) DisplayState()
DisplayState renders the bottom display based on the state of the UI
func (*Quadrant) DisplayStatus ¶
func (q *Quadrant) DisplayStatus()
DisplayStatus draws the status of the quadrant (the stuff to the right of the map)
func (*Quadrant) HandleKeyForState ¶
func (q *Quadrant) HandleKeyForState(key tcell.EventKey)
HandleKeyForState handles the current key for the various ui states
func (*Quadrant) IsPlayerDead ¶
IsPlayerDead checks if game is over
func (*Quadrant) MoveObject ¶
func (q *Quadrant) MoveObject(m MoveableObject, direction int)
MoveObject moves the object in the direction specified
func (*Quadrant) Update ¶
func (q *Quadrant) Update()
Update processes the next turn for the quadrant
func (*Quadrant) UpdateState ¶
UpdateState changes the current state of the UI
func (*Quadrant) UpdateTorpedoes ¶
func (q *Quadrant) UpdateTorpedoes()
UpdateTorpedoes moves the torpedo along it's path
type Star ¶
Star represents planets in the sector
func (Star) GetShields ¶
GetShields returns the object's shield strength
type Starbase ¶
Starbase represents planets in the sector
func NewStarbase ¶
NewStarbase returns a new instance of starbase
func (Starbase) GetShields ¶
GetShields returns the object's shield strength
func (*Starbase) TakeDamage ¶
TakeDamage does damage to klingon