File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 354354
355355 decodeKurarin : function ( ) {
356356 var bd = this . board ;
357- this . genericDecodeNumber16 ( ( bd . dots . length >> 1 ) | 1 , function ( idx , val ) {
357+ this . genericDecodeNumber16 ( ( bd . dots . length + 1 ) >> 1 , function ( idx , val ) {
358358 var dot = bd . dots [ idx * 2 ] ;
359359 var dot2 = bd . dots [ idx * 2 + 1 ] ;
360360 dot . setDot ( ( val >> 2 ) & 3 ) ;
366366
367367 encodeKurarin : function ( ) {
368368 var bd = this . board ;
369- this . genericEncodeNumber16 ( ( bd . dots . length >> 1 ) | 1 , function ( idx ) {
369+ this . genericEncodeNumber16 ( ( bd . dots . length + 1 ) >> 1 , function ( idx ) {
370370 var dot = bd . dots [ idx * 2 ] ;
371371 var dot2 = bd . dots [ idx * 2 + 1 ] ;
372372 var value = ( dot . getDot ( ) << 2 ) | ( dot2 ? dot2 . getDot ( ) : 0 ) ;
Original file line number Diff line number Diff line change 1+ var assert = require ( "assert" ) ;
2+ var pzpr = require ( "../../" ) ;
3+
4+ describe ( "Variety:kurarin" , function ( ) {
5+ it ( "Check URL encoding of last two dots on the board" , function ( ) {
6+ var puzzle = new pzpr . Puzzle ( ) ;
7+ puzzle . open ( "kurarin/5/6" ) ;
8+
9+ var dots = puzzle . board . dots ;
10+ var prevDot = dots [ dots . length - 2 ] ;
11+ var lastDot = dots [ dots . length - 1 ] ;
12+
13+ // Set distinct values to the last two dots
14+ // 1, 2, and 3 are valid states for a dot
15+ prevDot . setDot ( 2 ) ;
16+ lastDot . setDot ( 3 ) ;
17+
18+ var url = puzzle . getURL ( ) ;
19+
20+ var puzzle2 = new pzpr . Puzzle ( ) ;
21+ puzzle2 . open ( url ) ;
22+
23+ var dots2 = puzzle2 . board . dots ;
24+ var prevDot2 = dots2 [ dots2 . length - 2 ] ;
25+ var lastDot2 = dots2 [ dots2 . length - 1 ] ;
26+
27+ assert . equal ( prevDot2 . getDot ( ) , 2 ) ;
28+ assert . equal ( lastDot2 . getDot ( ) , 3 ) ;
29+ } ) ;
30+ } ) ;
You can’t perform that action at this time.
0 commit comments