55 A lot of thanks to:
66 * Thulinma for Pattern structure (check out his editor pattern http://www.thulinma.com/acnl/ )
77 * NeoKamek for his work on LeafTools and other help
8+ * jexom for documenting grass deterioration
89 * froggestspirit for extracting acre information and item list
910 * sprungit/shokolad-town for compiling hair style and color thumbnails
1011*/
@@ -570,25 +571,25 @@ Town.prototype.maxTurnipPrices=function(){
570571}
571572
572573Town . prototype . setGrass = function ( b ) {
573- var MAX_CURRENT = ( 16 * 16 ) * ( 8 * 6 ) ;
574+ var MAX_CURRENT = ( 16 * 16 ) * ( 5 * 4 ) ;
574575 for ( var i = 0 ; i < MAX_CURRENT ; i ++ ) {
575- if ( Math . floor ( i / 64 ) < ( Math . floor ( i / ( 64 * 16 ) ) + 1 ) * 16 - 2 ) {
576- grassCurrent . tiles [ i ] = ~ b & 0xff ;
577- savegame . storeByte ( Offsets . MAP_GRASS_CURRENT + i , grassCurrent . tiles [ i ] ) ;
578- }
576+ grassCurrent . tiles [ i ] = b & 0x0f ;
577+ savegame . storeByte ( Offsets . MAP_GRASS_CURRENT + i , grassCurrent . tiles [ i ] ) ;
579578 }
580-
581- var MAX = ( 16 * 16 ) * ( 8 * 6 ) ; // *2 ???
582- for ( var i = 0 ; i < MAX ; i ++ )
583- if ( Math . floor ( i / 64 ) < ( Math . floor ( i / ( 64 * 16 ) ) + 1 ) * 16 - 2 )
584- savegame . storeByte ( Offsets . MAP_GRASS_PREVIOUS + i , b ) ;
585579 grassCurrent . draw ( ) ;
586580
581+ var MAX = ( 8 * 8 ) * ( 8 * 6 ) * 4 ;
582+ for ( var i = 0 ; i < MAX ; i ++ ) {
583+ grassPrevious . tiles [ i ] = ~ b & 0xff ;
584+ savegame . storeByte ( Offsets . MAP_GRASS_PREVIOUS + i , grassPrevious . tiles [ i ] ) ;
585+ }
586+ grassPrevious . draw ( ) ;
587+
587588
588589 MarcDialogs . close ( ) ;
589590}
590- Town . prototype . fillGrass = function ( ) { MarcDialogs . confirm ( 'Do you want to revive all grass?' , function ( ) { town . setGrass ( 0xff ) } ) } ;
591- Town . prototype . fillDesert = function ( ) { MarcDialogs . confirm ( 'Do you want to kill all grass?' , function ( ) { town . setGrass ( 0x00 ) } ) } ;
591+ Town . prototype . fillGrass = function ( ) { MarcDialogs . confirm ( 'Do you want to revive all grass?' , function ( ) { town . setGrass ( 0x00 ) } ) } ;
592+ Town . prototype . fillDesert = function ( ) { MarcDialogs . confirm ( 'Do you want to kill all grass?' , function ( ) { town . setGrass ( 0xff ) } ) } ;
592593Town . prototype . fillStrippedGrass = function ( ) {
593594 MarcDialogs . confirm ( 'Do you want to strip all grass?' , function ( ) {
594595 var MAX_CURRENT = ( 16 * 16 ) * ( 5 * 4 ) ;
@@ -916,56 +917,48 @@ ItemGridMap.prototype.save=function(){
916917
917918
918919
919- function GrassMapPrevious ( offset , canvasId , width , height ) {
920+ function GrassMapCurrent ( offset , canvasId , width , height ) {
920921 this . offset = offset ;
921922 this . canvas = el ( canvasId ) ;
922923 this . width = width ;
923924 this . height = height ;
924925
925- this . canvas . width = this . width * 32 * 2 ;
926- this . canvas . height = this . height * 32 * 2 ;
926+ this . canvas . width = this . width * 16 ;
927+ this . canvas . height = this . height * 16 ;
927928
928929 this . tiles = new Array ( width * height * 16 * 16 ) ;
929930 for ( var i = 0 ; i < this . tiles . length ; i ++ ) {
930931 var b = savegame . readByte1 ( this . offset + i ) ;
931- this . tiles [ i ] = b & 0xff ;
932+ this . tiles [ i ] = b & 0x0f ;
932933 if ( b >> 4 ) {
933934 //alert(b);
934935 }
935936 }
936937
937938 this . draw ( ) ;
938939}
939- GrassMapPrevious . prototype . draw = function ( ) {
940+ GrassMapCurrent . prototype . draw = function ( ) {
940941 var tile = 0 ;
941942 var ctx = this . canvas . getContext ( '2d' ) ;
942- for ( var i = 0 ; i < this . height * 2 ; i ++ ) {
943- for ( var j = 0 ; j < this . width * 2 ; j ++ ) {
944- for ( var y4 = 0 ; y4 < 2 ; y4 ++ ) {
945- for ( var x4 = 0 ; x4 < 2 ; x4 ++ ) {
946- for ( var y2 = 0 ; y2 < 2 ; y2 ++ ) {
947- for ( var x2 = 0 ; x2 < 2 ; x2 ++ ) {
948- for ( var y1 = 0 ; y1 < 2 ; y1 ++ ) {
949- for ( var x1 = 0 ; x1 < 2 ; x1 ++ ) {
950- var color = 255 - this . tiles [ tile ] ;
951- ctx . fillStyle = 'rgba(' + color + ',' + color + ',' + color + ',1)' ;
952- ctx . fillRect ( ( j * 8 + x4 * 4 + x2 * 2 + x1 ) * 4 - 3 , ( i * 8 + y4 * 4 + y2 * 2 + y1 ) * 4 - 3 , 4 , 4 ) ;
943+ for ( var i = 0 ; i < this . height ; i ++ ) {
944+ for ( var j = 0 ; j < this . width ; j ++ ) {
945+ for ( var y = 0 ; y < 16 ; y ++ ) {
946+ for ( var x = 0 ; x < 16 ; x ++ ) {
947+ var color = 255 - this . tiles [ tile ] * 17 ;
948+ ctx . fillStyle = 'rgba(' + color + ',' + color + ',' + color + ',1)' ;
949+ ctx . fillRect ( j * 16 + x , i * 16 + y , 1 , 1 ) ;
953950
954- tile ++ ;
955- }
956- }
957- }
958- }
951+ tile ++ ;
959952 }
960953 }
961954 }
962955 }
963956}
964- GrassMapPrevious . prototype . save = function ( ) {
957+ GrassMapCurrent . prototype . save = function ( ) {
965958}
966959
967960
968- function GrassMapCurrent ( offset , canvasId , width , height ) {
961+ function GrassMapPrevious ( offset , canvasId , width , height ) {
969962 this . offset = offset ;
970963 this . canvas = el ( canvasId ) ;
971964 this . width = width ;
@@ -975,32 +968,36 @@ function GrassMapCurrent(offset,canvasId,width,height){
975968 this . canvas . height = this . height * 16 ;
976969
977970 this . tiles = new Array ( width * height * 16 * 16 ) ;
978- for ( var i = 0 ; i < this . tiles . length ; i ++ ) {
979- var b = savegame . readByte1 ( this . offset + i ) ;
980- this . tiles [ i ] = b ;
981- }
971+ for ( var i = 0 ; i < this . tiles . length ; i ++ )
972+ this . tiles [ i ] = savegame . readByte1 ( this . offset + i ) ;
982973
983974 this . draw ( ) ;
984975}
985- GrassMapCurrent . prototype . draw = function ( ) {
976+ GrassMapPrevious . prototype . draw = function ( ) {
986977 var tile = 0 ;
987978 var ctx = this . canvas . getContext ( '2d' ) ;
988- for ( var i = 0 ; i < this . height ; i ++ ) {
989- for ( var j = 0 ; j < this . width ; j ++ ) {
990- for ( var y = 0 ; y < 16 ; y ++ ) {
991- for ( var x = 0 ; x < 16 ; x ++ ) {
992- var color = 255 - this . tiles [ tile ] ;
993- ctx . fillStyle = 'rgba(' + color + ',' + color + ',' + color + ',1)' ;
994- ctx . fillRect ( j * 16 + x , i * 16 + y , 1 , 1 ) ;
979+ for ( var i = 0 ; i < this . height * 2 ; i ++ ) {
980+ for ( var j = 0 ; j < this . width * 2 ; j ++ ) {
981+ for ( var y4 = 0 ; y4 < 2 ; y4 ++ ) {
982+ for ( var x4 = 0 ; x4 < 2 ; x4 ++ ) {
983+ for ( var y2 = 0 ; y2 < 2 ; y2 ++ ) {
984+ for ( var x2 = 0 ; x2 < 2 ; x2 ++ ) {
985+ for ( var y1 = 0 ; y1 < 2 ; y1 ++ ) {
986+ for ( var x1 = 0 ; x1 < 2 ; x1 ++ ) {
987+ var color = this . tiles [ tile ] ;
988+ ctx . fillStyle = 'rgba(' + color + ',' + color + ',' + color + ',1)' ;
989+ ctx . fillRect ( ( j * 8 + x4 * 4 + x2 * 2 + x1 ) , ( i * 8 + y4 * 4 + y2 * 2 + y1 ) , 1 , 1 ) ;
995990
996- tile ++ ;
991+ tile ++ ;
992+ }
993+ }
994+ }
995+ }
997996 }
998997 }
999998 }
1000999 }
10011000}
1002- GrassMapCurrent . prototype . save = function ( ) {
1003- }
10041001
10051002
10061003
@@ -2830,8 +2827,8 @@ function initializeEverything(){
28302827 island = new ItemGridMap ( 'island' ) ;
28312828
28322829 /* Grass */
2833- grassCurrent = new GrassMapPrevious ( Offsets . MAP_GRASS_CURRENT , 'grass-current' , 5 , 4 ) ;
2834- // new GrassMapCurrent (Offsets.MAP_GRASS_PREVIOUS,'grass-previous',5,4 );
2830+ grassCurrent = new GrassMapCurrent ( Offsets . MAP_GRASS_CURRENT , 'grass-current' , 5 , 4 ) ;
2831+ grassPrevious = new GrassMapPrevious ( Offsets . MAP_GRASS_PREVIOUS , 'grass-previous' , 8 , 6 ) ;
28352832
28362833 /* read player data */
28372834 players = new Array ( 4 ) ;
@@ -3386,4 +3383,4 @@ var saveAs=saveAs||(navigator.msSaveBlob&&navigator.msSaveBlob.bind(navigator))|
33863383MarcDialogs = function ( ) { function e ( e , t , n ) { a ?e . attachEvent ( "on" + t , n ) :e . addEventListener ( t , n , ! 1 ) } function t ( ) { s && ( o ?history . go ( - 1 ) :( c . className = "dialog-overlay" , s . className = s . className . replace ( / a c t i v e / g, "" ) , s = null ) ) } function n ( e ) { for ( var t = 0 ; t < s . dialogElements . length ; t ++ ) { var n = s . dialogElements [ t ] ; if ( "INPUT" === n . nodeName && "hidden" !== n . type || "INPUT" !== n . nodeName ) return n . focus ( ) , ! 0 } return ! 1 } function l ( ) { s && ( s . style . marginLeft = "-" + s . offsetWidth / 2 + "px" , s . style . marginTop = "-" + s . offsetHeight / 2 - 30 + "px" ) } var a = / M S I E 8 / . test ( navigator . userAgent ) , o = navigator . userAgent . match ( / A n d r o i d | w e b O S | i P h o n e | i P a d | i P o d | B l a c k B e r r y | W i n d o w s P h o n e / i) && "function" == typeof history . pushState , i = [ "Cancel" , "Accept" ] , s = null , c = document . createElement ( "div" ) ; c . className = "dialog-overlay" , c . style . position = "fixed" , c . style . top = "0" , c . style . left = "0" , c . style . width = "100%" , c . style . height = "100%" , c . style . zIndex = 8e3 , e ( c , "click" , t ) , e ( window , "load" , function ( ) { document . body . appendChild ( c ) , o && history . replaceState ( { myDialog :! 1 } , null , null ) } ) , e ( window , "resize" , l ) , o && e ( window , "popstate" , function ( e ) { e . state . myDialog ?( s = e . state . myDialog , MarcDialogs . open ( e . state . myDialog ) ) :e . state . myDialog === ! 1 && s && ( c . className = "dialog-overlay" , s . className = s . className . replace ( / a c t i v e / g, "" ) , s = null ) } ) , e ( document , "keydown" , function ( e ) { s && ( 27 == e . keyCode ?( e . preventDefault ?e . preventDefault ( ) :e . returnValue = ! 1 , t ( ) ) :9 == e . keyCode && s . dialogElements [ s . dialogElements . length - 1 ] == document . activeElement && ( e . preventDefault ?e . preventDefault ( ) :e . returnValue = ! 1 , n ( ) ) ) } ) ; var d = null , u = null , m = null ; return { open :function ( e ) { s && ( s . className = s . className . replace ( / a c t i v e / g, "" ) ) , o && ( s ?history . replaceState ( { myDialog :e } , null , null ) :( console . log ( "a" ) , history . pushState ( { myDialog :e } , null , null ) ) ) , c . className = "dialog-overlay active" , s = "string" == typeof e ?document . getElementById ( "dialog-" + e ) :e , s . className += " active" , s . style . position = "fixed" , s . style . top = "50%" , s . style . left = "50%" , s . style . zIndex = 8001 , s . dialogElements || ( s . dialogElements = s . querySelectorAll ( "input,textarea,select" ) ) , n ( ) , l ( s ) , l ( s ) } , close :t , alert :function ( t ) { if ( ! d ) { d = document . createElement ( "div" ) , d . id = "dialog-quick-alert" , d . className = "dialog" , d . msg = document . createElement ( "div" ) , d . msg . style . textAlign = "center" , d . appendChild ( d . msg ) , d . buttons = document . createElement ( "div" ) , d . buttons . className = "buttons" ; var n = document . createElement ( "input" ) ; n . type = "button" , n . className = "button button-accept" , n . value = i [ 1 ] , e ( n , "click" , this . close ) , d . buttons . appendChild ( n ) , d . appendChild ( d . buttons ) , document . body . appendChild ( d ) } d . msg . innerHTML = t , MarcDialogs . open ( "quick-alert" ) } , confirm :function ( t , n ) { if ( ! u ) { u = document . createElement ( "div" ) , u . id = "dialog-quick-confirm" , u . className = "dialog" , u . msg = document . createElement ( "div" ) , u . msg . style . textAlign = "center" , u . appendChild ( u . msg ) , u . buttons = document . createElement ( "div" ) , u . buttons . className = "buttons" ; var l = document . createElement ( "input" ) ; l . type = "button" , l . className = "button button-accept" , l . value = i [ 1 ] , e ( l , "click" , function ( ) { m ( ) } ) , u . buttons . appendChild ( l ) ; var a = document . createElement ( "input" ) ; a . type = "button" , a . className = "button" , a . value = i [ 0 ] , e ( a , "click" , this . close ) , u . buttons . appendChild ( a ) , u . appendChild ( u . buttons ) , document . body . appendChild ( u ) } m = n , u . msg . innerHTML = t , MarcDialogs . open ( "quick-confirm" ) } } } ( ) ;
33873384/* MarcStringCleaner.js */
33883385var _STR_CLEAN = [ 'a' , / [ \xc0 \xc1 \xc2 \xc4 \xe0 \xe1 \xe2 \xe4 ] / g, 'e' , / [ \xc8 \xc9 \xca \xcb \xe8 \xe9 \xea \xeb ] / g, 'i' , / [ \xcc \xcd \xce \xcf \xec \xed \xee \xef ] / g, 'o' , / [ \xd2 \xd3 \xd4 \xd6 \xf2 \xf3 \xf4 \xf6 ] / g, 'u' , / [ \xd9 \xda \xdb \xdc \xf9 \xfa \xfb \xfc ] / g, 'n' , / [ \xd1 \xf1 ] / g, 'c' , / [ \xc7 \xe7 ] / g, 'ae' , / [ \xc6 \xe6 ] / g, 'and' , / \x26 / g, 'euro' , / \u20ac / g, '' , / [ ^ \w - ] / g, '_' , / ( | - ) / g, '_' , / _ + / g, '' , / ^ _ | _ $ / g] ;
3389- if ( ! String . prototype . clean ) String . prototype . clean = function ( ) { var s = this . toLowerCase ( ) ; for ( var i = 0 ; i < _STR_CLEAN . length ; i += 2 ) s = s . replace ( _STR_CLEAN [ i + 1 ] , _STR_CLEAN [ i ] ) ; return s }
3386+ if ( ! String . prototype . clean ) String . prototype . clean = function ( ) { var s = this . toLowerCase ( ) ; for ( var i = 0 ; i < _STR_CLEAN . length ; i += 2 ) s = s . replace ( _STR_CLEAN [ i + 1 ] , _STR_CLEAN [ i ] ) ; return s }
0 commit comments