Added option to using low played
Added Easter egg
This commit is contained in:
@@ -32,6 +32,16 @@
|
|||||||
/>
|
/>
|
||||||
<label for="hideTitle">Hide next track</label>
|
<label for="hideTitle">Hide next track</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="checkboxDiv">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="lowPlayed"
|
||||||
|
id="lowPlayed"
|
||||||
|
v-model="checkboxLowPlayed"
|
||||||
|
@change="updateOptionLowPlayed"
|
||||||
|
/>
|
||||||
|
<label for="lowPlayed">Use low played mode</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="winningScoreDiv">
|
<div class="winningScoreDiv">
|
||||||
<span>Winning Score: {{ winningScore }}</span>
|
<span>Winning Score: {{ winningScore }}</span>
|
||||||
@@ -64,10 +74,11 @@ export default {
|
|||||||
show: false,
|
show: false,
|
||||||
checkboxStopAfterCurrent: false,
|
checkboxStopAfterCurrent: false,
|
||||||
checkboxHideTitle: false,
|
checkboxHideTitle: false,
|
||||||
|
checkboxLowPlayed: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(["winningScore", "roundStarted", "stopAfterCurrent", "hideNextTrack"]),
|
...mapState(["winningScore", "roundStarted", "stopAfterCurrent", "hideNextTrack", "lowPlayed"]),
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
closeModal() {
|
closeModal() {
|
||||||
@@ -88,6 +99,13 @@ export default {
|
|||||||
this.$store.dispatch("updateHideNextTitle", false);
|
this.$store.dispatch("updateHideNextTitle", false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
updateOptionLowPlayed() {
|
||||||
|
if (this.checkboxLowPlayed) {
|
||||||
|
this.$store.dispatch("updateLowPlayed", true);
|
||||||
|
} else {
|
||||||
|
this.$store.dispatch("updateLowPlayed", false);
|
||||||
|
}
|
||||||
|
},
|
||||||
updateOptionStopAfterCurrent() {
|
updateOptionStopAfterCurrent() {
|
||||||
if (this.checkboxStopAfterCurrent) {
|
if (this.checkboxStopAfterCurrent) {
|
||||||
this.$store.dispatch("updateStopAfterCurrent", true);
|
this.$store.dispatch("updateStopAfterCurrent", true);
|
||||||
@@ -106,6 +124,7 @@ export default {
|
|||||||
mounted() {
|
mounted() {
|
||||||
this.checkboxStopAfterCurrent = this.stopAfterCurrent;
|
this.checkboxStopAfterCurrent = this.stopAfterCurrent;
|
||||||
this.checkboxHideTitle = this.hideNextTrack;
|
this.checkboxHideTitle = this.hideNextTrack;
|
||||||
|
this.checkboxLowPlayed = this.lowPlayed;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
alt="closeModalIMG"
|
alt="closeModalIMG"
|
||||||
@click="closeModal"
|
@click="closeModal"
|
||||||
/>
|
/>
|
||||||
<h1>{{ playerName }} won!!</h1>
|
<h1 v-if="showPeter()">Pete... I mean {{ playerName }} won!!</h1>
|
||||||
|
<h1 v-else>{{ playerName }} won!!</h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -28,6 +29,12 @@ export default {
|
|||||||
closeModal() {
|
closeModal() {
|
||||||
this.show = false;
|
this.show = false;
|
||||||
},
|
},
|
||||||
|
showPeter() {
|
||||||
|
let randomNumber = Math.floor(Math.random() * 10);
|
||||||
|
console.log(randomNumber);
|
||||||
|
console.log("Test");
|
||||||
|
return randomNumber < 2;
|
||||||
|
},
|
||||||
openModal(playerName) {
|
openModal(playerName) {
|
||||||
this.playerName = playerName;
|
this.playerName = playerName;
|
||||||
this.show = true;
|
this.show = true;
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ export default {
|
|||||||
"hideNextTrack",
|
"hideNextTrack",
|
||||||
"roundStarted",
|
"roundStarted",
|
||||||
"specialTrackIsPlaying",
|
"specialTrackIsPlaying",
|
||||||
|
"lowPlayed",
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -59,7 +60,11 @@ export default {
|
|||||||
//If the local playlist of MP3s is empty, wait for a new track to load
|
//If the local playlist of MP3s is empty, wait for a new track to load
|
||||||
if (copyOfPlaylist.length === 0) {
|
if (copyOfPlaylist.length === 0) {
|
||||||
console.log("No track preloaded, loading a new one");
|
console.log("No track preloaded, loading a new one");
|
||||||
|
if (this.lowPlayed) {
|
||||||
|
await this.APIgetRandomizedLowTrack();
|
||||||
|
} else {
|
||||||
await this.APIgetRandomizedTrack();
|
await this.APIgetRandomizedTrack();
|
||||||
|
}
|
||||||
await this.APIaddToQue();
|
await this.APIaddToQue();
|
||||||
trackAddedToQue = true;
|
trackAddedToQue = true;
|
||||||
}
|
}
|
||||||
@@ -86,7 +91,11 @@ export default {
|
|||||||
async randomizeTrackInAdvance() {
|
async randomizeTrackInAdvance() {
|
||||||
console.log("Randomizing track in advance");
|
console.log("Randomizing track in advance");
|
||||||
try {
|
try {
|
||||||
|
if (this.lowPlayed) {
|
||||||
|
await this.APIgetRandomizedLowTrack();
|
||||||
|
} else {
|
||||||
await this.APIgetRandomizedTrack();
|
await this.APIgetRandomizedTrack();
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
console.log("Error: A track couldn't be loaded in advance");
|
console.log("Error: A track couldn't be loaded in advance");
|
||||||
@@ -169,6 +178,36 @@ export default {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
APIgetRandomizedLowTrack() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
this.axios({
|
||||||
|
method: "get",
|
||||||
|
url: `${arne.hostname}/music/rand/low`,
|
||||||
|
responseType: "blob",
|
||||||
|
onDownloadProgress: (progressEvent) => {
|
||||||
|
let percentCompleted = Math.round(
|
||||||
|
(progressEvent.loaded * 100) / progressEvent.total
|
||||||
|
);
|
||||||
|
if (percentCompleted % 10 == 0) {
|
||||||
|
//Debug for slow downloading
|
||||||
|
//console.log(percentCompleted);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
let mp3 = new Blob([response.data], { type: "audio/mp3" });
|
||||||
|
this.$store.dispatch("updateLocalPlaylist", mp3);
|
||||||
|
this.$nextTick(() => {
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
console.log("An error happened when fetching the track");
|
||||||
|
console.log(error);
|
||||||
|
reject();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
APIaddToQue() {
|
APIaddToQue() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.axios({
|
this.axios({
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ const store = createStore({
|
|||||||
/* Options */
|
/* Options */
|
||||||
stopAfterCurrent: true,
|
stopAfterCurrent: true,
|
||||||
hideNextTrack: true,
|
hideNextTrack: true,
|
||||||
|
lowPlayed: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
@@ -93,6 +94,9 @@ const store = createStore({
|
|||||||
updateHideNextTitle(state, payload) {
|
updateHideNextTitle(state, payload) {
|
||||||
state.hideNextTrack = payload;
|
state.hideNextTrack = payload;
|
||||||
},
|
},
|
||||||
|
updateLowPlayed(state, payload) {
|
||||||
|
state.lowPlayed = payload;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
setCurrentGame(context, payload) {
|
setCurrentGame(context, payload) {
|
||||||
@@ -203,6 +207,9 @@ const store = createStore({
|
|||||||
updateHideNextTitle(context, payload) {
|
updateHideNextTitle(context, payload) {
|
||||||
context.commit("updateHideNextTitle", payload);
|
context.commit("updateHideNextTitle", payload);
|
||||||
},
|
},
|
||||||
|
updateLowPlayed(context, payload) {
|
||||||
|
context.commit("updateLowPlayed", payload);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
getters: {
|
getters: {
|
||||||
|
|||||||
Reference in New Issue
Block a user