...

Package saloon

import "joueur/games/saloon"
Overview
Index

Overview ▾

Package saloon contains all the interfaces and AI that are required to represent and play Saloon.

Saloon Game Info ▾

Use cowboys to have a good time and play some music on a Piano, while brawling with enemy Cowboys.

More Info

The full game rules for Saloon can be found on GitHub.

Additional materials, such as the story and game template can be found on GitHub as well.

Variables

TileDirections are all the direction strings that Tile's neighbors can be in.

var TileDirections = [...]string{"North", "South", "East", "West"}

func PlayerName

func PlayerName() string

PlayerName should return the string name of your Player in games it plays.

type AI

AI is your personal AI implimentation.

type AI struct {
    base.AIImpl
}

func (*AI) Ended

func (ai *AI) Ended(won bool, reason string)

Ended is called when the game ends, you can clean up your data and dump files here if need be.

func (*AI) Game

func (ai *AI) Game() Game

Game returns the instance of the Game this AI is currently playing.

func (*AI) GameUpdated

func (ai *AI) GameUpdated()

GameUpdated is called every time the game's state updates, so if you are tracking anything you can update it here.

func (*AI) Player

func (ai *AI) Player() Player

Player returns the instance of the Player this AI is represented by in the game this AI is playing.

func (*AI) RunTurn

func (ai *AI) RunTurn() bool

RunTurn this is called every time it is this AI.player's turn.

func (*AI) Start

func (ai *AI) Start()

Start is called once the game starts and your AI has a Player and Game. You can initialize your AI struct here.

type Bottle

Bottle is a bottle thrown by a bartender at a Tile.

type Bottle interface {
    // Parent interfaces
    GameObject

    // Direction is the Direction this Bottle is flying and will move
    // to between turns, can be 'North', 'East', 'South', or 'West'.
    //
    // Literal Values: "North", "East", "South", or "West"
    Direction() string

    // DrunkDirection is the direction any Cowboys hit by this will
    // move, can be 'North', 'East', 'South', or 'West'.
    //
    // Literal Values: "North", "East", "South", or "West"
    DrunkDirection() string

    // IsDestroyed is true if this Bottle has impacted and has been
    // destroyed (removed from the Game). False if still in the game
    // flying through the saloon.
    IsDestroyed() bool

    // Tile is the Tile this bottle is currently flying over.
    //
    // Value can be returned as a nil pointer.
    Tile() Tile
}

type Cowboy

Cowboy is a person on the map that can move around and interact within the saloon.

type Cowboy interface {
    // Parent interfaces
    GameObject

    // CanMove is if the Cowboy can be moved this turn via its owner.
    CanMove() bool

    // DrunkDirection is the direction this Cowboy is moving while
    // drunk. Will be 'North', 'East', 'South', or 'West' when drunk;
    // or '' (empty string) when not drunk.
    //
    // Literal Values: "", "North", "East", "South", or "West"
    DrunkDirection() string

    // Focus is how much focus this Cowboy has. Different Jobs do
    // different things with their Cowboy's focus.
    Focus() int64

    // Health is how much health this Cowboy currently has.
    Health() int64

    // IsDead is if this Cowboy is dead and has been removed from the
    // game.
    IsDead() bool

    // IsDrunk is if this Cowboy is drunk, and will automatically
    // walk.
    IsDrunk() bool

    // Job is the job that this Cowboy does, and dictates how they
    // fight and interact within the Saloon.
    //
    // Literal Values: "Bartender", "Brawler", or "Sharpshooter"
    Job() string

    // Owner is the Player that owns and can control this Cowboy.
    Owner() Player

    // Tile is the Tile that this Cowboy is located on.
    //
    // Value can be returned as a nil pointer.
    Tile() Tile

    // Tolerance is how many times this unit has been drunk before
    // taking their siesta and resetting this to 0.
    Tolerance() int64

    // TurnsBusy is how many turns this unit has remaining before it
    // is no longer busy and can `act()` or `play()` again.
    TurnsBusy() int64

    // Act does their job's action on a Tile.
    Act(Tile, string) bool

    // Move moves this Cowboy from its current Tile to an adjacent
    // Tile.
    Move(Tile) bool

    // Play sits down and plays a piano.
    Play(Furnishing) bool
}

type Furnishing

Furnishing is an furnishing in the Saloon that must be pathed around, or destroyed.

type Furnishing interface {
    // Parent interfaces
    GameObject

    // Health is how much health this Furnishing currently has.
    Health() int64

    // IsDestroyed is if this Furnishing has been destroyed, and has
    // been removed from the game.
    IsDestroyed() bool

    // IsPiano is true if this Furnishing is a piano and can be
    // played, False otherwise.
    IsPiano() bool

    // IsPlaying is if this is a piano and a Cowboy is playing it this
    // turn.
    IsPlaying() bool

    // Tile is the Tile that this Furnishing is located on.
    //
    // Value can be returned as a nil pointer.
    Tile() Tile
}

type Game

Game is use cowboys to have a good time and play some music on a Piano, while brawling with enemy Cowboys.

type Game interface {
    // Parent interfaces
    base.Game

    // BartenderCooldown is how many turns a Bartender will be busy
    // for after throwing a Bottle.
    BartenderCooldown() int64

    // Bottles is all the beer Bottles currently flying across the
    // saloon in the game.
    Bottles() []Bottle

    // BrawlerDamage is how much damage is applied to neighboring
    // things bit by the Sharpshooter between turns.
    BrawlerDamage() int64

    // Cowboys is every Cowboy in the game.
    Cowboys() []Cowboy

    // CurrentPlayer is the player whose turn it is currently. That
    // player can send commands. Other players cannot.
    CurrentPlayer() Player

    // CurrentTurn is the current turn number, starting at 0 for the
    // first player's turn.
    CurrentTurn() int64

    // Furnishings is every furnishing in the game.
    Furnishings() []Furnishing

    // GameObjects is a mapping of every game object's ID to the
    // actual game object. Primarily used by the server and client to
    // easily refer to the game objects via ID.
    GameObjects() map[string]GameObject

    // Jobs is all the jobs that Cowboys can be called in with.
    Jobs() []string

    // MapHeight is the number of Tiles in the map along the y
    // (vertical) axis.
    MapHeight() int64

    // MapWidth is the number of Tiles in the map along the x
    // (horizontal) axis.
    MapWidth() int64

    // MaxCowboysPerJob is the maximum number of Cowboys a Player can
    // bring into the saloon of each specific job.
    MaxCowboysPerJob() int64

    // MaxTurns is the maximum number of turns before the game will
    // automatically end.
    MaxTurns() int64

    // Players is array of all the players in the game.
    Players() []Player

    // RowdinessToSiesta is when a player's rowdiness reaches or
    // exceeds this number their Cowboys take a collective siesta.
    RowdinessToSiesta() int64

    // Session is a unique identifier for the game instance that is
    // being played.
    Session() string

    // SharpshooterDamage is how much damage is applied to things hit
    // by Sharpshooters when they act.
    SharpshooterDamage() int64

    // SiestaLength is how long siestas are for a player's team.
    SiestaLength() int64

    // Tiles is all the tiles in the map, stored in Row-major order.
    // Use `x + y * mapWidth` to access the correct index.
    Tiles() []Tile

    // TimeAddedPerTurn is the amount of time (in nano-seconds) added
    // after each player performs a turn.
    TimeAddedPerTurn() float64

    // TurnsDrunk is how many turns a Cowboy will be drunk for if a
    // bottle breaks on it.
    TurnsDrunk() int64

    // GetTileAt returns the Tile at a give position (x, y).
    GetTileAt(int64, int64) Tile
}

type GameObject

GameObject is an object in the game. The most basic class that all game classes should inherit from automatically.

type GameObject interface {
    // Parent interfaces
    base.GameObject

    // Logs is any strings logged will be stored here. Intended for
    // debugging.
    Logs() []string

    // Log adds a message to this GameObject's logs. Intended for your
    // own debugging purposes, as strings stored here are saved in the
    // gamelog.
    Log(string)
}

type Player

Player is a player in this game. Every AI controls one player.

type Player interface {
    // Parent interfaces
    GameObject

    // ClientType is what type of client this is, e.g. 'Python',
    // 'JavaScript', or some other language. For potential data mining
    // purposes.
    ClientType() string

    // Cowboys is every Cowboy owned by this Player.
    Cowboys() []Cowboy

    // Kills is how many enemy Cowboys this player's team has killed.
    Kills() int64

    // Lost is if the player lost the game or not.
    Lost() bool

    // Name is the name of the player.
    Name() string

    // Opponent is this player's opponent in the game.
    Opponent() Player

    // ReasonLost is the reason why the player lost the game.
    ReasonLost() string

    // ReasonWon is the reason why the player won the game.
    ReasonWon() string

    // Rowdiness is how rowdy their team is. When it gets too high
    // their team takes a collective siesta.
    Rowdiness() int64

    // Score is how many times their team has played a piano.
    Score() int64

    // Siesta is 0 when not having a team siesta. When greater than 0
    // represents how many turns left for the team siesta to complete.
    Siesta() int64

    // TimeRemaining is the amount of time (in ns) remaining for this
    // AI to send commands.
    TimeRemaining() float64

    // Won is if the player won the game or not.
    Won() bool

    // YoungGun is the YoungGun this Player uses to call in new
    // Cowboys.
    YoungGun() YoungGun
}

type Tile

Tile is a Tile in the game that makes up the 2D map grid.

type Tile interface {
    // Parent interfaces
    GameObject

    // Bottle is the beer Bottle currently flying over this Tile, nil
    // otherwise.
    //
    // Value can be returned as a nil pointer.
    Bottle() Bottle

    // Cowboy is the Cowboy that is on this Tile, nil otherwise.
    //
    // Value can be returned as a nil pointer.
    Cowboy() Cowboy

    // Furnishing is the furnishing that is on this Tile, nil
    // otherwise.
    //
    // Value can be returned as a nil pointer.
    Furnishing() Furnishing

    // HasHazard is if this Tile is pathable, but has a hazard that
    // damages Cowboys that path through it.
    HasHazard() bool

    // IsBalcony is if this Tile is a balcony of the Saloon that
    // YoungGuns walk around on, and can never be pathed through by
    // Cowboys.
    IsBalcony() bool

    // TileEast is the Tile to the 'East' of this one (x+1, y). Nil if
    // out of bounds of the map.
    //
    // Value can be returned as a nil pointer.
    TileEast() Tile

    // TileNorth is the Tile to the 'North' of this one (x, y-1). Nil
    // if out of bounds of the map.
    //
    // Value can be returned as a nil pointer.
    TileNorth() Tile

    // TileSouth is the Tile to the 'South' of this one (x, y+1). Nil
    // if out of bounds of the map.
    //
    // Value can be returned as a nil pointer.
    TileSouth() Tile

    // TileWest is the Tile to the 'West' of this one (x-1, y). Nil if
    // out of bounds of the map.
    //
    // Value can be returned as a nil pointer.
    TileWest() Tile

    // X is the x (horizontal) position of this Tile.
    X() int64

    // Y is the y (vertical) position of this Tile.
    Y() int64

    // YoungGun is the YoungGun on this tile, nil otherwise.
    //
    // Value can be returned as a nil pointer.
    YoungGun() YoungGun

    // GetNeighbors returns an array of the neighbors of this Tile.
    GetNeighbors() []Tile

    // IsPathable returns if the Tile is pathable for FindPath
    IsPathable() bool

    // HasNeighbor checks if this Tile has a specific neighboring Tile.
    HasNeighbor(Tile) bool
}

type YoungGun

YoungGun is an eager young person that wants to join your gang, and will call in the veteran Cowboys you need to win the brawl in the saloon.

type YoungGun interface {
    // Parent interfaces
    GameObject

    // CallInTile is the Tile that a Cowboy will be called in on if
    // this YoungGun calls in a Cowboy.
    CallInTile() Tile

    // CanCallIn is true if the YoungGun can call in a Cowboy, false
    // otherwise.
    CanCallIn() bool

    // Owner is the Player that owns and can control this YoungGun.
    Owner() Player

    // Tile is the Tile this YoungGun is currently on.
    Tile() Tile

    // CallIn tells the YoungGun to call in a new Cowboy of the given
    // job to the open Tile nearest to them.
    CallIn(string) Cowboy
}