Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

deck.gno

0.50 Kb · 23 lines
 1package engine
 2
 3// deckSize is the number of special cards in a deck.
 4const deckSize = 8
 5
 6// LegalDeck reports whether deck, a bit set by CardID, is deckSize cards of clan's pool
 7// holding exactly one Rare.
 8func (rs *Ruleset) LegalDeck(clan Clan, deck uint64) bool {
 9	if deck&^clan.Pool != 0 {
10		return false
11	}
12	cards, rares := 0, 0
13	for i := range rs.Cards {
14		if deck&(uint64(1)<<uint(i)) == 0 {
15			continue
16		}
17		cards++
18		if rs.Cards[i].Rare {
19			rares++
20		}
21	}
22	return cards == deckSize && rares == 1
23}