Got rid of bad color implementation

This commit is contained in:
Nox Sluijtman 2022-08-22 17:44:16 +02:00
parent 4d0ab352aa
commit 3afa5fb7db
7 changed files with 78 additions and 53 deletions

View file

@ -6,7 +6,7 @@ import (
"strings"
"time"
"gitlab.com/EternalWanderer/dice-roller/Colors"
"github.com/fatih/color"
)
var (
@ -37,22 +37,20 @@ func Cast(surfaces, diceThrows, modifier int) {
switch {
case modifier != 0:
fmt.Printf("%sRolling %dd%d + %d...\n%s", Colors.ColorYellow, diceThrows, surfaces, modifier, Colors.ColorReset)
color.Yellow("Rolling %dd%d + %d...\n", diceThrows, surfaces, modifier)
default:
fmt.Printf("%sRolling %dd%d...\n%s", Colors.ColorYellow, diceThrows, surfaces, Colors.ColorReset)
color.Yellow("Rolling %dd%d...\n", diceThrows, surfaces)
}
if diceThrows > 1 {
fmt.Println(Colors.ColorMagenta, "\tIndividual rolls:",
strings.Trim(fmt.Sprint(casts), "[]"),
Colors.ColorReset)
color.Magenta("\tIndividual rolls: %s", strings.Trim(fmt.Sprint(casts), "[]"))
}
if modifier != 0 {
fmt.Println("\tWithout modifier:", total)
fmt.Println(Colors.ColorGreen, "\tWith modifier:", total+modifier, Colors.ColorReset)
fmt.Printf("\tWithout modifier: %d\n", total)
color.Green("\tWith modifier: %d", total+modifier)
} else {
fmt.Printf("%s\t%d%s\n", Colors.ColorGreen, total, Colors.ColorReset)
color.Green("%d", total)
}
}