diff --git a/src/pregmod/FCTV/FCTV.js b/src/pregmod/FCTV/FCTV.js index 1f51027fd6666081eee05fd4fdb48bc758ae9d22..60d7ad5fba211ac45fb72b2b438424553acb46dc 100644 --- a/src/pregmod/FCTV/FCTV.js +++ b/src/pregmod/FCTV/FCTV.js @@ -24,6 +24,7 @@ globalThis.FCTV = (function() { channelCount: channelCount, showRange: showRange, FinalTouches: FinalTouches, + checkTags:checkTags, }; /** Produce an array of numbers representing all available channels in App.Data.FCTV.channels @@ -51,7 +52,7 @@ globalThis.FCTV = (function() { }; if (App.Data.FCTV.channels.hasOwnProperty(i)) { if (App.Data.FCTV.channels[i].hasOwnProperty("tags")) { - x = checkTags(App.Data.FCTV.channels[i].tags); + x = FCTV.checkTags(App.Data.FCTV.channels[i].tags); } if (App.Data.FCTV.channels[i].hasOwnProperty("disableSelection")) { x.canSelect = -1; x.text += `<i>This channel appears at random times</i>`; @@ -67,10 +68,6 @@ globalThis.FCTV = (function() { return x; } - function showEpisode() { - - } - function checkTags(tags){ let x = { canSelect: 1, @@ -379,13 +376,28 @@ globalThis.FctvDisplay = function({usedRemote = 0, seeAll = 0} = {}) { return p; } } - function displayShow() { - const frag = new DocumentFragment(); - const sel = V.FCTV.channel.selected || 1; + + function getEpisode(sel) { + let epToShow = -1; + const epsArray = []; const channel = App.Data.FCTV.channels[sel]; const viewedCount = V.FCTV.channel[num(sel, true)]; - const availableEp = channel.episode.length; - let epToShow; + for (let i = 0; i < App.Data.FCTV.channels[sel].episode.length; i++) { + const ep = App.Data.FCTV.channels[sel].episode[i]; + if (ep.tags) { + const x = FCTV.checkTags(ep.tags); + if (x.canSelect !== -1) { + epsArray.push(i); + } + } else { + epsArray.push(i); + } + } + const availableEp = epsArray.length; + if (epsArray.length === 0) { + return; + } + 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. epToShow = viewedCount; } else if (channel.loop === true) { @@ -395,6 +407,21 @@ globalThis.FctvDisplay = function({usedRemote = 0, seeAll = 0} = {}) { } else { // We have seen all the episodes, return a random one epToShow = jsRandom(0, availableEp-1); } + if (epToShow === -1) { + return epToShow; + } + return epsArray[epToShow]; + } + function displayShow() { + const frag = new DocumentFragment(); + const sel = V.FCTV.channel.selected || 1; + const channel = App.Data.FCTV.channels[sel]; + const epToShow = getEpisode(sel); + if (epToShow === -1) { + frag.append(`no valid episodes`); + return frag; + } + console.log(epToShow); FCTV.incrementChannel(sel); let slave; if (channel.episode[epToShow].slaves) { diff --git a/src/pregmod/FCTV/FCTVshows.js b/src/pregmod/FCTV/FCTVshows.js index 67de26994680f8a264e9b2111bc56f84dea93ed9..eb8b7ef635b7ece2930b367a87761ff497275216 100644 --- a/src/pregmod/FCTV/FCTVshows.js +++ b/src/pregmod/FCTV/FCTVshows.js @@ -1251,7 +1251,7 @@ App.Data.FCTV.channels = { }, { get slaves() { - array = []; + const array = []; let slave = App.Data.FCTV.actors.FSmodel; if (V.arcologies[0].FSSlimnessEnthusiast === "unset") { slave.dick = 4;