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>
|
||||
</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">
|
||||
<span>Winning Score: {{ winningScore }}</span>
|
||||
@@ -64,10 +74,11 @@ export default {
|
||||
show: false,
|
||||
checkboxStopAfterCurrent: false,
|
||||
checkboxHideTitle: false,
|
||||
checkboxLowPlayed: false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapState(["winningScore", "roundStarted", "stopAfterCurrent", "hideNextTrack"]),
|
||||
...mapState(["winningScore", "roundStarted", "stopAfterCurrent", "hideNextTrack", "lowPlayed"]),
|
||||
},
|
||||
methods: {
|
||||
closeModal() {
|
||||
@@ -88,6 +99,13 @@ export default {
|
||||
this.$store.dispatch("updateHideNextTitle", false);
|
||||
}
|
||||
},
|
||||
updateOptionLowPlayed() {
|
||||
if (this.checkboxLowPlayed) {
|
||||
this.$store.dispatch("updateLowPlayed", true);
|
||||
} else {
|
||||
this.$store.dispatch("updateLowPlayed", false);
|
||||
}
|
||||
},
|
||||
updateOptionStopAfterCurrent() {
|
||||
if (this.checkboxStopAfterCurrent) {
|
||||
this.$store.dispatch("updateStopAfterCurrent", true);
|
||||
@@ -106,6 +124,7 @@ export default {
|
||||
mounted() {
|
||||
this.checkboxStopAfterCurrent = this.stopAfterCurrent;
|
||||
this.checkboxHideTitle = this.hideNextTrack;
|
||||
this.checkboxLowPlayed = this.lowPlayed;
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
alt="closeModalIMG"
|
||||
@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>
|
||||
@@ -28,6 +29,12 @@ export default {
|
||||
closeModal() {
|
||||
this.show = false;
|
||||
},
|
||||
showPeter() {
|
||||
let randomNumber = Math.floor(Math.random() * 10);
|
||||
console.log(randomNumber);
|
||||
console.log("Test");
|
||||
return randomNumber < 2;
|
||||
},
|
||||
openModal(playerName) {
|
||||
this.playerName = playerName;
|
||||
this.show = true;
|
||||
|
||||
@@ -44,6 +44,7 @@ export default {
|
||||
"hideNextTrack",
|
||||
"roundStarted",
|
||||
"specialTrackIsPlaying",
|
||||
"lowPlayed",
|
||||
]),
|
||||
},
|
||||
methods: {
|
||||
@@ -59,7 +60,11 @@ export default {
|
||||
//If the local playlist of MP3s is empty, wait for a new track to load
|
||||
if (copyOfPlaylist.length === 0) {
|
||||
console.log("No track preloaded, loading a new one");
|
||||
if (this.lowPlayed) {
|
||||
await this.APIgetRandomizedLowTrack();
|
||||
} else {
|
||||
await this.APIgetRandomizedTrack();
|
||||
}
|
||||
await this.APIaddToQue();
|
||||
trackAddedToQue = true;
|
||||
}
|
||||
@@ -86,7 +91,11 @@ export default {
|
||||
async randomizeTrackInAdvance() {
|
||||
console.log("Randomizing track in advance");
|
||||
try {
|
||||
if (this.lowPlayed) {
|
||||
await this.APIgetRandomizedLowTrack();
|
||||
} else {
|
||||
await this.APIgetRandomizedTrack();
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
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() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.axios({
|
||||
|
||||
@@ -30,6 +30,7 @@ const store = createStore({
|
||||
/* Options */
|
||||
stopAfterCurrent: true,
|
||||
hideNextTrack: true,
|
||||
lowPlayed: false,
|
||||
};
|
||||
},
|
||||
mutations: {
|
||||
@@ -93,6 +94,9 @@ const store = createStore({
|
||||
updateHideNextTitle(state, payload) {
|
||||
state.hideNextTrack = payload;
|
||||
},
|
||||
updateLowPlayed(state, payload) {
|
||||
state.lowPlayed = payload;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
setCurrentGame(context, payload) {
|
||||
@@ -203,6 +207,9 @@ const store = createStore({
|
||||
updateHideNextTitle(context, payload) {
|
||||
context.commit("updateHideNextTitle", payload);
|
||||
},
|
||||
updateLowPlayed(context, payload) {
|
||||
context.commit("updateLowPlayed", payload);
|
||||
},
|
||||
},
|
||||
|
||||
getters: {
|
||||
|
||||
Reference in New Issue
Block a user