Skip to content

Commit 9be6efc

Browse files
authored
Add Oasis
1 parent 26bbed4 commit 9be6efc

File tree

7 files changed

+384
-2
lines changed

7 files changed

+384
-2
lines changed

src-ui/changes.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@
3333
<main>
3434
<div style="margin-bottom: 5px;"><b>Latest types</b> (<em><a href="/list.html" target="_parent">all types</a></em>)</div>
3535
<ul>
36+
<li><a href="/p?oasis" target="_parent">Oasis</a></li>
3637
<li><a href="/p?circuitwalk" target="_parent">Circuit Walk</a></li>
3738
<li><a href="/p?cornerch" target="_parent">Corner Chain 隅角チェーン</a></li>
3839
<li><a href="/p?sendai" target="_parent">Sendai-Miyagi 宮城県仙台市</a></li>
3940
<li><a href="/p?keywest" target="_parent">Key West キーウエスト</a></li>
4041
<li><a href="/p?morningwalk" target="_parent">Morning Walk</a></li>
4142
<li><a href="/p?energywalk" target="_parent">Energy Walk</a></li>
42-
<li><a href="/p?sansaroad" target="_parent">Sansa Road サンサロード</a></li>
4343
</ul>
4444
</main>
4545
</body>

src-ui/js/ui/KeyPopup.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ ui.keypopup = {
243243
morningwalk: [10, 0],
244244
energywalk: [10, 0],
245245
cornerch: [10, 0],
246-
keywest: [4, 4]
246+
keywest: [4, 4],
247+
oasis: [10, 0]
247248
},
248249

249250
//---------------------------------------------------------------------------

src-ui/list.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ <h2 id="title"><span lang="ja">パズルの種類のリスト</span><span lang="
123123
<li data-pid="smullyan"></li>
124124
<li data-pid="outofsight"></li>
125125
<li data-pid="sumiwake"></li>
126+
<li data-pid="oasis"></li>
126127
</ul>
127128
</div>
128129
<div class="lists loops">

src/pzpr/variety.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@
326326
nurimisaki: [0, 0, "ぬりみさき", "Nurimisaki", "kurodoko"],
327327
nuritwin: [0, 0, "ぬりツイン", "Nuritwin", "shimaguni"],
328328
nuriuzu: [0, 0, "ぬりうず", "Nuri-uzu", "tentaisho"],
329+
oasis: [0, 0, "Oasis", "Oasis"],
329330
ovotovata: [0, 0, "Ovotovata", "Ovotovata", "country"],
330331
oneroom: [0, 0, "ワンルームワンドア", "One Room One Door", "heyawake"],
331332
onsen: [0, 0, "温泉めぐり", "Onsen-meguri", "country"],

src/res/failcode.en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,8 @@
815815
"nmNumberNe.sukoro": "The number of numbers placed in four adjacent cells is not equal to the number.",
816816
"nmNumberNe.sukororoom": "The number of numbers placed in four adjacent cells is not equal to the number.",
817817
"nmNumberNe.view": "The number of numbers placed in four adjacent cells is not equal to the number.",
818+
"nmOasisGt": "A number is larger than the amount of circles that can be reached.",
819+
"nmOasisLt": "A number is smaller than the amount of circles that can be reached.",
818820
"nmOrbitNe.orbital": "A number does not indicate the amount of white circles used by the loop.",
819821
"nmOrder.numcity": "The size of a district is larger or equal to the size of the previous district.",
820822
"nmOutOfBk.oyakodori": "A bird is outside a nest.",

src/variety/oasis.js

Lines changed: 320 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,320 @@
1+
/* global Set:false */
2+
(function(pidlist, classbase) {
3+
if (typeof module === "object" && module.exports) {
4+
module.exports = [pidlist, classbase];
5+
} else {
6+
pzpr.classmgr.makeCustom(pidlist, classbase);
7+
}
8+
})(["oasis"], {
9+
//---------------------------------------------------------
10+
// マウス入力系
11+
MouseEvent: {
12+
RBShadeCell: true,
13+
use: true,
14+
inputModes: {
15+
edit: ["number", "clear"],
16+
play: ["shade", "unshade", "peke", "completion"]
17+
},
18+
mouseinput_auto: function() {
19+
if (this.puzzle.playmode) {
20+
if (this.mousestart) {
21+
this.isDraggingPeke = this.puzzle.key.isALT;
22+
}
23+
if (this.isDraggingPeke) {
24+
this.inputpeke();
25+
} else if (this.btn === "left" && this.mousestart) {
26+
if (!this.inputqcmp()) {
27+
this.inputcell();
28+
}
29+
} else if (this.inputData === null || this.inputData < 20) {
30+
this.inputcell();
31+
}
32+
} else if (this.puzzle.editmode) {
33+
if (this.mousestart) {
34+
this.inputqnum();
35+
}
36+
}
37+
},
38+
inputqcmp: function() {
39+
var cell = this.getcell();
40+
if (cell.isnull || !cell.isNum()) {
41+
return false;
42+
}
43+
44+
this.inputData = 20;
45+
cell.setQcmp(+!cell.qcmp);
46+
cell.draw();
47+
48+
this.mousereset();
49+
return true;
50+
}
51+
},
52+
53+
//---------------------------------------------------------
54+
// キーボード入力系
55+
KeyEvent: {
56+
enablemake: true
57+
},
58+
59+
//---------------------------------------------------------
60+
// 盤面管理系
61+
Cell: {
62+
numberRemainsUnshaded: true,
63+
64+
maxnum: function() {
65+
return this.board.cols * this.board.rows - 1;
66+
},
67+
68+
isCmp: function() {
69+
if (!this.isNum()) {
70+
return false;
71+
}
72+
if (this.qcmp === 1) {
73+
return true;
74+
}
75+
if (!this.isValidNum() || !this.puzzle.execConfig("autocmp")) {
76+
return false;
77+
}
78+
return this.countResult(true) === 0;
79+
},
80+
81+
countResult: function(explicit) {
82+
if (!this.isValidNum()) {
83+
return 0;
84+
}
85+
var targets = new Set();
86+
for (var dir in this.adjacent) {
87+
var c = this.adjacent[dir];
88+
if (c.isNum()) {
89+
targets.add(c);
90+
}
91+
var group = explicit ? c.autooasis : c.oasis;
92+
if (group) {
93+
group.adjclist.each(function(obj) {
94+
targets.add(obj);
95+
});
96+
}
97+
}
98+
targets.delete(this);
99+
return targets.size - this.qnum;
100+
},
101+
redrawConnected: function() {
102+
if (this.autooasis) {
103+
this.autooasis.adjclist.each(function(c) {
104+
c.draw();
105+
});
106+
} else {
107+
for (var dir in this.adjacent) {
108+
var c = this.adjacent[dir];
109+
if (c && c.autooasis) {
110+
c.redrawConnected();
111+
} else if (c && c.isNum()) {
112+
c.draw();
113+
}
114+
}
115+
}
116+
},
117+
118+
posthook: {
119+
qnum: function() {
120+
var bd = this.board;
121+
var oasis = new Set();
122+
var autooasis = new Set();
123+
124+
for (var dir in this.adjacent) {
125+
var c = this.adjacent[dir];
126+
if (c && c.oasis) {
127+
oasis.add(c.oasis);
128+
}
129+
if (c && c.autooasis) {
130+
autooasis.add(c.autooasis);
131+
}
132+
}
133+
134+
oasis.forEach(function(cmp) {
135+
bd.oasisgraph.setExtraData(cmp);
136+
});
137+
autooasis.forEach(function(cmp) {
138+
bd.autooasisgraph.setExtraData(cmp);
139+
});
140+
this.redrawConnected();
141+
},
142+
qsub: function() {
143+
this.redrawConnected();
144+
}
145+
}
146+
},
147+
Board: {
148+
hasborder: 1,
149+
cols: 8,
150+
rows: 8,
151+
152+
addExtraInfo: function() {
153+
this.oasisgraph = this.addInfoList(this.klass.ImplicitOasisGraph);
154+
this.autooasisgraph = this.addInfoList(this.klass.ExplicitOasisGraph);
155+
}
156+
},
157+
158+
AreaUnshadeGraph: {
159+
enabled: true
160+
},
161+
"ImplicitOasisGraph:AreaGraphBase": {
162+
enabled: true,
163+
relation: { "cell.qans": "node", "cell.qnum": "node", "cell.qsub": "node" },
164+
setExtraData: function(component) {
165+
this.common.setExtraData.call(this, component);
166+
167+
var set = new Set();
168+
169+
component.clist.each(function(cell) {
170+
for (var dir in cell.adjacent) {
171+
var adj = cell.adjacent[dir];
172+
if (adj.isNum()) {
173+
set.add(adj);
174+
}
175+
}
176+
});
177+
component.adjclist = new this.klass.CellList(Array.from(set));
178+
},
179+
180+
isnodevalid: function(cell) {
181+
return cell.isUnshade() && !cell.isNum();
182+
},
183+
184+
getComponentRefs: function(obj) {
185+
return obj.oasis;
186+
},
187+
setComponentRefs: function(obj, component) {
188+
obj.oasis = component;
189+
},
190+
getObjNodeList: function(nodeobj) {
191+
return nodeobj.oasisnodes;
192+
},
193+
resetObjNodeList: function(nodeobj) {
194+
nodeobj.oasisnodes = [];
195+
}
196+
},
197+
"ExplicitOasisGraph:ImplicitOasisGraph": {
198+
isnodevalid: function(cell) {
199+
return cell.isUnshade() && !cell.isNum() && cell.qsub;
200+
},
201+
getComponentRefs: function(obj) {
202+
return obj.autooasis;
203+
},
204+
setComponentRefs: function(obj, component) {
205+
obj.autooasis = component;
206+
},
207+
getObjNodeList: function(nodeobj) {
208+
return nodeobj.autooasisnodes;
209+
},
210+
resetObjNodeList: function(nodeobj) {
211+
nodeobj.autooasisnodes = [];
212+
}
213+
},
214+
215+
//---------------------------------------------------------
216+
// 画像表示系
217+
Graphic: {
218+
qanscolor: "black",
219+
gridcolor_type: "LIGHT",
220+
221+
autocmp: "number",
222+
hideHatena: true,
223+
224+
paint: function() {
225+
this.drawBGCells();
226+
this.drawDotCells();
227+
this.drawGrid();
228+
this.drawShadedCells();
229+
230+
this.drawCircledNumbers();
231+
232+
this.drawChassis();
233+
234+
this.drawPekes();
235+
236+
this.drawTarget();
237+
},
238+
239+
getCircleFillColor: function(cell) {
240+
if (!cell.isNum()) {
241+
return null;
242+
}
243+
return cell.isCmp() ? this.qcmpcolor : this.bgcolor;
244+
}
245+
},
246+
247+
//---------------------------------------------------------
248+
// URLエンコード/デコード処理
249+
Encode: {
250+
decodePzpr: function(type) {
251+
this.decodeNumber16();
252+
},
253+
encodePzpr: function(type) {
254+
this.encodeNumber16();
255+
}
256+
},
257+
//---------------------------------------------------------
258+
FileIO: {
259+
decodeData: function() {
260+
this.decodeCellQnum();
261+
this.decodeCellQanssubcmp();
262+
this.decodeBorderLine();
263+
},
264+
encodeData: function() {
265+
this.encodeCellQnum();
266+
this.encodeCellQanssubcmp();
267+
this.encodeBorderLineIfPresent();
268+
},
269+
270+
decodeCellQanssubcmp: function() {
271+
this.decodeCell(function(cell, ca) {
272+
if (ca === "+") {
273+
cell.qsub = 1;
274+
} else if (ca === "-") {
275+
cell.qcmp = 1;
276+
} else if (ca === "1") {
277+
cell.qans = 1;
278+
}
279+
});
280+
},
281+
encodeCellQanssubcmp: function() {
282+
this.encodeCell(function(cell) {
283+
if (cell.qans === 1) {
284+
return "1 ";
285+
} else if (cell.qsub === 1) {
286+
return "+ ";
287+
} else if (cell.qcmp === 1) {
288+
return "- ";
289+
} else {
290+
return ". ";
291+
}
292+
});
293+
}
294+
},
295+
296+
//---------------------------------------------------------
297+
// 正解判定処理実行部
298+
AnsCheck: {
299+
checklist: [
300+
"checkShadeCellExist",
301+
"checkAdjacentShadeCell",
302+
"checkConnectUnshadeRB",
303+
"checkCellNumberLarge",
304+
"check2x2UnshadeCell++",
305+
"checkCellNumberSmall",
306+
"doneShadingDecided"
307+
],
308+
309+
checkCellNumberLarge: function() {
310+
this.checkAllCell(function(cell) {
311+
return cell.countResult(false) < 0;
312+
}, "nmOasisGt");
313+
},
314+
checkCellNumberSmall: function() {
315+
this.checkAllCell(function(cell) {
316+
return cell.countResult(false) > 0;
317+
}, "nmOasisLt");
318+
}
319+
}
320+
});

0 commit comments

Comments
 (0)