Skip to content

Commit 15e430f

Browse files
committed
fillomino: Improve key combo inputs
1 parent 0d7a25c commit 15e430f

File tree

3 files changed

+40
-9
lines changed

3 files changed

+40
-9
lines changed

src/puzzle/KeyInput.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pzpr.classmgr.makeCommon({
2424
// kc.keyreset() キーボード入力に関する情報を初期化する
2525
// kc.isenablemode() 現在のモードでキー入力が有効か判定する
2626
//---------------------------------------------------------------------------
27-
keyreset: function() {
27+
keyreset: function(isTest) {
2828
this.isCTRL = false;
2929
this.isMETA = false; // MacのCommandキーなど
3030
this.isALT = false; // ALTはメニュー用なので基本的に使わない
@@ -36,9 +36,11 @@ pzpr.classmgr.makeCommon({
3636
this.keydown = false;
3737
this.keyup = false;
3838

39-
this.ca = "";
39+
if (!isTest) {
40+
this.ca = "";
4041

41-
this.prev = null;
42+
this.prev = null;
43+
}
4244
},
4345
isenablemode: function() {
4446
return (
@@ -190,8 +192,19 @@ pzpr.classmgr.makeCommon({
190192
//---------------------------------------------------------------------------
191193
inputKeys: function(array) {
192194
for (var i = 0; i < arguments.length; i++) {
193-
this.keyevent(arguments[i], 0);
194-
this.keyevent(arguments[i], 1);
195+
var ca = arguments[i];
196+
197+
this.isSHIFT = ca.match(/shift\+/);
198+
this.isCTRL = ca.match(/ctrl\+/);
199+
this.isALT = ca.match(/alt\+/);
200+
this.isMETA = ca.match(/meta\+/);
201+
this.isX = ca.match(/x\+/);
202+
this.isY = ca.match(/y\+/);
203+
this.isZ = ca.match(/z\+/);
204+
205+
this.keyevent(ca, 0);
206+
this.keyevent(ca, 1);
207+
this.keyreset(true);
195208
}
196209
},
197210

src/variety/fillomino.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
return this.moveTBorder(ca);
229229
} else if (
230230
this.puzzle.playmode &&
231-
(this.isCTRL || this.isX || this.isZ)
231+
(this.isCTRL || this.isALT || this.isX || this.isZ)
232232
) {
233233
return this.move_fillomino(ca);
234234
}
@@ -244,6 +244,9 @@
244244
var adc = cell.adjacent,
245245
adb = cell.adjborder;
246246
var nc, nb;
247+
248+
var tokens = ca.split("+");
249+
ca = tokens[tokens.length - 1];
247250
switch (ca) {
248251
case "up":
249252
nc = adc.top;
@@ -265,23 +268,24 @@
265268
return false;
266269
}
267270
if (!nc.isnull) {
268-
var isMoved = this.isCTRL || this.isX || this.isZ;
271+
var isMoved = this.isCTRL || this.isALT || this.isX || this.isZ;
269272
if (!isMoved) {
270273
return false;
271274
}
272275

273-
if (this.isCTRL) {
276+
if (this.isCTRL || this.isALT) {
274277
if (!nb.isnull) {
275278
nb.setQsub(nb.qsub === 0 ? 1 : 0);
276279
this.cursor.setaddr(nc);
277280
}
278-
} else if (this.isZ) {
281+
} else if (this.isZ && this.pid !== "numcity") {
279282
if (!nb.isnull) {
280283
nb.setQans(!nb.isBorder() ? 1 : 0);
281284
}
282285
} else if (this.isX) {
283286
if (!nc.isnull) {
284287
nc.setAnum(cell.getNum());
288+
nc.draw();
285289
this.cursor.setaddr(nc);
286290
}
287291
}

test/script/fillomino.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,20 @@ ui.debug.addDebugData("fillomino", {
7777
input: ["mouse,left, 2,0, 2,2, 0,2"],
7878
result:
7979
"pzprv3/fillomino/2/4/3 . . . /. . . . /. . . . /. . . . /2 -1 0 /0 0 0 /1 0 0 0 /"
80+
},
81+
{
82+
input: ["playmode,copynum", "mouse,left,1.9,1.9,1.9,3.9"],
83+
result:
84+
"pzprv3/fillomino/2/4/3 . . . /. . . . /. . . . /3 . . . /2 -1 0 /0 0 0 /1 0 0 0 /"
85+
},
86+
{
87+
input: [
88+
"playmode",
89+
"cursor,5,1",
90+
"key,alt+down,left,left,x+right,z+right"
91+
],
92+
result:
93+
"pzprv3/fillomino/2/4/3 . . . /. . . . /. . . . /3 3 . . /2 -1 0 /0 1 0 /1 0 -1 0 /"
8094
}
8195
]
8296
});

0 commit comments

Comments
 (0)