aboutsummaryrefslogtreecommitdiff
path: root/go/game/deck.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-01-26 22:16:10 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2025-01-27 16:43:44 +0100
commit926ca5cdd20a39e3e05aaa3486cb166718dab5ca (patch)
tree3d7bc8a0e1e0be1ce8d92d5503bdede878e718e9 /go/game/deck.go
parent8720ebf9c74d9e11001772b5c00c293fa3a8b9e5 (diff)
downloadmuhqs-game-926ca5cdd20a39e3e05aaa3486cb166718dab5ca.tar.gz
muhqs-game-926ca5cdd20a39e3e05aaa3486cb166718dab5ca.zip
intermeditae commit
Diffstat (limited to 'go/game/deck.go')
-rw-r--r--go/game/deck.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/go/game/deck.go b/go/game/deck.go
index f1290fa4..569a952d 100644
--- a/go/game/deck.go
+++ b/go/game/deck.go
@@ -34,6 +34,20 @@ func (d *Deck) Draw(amount int) []*Card {
return drawn
}
+func (d *Deck) DrawOne() *Card {
+ drawn := d.Draw(1)
+ if len(drawn) == 0 {
+ return nil
+ }
+ return drawn[0]
+}
+
+func NewDeckFrom(cards PileOfCards) *Deck {
+ d := NewDeck()
+ cards.MoveInto(d)
+ return d
+}
+
func NewDeckFromCardPaths(cardPaths []string) *Deck {
d := NewDeck()
for _, cardPath := range cardPaths {