|
1 | 1 | // |
2 | 2 | // パズル固有スクリプト部 島国・チョコナ・ストストーン版 shimaguni.js |
3 | 3 | // |
| 4 | +/* global Set:false */ |
4 | 5 | (function(pidlist, classbase) { |
5 | 6 | if (typeof module === "object" && module.exports) { |
6 | 7 | module.exports = [pidlist, classbase]; |
|
15 | 16 | "hinge", |
16 | 17 | "heyablock", |
17 | 18 | "cocktail", |
18 | | - "martini" |
| 19 | + "martini", |
| 20 | + "nuritwin" |
19 | 21 | ], |
20 | 22 | { |
21 | 23 | //--------------------------------------------------------- |
|
35 | 37 | play: ["shade", "unshade", "number"] |
36 | 38 | } |
37 | 39 | }, |
38 | | - "MouseEvent@cocktail": { |
| 40 | + "MouseEvent@cocktail,nuritwin": { |
39 | 41 | inputModes: { |
40 | 42 | edit: ["border", "number", "clear", "info-blk"], |
41 | 43 | play: ["shade", "unshade", "info-blk"] |
|
111 | 113 | return Math.min(999, this.room.clist.length); |
112 | 114 | } |
113 | 115 | }, |
| 116 | + "Cell@nuritwin": { |
| 117 | + maxnum: function() { |
| 118 | + var half = (this.room.clist.length - 1) >> 1; |
| 119 | + return Math.max(1, Math.min(999, half)); |
| 120 | + } |
| 121 | + }, |
114 | 122 | "Cell@shimaguni": { |
115 | 123 | enableSubNumberArray: true, |
116 | 124 | disableAnum: true |
|
174 | 182 | Board: { |
175 | 183 | hasborder: 1 |
176 | 184 | }, |
177 | | - "Board@shimaguni,stostone,heyablock,cocktail,martini": { |
| 185 | + "Board@shimaguni,stostone,heyablock,cocktail,martini,nuritwin": { |
178 | 186 | addExtraInfo: function() { |
179 | 187 | this.stonegraph = this.addInfoList(this.klass.AreaStoneGraph); |
180 | 188 | if (this.pid === "cocktail" || this.pid === "martini") { |
|
296 | 304 | } |
297 | 305 | }, |
298 | 306 |
|
299 | | - "AreaShadeGraph@chocona": { |
| 307 | + "AreaShadeGraph@chocona,nuritwin": { |
300 | 308 | enabled: true |
301 | 309 | }, |
302 | 310 | "AreaShadeGraph@hinge": { |
|
307 | 315 | component.hinge = null; |
308 | 316 | } |
309 | 317 | }, |
310 | | - "AreaStoneGraph:AreaShadeGraph@shimaguni,stostone,heyablock,cocktail,martini": { |
| 318 | + "AreaStoneGraph:AreaShadeGraph@shimaguni,stostone,heyablock,cocktail,martini,nuritwin": { |
311 | 319 | // Same as LITS AreaTetrominoGraph |
312 | 320 | enabled: true, |
313 | 321 | relation: { "cell.qans": "node", "border.ques": "separator" }, |
|
618 | 626 | "checkShadeCellCount" |
619 | 627 | ] |
620 | 628 | }, |
| 629 | + "AnsCheck@nuritwin#1": { |
| 630 | + checklist: [ |
| 631 | + "check2x2ShadeCell", |
| 632 | + "checkShadeBlockSize", |
| 633 | + "checkSizesEqual", |
| 634 | + "checkTwoBlocks", |
| 635 | + "checkConnectShade", |
| 636 | + "checkNoShadeCellInArea", |
| 637 | + "doneShadingDecided" |
| 638 | + ] |
| 639 | + }, |
621 | 640 | "AnsCheck@shimaguni,stostone,heyablock,cocktail,martini": { |
622 | 641 | checkSideAreaShadeCell: function() { |
623 | 642 | this.checkSideAreaCell( |
|
926 | 945 | this.checkOneArea(this.board.sblk8mgr, "csDivide"); |
927 | 946 | } |
928 | 947 | }, |
| 948 | + "AnsCheck@nuritwin": { |
| 949 | + checkShadeBlockSize: function() { |
| 950 | + var blocks = this.board.stonegraph.components; |
| 951 | + for (var id = 0; id < blocks.length; id++) { |
| 952 | + var block = blocks[id]; |
| 953 | + var room = block.clist[0].room; |
| 954 | + if (!room || !room.top.isValidNum()) { |
| 955 | + continue; |
| 956 | + } |
| 957 | + |
| 958 | + if (block.clist.length !== room.top.getNum()) { |
| 959 | + this.failcode.add("bkSizeNe"); |
| 960 | + if (this.checkOnly) { |
| 961 | + break; |
| 962 | + } |
| 963 | + room.clist.seterr(1); |
| 964 | + } |
| 965 | + } |
| 966 | + }, |
| 967 | + checkSizesEqual: function() { |
| 968 | + var rooms = this.board.roommgr.components; |
| 969 | + for (var r = 0; r < rooms.length; r++) { |
| 970 | + var room = rooms[r]; |
| 971 | + if (room.top.isValidNum()) { |
| 972 | + continue; |
| 973 | + } |
| 974 | + |
| 975 | + var units = this.getUnits(room); |
| 976 | + if (units.length !== 2) { |
| 977 | + continue; |
| 978 | + } |
| 979 | + if (units[0].clist.length === units[1].clist.length) { |
| 980 | + continue; |
| 981 | + } |
| 982 | + |
| 983 | + this.failcode.add("bkDifferentShape"); |
| 984 | + if (this.checkOnly) { |
| 985 | + break; |
| 986 | + } |
| 987 | + room.clist.seterr(1); |
| 988 | + } |
| 989 | + }, |
| 990 | + checkTwoBlocks: function() { |
| 991 | + var rooms = this.board.roommgr.components; |
| 992 | + for (var r = 0; r < rooms.length; r++) { |
| 993 | + var room = rooms[r]; |
| 994 | + var units = this.getUnits(room); |
| 995 | + if (units.length === 0 || units.length === 2) { |
| 996 | + continue; |
| 997 | + } |
| 998 | + |
| 999 | + this.failcode.add("bkUnitNe2"); |
| 1000 | + if (this.checkOnly) { |
| 1001 | + break; |
| 1002 | + } |
| 1003 | + room.clist.seterr(1); |
| 1004 | + } |
| 1005 | + }, |
| 1006 | + getUnits: function(room) { |
| 1007 | + var set = new Set(); |
| 1008 | + room.clist.each(function(cell) { |
| 1009 | + if (cell.isShade()) { |
| 1010 | + set.add(cell.stone); |
| 1011 | + } |
| 1012 | + }); |
| 1013 | + return Array.from(set); |
| 1014 | + } |
| 1015 | + }, |
929 | 1016 |
|
930 | 1017 | FailCode: { |
931 | 1018 | bkShadeDivide: "bkShadeDivide", |
|
0 commit comments