deck func consistency
This commit is contained in:
parent
354167535a
commit
8d4e875891
30
deck.go
30
deck.go
@ -2,6 +2,7 @@ package tome_lib
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
@ -31,22 +32,31 @@ func (d *Deck) Shuffle() {
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Deck) Scry(s int) []*Card {
|
||||
seen := []*Card{}
|
||||
func (d *Deck) Scry(s int) *Deck {
|
||||
seen := make([]*Card, s)
|
||||
if len(d.Cards) < s {
|
||||
seen = d.Cards
|
||||
d.Cards = []*Card{}
|
||||
return seen
|
||||
copy(seen, d.Cards)
|
||||
d.Reset()
|
||||
} else {
|
||||
scrybox := d.Cards[(len(d.Cards) - s):len(d.Cards)]
|
||||
res := copy(seen, scrybox)
|
||||
if res == 0 {
|
||||
panic("Error copy scrybox")
|
||||
}
|
||||
log.Println(seen)
|
||||
d.Cards = d.Cards[0 : len(d.Cards)-s]
|
||||
}
|
||||
seen = d.Cards[(len(d.Cards) - s):len(d.Cards)]
|
||||
d.Cards = d.Cards[0 : len(d.Cards)-s]
|
||||
return seen
|
||||
return DeckFromCards(seen)
|
||||
}
|
||||
|
||||
func (d *Deck) Bottom(result []*Card) {
|
||||
d.Cards = append(result, d.Cards...) //Should shuffle result first?
|
||||
func (d *Deck) Bottom(bot *Deck) {
|
||||
d.Cards = append(bot.Cards, d.Cards...) //Should shuffle result first?
|
||||
}
|
||||
|
||||
func (d *Deck) Size() int {
|
||||
return len(d.Cards)
|
||||
}
|
||||
|
||||
func (d *Deck) Reset() {
|
||||
d.Cards = []*Card{}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user