game

package
v0.0.0-...-4a4c412 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2017 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alliance

type Alliance int
const (
	ALLIANCE_GOOD    Alliance = 1
	ALLIANCE_NEUTRAL Alliance = 2
	ALLIANCE_EVIL    Alliance = 3
)

type EventListener

type EventListener interface {
	OnGameStarted(*Game, *events.GameStartedEvent)
	OnNightStarted(*Game, *events.NightStartedEvent)
	OnWerewolfVote(*Game, *events.WerewolfVoteEvent)
	OnDailyVote(*Game, *events.DailyVoteEvent)
	OnPlayerDead(*Game, *events.PlayerDeadEvent)
	OnPlayerRevealed(*Game, *events.PlayerRevealedEvent)
}

type EventSystem

type EventSystem struct {
}

func NewEventSystem

func NewEventSystem() *EventSystem

func (EventSystem) DailyVoteEvent

func (e EventSystem) DailyVoteEvent(g *Game, event *events.DailyVoteEvent)

func (EventSystem) GameStartedEvent

func (e EventSystem) GameStartedEvent(g *Game, event *events.GameStartedEvent)

func (EventSystem) NightStartedEvent

func (e EventSystem) NightStartedEvent(g *Game, event *events.NightStartedEvent)

func (EventSystem) PlayerDeadEvent

func (e EventSystem) PlayerDeadEvent(g *Game, event *events.PlayerDeadEvent)

func (EventSystem) PlayerRevealedEvent

func (e EventSystem) PlayerRevealedEvent(g *Game, event *events.PlayerRevealedEvent)

func (EventSystem) WerewolfVoteEvent

func (e EventSystem) WerewolfVoteEvent(g *Game, event *events.WerewolfVoteEvent)

type Game

type Game struct {
	*PlayerGroup
	*EventSystem
	// contains filtered or unexported fields
}

func New

func New(deck *deck.Deck, roleFactory RoleFactory) *Game

func NewGame

func NewGame(group *PlayerGroup, eventSystem *EventSystem) *Game

func (*Game) Round

func (g *Game) Round() int

func (*Game) Run

func (g *Game) Run()

type Group

type Group interface {
	Count() int
	Player(int) *Player
}

type Player

type Player struct {
	Role
	io.PlayerWriter
	io.PlayerReader
}

func NewPlayer

func NewPlayer(role Role, w io.PlayerWriter, r io.PlayerReader) *Player

type PlayerGroup

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

func (*PlayerGroup) Count

func (p *PlayerGroup) Count() int

func (*PlayerGroup) Player

func (p *PlayerGroup) Player(id int) *Player

type Role

type Role interface {
	Name() string         //Role name or player name?
	ID() int              //Should Role really have identity? Player has identity
	SetID(int)            //Same
	Alive() bool          //Player is alive or dead, not the role
	SetAlive(bool)        // same
	Die(*Game, bool)      //Player dies, the role does not die.
	Alliance() Alliance   //Should be bound to player. Alliance can possibly change
	SetAlliance(Alliance) //same
	EventListener         //belongs here probably.
}

type RoleFactory

type RoleFactory interface {
	New(role string, id int) (Role, error)
}

Jump to

Keyboard shortcuts

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