@@ -333,9 +333,7 @@ function loadCard(data) {
333333
334334 //save loaded game if daily
335335 if ( window . game . mode == 'daily' ) {
336- setStorage ( 'daily' , JSON . stringify ( window . gameSesh ) , {
337- expires : 365
338- } ) ;
336+ setStorage ( 'daily' , JSON . stringify ( window . gameSesh ) ) ; //save daily game session data to local storage
339337 }
340338}
341339
@@ -405,9 +403,7 @@ function submitLetter(char) {
405403 window . stats [ window . game . mode ] . acc [ 1 ] ++ ;
406404 else
407405 window . stats [ window . game . mode ] . acc [ 3 ] ++ ;
408- setStorage ( window . game . mode + 'Stats' , JSON . stringify ( window . stats [ window . game . mode ] ) , {
409- expires : 365
410- } ) ;
406+ setStorage ( window . game . mode + 'Stats' , JSON . stringify ( window . stats [ window . game . mode ] ) ) ; //save game stats to local storage
411407 }
412408
413409 if ( window . lives != - 1 ) {
@@ -448,9 +444,7 @@ function submitLetter(char) {
448444 window . stats [ window . game . mode ] . acc [ 0 ] ++ ;
449445 else
450446 window . stats [ window . game . mode ] . acc [ 2 ] ++ ;
451- setStorage ( window . game . mode + 'Stats' , JSON . stringify ( window . stats [ window . game . mode ] ) , {
452- expires : 365
453- } ) ;
447+ setStorage ( window . game . mode + 'Stats' , JSON . stringify ( window . stats [ window . game . mode ] ) ) ; //save game stats to local storage
454448 }
455449
456450 //player win!
@@ -471,9 +465,7 @@ function submitLetter(char) {
471465 }
472466
473467 //save game session data to respective mode cookie
474- setStorage ( window . game . mode , JSON . stringify ( window . gameSesh ) , {
475- expires : 365
476- } ) ;
468+ setStorage ( window . game . mode , JSON . stringify ( window . gameSesh ) ) ; //save game session data to local storage
477469}
478470
479471//handler for see card button
@@ -502,9 +494,7 @@ function gameLostFree() {
502494 } else {
503495 window . stats . free . wr [ 1 ] [ window . gameSesh . tlv - 1 ] [ 1 ] ++ ;
504496 }
505- setStorage ( 'freeStats' , JSON . stringify ( window . stats . free ) , {
506- expires : 365
507- } ) ;
497+ setStorage ( 'freeStats' , JSON . stringify ( window . stats . free ) ) ; //save free mode stats to local storage
508498 }
509499
510500 $ . confirm ( {
@@ -572,9 +562,7 @@ function gameLostDaily() {
572562 } else {
573563 window . stats . daily . WL [ 3 ] ++ ;
574564 }
575- setStorage ( 'dailyStats' , JSON . stringify ( window . stats . daily ) , {
576- expires : 365
577- } ) ;
565+ setStorage ( 'dailyStats' , JSON . stringify ( window . stats . daily ) ) ; //save daily stats to local storage
578566 }
579567
580568 let imgSrc = 'https://storage.ko-fi.com/cdn/cup-border.png' ;
@@ -668,9 +656,7 @@ function gameWinDaily() {
668656 window . stats . daily . score [ 1 ] [ wr ] ++ ;
669657 window . stats . daily . WL [ 2 ] ++ ;
670658 }
671- setStorage ( 'dailyStats' , JSON . stringify ( window . stats . daily ) , {
672- expires : 365
673- } ) ;
659+ setStorage ( 'dailyStats' , JSON . stringify ( window . stats . daily ) ) ; //save daily stats to local storage
674660
675661 //vibrate if on
676662 if ( window . game . vibra && canVibrate )
@@ -783,9 +769,7 @@ function gameWinFree() {
783769 colors : window . game . theme == 'dark' ? [ '#eee' ] : [ '#333' ]
784770 } ) ;
785771 }
786- setStorage ( 'freeStats' , JSON . stringify ( window . stats . free ) , {
787- expires : 365
788- } ) ;
772+ setStorage ( 'freeStats' , JSON . stringify ( window . stats . free ) ) ; //save free mode stats to local storage
789773
790774 $ . confirm ( {
791775 title : `<span class=\"modalText\">${ getWinTerms ( wr ) } ${ ( wr != 0 ? ( ` — ${ wr } wrong` ) : '' ) } </span>` ,
@@ -1027,27 +1011,21 @@ function settingsModal() {
10271011 let hi = this . $content . find ( '#hmInput' ) ;
10281012 hi . on ( 'input' , function ( ) {
10291013 window . game . daily . hideBlanks = this . checked ;
1030- setStorage ( 'befuddle' , JSON . stringify ( window . game ) , {
1031- expires : 365
1032- } ) ; //save game settings data to cookies
1014+ setStorage ( 'befuddle' , JSON . stringify ( window . game ) ) ; //save game settings data to local storage
10331015 } ) ;
10341016
10351017 let di = this . $content . find ( '#darkInput' ) ;
10361018 di . on ( 'input' , function ( ) {
10371019 window . game . theme = ( this . checked ? 'dark' : 'light' ) ;
10381020 setTheme ( ) ;
1039- setStorage ( 'befuddle' , JSON . stringify ( window . game ) , {
1040- expires : 365
1041- } ) ; //save game settings data to cookies
1021+ setStorage ( 'befuddle' , JSON . stringify ( window . game ) ) ; //save game settings data to local storage
10421022 } ) ;
10431023
10441024 if ( canVibrate ) {
10451025 let vi = this . $content . find ( '#vibraInput' ) ;
10461026 vi . on ( 'input' , function ( ) {
10471027 window . game . vibra = this . checked ;
1048- setStorage ( 'befuddle' , JSON . stringify ( window . game ) , {
1049- expires : 365
1050- } ) ; //save game settings data to cookies
1028+ setStorage ( 'befuddle' , JSON . stringify ( window . game ) ) ; //save game settings data to local storage
10511029 } ) ;
10521030 }
10531031 }
@@ -1094,44 +1072,34 @@ function settingsModal() {
10941072 document . getElementById ( 'livesdisplay' ) . innerText = 'Off' ;
10951073 window . game . free . lives = - 1 ;
10961074 }
1097- setStorage ( 'befuddle' , JSON . stringify ( window . game ) , {
1098- expires : 365
1099- } ) ; //save game settings data to cookies
1075+ setStorage ( 'befuddle' , JSON . stringify ( window . game ) ) ; //save game settings data to local storage
11001076 } ) ;
11011077
11021078 let mi = this . $content . find ( '#manaInput' ) ;
11031079 mi . on ( 'input' , function ( ) {
11041080 let manastates = [ 'Show Nothing' , 'Show Colors' , 'Show Mana Cost' ] ;
11051081 window . game . free . manaState = parseInt ( this . value ) ;
11061082 document . getElementById ( 'manadisplay' ) . innerText = manastates [ parseInt ( this . value ) ] ;
1107- setStorage ( 'befuddle' , JSON . stringify ( window . game ) , {
1108- expires : 365
1109- } ) ; //save game settings data to cookies
1083+ setStorage ( 'befuddle' , JSON . stringify ( window . game ) ) ; //save game settings data to local storage
11101084 } ) ;
11111085
11121086 let hi = this . $content . find ( '#hideInput' ) ;
11131087 hi . on ( 'input' , function ( ) {
11141088 window . game . free . hideBlanks = this . checked ;
1115- setStorage ( 'befuddle' , JSON . stringify ( window . game ) , {
1116- expires : 365
1117- } ) ; //save game settings data to cookies
1089+ setStorage ( 'befuddle' , JSON . stringify ( window . game ) ) ; //save game settings data to local storage
11181090 } ) ;
11191091
11201092 let di = this . $content . find ( '#darkInput' ) ;
11211093 di . on ( 'input' , function ( ) {
11221094 window . game . theme = ( this . checked ? 'dark' : 'light' ) ;
11231095 setTheme ( ) ;
1124- setStorage ( 'befuddle' , JSON . stringify ( window . game ) , {
1125- expires : 365
1126- } ) ; //save game settings data to cookies
1096+ setStorage ( 'befuddle' , JSON . stringify ( window . game ) ) ; //save game settings data to local storage
11271097 } ) ;
11281098 if ( canVibrate ) {
11291099 let vi = this . $content . find ( '#vibraInput' ) ;
11301100 vi . on ( 'input' , function ( ) {
11311101 window . game . vibra = this . checked ;
1132- setStorage ( 'befuddle' , JSON . stringify ( window . game ) , {
1133- expires : 365
1134- } ) ; //save game settings data to cookies
1102+ setStorage ( 'befuddle' , JSON . stringify ( window . game ) ) ; //save game settings data to local storage
11351103 } ) ;
11361104 }
11371105 }
@@ -1353,9 +1321,7 @@ function menuModal() {
13531321 } else if ( window . game . mode == 'free' )
13541322 gameLostFree ( ) ;
13551323
1356- setStorage ( window . game . mode , JSON . stringify ( window . gameSesh ) , {
1357- expires : 365
1358- } ) ;
1324+ setStorage ( window . game . mode , JSON . stringify ( window . gameSesh ) ) ; //save game session data to local storage
13591325 menuD . close ( ) ;
13601326 }
13611327 } ,
@@ -1808,8 +1774,7 @@ function startDaily() {
18081774 if ( getStorage ( 'daily' ) ) {
18091775 window . gameSesh = JSON . parse ( getStorage ( 'daily' ) ) ;
18101776 window . mtgCard = window . gameSesh . card ;
1811- if ( window . gameSesh . end ) //seems counterintuitive, but is for reshowing the daily result
1812- window . gameSesh . end = false ;
1777+ window . gameSesh . end = false ; //seems counterintuitive, but is for reshowing the daily result
18131778 }
18141779 loadGame ( ) ;
18151780}
@@ -1833,9 +1798,7 @@ function loadGame() {
18331798 window . gameSesh . end = true ;
18341799 document . getElementById ( 'seeCard' ) . style = '' ;
18351800 gameLostDaily ( ) ;
1836- setStorage ( 'daily' , JSON . stringify ( window . gameSesh ) , {
1837- expires : 365
1838- } ) ;
1801+ setStorage ( 'daily' , JSON . stringify ( window . gameSesh ) ) ; //save daily game session data to local storage
18391802 }
18401803 return ; //don't load a new game
18411804 } else {
@@ -1861,7 +1824,7 @@ function loadGame() {
18611824 console . error ( 'Daily Befuddle needs to be updated, please report a bug to Suitangi' ) ;
18621825 $ . dialog ( {
18631826 title : '<span class=\"modalTitle\">Error</span>' ,
1864- content : '<span class=\"modalText\">Daily Befuddle needs to be updated, please contact us on Twitter or on discord !</span>' ,
1827+ content : '<span class=\"modalText\">Daily Befuddle needs to be updated, please contact us on <a href="https://x.com/BefuddleMTG" target="_blank"> Twitter</a> or on Discord !</span>' ,
18651828 type : 'red' ,
18661829 theme : window . game . theme ,
18671830 animation : 'top' ,
@@ -2394,7 +2357,7 @@ async function getDiscordUserInfo() {
23942357}
23952358
23962359async function sendDiscordMessageUpdate ( ) {
2397- if ( window . isDiscord ) {
2360+ if ( window . isDiscord && ! window . gameSesh . discordSent ) {
23982361 const response = await fetch ( '/share' , {
23992362 method : 'POST' ,
24002363 body : JSON . stringify ( {
@@ -2406,6 +2369,8 @@ async function sendDiscordMessageUpdate() {
24062369 guessProgress : window . gameSesh . guessProgress
24072370 } )
24082371 } ) ;
2372+ window . gameSesh . discordSent = true ;
2373+ setStorage ( 'daily' , JSON . stringify ( window . gameSesh ) ) ;
24092374 }
24102375}
24112376
@@ -2503,9 +2468,9 @@ $(document).ready(function () {
25032468
25042469 if ( getStorage ( 'daily' ) ) { //check for new day in daily
25052470 let tmp = JSON . parse ( getStorage ( 'daily' ) ) ;
2506- let dday = new Date ( ) ;
2507- if ( tmp . doy == undefined || getDateNumber ( ) != tmp . doy )
2471+ if ( tmp . doy == undefined || getDateNumber ( ) != tmp . doy ) {
25082472 removeStorage ( 'daily' ) ;
2473+ }
25092474 }
25102475
25112476 //set up storage
0 commit comments