-
Notifications
You must be signed in to change notification settings - Fork 0
/
sgf.js
125 lines (112 loc) · 2.87 KB
/
sgf.js
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
/*class NodeObj {
constructor(parentTree, parentNode) {
this.parentTree = parentTree;
this.parentNode = parentNode;
this.nextNode = null;
this.subtrees = [];
this.rootProperties = null;
this.gameInfoProperties = null;
this.moveProperties = null;
this.setupProperties = null;
this.nodeAnnotationProperties = null;
this.moveAnnotationProperties = null;
}
setNext(next) {
this.nextNode = next;
}
addSubtree(subtree) {
this.subtrees.push(subtree)
}
}
class RootProperties {
constructor() {
this.applicationName = "";
this.applicationVersion = "";
this.charset = "UTF-8";
this.format = 1;
this.gameType = 1;
this.boardSize = [19,19];
}
}
class GameInfoProperties {
constructor() {
this.annotator = "";
this.blackRank = "";
this.blackTeamName = "";
this.copyright = "";
this.date = "";
this.eventName = "";
this.gameName = "";
this.gameComment = "";
this.openingComment = "";
this.overtimeMethod = "";
this.blackPlayer = "";
this.placeName = "";
this.whitePlayer = "";
this.result = "";
this.round = "";
this.rules = "";
this.source = "";
this.timeLimits = 0;
this.userName = "";
this.whiteRank = "";
this.whiteTeamName = "";
this.handicap = 0;
this.komi = 0;
this.blackTerritory = [];
this.whiteTerritory = [];
}
}
const MOVE_LOOKUP = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
let gameTreeSequence = later();
class MoveInfo {
constructor(text, boardSize, color) {
if((boardSize[0] <= 19 && boardSize[1] <= 19 && text === "tt") || text === "") {
this.isPass = true;
this.x = 0;
this.y = 0;
this.invalid = false;
} else {
this.isPass = false;
this.x = MOVE_LOOKUP.indexOf(text[0])+1
this.y = MOVE_LOOKUP.indexOf(text[1])+1
this.invalid = (this.x == 0 || this.y == 0)
}
this.color = color;
}
}
class MoveProperties {
constructor() {
this.move = null;
this.ko = false;
this.moveNumber = 0;
}
}
class SetupProperties {
constructor() {
this.addBlack = [];
this.clearPoints = [];
this.addWhite = [];
this.whoseTurn = "";
}
}
class NodeAnnotationProperties {
constructor() {
this.comment = "";
this.name = "";
}
}
class MoveAnnotationProperties {
constructor() {
this.badMove = false;
this.doubful = false;
this.interesting = false;
this.tesuji = false;
}
}
class GameTreeObj {
constructor() {
this.root = null;
this.gameInfoNode = null;
}
}*/