Documentation
¶
Index ¶
- func NewGame(u *plugins.User) (*Game, []*Message)
- type Card
- type ColorChangeNotifier
- type ColorCode
- type DrawFourWildCard
- type DrawTwoCard
- type Game
- func (g *Game) AddPlayer(u *plugins.User) []*Message
- func (g *Game) Draw(u *plugins.User) []*Message
- func (g *Game) DrawPlay(u *plugins.User, action string) []*Message
- func (g *Game) GetHand(u *plugins.User) []*Message
- func (g *Game) Play(u *plugins.User, card string) ([]*Message, bool)
- func (g *Game) SayUno(u *plugins.User) []*Message
- func (g *Game) SetColor(u *plugins.User, color string) []*Message
- func (g *Game) Start(u *plugins.User) []*Message
- func (g *Game) Stop(u *plugins.User) ([]*Message, bool)
- type Message
- type ReverseCard
- type SimpleCard
- type SkipCard
- type WildCard
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Card ¶
type Card interface { // Playable returns true if the card can be played right now and // false if it can't. It assumes that the game knows that this is // in the hand of the current player. Playable(*Game) bool // Play applies the effects of this card. It assumes Playable has // already been checked. It returns messages explaining additional // actions which happened. The plugin will handle basic "[user] // played a [card]" and "It is now [user]'s turn" messages. Play(*Game) []*Message // Color returns the color of this card. Color() ColorCode // Symbol representing this card. Symbol() string // String returns how this card should be displayed to players. String() string }
Card is a generic interface for all cards.
type ColorChangeNotifier ¶
ColorChangeNotifier is meant to add onto the Card interface. It defines what happens when a color is set. This is needed for the Wild cards so they can advance the turn after a color is set.
type ColorCode ¶
type ColorCode int
ColorCode represents the color of a card.
Each color in here can be used on a card. ColorNone is a special color mearning the color is unknown and ColorWild means the card doesn't have a color.
func ColorCodeFromString ¶
ColorCodeFromString tries to look up a ColorCode for any given string.
type DrawFourWildCard ¶
type DrawFourWildCard struct {
WildCard
}
DrawFourWildCard represents a draw four wild.
func NewDrawFourWildCard ¶
func NewDrawFourWildCard() *DrawFourWildCard
NewDrawFourWildCard creates a new draw four wild.
func (*DrawFourWildCard) ColorChanged ¶
func (c *DrawFourWildCard) ColorChanged(g *Game) []*Message
ColorChanged implements (ColorChangeNotifier).Color. This overrides the embedded (WildCard).ColorChanged method.
func (*DrawFourWildCard) Playable ¶
func (c *DrawFourWildCard) Playable(g *Game) bool
Playable implements (Card).Playable. This overrides the embedded (WildCard).Playable method.
type DrawTwoCard ¶
type DrawTwoCard struct {
SimpleCard
}
DrawTwoCard represents a draw two
func NewDrawTwoCard ¶
func NewDrawTwoCard(color ColorCode) *DrawTwoCard
NewDrawTwoCard creates a new draw two given a color
func (*DrawTwoCard) Play ¶
func (c *DrawTwoCard) Play(g *Game) []*Message
Play implements (Card).Play
type Game ¶
type Game struct {
// contains filtered or unexported fields
}
Game represents an Uno game.
func (*Game) AddPlayer ¶
AddPlayer only works if the game has not been started yet. It will add the player to the list of players.
func (*Game) DrawPlay ¶
DrawPlay can only be called after a draw and mostly matters if their card is playable.
func (*Game) Play ¶
Play will handle a user playing a card. It will return messages along with if the game is now over.
type Message ¶
type Message struct { // Target is the user who this message should be sent to. It // should be nil if it should be sent to everyone. Target *plugins.User // Message contains the contents of the message Message string // Private means that the message should be sent privately, rather // than to the channel. This can only be used if Target is // non-nil. Private bool }
Message represents a message to be sent to at least one person.
type ReverseCard ¶
type ReverseCard struct {
SimpleCard
}
ReverseCard represents a reverse
func NewReverseCard ¶
func NewReverseCard(color ColorCode) *ReverseCard
NewReverseCard creates a new reverse given a color
func (*ReverseCard) Play ¶
func (c *ReverseCard) Play(g *Game) []*Message
Play implements (Card).Play
type SimpleCard ¶
type SimpleCard struct {
// contains filtered or unexported fields
}
SimpleCard represents a 0-9
func (*SimpleCard) Playable ¶
func (c *SimpleCard) Playable(g *Game) bool
Playable implements (Card).Playable
func (*SimpleCard) String ¶
func (c *SimpleCard) String() string
type SkipCard ¶
type SkipCard struct {
SimpleCard
}
SkipCard represents a skip
func NewSkipCard ¶
NewSkipCard creates a new skip given a color
type WildCard ¶
type WildCard struct {
SimpleCard
}
WildCard represents a wild
func (*WildCard) ColorChanged ¶
ColorChanged implements (ColorChangeNotifier).ColorChanged
func (*WildCard) Play ¶
Play implements (Card).Play. This overrides the embedded (SimpleCard).Play method.