quadrant

package
v0.0.0-...-0e4f151 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Dir1
	Dir2
	Dir3
	Dir4
	Dir5
	Dir6
	Dir7
	Dir8
	Dir9
)

Direction constants

View Source
const (
	Normal = iota
	NavigationX
	NavigationY
	Weapons
	Shields
	Sensors
	Computer

	WeaponsPhasers
	WeaponsTorpedoes
)

State of interface - which option currently selected

View Source
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) Move

func (e *Enterprise) Move(x int, y int)

Move the enterprise

func (Enterprise) Name

func (e Enterprise) Name() string

Name returns the display-friendly name

func (*Enterprise) TakeDamage

func (e *Enterprise) TakeDamage(damage int)

TakeDamage reduces damage to Enterprise

type Klingon

type Klingon struct {
	X         int
	Y         int
	Shields   int
	Torpedoes int
}

Klingon for the Enterprise to blow up

func NewKlingon

func NewKlingon(x int, y int) *Klingon

NewKlingon creates a new Klingon

func (Klingon) GetShields

func (k Klingon) GetShields() int

GetShields returns the object's shield strength

func (Klingon) Location

func (k Klingon) Location() (int, int)

Location returns the location of the Enterprise

func (*Klingon) Move

func (k *Klingon) Move(x int, y int)

Move the klingon

func (Klingon) Name

func (k Klingon) Name() string

Name returns the display-friendly name

func (*Klingon) TakeDamage

func (k *Klingon) TakeDamage(damage int)

TakeDamage does damage to klingon

type Message

type Message struct {
	Text     string
	Stardate float64
}

Message type for ui messages

type MoveableObject

type MoveableObject interface {
	Object
	Move(x int, y int)
}

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

func (q *Quadrant) AddMessage(t string)

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

func (q *Quadrant) IsPlayerDead() bool

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

func (q *Quadrant) UpdateState(newState int)

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

type Star struct {
	X int
	Y int
}

Star represents planets in the sector

func (Star) GetShields

func (s Star) GetShields() int

GetShields returns the object's shield strength

func (Star) Location

func (s Star) Location() (int, int)

Location returns the location of the star in the quadrant

func (Star) Name

func (s Star) Name() string

Name returns the display-friendly name

func (*Star) TakeDamage

func (s *Star) TakeDamage(damage int)

TakeDamage does no damage to star

type Starbase

type Starbase struct {
	X       int
	Y       int
	Shields int
}

Starbase represents planets in the sector

func NewStarbase

func NewStarbase(x int, y int) *Starbase

NewStarbase returns a new instance of starbase

func (Starbase) GetShields

func (s Starbase) GetShields() int

GetShields returns the object's shield strength

func (Starbase) Location

func (s Starbase) Location() (int, int)

Location returns the location of the planet in the quadrant

func (Starbase) Name

func (s Starbase) Name() string

Name returns the display-friendly name

func (*Starbase) TakeDamage

func (s *Starbase) TakeDamage(damage int)

TakeDamage does damage to klingon

type Torpedo

type Torpedo struct {
	X         int
	Y         int
	Direction int
}

Torpedo is the struct representing a photon torpedo

func (Torpedo) Location

func (t Torpedo) Location() (int, int)

Location returns the location of the torpedo

func (*Torpedo) Move

func (t *Torpedo) Move(x int, y int)

Move the torpedo

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL