-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
64 lines (58 loc) 路 1.04 KB
/
Copy pathmain.go
File metadata and controls
64 lines (58 loc) 路 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import (
"fmt"
)
func checkWin(spin [][]string, multipliers map[string]uint) []uint {
lines := []uint{}
for _, row := range spin {
win := true
checkSymbol := row[0]
for _, symbol := range row[1:] {
if checkSymbol != symbol {
win = false
break
}
}
if win {
lines = append(lines, multipliers[checkSymbol])
} else {
lines = append(lines, 0)
}
}
return lines
}
func main() {
symbols := map[string]uint{
"A": 4,
"B": 7,
"C": 12,
"D": 20,
}
multipliers := map[string]uint{
"A": 28,
"B": 10,
"C": 5,
"D": 2,
}
symbolArr := GenerateSymbolArray(symbols)
balance := uint(200)
GetName()
for balance > 0 {
bet := GetBet(balance)
if bet == 0 {
break
}
balance -= bet
spin := GetSpin(symbolArr, 3, 3)
PrintSpin(spin)
WinningLines := checkWin(spin, multipliers)
for i, multi := range WinningLines {
win := multi * bet
balance += win
if multi > 0 {
fmt.Printf("Won $%d, (%dx) on Line #%d\n", win, multi, i+1)
}
}
}
fmt.Printf("You're left with, $%d.\n", balance)
}