goRemi

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

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

Go to latest
Published: Oct 1, 2018 License: MIT Imports: 6 Imported by: 1

README

goRemi

Go Report Card Release Status Go GitHub license

prototype for playing card game

Cangkulan Game Rules

  1. shuffle deck
  2. put 1 card from top of deck to table
  3. give each player 7 cards
  4. start playing from player 1 (clockwise)
  5. each player pick one card with the same flag as the card on top of the table, place player card on top of the table
  6. if player doesnt have card with the same flag draw card from deck until player get the card with the same flag 6.a. if deck doesnt have any more card, draw card from the top of the table
  7. after all player throw card to the table, compare players card, player with highest number win the round
  8. continue to play from player who win from last round, player who win last round can choose any card to play first
  9. repeat 5-9 until one of players doesnt have any more card
  10. Win!!!

Preview :

https://gph.is/2xIMo6o

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCardHigher

func IsCardHigher(c1 Card, c2 Card) bool

IsCardHigher : Compare 2 card, return true if card 1 number and symbol is higher

Types

type Cangkulan

type Cangkulan struct {
	Deck    Deck
	Field   Deck
	Players []Player
}

Cangkulan : Cangkulan The Game Rules

  1. shuffle deck
  2. put 1 card from top of deck to table
  3. give each player 7 cards
  4. start playing from player 1 (clockwise)
  5. each player pick one card with the same flag as the card on top of the table, place player card on top of the table
  6. if player doesnt have card with the same flag draw card from deck until player get the card with the same flag 6.a. if deck doesnt have any more card, draw card from the top of the table
  7. after all player throw card to the table, compare players card, player with highest number win the round
  8. continue to play from player who win from last round, player who win last round can choose any card to play first
  9. repeat 5-9 until one of players doesnt have any more card

func (*Cangkulan) InitGame

func (c *Cangkulan) InitGame(playerName string, numberOfPlayers int)

InitGame : create new game instance

func (*Cangkulan) StartGame

func (c *Cangkulan) StartGame()

StartGame : start game instance

type Card

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

Card : Remi Card struct

func (Card) Info

func (c Card) Info() (string, string)

Info : Show human readable card info

type Deck

type Deck []Card

Deck : Array collection of card

func InitDeck

func InitDeck() Deck

InitDeck : initialize dynamic array Deck

func (*Deck) AddCard

func (deck *Deck) AddCard(card Card)

AddCard : add card to top of deck

func (*Deck) Draw

func (deck *Deck) Draw(numberOfCards int) Deck

Draw card from deck

func (Deck) Show

func (deck Deck) Show()

Show Deck Content

func (Deck) Shuffle

func (deck Deck) Shuffle()

Shuffle Deck

type Player

type Player struct {
	Name     string
	Score    float64
	LastPlay Card
	Hand     []Card
	AI       bool // false player, true ai
}

Player struct

func (*Player) DrawCards

func (p *Player) DrawCards(deck *Deck, numberOfDraw int)

DrawCards : Draw card from deck

func (Player) ShowHand

func (p Player) ShowHand()

ShowHand : show human readable info of cards in player hand

func (*Player) ThrowCards

func (p *Player) ThrowCards(cardIndex int, deck *Deck)

ThrowCards : Return card to deck

type Players

type Players []Player

Players : collection of player

func Register

func Register(pl []string, numberOfAI int) Players

Register : Register Player

func (Players) Less

func (p Players) Less(i, j int) bool

Less : sort player

type SortSymbolNumber

type SortSymbolNumber []Card

SortSymbolNumber : sort card by symbol and number

func (SortSymbolNumber) Len

func (a SortSymbolNumber) Len() int

func (SortSymbolNumber) Less

func (a SortSymbolNumber) Less(i, j int) bool

func (SortSymbolNumber) Swap

func (a SortSymbolNumber) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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