pnp

package
v0.0.0-...-60c38a5 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Rand = rand.Intn

Rand - random function

Functions

This section is empty.

Types

type Action

type Action = Skill

Action ...

type Engine

type Engine interface {
	Reaction(xp int, health int, player Player, state State, action Action, fn func())
	Start()
	RenderGame(players []Player, p Player)
	SelectAction(player Player, state State, onSelect func(action Action))
	GameOver()
	GameWon()
	PizzaDelivery(fn func())
	Welcome(fn func(string))
}

Engine represents the game's user interface rendering engine

type Game

type Game struct {
	Players  []Player
	Round    int
	Prod     Production
	Alive    []Player
	BandName string
}

Game represents a Platforms and Programmers Game where a band of player will attempt to take on production

func New

func New(players ...Player) *Game

New returns a new P&P game

func (*Game) DequeuePlayer

func (g *Game) DequeuePlayer() Player

DequeuePlayer pops the next player from the queue

func (*Game) EnqueuePlayer

func (g *Game) EnqueuePlayer(p Player)

EnqueuePlayer returns a player to the end of the queue

func (*Game) MainLoop

func (g *Game) MainLoop(e Engine)

MainLoop kicks off the next players round

func (*Game) React

func (g *Game) React(p Player, action Action) (int, int)

React applies a player's action to production, applies its outcome (xp, health) to the player and returns it.

func (*Game) Run

func (g *Game) Run(e Engine)

Run starts a new game

func (*Game) Welcome

func (g *Game) Welcome(e Engine, fn func())

type Player

type Player interface {
	// Alive checks if the player is alive
	Alive() bool
	// ApplyXPDiff applies the XP diff to the player's XP
	ApplyXPDiff(xp int) (actual int)
	// ApplyHealthDiff takes in the amount of health to be gained and applies it to the player's health
	// up to a maximum health of 100 and down to 0. It returns the actual difference that was applied
	ApplyHealthDiff(health int) (actual int)
	// Skills returns the skills of the player
	Skills() []Skill
	// Health returns the player's current health level
	Health() int
	// AsciiArt returns the player's ascii art
	AsciiArt() string
	// XP returns the player's XP level
	XP() int
}

Player represents a P&P player

type Production

type Production struct {
	State State
}

Production ...

func NewProduction

func NewProduction() Production

NewProduction ...

func (*Production) React

func (p *Production) React(a Action) (xp int, health int)

React returns the X and health gained by Production's reaction to the player's action

type Skill

type Skill int

Skill represents a Player's skill in a Programmers & Platforms game

const (
	Banana Skill = iota
	DuckTyping
	TypeSafety
	Inheritance
	Interfaces
	Modules
	Reflect
	MetaProgramming
	Generics
	DarkMagic
	Boredom
)

Skills

func (Skill) String

func (i Skill) String() string

type State

type State int

State represents a production state There are 4 possible states - Calm, Annoyed, Enraged and Legacy

const (
	Calm State = iota
	Annoyed
	Enraged
	Legacy
)

func (State) Chances

func (s State) Chances(a Action) int

func (State) React

func (s State) React(a Action) (int, int, State)

React returns XP gained, Health gained and the new Production state

func (State) String

func (s State) String() string

String ...

Directories

Path Synopsis
simple
Package engine provides a simple engine for a P&P game
Package engine provides a simple engine for a P&P game
tview
Package engine provides a simple P&P engine
Package engine provides a simple P&P engine

Jump to

Keyboard shortcuts

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