diff --git a/CookieMonster.js b/CookieMonster.js index fd344f0..0f915a8 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -554,6 +554,13 @@ for (var i = 0; i < 101; i++) { CM.ConfigData.GCSoundURL = {label: 'Golden Cookie Sound URL:', desc: 'URL of the sound to be played when a Golden Cookie spawns'}; CM.ConfigData.GCTimer = {label: ['Golden Cookie Timer OFF', 'Golden Cookie Timer ON'], desc: 'A timer on the Golden Cookie when it has been spawned', toggle: true, func: function() {CM.Disp.ToggleGCTimer();}}; CM.ConfigData.Favicon = {label: ['Favicon OFF', 'Favicon ON'], desc: 'Update favicon with Golden/Wrath Cookie', toggle: true, func: function() {CM.Disp.UpdateFavicon();}}; +CM.ConfigData.FortuneFlash = {label: ['Fortune Cookie Flash OFF', 'Fortune Cookie Flash ON'], desc: 'Flash screen on Fortune Cookie', toggle: true}; +CM.ConfigData.FortuneSound = {label: ['Fortune Cookie Sound OFF', 'Fortune Cookie Sound ON'], desc: 'Play a sound on Fortune Cookie', toggle: true}; +CM.ConfigData.FortuneVolume = {label: [], desc: 'Volume of the Fortune Cookie sound'}; +for (var i = 0; i < 101; i++) { + CM.ConfigData.FortuneVolume.label[i] = i + '%'; +} +CM.ConfigData.FortuneSoundURL = {label: 'Fortune Cookie Sound URL:', desc: 'URL of the sound to be played when the Ticker has a Fortune Cookie'}; CM.ConfigData.SeaFlash = {label: ['Season Special Flash OFF', 'Season Special Flash ON'], desc: 'Flash screen on Season Popup', toggle: true}; CM.ConfigData.SeaSound = {label: ['Season Special Sound OFF', 'Season Special Sound ON'], desc: 'Play a sound on Season Popup', toggle: true}; CM.ConfigData.SeaVolume = {label: [], desc: 'Volume of the Season Special sound'}; @@ -1461,6 +1468,15 @@ CM.Disp.CheckGoldenCookie = function() { } } +CM.Disp.CheckTickerFortune = function() { + if (CM.Disp.lastTickerFortuneState != (Game.TickerEffect && Game.TickerEffect.type == 'fortune')) { + CM.Disp.lastTickerFortuneState = (Game.TickerEffect && Game.TickerEffect.type == 'fortune'); + if (CM.Disp.lastTickerFortuneState) { + CM.Disp.Flash(3, 'FortuneFlash'); + CM.Disp.PlaySound(CM.Config.FortuneSoundURL, 'FortuneSound', 'FortuneVolume'); + } + } +} CM.Disp.CheckSeasonPopup = function() { if (CM.Disp.lastSeasonPopupState != Game.shimmerTypes['reindeer'].spawned) { @@ -1498,6 +1514,7 @@ CM.Disp.UpdateTitle = function() { var addSP = false; var titleGC; + var titleFC = ''; var titleSP; if (CM.Disp.lastGoldenCookieState) { if (CM.Disp.goldenShimmer.wrath) { @@ -1513,6 +1530,9 @@ CM.Disp.UpdateTitle = function() { else { titleGC = '[GS]' } + if (CM.Disp.lastTickerFortuneState) { + titleFC = '[F]'; + } if (Game.season == 'christmas') { addSP = true; if (CM.Disp.lastSeasonPopupState) { @@ -1528,11 +1548,14 @@ CM.Disp.UpdateTitle = function() { str = str.substring(str.lastIndexOf(']') + 1); } - document.title = titleGC + (addSP ? titleSP : '') + ' ' + str; + document.title = titleFC + titleGC + (addSP ? titleSP : '') + ' ' + str; } else if (CM.Config.Title == 2) { var str = ''; var spawn = false; + if (CM.Disp.lastTickerFortuneState) { + str += '[F]'; + } if (CM.Disp.lastGoldenCookieState) { spawn = true; if (CM.Disp.goldenShimmer.wrath) { @@ -1704,6 +1727,10 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(url('GCSoundURL')); frag.appendChild(listing('GCTimer')); frag.appendChild(listing('Favicon')); + frag.appendChild(listing('FortuneFlash')); + frag.appendChild(listing('FortuneSound')); + frag.appendChild(vol('FortuneVolume')); + frag.appendChild(url('FortuneSoundURL')); frag.appendChild(listing('SeaFlash')); frag.appendChild(listing('SeaSound')); frag.appendChild(vol('SeaVolume')); @@ -2623,6 +2650,7 @@ CM.Disp.colorBrown = 'Brown'; CM.Disp.colors = [CM.Disp.colorBlue, CM.Disp.colorGreen, CM.Disp.colorYellow, CM.Disp.colorOrange, CM.Disp.colorRed, CM.Disp.colorPurple, CM.Disp.colorGray, CM.Disp.colorPink, CM.Disp.colorBrown]; CM.Disp.buffColors = {'Frenzy': CM.Disp.colorYellow, 'Dragon Harvest': CM.Disp.colorBrown, 'Elder frenzy': CM.Disp.colorGreen, 'Clot': CM.Disp.colorRed, 'Click frenzy': CM.Disp.colorBlue, 'Dragonflight': CM.Disp.colorPink}; CM.Disp.lastGoldenCookieState = 0; +CM.Disp.lastTickerFortuneState = 0; CM.Disp.lastSeasonPopupState = 0; CM.Disp.lastGardenNextStep = 0; CM.Disp.goldenShimmer; @@ -2839,6 +2867,9 @@ CM.Loop = function() { // Check Golden Cookies CM.Disp.CheckGoldenCookie(); + // Check Fortune Cookies + CM.Disp.CheckTickerFortune(); + // Check Season Popup CM.Disp.CheckSeasonPopup(); @@ -2919,6 +2950,10 @@ CM.ConfigDefault = { GCSoundURL: 'https://freesound.org/data/previews/66/66717_931655-lq.mp3', GCTimer: 1, Favicon: 1, + FortuneFlash: 1, + FortuneSound: 1, + FortuneVolume: 100, + FortuneSoundURL: 'https://freesound.org/data/previews/419/419594_7062176-lq.mp3', SeaFlash: 1, SeaSound: 1, SeaVolume: 100, diff --git a/src/Config.js b/src/Config.js index 63c6b18..1598ebf 100644 --- a/src/Config.js +++ b/src/Config.js @@ -148,6 +148,13 @@ for (var i = 0; i < 101; i++) { CM.ConfigData.GCSoundURL = {label: 'Golden Cookie Sound URL:', desc: 'URL of the sound to be played when a Golden Cookie spawns'}; CM.ConfigData.GCTimer = {label: ['Golden Cookie Timer OFF', 'Golden Cookie Timer ON'], desc: 'A timer on the Golden Cookie when it has been spawned', toggle: true, func: function() {CM.Disp.ToggleGCTimer();}}; CM.ConfigData.Favicon = {label: ['Favicon OFF', 'Favicon ON'], desc: 'Update favicon with Golden/Wrath Cookie', toggle: true, func: function() {CM.Disp.UpdateFavicon();}}; +CM.ConfigData.FortuneFlash = {label: ['Fortune Cookie Flash OFF', 'Fortune Cookie Flash ON'], desc: 'Flash screen on Fortune Cookie', toggle: true}; +CM.ConfigData.FortuneSound = {label: ['Fortune Cookie Sound OFF', 'Fortune Cookie Sound ON'], desc: 'Play a sound on Fortune Cookie', toggle: true}; +CM.ConfigData.FortuneVolume = {label: [], desc: 'Volume of the Fortune Cookie sound'}; +for (var i = 0; i < 101; i++) { + CM.ConfigData.FortuneVolume.label[i] = i + '%'; +} +CM.ConfigData.FortuneSoundURL = {label: 'Fortune Cookie Sound URL:', desc: 'URL of the sound to be played when the Ticker has a Fortune Cookie'}; CM.ConfigData.SeaFlash = {label: ['Season Special Flash OFF', 'Season Special Flash ON'], desc: 'Flash screen on Season Popup', toggle: true}; CM.ConfigData.SeaSound = {label: ['Season Special Sound OFF', 'Season Special Sound ON'], desc: 'Play a sound on Season Popup', toggle: true}; CM.ConfigData.SeaVolume = {label: [], desc: 'Volume of the Season Special sound'}; diff --git a/src/Disp.js b/src/Disp.js index f5b4e35..3996bb0 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -869,6 +869,15 @@ CM.Disp.CheckGoldenCookie = function() { } } +CM.Disp.CheckTickerFortune = function() { + if (CM.Disp.lastTickerFortuneState != (Game.TickerEffect && Game.TickerEffect.type == 'fortune')) { + CM.Disp.lastTickerFortuneState = (Game.TickerEffect && Game.TickerEffect.type == 'fortune'); + if (CM.Disp.lastTickerFortuneState) { + CM.Disp.Flash(3, 'FortuneFlash'); + CM.Disp.PlaySound(CM.Config.FortuneSoundURL, 'FortuneSound', 'FortuneVolume'); + } + } +} CM.Disp.CheckSeasonPopup = function() { if (CM.Disp.lastSeasonPopupState != Game.shimmerTypes['reindeer'].spawned) { @@ -906,6 +915,7 @@ CM.Disp.UpdateTitle = function() { var addSP = false; var titleGC; + var titleFC = ''; var titleSP; if (CM.Disp.lastGoldenCookieState) { if (CM.Disp.goldenShimmer.wrath) { @@ -921,6 +931,9 @@ CM.Disp.UpdateTitle = function() { else { titleGC = '[GS]' } + if (CM.Disp.lastTickerFortuneState) { + titleFC = '[F]'; + } if (Game.season == 'christmas') { addSP = true; if (CM.Disp.lastSeasonPopupState) { @@ -936,11 +949,14 @@ CM.Disp.UpdateTitle = function() { str = str.substring(str.lastIndexOf(']') + 1); } - document.title = titleGC + (addSP ? titleSP : '') + ' ' + str; + document.title = titleFC + titleGC + (addSP ? titleSP : '') + ' ' + str; } else if (CM.Config.Title == 2) { var str = ''; var spawn = false; + if (CM.Disp.lastTickerFortuneState) { + str += '[F]'; + } if (CM.Disp.lastGoldenCookieState) { spawn = true; if (CM.Disp.goldenShimmer.wrath) { @@ -1112,6 +1128,10 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(url('GCSoundURL')); frag.appendChild(listing('GCTimer')); frag.appendChild(listing('Favicon')); + frag.appendChild(listing('FortuneFlash')); + frag.appendChild(listing('FortuneSound')); + frag.appendChild(vol('FortuneVolume')); + frag.appendChild(url('FortuneSoundURL')); frag.appendChild(listing('SeaFlash')); frag.appendChild(listing('SeaSound')); frag.appendChild(vol('SeaVolume')); @@ -2031,6 +2051,7 @@ CM.Disp.colorBrown = 'Brown'; CM.Disp.colors = [CM.Disp.colorBlue, CM.Disp.colorGreen, CM.Disp.colorYellow, CM.Disp.colorOrange, CM.Disp.colorRed, CM.Disp.colorPurple, CM.Disp.colorGray, CM.Disp.colorPink, CM.Disp.colorBrown]; CM.Disp.buffColors = {'Frenzy': CM.Disp.colorYellow, 'Dragon Harvest': CM.Disp.colorBrown, 'Elder frenzy': CM.Disp.colorGreen, 'Clot': CM.Disp.colorRed, 'Click frenzy': CM.Disp.colorBlue, 'Dragonflight': CM.Disp.colorPink}; CM.Disp.lastGoldenCookieState = 0; +CM.Disp.lastTickerFortuneState = 0; CM.Disp.lastSeasonPopupState = 0; CM.Disp.lastGardenNextStep = 0; CM.Disp.goldenShimmer; diff --git a/src/Main.js b/src/Main.js index eb23caf..f582da7 100644 --- a/src/Main.js +++ b/src/Main.js @@ -186,6 +186,9 @@ CM.Loop = function() { // Check Golden Cookies CM.Disp.CheckGoldenCookie(); + // Check Fortune Cookies + CM.Disp.CheckTickerFortune(); + // Check Season Popup CM.Disp.CheckSeasonPopup(); @@ -266,6 +269,10 @@ CM.ConfigDefault = { GCSoundURL: 'https://freesound.org/data/previews/66/66717_931655-lq.mp3', GCTimer: 1, Favicon: 1, + FortuneFlash: 1, + FortuneSound: 1, + FortuneVolume: 100, + FortuneSoundURL: 'https://freesound.org/data/previews/419/419594_7062176-lq.mp3', SeaFlash: 1, SeaSound: 1, SeaVolume: 100,