republique

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: BSD-2-Clause Imports: 18 Imported by: 0

README

RServer

Backend REST server for running a game

Game Runner API

  • Generate startup emails
  • Players login
  • Everyone in

Both Players

  • Generate leader instructions

  • Attach / Detach leaders

  • Rally Units

  • Move leaders

  • Place orders

  • Players done with commanders phase

  • Generate move instructions and initiative

  • Move un-engaged units

  • Record new engagements

  • Players done with movement phase

  • Generate SK engagement and gunnery instructions

  • SK engagements

  • Players done

  • Gunnery

  • Players done

  • Generate assault instructions - Initiative player

  • Assault

  • Player A done

  • Generate assault instructions - Non-Initiative player

  • Assault

  • Player B done

  • Panic tests

  • Increment turn markers

Documentation

Index

Constants

View Source
const (
	DateTimeFormat = "Monday, 02-Jan-2006 15:04"
	DateFormat     = "Monday, 02-Jan-2006"
	TimeFormat     = "Monday, 15:04"
)

Constants for use in the UI

Variables

This section is empty.

Functions

func NewTokenCache

func NewTokenCache(game *rp.Game) map[string]*rp.Player

NewTokenCache returns a new map of TokenValue to player details

Types

type Server

type Server struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Server object stores the whole game state

func NewServer

func NewServer(log *logrus.Logger, version string, filename string, port int, web int) (*Server, error)

NewServer returns a new republique server

func (*Server) Auth

func (s *Server) Auth(token string) (*rp.Player, error)

Auth is a helper function in the server to validate a token and return the details of the player

func (*Server) Close

func (s *Server) Close()

Close closes the DB - needed when you quit

func (*Server) GameTime

func (s *Server) GameTime(c context.Context, req *rp.TokenMessage) (*rp.GameTimeResponse, error)

GameTime is an RPC that returns the current game time

func (*Server) GetEnemy

func (s *Server) GetEnemy(c context.Context, req *rp.TokenMessage) (*rp.Units, error)

GetEnemy returns the visible enemy units

func (*Server) GetMap

func (s *Server) GetMap(c context.Context, req *rp.TokenMessage) (*rp.MapData, error)

GetMap returns the map data relative to the player with the given token

func (*Server) GetUnits

func (s *Server) GetUnits(c context.Context, req *rp.TokenMessage) (*rp.Units, error)

GetUnits returns all the units owned by the player with the given token

func (*Server) Login

func (s *Server) Login(c context.Context, req *rp.LoginMessage) (*rp.LoginResponse, error)

Login is an RPC that validates the given credentials, and returns a struct with the player data if success

func (*Server) Save

func (s *Server) Save()

Save saves the game state to the DB

func (*Server) Serve

func (s *Server) Serve()

Serve runs a game

func (*Server) Version

func (s *Server) Version(c context.Context, req *rp.EmptyMessage) (*rp.StringMessage, error)

Version is an RPC handler for the version request

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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