diff --git a/src/pregmod/FCTV/FCTV.js b/src/pregmod/FCTV/FCTV.js index d006274c95c5ed6e64fc810dc92bdabf48f44110..7d02554b44af2c8809ce34dcfb1dbc1152ddd0f2 100644 --- a/src/pregmod/FCTV/FCTV.js +++ b/src/pregmod/FCTV/FCTV.js @@ -224,7 +224,7 @@ globalThis.FctvDisplay = function({usedRemote = 0, seeAll = 0} = {}) { } ) ); - } + }/* for (let _i = 0; ; _i++) { V.FCTV.channel.selected = _possibleChannels[Math.floor(jsRandom() * _possibleChannels.length)]; if (V.FCTV.channel.last > -1 && V.FCTV.channel.selected === V.FCTV.channel.last) { @@ -248,7 +248,7 @@ globalThis.FctvDisplay = function({usedRemote = 0, seeAll = 0} = {}) { break; } break; - } + }*/ } else if (usedRemote && (V.cheatMode > 0 || V.debugMode > 0 || V.FCTV.remote)) { p.append(`bring you the remote so you can choose whatever show you find interesting. `); if (V.FCTV.channel.selected === V.FCTV.channel.last) { @@ -262,29 +262,25 @@ globalThis.FctvDisplay = function({usedRemote = 0, seeAll = 0} = {}) { } } - if (V.FCTV.channel.selected >= -1) { - div = document.createElement("div"); - if (V.FCTV.channel.selected !== -1) { // TODO: remove with new randomizer - if (usedRemote) { - div.append(`You select `); - } else { - div.append(`It looks like the random function chose `); - } - App.UI.DOM.appendNewElement("span", div, `channel number: ${V.FCTV.channel.selected}`, "bold"); + div = document.createElement("div"); + if (usedRemote) { + div.append(`You select `); + } else { + div.append(`It looks like the random function chose `); + } + App.UI.DOM.appendNewElement("span", div, `channel number: ${V.FCTV.channel.selected}`, "bold"); - // A little glue to get unique data based stuff to stick. - if (V.FCTV.channel.selected === 16) { - div.append(`. `); - } else { - div.append(`, `); - if (V.FCTV.channel.selected === 11 && usedRemote) { - div.append(`for some foolish reason`); - } - } + // A little glue to get unique data based stuff to stick. + if (V.FCTV.channel.selected === 16) { + div.append(`. `); + } else { + div.append(`, `); + if (V.FCTV.channel.selected === 11 && usedRemote) { + div.append(`for some foolish reason`); } - div.append(displayShow()); - p.append(div); } + div.append(displayShow()); + p.append(div); p = displayRemote(p); return jQuery("#FctvWatch").empty().append(p); @@ -397,7 +393,7 @@ globalThis.FctvDisplay = function({usedRemote = 0, seeAll = 0} = {}) { } const availableEp = epsArray.length; if (epsArray.length === 0) { - return; + return -1; } if (availableEp > viewedCount) { // If we watched ep 0 last time, our view count will be 1. Now we can use 1 as our new ep, etc. @@ -416,6 +412,33 @@ globalThis.FctvDisplay = function({usedRemote = 0, seeAll = 0} = {}) { } function displayShow() { const frag = new DocumentFragment(); + if (Number.isNaN(V.FCTV.channel.selected)) { + V.FCTV.channel.selected = 1; + } + + // Random + if (!usedRemote) { + const channels = FCTV.channels(); + channels.push(3); // Double chance for slave sale + for (let i = 0; ; i++){ + const channel = _.sample(channels); + const x = FCTV.showChannel(channel); + if (x.canSelect === -1) { + const p = document.createElement("p"); + $(p).append(x.text); + frag.append(p); + } else { + V.FCTV.channel.selected = channel; + break; + } + + // Three strikes, then move on + if (i > 2) { + App.UI.DOM.appendNewElement("p", frag, `It looks like there is simply nothing on FCTV tonight worth watching.`); + return frag; + } + } + } const sel = V.FCTV.channel.selected; /** @type {FctvChannel} */ const channel = App.Data.FCTV.channels[sel];