-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender.go
More file actions
138 lines (135 loc) · 3.23 KB
/
render.go
File metadata and controls
138 lines (135 loc) · 3.23 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package main
import (
"fmt"
"strconv"
)
const escape = "\x1b"
const white = escape + "[37m"
const black = escape + "[30m"
const cyanB = escape + "[46m"
const blue = escape + "[34m"
const yellowB = escape + "[43m"
const reset = escape + "[0m"
func (board Board) render() {
fmt.Print("Current turn: ")
if board.turn == 1 {
fmt.Print("White")
} else {
fmt.Print("Black")
}
if board.adice1 != -1 && board.adice2 != -1 && board.uses == 0 {
fmt.Println("\nThe dice rolled: " + strconv.Itoa(board.dice1) + " " + strconv.Itoa(board.dice2))
} else if board.uses != 0 {
fmt.Println("\nThe dice rolled: " + strconv.Itoa(board.dice1) + " " + strconv.Itoa(board.dice2) + "! You have " + strconv.Itoa(board.uses) + " more uses!")
} else if board.adice1 == -1 {
fmt.Println("\nThe dice rolled: " + strconv.Itoa(board.dice1) + " " + strconv.Itoa(board.dice2) + "! You still have to play : " + strconv.Itoa(board.dice2))
} else if board.adice2 == -1 {
fmt.Println("\nThe dice rolled: " + strconv.Itoa(board.dice1) + " " + strconv.Itoa(board.dice2) + "! You still have to play : " + strconv.Itoa(board.dice1))
}
ro := yellowB + blue + " A B C D E F G H I J K L " + reset + "\n"
// Top half
for i := 1; i < 6; i++ {
ro += cyanB + " "
for y := 0; y < 6; y++ {
if board.table[y].amount >= i {
if board.table[y].color == 1 {
ro += white + "●"
} else {
ro += black + "●"
}
} else {
ro += " "
}
ro += " "
}
ro += " "
for y := 6; y < 12; y++ {
if board.table[y].amount >= i {
if board.table[y].color == 1 {
ro += white + "●"
} else {
ro += black + "●"
}
} else {
ro += " "
}
ro += " "
}
ro += "" + reset + "\n"
}
// Middle
for i := 0; i < 6; i++ {
ro += cyanB + white + " "
if board.table[i].amount > 5 {
ro += strconv.Itoa(board.table[i].amount)
} else {
ro += " "
}
}
ro += " "
for i := 6; i < 12; i++ {
ro += " "
if board.table[i].amount > 5 {
ro += strconv.Itoa(board.table[i].amount)
} else {
ro += " "
}
}
ro += " " + reset + "\n" + yellowB + " " + reset + "\n" + cyanB + white
for i := 23; i > 17; i-- {
ro += " "
if board.table[i].amount > 5 {
ro += strconv.Itoa(board.table[i].amount)
} else {
ro += " "
}
}
ro += " "
for i := 17; i > 11; i-- {
ro += " "
if board.table[i].amount > 5 {
ro += strconv.Itoa(board.table[i].amount)
} else {
ro += " "
}
}
ro += " " + reset + "\n" + cyanB
// Bottom Half
for i := 5; i > 0; i-- {
ro += " "
for y := 23; y > 17; y-- {
if board.table[y].amount >= i {
if board.table[y].color == 1 {
ro += white + "●"
} else {
ro += black + "●"
}
} else {
ro += " "
}
ro += " "
}
ro += " "
for y := 17; y > 11; y-- {
if board.table[y].amount >= i {
if board.table[y].color == 1 {
ro += white + "●"
} else {
ro += black + "●"
}
} else {
ro += " "
}
ro += " "
}
ro += reset + "\n" + cyanB
}
ro += yellowB + blue + " M N O P Q R S T U V W X " + reset + "\n"
if board.holding[0] > 0 {
ro += "Black is holding " + strconv.Itoa(board.holding[0]) + "\n"
}
if board.holding[1] > 0 {
ro += "White is holding " + strconv.Itoa(board.holding[1]) + "\n"
}
fmt.Println(ro)
}