shared

package module
v0.0.0-...-ec66dda Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Handshake = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "TECHNICAL_CHALLENGE_POKER_BOT",
	MagicCookieValue: "all-in",
}

Functions

func HostBot

func HostBot(conf *BotConfig, bot Bot)

func ParseBoardToProto

func ParseBoardToProto(in []*Card) []*proto.Card

func ParsePlayerListToProto

func ParsePlayerListToProto(in []*Player) []*proto.Player

func ParsePotListToProto

func ParsePotListToProto(in []*Pot) []*proto.Pot

func SliceMap

func SliceMap[T, U any](
	slice []T,
	callback func(value T, index int) U,
) []U

Types

type BaseBot

type BaseBot struct {
	Defined Bot
	Conf    *BotConfig
}

func (*BaseBot) Action

func (b *BaseBot) Action(
	players []*Player,
	hole_cards, board []*Card,
	pots []*Pot,
	bet_so_far, bet_to_player, min_raise uint,
) (proto.Action, uint, error)

func (*BaseBot) Register

func (b *BaseBot) Register(
	guid string,
	timeout_seconds uint,
) (string, error)

type Bot

type Bot interface {
	Action(
		players []*Player,
		hole_cards, board []*Card,
		pots []*Pot,
		bet_so_far, bet_to_player_this_round, min_raise uint,
	) (proto.Action, uint)
}

type BotConfig

type BotConfig struct {
	BotName string
}

type Card

type Card struct {
	Rank proto.Rank
	Suit proto.Suit
}

func ParseBoardToStruct

func ParseBoardToStruct(in []*proto.Card) []*Card

func ParseCardToStruct

func ParseCardToStruct(c *proto.Card) *Card

func (*Card) ParseToProto

func (c *Card) ParseToProto() *proto.Card

func (*Card) String

func (c *Card) String() string

type ConcretePlugin

type ConcretePlugin struct {
	// GRPCPlugin must still implement the Plugin interface
	plugin.Plugin
	// Concrete implementation
	Impl Plugin
}

This is the implementation of plugin.GRPCPlugin so we can serve/consume this.

func (*ConcretePlugin) GRPCClient

func (p *ConcretePlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

func (*ConcretePlugin) GRPCServer

func (p *ConcretePlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

type GRPCClient

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

func (*GRPCClient) Action

func (m *GRPCClient) Action(
	players []*Player,
	hole_cards, board []*Card,
	pots []*Pot,
	bet_so_far, bet_to_player, min_raise uint,
) (proto.Action, uint, error)

func (*GRPCClient) Register

func (m *GRPCClient) Register(
	guid string,
	timeout_seconds uint,
) (string, error)

type GRPCServer

type GRPCServer struct {
	proto.UnimplementedPluginServer
	// This is the real implementation
	Impl Plugin
}

func (*GRPCServer) Action

func (*GRPCServer) Register

type Player

type Player struct {
	Guid     string
	Name     string
	State    proto.State
	Bank     uint
	BetSoFar uint
}

func ParsePlayerListToStruc

func ParsePlayerListToStruc(in []*proto.Player) []*Player

func ParsePlayerToStruct

func ParsePlayerToStruct(p *proto.Player) *Player

func (*Player) ParseToProto

func (p *Player) ParseToProto() *proto.Player

type Plugin

type Plugin interface {
	Register(
		guid string,
		timeout_seconds uint,
	) (string, error)

	Action(
		players []*Player,
		hole_cards, board []*Card,
		pots []*Pot,
		bet_so_far, bet_to_player, min_raise uint,
	) (proto.Action, uint, error)
}

This is the interface that is exposing as a plugin.

type Pot

type Pot struct {
	Size    uint
	Players []string
}

func ParsePotListToStruct

func ParsePotListToStruct(in []*proto.Pot) []*Pot

func ParsePotToStruct

func ParsePotToStruct(p *proto.Pot) *Pot

func (*Pot) ParseToProto

func (p *Pot) ParseToProto() *proto.Pot

Jump to

Keyboard shortcuts

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