random chance for room vids

This commit is contained in:
Chris Ham
2018-09-25 22:06:15 -07:00
parent 2dad2a3bc5
commit b9568c7362
2 changed files with 31 additions and 8 deletions

View File

@@ -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
}

35
fgfm.js
View File

@@ -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);