diff --git a/Dice/Dice.go b/Dice/Dice.go index c116ed1..d9ea822 100644 --- a/Dice/Dice.go +++ b/Dice/Dice.go @@ -45,32 +45,25 @@ func Cast(surfaces, diceThrows, modifier int) { } } -func SimpleCast(modifier int) int { +func SimpleCast() int { var cast = rand.Intn(20) + 1 - if modifier != 0 { - fmt.Println("Without modifier:", cast) - } - return cast + modifier + return cast } -func Advantage(x, y int) int { - fmt.Println("\tx:", x) - fmt.Println("\tY:", y) +func Advantage(x, y int) (int, int, int) { if x > y { - return x + return x, x, y } else { - return y + return y, x, y } } -func Disadvantage(x, y int) int { - fmt.Println("\tx:", x) - fmt.Println("\tY:", y) +func Disadvantage(x, y int) (int, int, int) { if x < y { - return x + return x, x, y } else { - return y + return y, x, y } } diff --git a/main.go b/main.go index 73f575a..34afab7 100644 --- a/main.go +++ b/main.go @@ -41,20 +41,34 @@ func main() { Coin.Toss(diceThrows) case advantage: - if modifier > 0 { + x := Dice.SimpleCast() + y := Dice.SimpleCast() + result, x_block, y_block := Dice.Advantage(x, y) + if modifier != 0 { fmt.Printf("%sRolling 1d20 + %d with advantage...%s\n", Colors.ColorGreen, modifier, Colors.ColorReset) + fmt.Printf("\t%s%s%s\n", Colors.ColorYellow, "Without modifier...", Colors.ColorReset) + fmt.Printf("\t%s%d%s\t%s %d\t%s %d\n", Colors.ColorGreen, result, Colors.ColorReset, "x:", x_block, "y:", y_block) + fmt.Printf("\t%s%s%s\n", Colors.ColorYellow, "With modifier...", Colors.ColorReset) + fmt.Printf("\t%s%d%s\t%s %d\t%s %d\n", Colors.ColorGreen, result+modifier, Colors.ColorReset, "x:", x_block+modifier, "y:", y_block+modifier) } else { fmt.Printf("%sRolling 1d20 with advantage...%s\n", Colors.ColorGreen, Colors.ColorReset) + fmt.Printf("\t%s%d%s\t%s %d\t%s %d\n", Colors.ColorGreen, result, Colors.ColorReset, "x:", x_block, "y:", y_block) } - fmt.Printf("\t%s%d%s\n", Colors.ColorGreen, Dice.Advantage(Dice.SimpleCast(modifier), Dice.SimpleCast(modifier)), Colors.ColorReset) case disadvantage: + x := Dice.SimpleCast() + y := Dice.SimpleCast() + result, x_block, y_block := Dice.Disadvantage(x, y) if modifier != 0 { fmt.Printf("%sRolling 1d20 + %d with disadvantage...%s\n", Colors.ColorRed, modifier, Colors.ColorReset) + fmt.Printf("\t%s%s%s\n", Colors.ColorYellow, "Without modifier...", Colors.ColorReset) + fmt.Printf("\t%s%d%s\t%s %d\t%s %d\n", Colors.ColorRed, result, Colors.ColorReset, "x:", x_block, "y:", y_block) + fmt.Printf("\t%s%s%s\n", Colors.ColorYellow, "With modifier...", Colors.ColorReset) + fmt.Printf("\t%s%d%s\t%s %d\t%s %d\n", Colors.ColorRed, result+modifier, Colors.ColorReset, "x:", x_block+modifier, "y:", y_block+modifier) } else { fmt.Printf("%sRolling 1d20 with disadvantage...%s\n", Colors.ColorRed, Colors.ColorReset) + fmt.Printf("\t%s%d%s\t%s %d\t%s %d\n", Colors.ColorRed, result, Colors.ColorReset, "x:", x_block, "y:", y_block) } - fmt.Printf("\t%s%d%s\n", Colors.ColorRed, Dice.Disadvantage(Dice.SimpleCast(modifier), Dice.SimpleCast(modifier)), Colors.ColorReset) case attacks > 1: for i := 0; i < attacks; i++ {