Smart Contract
GomokuType
A.a10dde51240c1ec7.GomokuType
1pub contract GomokuType {
2
3 pub enum VerifyDirection: UInt8 {
4 pub case vertical
5 pub case horizontal
6 pub case diagonal // "/"
7 pub case reversedDiagonal // "\"
8 }
9
10 pub enum Role: UInt8 {
11 pub case host
12 pub case challenger
13 }
14
15 pub enum StoneColor: UInt8 {
16 // block stone go first
17 pub case black
18 pub case white
19 }
20
21 pub enum Result: UInt8 {
22 pub case hostWins
23 pub case challengerWins
24 pub case draw
25 }
26
27 pub resource interface Stoning {
28 pub let color: StoneColor
29 pub let location: StoneLocation
30
31 pub fun key(): String
32
33 pub fun convertToData(): StoneData
34 }
35
36 pub struct interface StoneDataing {
37 pub let color: StoneColor
38 pub let location: StoneLocation
39
40 pub init(
41 color: StoneColor,
42 location: StoneLocation
43 )
44 }
45
46 pub struct StoneData {
47 pub let color: StoneColor
48 pub let location: StoneLocation
49
50 pub init(
51 color: StoneColor,
52 location: StoneLocation
53 ) {
54 self.color = color
55 self.location = location
56 }
57 }
58
59 pub struct StoneLocation {
60
61 pub let x: Int8
62 pub let y: Int8
63
64 pub init(x: Int8, y: Int8) {
65 self.x = x
66 self.y = y
67 }
68
69 pub fun key(): String {
70 return self.x.toString().concat(",").concat(self.y.toString())
71 }
72
73 pub fun description(): String {
74 return "x: ".concat(self.x.toString()).concat(", y: ").concat(self.y.toString())
75 }
76
77 }
78}