Documentation ¶
Overview ¶
Package simonsays is a generated protocol buffer package.
It is generated from these files:
simonsays.proto
It has these top-level messages:
Request Response
Index ¶
- Constants
- Variables
- func RegisterSimonSaysServer(s *grpc.Server, srv SimonSaysServer)
- type Color
- type Game
- type Request
- func (*Request) Descriptor() ([]byte, []int)
- func (m *Request) GetEvent() isRequest_Event
- func (m *Request) GetJoin() *Request_Player
- func (m *Request) GetPress() Color
- func (*Request) ProtoMessage()
- func (m *Request) Reset()
- func (m *Request) String() string
- func (*Request) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, ...)
- type Request_Join
- type Request_Player
- type Request_Press
- type Response
- func (*Response) Descriptor() ([]byte, []int)
- func (m *Response) GetEvent() isResponse_Event
- func (m *Response) GetLightup() Color
- func (m *Response) GetTurn() Response_State
- func (*Response) ProtoMessage()
- func (m *Response) Reset()
- func (m *Response) String() string
- func (*Response) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, ...)
- type Response_Lightup
- type Response_State
- type Response_Turn
- type SimonSays
- type SimonSaysClient
- type SimonSaysServer
- type SimonSays_GameClient
- type SimonSays_GameServer
Constants ¶
const Version string = "v0.1e"
Version is the current version of this implementation of Simon Says.
Variables ¶
var Color_name = map[int32]string{
0: "RED",
1: "GREEN",
2: "YELLOW",
3: "BLUE",
}
var Color_value = map[string]int32{
"RED": 0,
"GREEN": 1,
"YELLOW": 2,
"BLUE": 3,
}
var ErrColorPressedOutOfTurn = errors.New("Color pressed outside of player turn")
ErrColorPressedOutOfTurn is returned when a colour is pressed outside of the Game player's turn.
var Response_State_name = map[int32]string{
0: "BEGIN",
1: "START_TURN",
2: "STOP_TURN",
3: "WIN",
4: "LOSE",
}
var Response_State_value = map[string]int32{
"BEGIN": 0,
"START_TURN": 1,
"STOP_TURN": 2,
"WIN": 3,
"LOSE": 4,
}
Functions ¶
func RegisterSimonSaysServer ¶
func RegisterSimonSaysServer(s *grpc.Server, srv SimonSaysServer)
Types ¶
type Game ¶
type Game struct { ID string // contains filtered or unexported fields }
Game represents a Game that an individual player is playing. It keeps track of internal Game state for that player. Only use exported methods are guaranteed to be concurrently safe.
func (*Game) EncodePresses ¶
EncodePresses encodes the current set of Color presses into an []bytes for transmission.
func (*Game) Match ¶
Match checks to see if the currently entered presses, line up with what we have as valid presses.
func (*Game) PressColor ¶
PressColor should be called when this player presses a colour. This will append the colour value to the list of currentPresses. Returns a ErrColorPressedOutOfTurn if it not this player's turn Will set IsMyTurn() to false when the number of currentPresses is one more than the current validPresses (what colours the last player pressed) value, or colours don't match up to the previous turn's colour sequence.
type Request ¶
type Request struct { // Types that are valid to be assigned to Event: // *Request_Join // *Request_Press Event isRequest_Event `protobuf_oneof:"event"` }
func (*Request) Descriptor ¶
func (*Request) GetJoin ¶
func (m *Request) GetJoin() *Request_Player
func (*Request) ProtoMessage ¶
func (*Request) ProtoMessage()
type Request_Join ¶
type Request_Join struct {
Join *Request_Player `protobuf:"bytes,1,opt,name=join,oneof"`
}
type Request_Player ¶
type Request_Player struct {
Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
}
A Player of the Simon says game.
func (*Request_Player) Descriptor ¶
func (*Request_Player) Descriptor() ([]byte, []int)
func (*Request_Player) ProtoMessage ¶
func (*Request_Player) ProtoMessage()
func (*Request_Player) Reset ¶
func (m *Request_Player) Reset()
func (*Request_Player) String ¶
func (m *Request_Player) String() string
type Request_Press ¶
type Request_Press struct {
Press Color `protobuf:"varint,2,opt,name=press,enum=simonsays.Color,oneof"`
}
type Response ¶
type Response struct { // Types that are valid to be assigned to Event: // *Response_Turn // *Response_Lightup Event isResponse_Event `protobuf_oneof:"event"` }
func (*Response) Descriptor ¶
func (*Response) GetLightup ¶
func (*Response) GetTurn ¶
func (m *Response) GetTurn() Response_State
func (*Response) ProtoMessage ¶
func (*Response) ProtoMessage()
type Response_Lightup ¶
type Response_Lightup struct {
Lightup Color `protobuf:"varint,2,opt,name=lightup,enum=simonsays.Color,oneof"`
}
type Response_State ¶
type Response_State int32
const ( Response_BEGIN Response_State = 0 Response_START_TURN Response_State = 1 Response_STOP_TURN Response_State = 2 Response_WIN Response_State = 3 Response_LOSE Response_State = 4 )
func (Response_State) EnumDescriptor ¶
func (Response_State) EnumDescriptor() ([]byte, []int)
func (Response_State) String ¶
func (x Response_State) String() string
type Response_Turn ¶
type Response_Turn struct {
Turn Response_State `protobuf:"varint,1,opt,name=turn,enum=simonsays.Response_State,oneof"`
}
type SimonSays ¶
type SimonSays struct {
// contains filtered or unexported fields
}
SimonSays is the data structure that implements the SimonSaysServer interface for our gRPC server.
func NewSimonSays ¶
NewSimonSays Create a new Simon Says.
func (*SimonSays) Game ¶
func (s *SimonSays) Game(stream SimonSays_GameServer) error
Game function is an implementation of the gRPC Game Service. When connected, this is the main functionality of running a Game for the connected player.
type SimonSaysClient ¶
type SimonSaysClient interface { // // Game process is the following: // // A Join Request should be sent to the game. This tells it // to join a game (or start a new one if one isn't already waiting on a game). // // The Response stream will send through a BEGIN Response.State to let you know that // the Game has been started. // // When the player recieves a START_TURN response, the server can take your input for the turn. // // When the player recieves a STOP_TURN response, the serer is no longer taking input for the turn. // // A WIN state says you won the game. A LOSE state means that you got an input wrong, and have lost. // // To send input, send a Request with an event type of Color. // // When you recieve a Response of type Color, then light up that colour. Game(ctx context.Context, opts ...grpc.CallOption) (SimonSays_GameClient, error) }
func NewSimonSaysClient ¶
func NewSimonSaysClient(cc *grpc.ClientConn) SimonSaysClient
type SimonSaysServer ¶
type SimonSaysServer interface { // // Game process is the following: // // A Join Request should be sent to the game. This tells it // to join a game (or start a new one if one isn't already waiting on a game). // // The Response stream will send through a BEGIN Response.State to let you know that // the Game has been started. // // When the player recieves a START_TURN response, the server can take your input for the turn. // // When the player recieves a STOP_TURN response, the serer is no longer taking input for the turn. // // A WIN state says you won the game. A LOSE state means that you got an input wrong, and have lost. // // To send input, send a Request with an event type of Color. // // When you recieve a Response of type Color, then light up that colour. Game(SimonSays_GameServer) error }
type SimonSays_GameClient ¶
type SimonSays_GameServer ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package logger is logging that is specific to this application Need to track the game, and the player, so we can see everything that is going on.
|
Package logger is logging that is specific to this application Need to track the game, and the player, so we can see everything that is going on. |