Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateOptions(turn int) ([]Appliance, []Upgrade)
- func GetIndex(width, x, y int8) int8
- func LocationIsHouse(height, team int8, l Location) bool
- func LocationValid(width, height int8, l Location) bool
- func PrintCanvas(canvas [][]string)
- func PrintState(width, height int8, state State)
- func SameLocation(loc1, loc2 Location) bool
- func ValidatePlayerSelection(previousState, nextState Selection) bool
- type Appliance
- type ApplianceBirthEvent
- type ApplianceDeathEvent
- type BuyApplianceEvent
- type EndGameEvent
- type Event
- type EventBase
- type EventType
- type GameSquare
- type House
- type HouseDeathEvent
- type HouseState
- type Location
- type ModifyHealthEvent
- type ObjectState
- type ObjectType
- type RelocationEvent
- type Rumba
- type Selection
- type StartGameEvent
- type State
- type Sticky
- type Team
- type Toaster
- type TurnEndEvent
- type TurnStartEvent
- type Upgrade
Constants ¶
View Source
const ( // EventTypeModifyHouseHealth = "modify_house_health" EventTypeModifyHealth = "modify_health" EventTypeRelocate = "relocate" EventTypeApplianceBirth = "appliance_birth" EventTypeApplianceDeath = "appliance_death" EventTypeApplianceBought = "appliance_bought" EventTypeApplianceSold = "appliance_sold" EventTypeStartGame = "start_game" EventTypeEndGame = "end_game" EventTurnStart = "turn_start" EventTurnEnd = "turn_end" EventTypeHouseDeath = "house_death" EventTypePlayerMovedAppliance = "player_moved_appliance" EventTypePlayerBoughtAppliance = "player_bought_appliance" EventTypePlayerSoldAppliance = "player_sold_appliance" EventTypePlayerBoughtItem = "player_bought_item" )
View Source
const ( ResultGoingDown = int8(-1) ResultNotFinished = int8(0) ResultGoingUp = int8(1) ResultDraw = int8(2) ResultTimeout = int8(3) )
View Source
const ( SquareWidthBytes = 15 SquareHeightLines = 7 )
View Source
const ObjectTypeHouse = "house"
Variables ¶
View Source
var (
TeamValues = []int8{
-1,
1,
}
)
Functions ¶
func GenerateOptions ¶
func LocationIsHouse ¶
func LocationValid ¶
func PrintCanvas ¶
func PrintCanvas(canvas [][]string)
func PrintState ¶
func SameLocation ¶
func ValidatePlayerSelection ¶
players can rearrange their appliances without triggering events. only selection events that trigger other events are: - buy - sell - merge - upgrade for validation, will need a function that confirms all appliances listed in each event match previous known state, even if they've been rearranged
Types ¶
type Appliance ¶
type Appliance interface { State() ObjectState Type() ObjectType // this allows the appliance to be converted to its street location (ie in the two player grid). // may decouple location somehow to remove this as a required method.... MoveToStreet(width, height, team int8) Appliance // ReceiveEvent is how the appliance responds to events. // The returned appliance object is the next state of the appliance // All appliances receive all events in case they have behaviour based on things happening to // appliances elsewhere on the board. // Receiving events can also trigger more events, for example incoming damage to an ally might trigger a heal event etc ReceiveEvents(appliances []Appliance, events []Event, turn uint8) ([]Appliance, []Event) }
func ApplySelection ¶
type ApplianceBirthEvent ¶
func (ApplianceBirthEvent) Base ¶
func (e ApplianceBirthEvent) Base() EventBase
func (ApplianceBirthEvent) Type ¶
func (e ApplianceBirthEvent) Type() EventType
type ApplianceDeathEvent ¶
func (ApplianceDeathEvent) Base ¶
func (e ApplianceDeathEvent) Base() EventBase
func (ApplianceDeathEvent) Type ¶
func (e ApplianceDeathEvent) Type() EventType
type BuyApplianceEvent ¶
func (BuyApplianceEvent) Base ¶
func (e BuyApplianceEvent) Base() EventBase
func (BuyApplianceEvent) Type ¶
func (e BuyApplianceEvent) Type() EventType
type EndGameEvent ¶
type EndGameEvent struct {
EventBase
}
func (EndGameEvent) Base ¶
func (e EndGameEvent) Base() EventBase
func (EndGameEvent) Type ¶
func (e EndGameEvent) Type() EventType
type EventBase ¶
type EventBase struct { // Iteration is used for events that occur as a result of another event. // For instance the first time someone gets moved they might then get moved back as a result. // On the second move any appliance that responds to any move would then try to move them back again // creating an infinite loop. // By incrementing the iteration on the event we can check for iteration and only act a few times. Iteration int8 // CausedBy is an appliance since team is important CausedBy Appliance // Target is only a location since it may not be specific to an appliance Target Location }
type GameSquare ¶
func (GameSquare) Print ¶
func (g GameSquare) Print(x, y int8, canvas [][]string)
puts all the rows for one square into the right string in the canvas
type HouseDeathEvent ¶
type HouseDeathEvent struct {
EventBase
}
func (HouseDeathEvent) Base ¶
func (e HouseDeathEvent) Base() EventBase
func (HouseDeathEvent) Type ¶
func (e HouseDeathEvent) Type() EventType
type HouseState ¶
type HouseState struct { // May rethink the appliancestate interface ObjectState }
HouseState implements Appliance since it can be responsible for events, and receive damage
func (HouseState) MoveToStreet ¶
func (h HouseState) MoveToStreet(width, height, team int8) Appliance
func (HouseState) ReceiveEvents ¶
func (HouseState) Type ¶
func (h HouseState) Type() ObjectType
type Location ¶
func (Location) MoveToStreet ¶
team is either -1 or 1 team 1 gets moved to top and inverted on both axis
type ModifyHealthEvent ¶
func (ModifyHealthEvent) Base ¶
func (e ModifyHealthEvent) Base() EventBase
func (ModifyHealthEvent) Type ¶
func (e ModifyHealthEvent) Type() EventType
type ObjectState ¶
type ObjectState struct { Location Location Upgrade Upgrade // -1 = going down // 0 = not set (default when viewing your own team) // 1 = going up Team int8 Health int8 Strength int8 // TODO Repair int8 Model int8 }
func (ObjectState) State ¶
func (s ObjectState) State() ObjectState
this make any object that contains an object state implement the state method
type ObjectType ¶
type ObjectType string
type RelocationEvent ¶
func (RelocationEvent) Base ¶
func (e RelocationEvent) Base() EventBase
func (RelocationEvent) Type ¶
func (e RelocationEvent) Type() EventType
type Rumba ¶
type Rumba struct {
ObjectState
}
want him to path towards home currently just a copy of toaster
func (Rumba) MoveToStreet ¶
func (Rumba) ReceiveEvents ¶
func (Rumba) Type ¶
func (t Rumba) Type() ObjectType
type StartGameEvent ¶
type StartGameEvent struct {
EventBase
}
func (StartGameEvent) Base ¶
func (e StartGameEvent) Base() EventBase
func (StartGameEvent) Type ¶
func (e StartGameEvent) Type() EventType
type Sticky ¶
type Sticky struct {
ObjectState
}
func (Sticky) MoveToStreet ¶
func (Sticky) ReceiveEvents ¶
func (Sticky) Type ¶
func (t Sticky) Type() ObjectType
type Toaster ¶
type Toaster struct {
ObjectState
}
func (Toaster) MoveToStreet ¶
func (Toaster) ReceiveEvents ¶
func (Toaster) Type ¶
func (t Toaster) Type() ObjectType
type TurnEndEvent ¶
func (TurnEndEvent) Base ¶
func (e TurnEndEvent) Base() EventBase
func (TurnEndEvent) Type ¶
func (e TurnEndEvent) Type() EventType
type TurnStartEvent ¶
func (TurnStartEvent) Base ¶
func (e TurnStartEvent) Base() EventBase
func (TurnStartEvent) Type ¶
func (e TurnStartEvent) Type() EventType
Source Files ¶
Click to show internal directories.
Click to hide internal directories.