game

package
v0.0.0-...-b2c6f3e Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Color_name = map[int32]string{
		0: "RANDOM",
		1: "BLACK",
		2: "WHITE",
	}
	Color_value = map[string]int32{
		"RANDOM": 0,
		"BLACK":  1,
		"WHITE":  2,
	}
)

Enum value maps for Color.

View Source
var File_reversi_server_reversi_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Client

type Client struct {
	State struct {
		Username string
		Game     *Game
	}
	// contains filtered or unexported fields
}

func NewClient

func NewClient(conn net.Conn, owner *Server, handler MessageHandler) Client

func (*Client) Close

func (c *Client) Close()

func (*Client) Send

func (c *Client) Send(msg proto.Message)

func (*Client) Start

func (c *Client) Start()

type Color

type Color int32
const (
	Color_RANDOM Color = 0
	Color_BLACK  Color = 1
	Color_WHITE  Color = 2
)

func ClientJoin

func ClientJoin(c *Client, id snowflake.Snowflake) (Color, error)

func (Color) Descriptor

func (Color) Descriptor() protoreflect.EnumDescriptor

func (Color) Enum

func (x Color) Enum() *Color

func (Color) EnumDescriptor deprecated

func (Color) EnumDescriptor() ([]byte, []int)

Deprecated: Use Color.Descriptor instead.

func (Color) Number

func (x Color) Number() protoreflect.EnumNumber

func (Color) String

func (x Color) String() string

func (Color) Type

func (Color) Type() protoreflect.EnumType

type Connected

type Connected struct {
	PlayerId int64 `protobuf:"varint,1,opt,name=player_id,json=playerId,proto3" json:"player_id,omitempty"`
	// contains filtered or unexported fields
}

func (*Connected) Descriptor deprecated

func (*Connected) Descriptor() ([]byte, []int)

Deprecated: Use Connected.ProtoReflect.Descriptor instead.

func (*Connected) GetPlayerId

func (x *Connected) GetPlayerId() int64

func (*Connected) ProtoMessage

func (*Connected) ProtoMessage()

func (*Connected) ProtoReflect

func (x *Connected) ProtoReflect() protoreflect.Message

func (*Connected) Reset

func (x *Connected) Reset()

func (*Connected) String

func (x *Connected) String() string

type CreateGame

type CreateGame struct {
	PlayerName string `protobuf:"bytes,1,opt,name=player_name,json=playerName,proto3" json:"player_name,omitempty"`
	Color      Color  `protobuf:"varint,2,opt,name=color,proto3,enum=reversi.Color" json:"color,omitempty"`
	// contains filtered or unexported fields
}

func (*CreateGame) Descriptor deprecated

func (*CreateGame) Descriptor() ([]byte, []int)

Deprecated: Use CreateGame.ProtoReflect.Descriptor instead.

func (*CreateGame) GetColor

func (x *CreateGame) GetColor() Color

func (*CreateGame) GetPlayerName

func (x *CreateGame) GetPlayerName() string

func (*CreateGame) ProtoMessage

func (*CreateGame) ProtoMessage()

func (*CreateGame) ProtoReflect

func (x *CreateGame) ProtoReflect() protoreflect.Message

func (*CreateGame) Reset

func (x *CreateGame) Reset()

func (*CreateGame) String

func (x *CreateGame) String() string

type CreateGameResponse

type CreateGameResponse struct {
	GameId int64   `protobuf:"varint,1,opt,name=game_id,json=gameId,proto3" json:"game_id,omitempty"`
	Color  Color   `protobuf:"varint,2,opt,name=color,proto3,enum=reversi.Color" json:"color,omitempty"`
	Error  *string `protobuf:"bytes,3,opt,name=error,proto3,oneof" json:"error,omitempty"`
	// contains filtered or unexported fields
}

func (*CreateGameResponse) Descriptor deprecated

func (*CreateGameResponse) Descriptor() ([]byte, []int)

Deprecated: Use CreateGameResponse.ProtoReflect.Descriptor instead.

func (*CreateGameResponse) GetColor

func (x *CreateGameResponse) GetColor() Color

func (*CreateGameResponse) GetError

func (x *CreateGameResponse) GetError() string

func (*CreateGameResponse) GetGameId

func (x *CreateGameResponse) GetGameId() int64

func (*CreateGameResponse) ProtoMessage

func (*CreateGameResponse) ProtoMessage()

func (*CreateGameResponse) ProtoReflect

func (x *CreateGameResponse) ProtoReflect() protoreflect.Message

func (*CreateGameResponse) Reset

func (x *CreateGameResponse) Reset()

func (*CreateGameResponse) String

func (x *CreateGameResponse) String() string

type Game

type Game struct {
	Id      snowflake.Snowflake
	Started bool
	Turn    Color
	// contains filtered or unexported fields
}

func NewGame

func NewGame(c *Client) (*Game, error)

func (*Game) AddPlayer

func (g *Game) AddPlayer(c *Client, color Color) error

func (*Game) End

func (g *Game) End()

func (*Game) Move

func (g *Game) Move(c *Client, move *PlayMove) error

func (*Game) RemovePlayer

func (g *Game) RemovePlayer(c *Client)

func (*Game) Start

func (g *Game) Start() error

type GameEnded

type GameEnded struct {
	Winner        *Color  `protobuf:"varint,1,opt,name=winner,proto3,enum=reversi.Color,oneof" json:"winner,omitempty"`
	SpecialReason *string `protobuf:"bytes,2,opt,name=special_reason,json=specialReason,proto3,oneof" json:"special_reason,omitempty"`
	// contains filtered or unexported fields
}

func (*GameEnded) Descriptor deprecated

func (*GameEnded) Descriptor() ([]byte, []int)

Deprecated: Use GameEnded.ProtoReflect.Descriptor instead.

func (*GameEnded) GetSpecialReason

func (x *GameEnded) GetSpecialReason() string

func (*GameEnded) GetWinner

func (x *GameEnded) GetWinner() Color

func (*GameEnded) ProtoMessage

func (*GameEnded) ProtoMessage()

func (*GameEnded) ProtoReflect

func (x *GameEnded) ProtoReflect() protoreflect.Message

func (*GameEnded) Reset

func (x *GameEnded) Reset()

func (*GameEnded) String

func (x *GameEnded) String() string

type GameMove

type GameMove struct {
	GameId int64  `protobuf:"varint,1,opt,name=game_id,json=gameId,proto3" json:"game_id,omitempty"`
	X      uint32 `protobuf:"varint,2,opt,name=x,proto3" json:"x,omitempty"`
	Y      uint32 `protobuf:"varint,3,opt,name=y,proto3" json:"y,omitempty"`
	Pass   bool   `protobuf:"varint,4,opt,name=pass,proto3" json:"pass,omitempty"`
	// contains filtered or unexported fields
}

func (*GameMove) Descriptor deprecated

func (*GameMove) Descriptor() ([]byte, []int)

Deprecated: Use GameMove.ProtoReflect.Descriptor instead.

func (*GameMove) GetGameId

func (x *GameMove) GetGameId() int64

func (*GameMove) GetPass

func (x *GameMove) GetPass() bool

func (*GameMove) GetX

func (x *GameMove) GetX() uint32

func (*GameMove) GetY

func (x *GameMove) GetY() uint32

func (*GameMove) ProtoMessage

func (*GameMove) ProtoMessage()

func (*GameMove) ProtoReflect

func (x *GameMove) ProtoReflect() protoreflect.Message

func (*GameMove) Reset

func (x *GameMove) Reset()

func (*GameMove) String

func (x *GameMove) String() string

type GameStart

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

func (*GameStart) Descriptor deprecated

func (*GameStart) Descriptor() ([]byte, []int)

Deprecated: Use GameStart.ProtoReflect.Descriptor instead.

func (*GameStart) ProtoMessage

func (*GameStart) ProtoMessage()

func (*GameStart) ProtoReflect

func (x *GameStart) ProtoReflect() protoreflect.Message

func (*GameStart) Reset

func (x *GameStart) Reset()

func (*GameStart) String

func (x *GameStart) String() string

type Heartbeat

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

func (*Heartbeat) Descriptor deprecated

func (*Heartbeat) Descriptor() ([]byte, []int)

Deprecated: Use Heartbeat.ProtoReflect.Descriptor instead.

func (*Heartbeat) ProtoMessage

func (*Heartbeat) ProtoMessage()

func (*Heartbeat) ProtoReflect

func (x *Heartbeat) ProtoReflect() protoreflect.Message

func (*Heartbeat) Reset

func (x *Heartbeat) Reset()

func (*Heartbeat) String

func (x *Heartbeat) String() string

type JoinGame

type JoinGame struct {
	PlayerName string `protobuf:"bytes,1,opt,name=player_name,json=playerName,proto3" json:"player_name,omitempty"`
	GameId     int64  `protobuf:"varint,2,opt,name=game_id,json=gameId,proto3" json:"game_id,omitempty"`
	// contains filtered or unexported fields
}

func (*JoinGame) Descriptor deprecated

func (*JoinGame) Descriptor() ([]byte, []int)

Deprecated: Use JoinGame.ProtoReflect.Descriptor instead.

func (*JoinGame) GetGameId

func (x *JoinGame) GetGameId() int64

func (*JoinGame) GetPlayerName

func (x *JoinGame) GetPlayerName() string

func (*JoinGame) ProtoMessage

func (*JoinGame) ProtoMessage()

func (*JoinGame) ProtoReflect

func (x *JoinGame) ProtoReflect() protoreflect.Message

func (*JoinGame) Reset

func (x *JoinGame) Reset()

func (*JoinGame) String

func (x *JoinGame) String() string

type JoinGameResponse

type JoinGameResponse struct {
	Color Color   `protobuf:"varint,1,opt,name=color,proto3,enum=reversi.Color" json:"color,omitempty"`
	Error *string `protobuf:"bytes,2,opt,name=error,proto3,oneof" json:"error,omitempty"`
	// contains filtered or unexported fields
}

func (*JoinGameResponse) Descriptor deprecated

func (*JoinGameResponse) Descriptor() ([]byte, []int)

Deprecated: Use JoinGameResponse.ProtoReflect.Descriptor instead.

func (*JoinGameResponse) GetColor

func (x *JoinGameResponse) GetColor() Color

func (*JoinGameResponse) GetError

func (x *JoinGameResponse) GetError() string

func (*JoinGameResponse) ProtoMessage

func (*JoinGameResponse) ProtoMessage()

func (*JoinGameResponse) ProtoReflect

func (x *JoinGameResponse) ProtoReflect() protoreflect.Message

func (*JoinGameResponse) Reset

func (x *JoinGameResponse) Reset()

func (*JoinGameResponse) String

func (x *JoinGameResponse) String() string

type LeaveGame

type LeaveGame struct {
	GameId int64 `protobuf:"varint,1,opt,name=game_id,json=gameId,proto3" json:"game_id,omitempty"`
	// contains filtered or unexported fields
}

func (*LeaveGame) Descriptor deprecated

func (*LeaveGame) Descriptor() ([]byte, []int)

Deprecated: Use LeaveGame.ProtoReflect.Descriptor instead.

func (*LeaveGame) GetGameId

func (x *LeaveGame) GetGameId() int64

func (*LeaveGame) ProtoMessage

func (*LeaveGame) ProtoMessage()

func (*LeaveGame) ProtoReflect

func (x *LeaveGame) ProtoReflect() protoreflect.Message

func (*LeaveGame) Reset

func (x *LeaveGame) Reset()

func (*LeaveGame) String

func (x *LeaveGame) String() string

type MessageHandler

type MessageHandler func(msg *anypb.Any, client *Client) error

type PlayMove

type PlayMove struct {
	X uint32 `protobuf:"varint,1,opt,name=x,proto3" json:"x,omitempty"`
	Y uint32 `protobuf:"varint,2,opt,name=y,proto3" json:"y,omitempty"`
	// contains filtered or unexported fields
}

func (*PlayMove) Descriptor deprecated

func (*PlayMove) Descriptor() ([]byte, []int)

Deprecated: Use PlayMove.ProtoReflect.Descriptor instead.

func (*PlayMove) GetX

func (x *PlayMove) GetX() uint32

func (*PlayMove) GetY

func (x *PlayMove) GetY() uint32

func (*PlayMove) ProtoMessage

func (*PlayMove) ProtoMessage()

func (*PlayMove) ProtoReflect

func (x *PlayMove) ProtoReflect() protoreflect.Message

func (*PlayMove) Reset

func (x *PlayMove) Reset()

func (*PlayMove) String

func (x *PlayMove) String() string

type PlayMoveResponse

type PlayMoveResponse struct {
	Success bool    `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
	Error   *string `protobuf:"bytes,2,opt,name=error,proto3,oneof" json:"error,omitempty"`
	// contains filtered or unexported fields
}

func (*PlayMoveResponse) Descriptor deprecated

func (*PlayMoveResponse) Descriptor() ([]byte, []int)

Deprecated: Use PlayMoveResponse.ProtoReflect.Descriptor instead.

func (*PlayMoveResponse) GetError

func (x *PlayMoveResponse) GetError() string

func (*PlayMoveResponse) GetSuccess

func (x *PlayMoveResponse) GetSuccess() bool

func (*PlayMoveResponse) ProtoMessage

func (*PlayMoveResponse) ProtoMessage()

func (*PlayMoveResponse) ProtoReflect

func (x *PlayMoveResponse) ProtoReflect() protoreflect.Message

func (*PlayMoveResponse) Reset

func (x *PlayMoveResponse) Reset()

func (*PlayMoveResponse) String

func (x *PlayMoveResponse) String() string

type Server

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

func NewServer

func NewServer(handler MessageHandler) Server

func (*Server) Start

func (g *Server) Start()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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