From b9568c7362711d82aff8f480ed07924facb4456e Mon Sep 17 00:00:00 2001 From: Chris Ham Date: Tue, 25 Sep 2018 22:06:15 -0700 Subject: [PATCH] random chance for room vids --- config.json | 4 +++- fgfm.js | 35 ++++++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/config.json b/config.json index 51181a3..f255ae0 100755 --- a/config.json +++ b/config.json @@ -37,7 +37,7 @@ "defaultSceneName": "fgfm", "commercialSceneName": "commercial", "currentActivitySceneItemName": "now-showing-txt", - "initialQueueSize": 3, + "initialQueueSize": 1, "recentlyPlayedMemory": 5, "roomGrindChance": 25, "roomGrindPlaytime": 1800, @@ -51,5 +51,7 @@ "roomConfigFile": "./conf/rooms.json", "roomVidsBasePath": "Y:\\media\\videos\\ALttP\\my-vids\\room-vids", "roomVidPlaytime": 60, + "roomShuffleChance": 85, + "roomShuffleCount": 15, "debug": false } \ No newline at end of file diff --git a/fgfm.js b/fgfm.js index 661dd72..16bf78e 100755 --- a/fgfm.js +++ b/fgfm.js @@ -105,8 +105,17 @@ const streamInit = (config, twitch) => { .catch(console.error); }; - const addRoomVideo = room => { - let loops = Math.floor(config.roomVidPlaytime / room.videoData.length); + const addRoomVideo = (room, loop) => { + if (Array.isArray(room)) { + for (var i = 0; i < room.length; i++) { + return addRoomVideo(room[i], loop); + } + } + + let loops = 1; + if (typeof loop === 'undefined' || loop === true) { + loops = Math.floor(config.roomVidPlaytime / room.videoData.length); + } console.log(`Adding ${loops} instances of room video for ${room.dungeonName} - ${room.roomName} to the queue`); let video = { @@ -171,11 +180,23 @@ const streamInit = (config, twitch) => { return; } - // filter recently played from shuffle - let freshVods = config.vods.alttp.filter(e => { - return e.includeInShuffle === true && !state.recentlyPlayed.includes(e.id); - }); - state.currentVideo = freshVods.sort(util.randSort).slice(0, 1).shift(); + // Random chance for room videos to be added + if ((Math.floor(Math.random() * 100) + 1) <= config.roomShuffleChance) { + console.log(`Room vids selected!`); + + let roomVid = config.rooms.sort(util.randSort).slice(0, 1); + + addRoomVideo(roomVid); + + // play the first one + state.currentVideo = state.videoQueue.shift(); + } else { + // filter recently played from shuffle + let freshVods = config.vods.alttp.filter(e => { + return e.includeInShuffle === true && !state.recentlyPlayed.includes(e.id); + }); + state.currentVideo = freshVods.sort(util.randSort).slice(0, 1).shift(); + } } showVideo(state.currentVideo);