Adding cards now requires confirmation

This commit is contained in:
shylie 2025-12-21 11:02:09 -05:00
parent c4b4967777
commit b58718b537

View File

@ -141,11 +141,14 @@ func addCards(cards []string, unique bool, count int64) error {
continue
}
modifyCardCount(coll, &c, count, foil)
if askConfirmation(&c) {
modifyCardCount(coll, &c, count, foil)
}
} else {
// Fetch card from scryfall
c, err := fetchCard(setName, collectorNumber)
outputColor := coloredValue(c.getValue(foil))
if err != nil {
l.Warn(err)
@ -163,6 +166,11 @@ func addCards(cards []string, unique bool, count int64) error {
c.SerraCountDeck = 0
total = c.SerraCount
}
if !askConfirmation(c) {
continue
}
err = coll.storageAdd(c)
if err != nil {
l.Warn(err)
@ -180,3 +188,16 @@ func addCards(cards []string, unique bool, count int64) error {
storageDisconnect(client)
return nil
}
func askConfirmation(card *Card) bool {
drawImage(card)
fmt.Println("Is this correct (y/n)?")
var char = 'x'
for char != 'y' && char != 'n' {
fmt.Scanf("%c\n", &char)
}
return char == 'y'
}