tables

package
v0.0.0-...-0992052 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2017 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package tables contains the tables server. Keeping track of the games being played.

Index

Constants

View Source
const (
	//SAVEGamesFile the file where unfinished games are saved.
	SAVEGamesFile = "data/savegames.gob"
)

Variables

This section is empty.

Functions

func IsPlaying

func IsPlaying(ids [2]int, games map[int]*pub.GameData) bool

func NewGameData

func NewGameData(opp int, watch *pub.WatchChCl) (g *pub.GameData)

NewGameData create a new GameData pointer.

func NewMoveBench

func NewMoveBench(view *MoveBenchView, ini bool) (move *pub.MoveBench)

Types

type BenchPos

type BenchPos struct {
	Flags      [bat.NOFlags]*Flag //Player 0 flags
	DishTroops [2][]int
	DishTacs   [2][]int
	Hands      [2][]bool
	DeckTacs   int
	DeckTroops int
	Ids        [2]int
}

BenchPos the complete data that describe a game position for a watcher.

func NewBenchPos

func NewBenchPos(pos *bat.GamePos, ids [2]int) (bench *BenchPos)

func (*BenchPos) Equal

func (b *BenchPos) Equal(other *BenchPos) (equal bool)

type FinishTableData

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

FinishTableData the data structur send on the finish channel.

type Flag

type Flag struct {
	OppFlag    bool
	NeuFlag    bool
	PlayFlag   bool
	OppTroops  []int
	OppEnvs    []int
	PlayEnvs   []int
	PlayTroops []int
}

Flag a battleline flag.

func NewFlag

func NewFlag(flag *flag.Flag, playerix int) (view *Flag)

func (*Flag) Equal

func (flag *Flag) Equal(other *Flag) (equal bool)

type MoveBenchInit

type MoveBenchInit struct {
	Ids      [2]int
	JsonType string
}

MoveBenchInit the first move in new game.

func NewMoveBenchInit

func NewMoveBenchInit(ids [2]int) *MoveBenchInit

func (MoveBenchInit) Copy

func (m MoveBenchInit) Copy() (c bat.Move)

func (MoveBenchInit) MoveEqual

func (m MoveBenchInit) MoveEqual(other bat.Move) (equal bool)

type MoveBenchPos

type MoveBenchPos struct {
	Pos      *BenchPos
	JsonType string
}

MoveBenchPos the first move when restarting a game or when joining a game.

func NewMoveBenchPos

func NewMoveBenchPos(pos *BenchPos) *MoveBenchPos

func (MoveBenchPos) Copy

func (m MoveBenchPos) Copy() (c bat.Move)

func (MoveBenchPos) MoveEqual

func (m MoveBenchPos) MoveEqual(other bat.Move) (equal bool)

type MoveBenchView

type MoveBenchView struct {
	pub.MoveBench
	MoveInit bat.Move
}

MoveBenchView the information send from the table to the bench. The informationn is then relayed to all watchers. As watchers can be new it must always contain a init move and a move unless it is the first move in a new game. This is because we can always have new watchers.

type MoveClaimView

type MoveClaimView struct {
	Claim    []int //The players claimed this flags
	Claimed  []int //The players claimed flag that was not rejected
	Win      bool
	FailsExs [9][]int
	JsonType string
}

MoveClaimView the claim view contain the opriginal claim move and the result. The claimed flags, if the game was won and evt. information from failed claims.

func NewMoveClaimView

func NewMoveClaimView(move bat.MoveClaim, pos *bat.GamePos, claimFailExs [9][]int) (m *MoveClaimView)

func (MoveClaimView) Copy

func (m MoveClaimView) Copy() (c bat.Move)

func (MoveClaimView) Equal

func (m MoveClaimView) Equal(other MoveClaimView) (equal bool)

func (MoveClaimView) MoveEqual

func (m MoveClaimView) MoveEqual(other bat.Move) (equal bool)

type MoveDeserterView

type MoveDeserterView struct {
	Move     *bat.MoveDeserter
	Dishixs  []int
	JsonType string
}

MoveReployView the redeploy move view.

func NewMoveDeserterView

func NewMoveDeserterView(move *bat.MoveDeserter, dishixs []int) (m *MoveDeserterView)

func (MoveDeserterView) Copy

func (m MoveDeserterView) Copy() (c bat.Move)

func (MoveDeserterView) MoveEqual

func (m MoveDeserterView) MoveEqual(other bat.Move) (equal bool)

type MoveInit

type MoveInit struct {
	Hand     []int //nil for bench
	JsonType string
}

MoveInit the initial move in a new game. Just the 7 cards the player get.

func NewMoveInit

func NewMoveInit(hand []int) *MoveInit

func (MoveInit) Copy

func (m MoveInit) Copy() (c bat.Move)

func (MoveInit) Equal

func (m MoveInit) Equal(other MoveInit) (equal bool)

func (MoveInit) MoveEqual

func (m MoveInit) MoveEqual(other bat.Move) (equal bool)

type MoveInitPos

type MoveInitPos struct {
	Pos      *PlayPos
	JsonType string
}

MoveInitPos is the first move in a resumed game.

func NewMoveInitPos

func NewMoveInitPos(pos *PlayPos) *MoveInitPos

func (MoveInitPos) Copy

func (m MoveInitPos) Copy() (c bat.Move)

func (MoveInitPos) MoveEqual

func (m MoveInitPos) MoveEqual(other bat.Move) (equal bool)

type MovePass

type MovePass struct {
	JsonType string
}

MovePass is the pass move.

func NewMovePass

func NewMovePass() *MovePass

func (MovePass) Copy

func (m MovePass) Copy() (c bat.Move)

func (MovePass) MoveEqual

func (m MovePass) MoveEqual(other bat.Move) (equal bool)

type MoveQuit

type MoveQuit struct {
	JsonType string
}

MoveQuit the quit move.

func NewMoveQuit

func NewMoveQuit() *MoveQuit

func (MoveQuit) Copy

func (m MoveQuit) Copy() (c bat.Move)

func (MoveQuit) MoveEqual

func (m MoveQuit) MoveEqual(other bat.Move) (equal bool)

type MoveRedeployView

type MoveRedeployView struct {
	Move            *bat.MoveRedeploy
	RedeployDishixs []int
	JsonType        string
}

MoveReployView the redeploy move view.

func NewMoveRedeployView

func NewMoveRedeployView(move *bat.MoveRedeploy, dishixs []int) (m *MoveRedeployView)

func (MoveRedeployView) Copy

func (m MoveRedeployView) Copy() (c bat.Move)

func (MoveRedeployView) MoveEqual

func (m MoveRedeployView) MoveEqual(other bat.Move) (equal bool)

type MoveSave

type MoveSave struct {
	JsonType string
}

MoveSave the save move.

func NewMoveSave

func NewMoveSave() *MoveSave

func (MoveSave) Copy

func (m MoveSave) Copy() (c bat.Move)

func (MoveSave) MoveEqual

func (m MoveSave) MoveEqual(other bat.Move) (equal bool)

type MoveScoutReturnView

type MoveScoutReturnView struct {
	Tac      int
	Troop    int
	JsonType string
}

MoveScoutReturnView the scout return move view. the scout return move as view by the opponent and the public.

func NewMoveScoutReturnView

func NewMoveScoutReturnView(scout bat.MoveScoutReturn) (m *MoveScoutReturnView)

func (MoveScoutReturnView) Copy

func (m MoveScoutReturnView) Copy() (c bat.Move)

func (MoveScoutReturnView) MoveEqual

func (m MoveScoutReturnView) MoveEqual(other bat.Move) (equal bool)

type PlayPos

type PlayPos struct {
	Flags         [bat.NOFlags]*Flag
	OppDishTroops []int
	OppDishTacs   []int
	DishTroops    []int
	DishTacs      []int
	OppHand       []bool //true equal troop false equal tactic.
	Hand          []int
	DeckTacs      int
	DeckTroops    int
}

PlayPos a player position for starting a old game.

func NewPlayPos

func NewPlayPos(pos *bat.GamePos, playerix int) (posView *PlayPos)

func (*PlayPos) Equal

func (pp *PlayPos) Equal(other *PlayPos) (equal bool)

type SaveGames

type SaveGames struct {
	Games map[string]*bat.Game
}

SaveGames the data structur for saved games used to save as Gob.

func LoadSaveGames

func LoadSaveGames(filePath string) (games *SaveGames, err error)

LoadSaveGames loads the save games.

func NewSaveGames

func NewSaveGames() (sg *SaveGames)

NewSaveGames creates a SaveGames structur. To use Gob we single structur tow same multible games.

type Server

type Server struct {
	StartGameChCl *pub.StartGameChCl
	// contains filtered or unexported fields
}

Server the battleline tables server Keeps track of games being played. Who is playing, who is watching and saved unfinished games. It here you ask to start a game.

func New

func New(
	pubList *pub.List,
	errCh chan<- error,
	save bool,
	saveDir string,
	archiverPort int) (s *Server, err error)

New creates a battleline tables server.

func (*Server) Start

func (s *Server) Start()

Start starts the tables server.

func (*Server) Stop

func (s *Server) Stop()

Stop stops the tables server.

Jump to

Keyboard shortcuts

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