card

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: MIT Imports: 3 Imported by: 13

Documentation

Overview

Package card contains all the utilities to manipulate italian-style cards (set of 40 cards)

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

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

Item represents a card with number and seed

func FromID

func FromID[T constraints.Integer](id T) (*Item, error)

FromID creates a new card Item (a card with number and seed) from an id ranging from 1 to 40 1-10 are Coin cards 11-20 are Cup cards 21-30 are Sword cards 31-40 are Cudgel cards

func MustID

func MustID[T constraints.Integer](n T) *Item

MustID creates a new card Item (a card with number and seed) from an id ranging from 1 to 40, panics if outside

func New

func New(number, seed string) (*Item, error)

New creates a new card Item (a card with number and seed)

Example
package main

import (
	"fmt"

	"github.com/mcaci/ita-cards/card"
)

func main() {
	c, err := card.New("1", "Coin")
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(c)
}
Output:

func (Item) Number

func (c Item) Number() uint8

Number returns the number value of the card (1 to 10)

func (Item) Seed

func (c Item) Seed() Seed

Seed returns the seed value of the card as Seed type (Coin, Cup, Sword, Cudgel)

func (Item) String

func (c Item) String() string

type Seed

type Seed uint8

Seed type is an id for the seed ranging from 0 to 3

const (
	// Coin is the english equivalent of ORO
	Coin Seed = iota
	// Cup is the english equivalent of COPPE
	Cup
	// Sword is the english equivalent of SPADE
	Sword
	// Cudgel is the english equivalent of BASTONI/MAZZE
	Cudgel
)

func (Seed) Seed added in v0.1.4

func (s Seed) Seed() Seed

func (Seed) String

func (s Seed) String() string

Jump to

Keyboard shortcuts

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