Cowboy

class games.saloon.cowboy.Cowboy

Bases: games.saloon.game_object.GameObject

The class representing the Cowboy in the Saloon game.

A person on the map that can move around and interact within the saloon.

act(tile: games.saloon.tile.Tile, drunk_direction: str = '') → bool

Does their job’s action on a Tile.

Parameters
  • tile (games.saloon.tile.Tile) – The Tile you want this Cowboy to act on.

  • drunk_direction ('', 'North', 'East', 'South', or 'West') – The direction the bottle will cause drunk cowboys to be in, can be ‘North’, ‘East’, ‘South’, or ‘West’.

Returns

True if the act worked, False otherwise.

Return type

bool

property can_move

If the Cowboy can be moved this turn via its owner.

Type

bool

property drunk_direction

The direction this Cowboy is moving while drunk. Will be ‘North’, ‘East’, ‘South’, or ‘West’ when drunk; or ‘’ (empty string) when not drunk.

Type

‘’, ‘North’, ‘East’, ‘South’, or ‘West’

property focus

How much focus this Cowboy has. Different Jobs do different things with their Cowboy’s focus.

Type

int

property game_object_name

String representing the top level Class that this game object is an instance of. Used for reflection to create new instances on clients, but exposed for convenience should AIs want this data.

Type

str

property health

How much health this Cowboy currently has.

Type

int

property id

A unique id for each instance of a GameObject or a sub class. Used for client and server communication. Should never change value after being set.

Type

str

property is_dead

If this Cowboy is dead and has been removed from the game.

Type

bool

property is_drunk

If this Cowboy is drunk, and will automatically walk.

Type

bool

property job

The job that this Cowboy does, and dictates how they fight and interact within the Saloon.

Type

‘Bartender’, ‘Brawler’, or ‘Sharpshooter’

log(message: str) → None

Adds a message to this GameObject’s logs. Intended for your own debugging purposes, as strings stored here are saved in the gamelog.

Parameters

message (str) – A string to add to this GameObject’s log. Intended for debugging.

property logs

Any strings logged will be stored here. Intended for debugging.

Type

list[str]

move(tile: games.saloon.tile.Tile) → bool

Moves this Cowboy from its current Tile to an adjacent Tile.

Parameters

tile (games.saloon.tile.Tile) – The Tile you want to move this Cowboy to.

Returns

True if the move worked, False otherwise.

Return type

bool

property owner

The Player that owns and can control this Cowboy.

Type

games.saloon.player.Player

play(piano: games.saloon.furnishing.Furnishing) → bool

Sits down and plays a piano.

Parameters

piano (games.saloon.furnishing.Furnishing) – The Furnishing that is a piano you want to play.

Returns

True if the play worked, False otherwise.

Return type

bool

property tile

The Tile that this Cowboy is located on.

Type

games.saloon.tile.Tile or None

property tolerance

How many times this unit has been drunk before taking their siesta and resetting this to 0.

Type

int

property turns_busy

How many turns this unit has remaining before it is no longer busy and can act() or play() again.

Type

int