forked from robx/pzprjs
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathkeywest.js
More file actions
158 lines (139 loc) · 3.14 KB
/
Copy pathkeywest.js
File metadata and controls
158 lines (139 loc) · 3.14 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
(function(pidlist, classbase) {
if (typeof module === "object" && module.exports) {
module.exports = [pidlist, classbase];
} else {
pzpr.classmgr.makeCustom(pidlist, classbase);
}
})(["keywest"], {
MouseEvent: {
inputModes: {
edit: ["number", "line", "peke", "clear"],
play: ["number", "line", "peke", "clear"]
},
mouseinput_clear: function() {
this.inputFixedNumber(-1);
},
mouseinput_auto: function() {
if (this.btn === "left") {
this.inputLine();
} else {
this.inputpeke();
}
if (this.mouseend && this.notInputted()) {
this.inputqnum();
}
}
},
KeyEvent: {
enablemake: true,
enableplay: true
},
Cell: {
disInputHatena: true,
minnum: 0,
maxnum: 4
},
Board: {
cols: 7,
rows: 7,
hasborder: 1
},
LineGraph: {
enabled: true,
makeClist: true
},
Graphic: {
gridcolor_type: "THIN",
irowake: true,
circleratio: [0.37, 0.33],
lwratio: 8,
paint: function() {
this.drawPekes();
this.drawLines();
this.drawCircledNumbers();
this.drawAnsNumbers();
this.drawCursor();
},
drawAnsNumbers: function() {
this.vinc("cell_ans_number", "auto");
this.drawNumbers_com(
this.getAnsNumberText,
this.getAnsNumberColor,
"cell_ans_text_",
{ ratio: 0.65 }
);
},
getQuesNumberColor: function(cell) {
return cell.error === 1 ? this.errcolor1 : this.quescolor;
},
getCircleStrokeColor: function(cell) {
// Also shows connectivity error
return cell.error ? this.errcolor1 : this.quescolor;
},
getCircleFillColor: function(cell) {
return cell.error === 1 ? this.errbcolor1 : "white";
}
},
Encode: {
decodePzpr: function(type) {
this.decode4Cell();
},
encodePzpr: function(type) {
this.encode4Cell();
}
},
//---------------------------------------------------------
FileIO: {
decodeData: function() {
this.decodeCellQnum();
this.decodeBorderLine();
this.decodeCellAnumsub();
},
encodeData: function() {
this.encodeCellQnum();
this.encodeBorderLine();
this.encodeCellAnumsub();
}
},
//---------------------------------------------------------
// 正解判定処理実行部
AnsCheck: {
checklist: [
"checkAdjacentDiffNumber",
"checkCellNumberNotOver",
"checkCellNumberNotLess",
"checkConnectAllNumber",
"checkAdjacentDiffWithoutNumber",
"checkNoNumCell_keywest+"
],
checkCellNumberNotOver: function() {
this.checkAllCell(function(cell) {
return cell.isValidNum() && cell.getNum() < cell.lcnt;
}, "nmLineGt");
},
checkCellNumberNotLess: function() {
this.checkAllCell(function(cell) {
return cell.isValidNum() && cell.getNum() > cell.lcnt;
}, "nmLineLt");
},
checkAdjacentDiffWithoutNumber: function() {
this.checkSideCell(function(cell1, cell2) {
if (cell1.isValidNum() && cell2.isValidNum()) {
return false;
}
return cell1.lcnt === cell2.lcnt;
}, "nmLineAdjacent");
},
checkNoNumCell_keywest: function() {
if (this.puzzle.getConfig("forceallcell")) {
this.checkAllCell(function(cell) {
return cell.noNum();
}, "ceNoNum");
}
}
},
FailCode: {
nmLineGt: "nmLineGt.hashikake",
nmLineLt: "nmLineLt.hashikake"
}
});