game

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxPlayers is the maximum number of players allowed in a game.
	MaxPlayers = 4

	// MaxTurns is the maximum number of turns in a game.
	MaxTurns = 15

	// StartingCash is the starting cash for each player.
	StartingCash = 100

	// StartingPrice is the starting price for each company.
	StartingPrice = 150

	// MaxPrice is the maximum price for each company.
	MaxPrice = 400

	// WildcardCompany is the company ID for the wildcard company.
	WildcardCompany = -1
)

Variables

View Source
var (
	// Version is the current version of the game.
	Version = "0.0.0-dev"
)

Functions

func CashLevel

func CashLevel(cash int) int

CashLevel returns the level for the given cash amount.

func StockLevel

func StockLevel(amount int) int

StockLevel returns the level for the given stock amount.

Types

type Assets

type Assets struct {
	Companies  []string `json:"companies"`
	PlayerDeck []*Card  `json:"playerDeck"`
	BankDeck   []*Card  `json:"bankDeck"`
}

func (*Assets) ShuffleBankDeck

func (a *Assets) ShuffleBankDeck()

func (*Assets) ShufflePlayerDeck

func (a *Assets) ShufflePlayerDeck()

type Card

type Card struct {
	ID   int        `json:"id"`
	Mods []Modifier `json:"mods"`
}

Card represents a player or bank action card.

type Mod

type Mod struct {
	// contains filtered or unexported fields
}

Mod is a value modifier.

func NewMod

func NewMod(op string, value int) *Mod

NewMod creates a new Mod.

func (*Mod) Calculate

func (m *Mod) Calculate(p int) int

Calculate applies the Mod on p.

func (*Mod) MarshalJSON

func (m *Mod) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*Mod) Op

func (m *Mod) Op() string

Op returns the Mod's operator.

func (*Mod) String

func (m *Mod) String() string

String implements the fmt.Stringer interface.

func (*Mod) UnmarshalJSON

func (m *Mod) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*Mod) Value

func (m *Mod) Value() int

Value return the Mod's operand value.

type Modifier

type Modifier struct {
	Company int  `json:"company"`
	Mod     *Mod `json:"mod"`
}

Modifier represents a stock price modifier.

type Player

type Player struct {
	Name   string
	Cash   int
	Stocks [4]int
	Hand   []*Card
}

Player holds player data.

type TurnPhase

type TurnPhase int

TurnPhase is the phase of a turn.

const (
	// ActionPhase is the phase where players play cards.
	ActionPhase TurnPhase = iota

	// TradePhase is the phase where players trade stocks.
	TradePhase
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳