Feat: skip me

This commit is contained in:
Dorian Zedler 2023-01-05 18:50:55 +01:00
parent 425ae6a1e5
commit 6d5f4047e2
Signed by: dorian
GPG key ID: 989DE36109AFA354
3 changed files with 17 additions and 2 deletions

View file

@ -28,6 +28,10 @@
margin-top: 2.5em; margin-top: 2.5em;
} }
.mb {
margin-bottom: var(--spacing) !important;
}
.first-details { .first-details {
padding-top: var(--spacing); padding-top: var(--spacing);
border-bottom: var(--border-width) solid var(--accordion-border-color); border-bottom: var(--border-width) solid var(--accordion-border-color);

View file

@ -31,11 +31,17 @@
x-text="time + 's'"></p> x-text="time + 's'"></p>
</div> </div>
<button @click="$store.remoteState.giveTurnToNextPlayer()" <button x-show="!$store.remoteState.skipMe" @click="$store.remoteState.giveTurnToNextPlayer()"
x-bind:disabled="$store.remoteState.currentPlayer !== $store.localState.id"> x-bind:disabled="$store.remoteState.currentPlayer !== $store.localState.id">
I'm done! I'm done!
</button> </button>
<label for="skip_switch" class="mb">
<input x-model="$store.remoteState.skipMe"
type="checkbox" id="skip_switch" role="switch" />
Skip me
</label>
<details class="first-details"> <details class="first-details">
<summary>Options</summary> <summary>Options</summary>

View file

@ -6,6 +6,7 @@ document.addEventListener("alpine:init", () => {
lastPlayerSwitch: null, lastPlayerSwitch: null,
connected: false, connected: false,
isMyTurn: false, isMyTurn: false,
skipMe: false,
_client: null, _client: null,
_currentPlayerTopic: null, _currentPlayerTopic: null,
@ -29,9 +30,13 @@ document.addEventListener("alpine:init", () => {
}); });
Alpine.effect(() => { Alpine.effect(() => {
if (this.currentPlayer == Alpine.store("localState").id) { const myTurn = this.currentPlayer == Alpine.store("localState").id
if (myTurn && !this.skipMe) {
this.isMyTurn = true; this.isMyTurn = true;
Alpine.store("audio").playDing(); Alpine.store("audio").playDing();
}
else if(myTurn && this.skipMe) {
this.giveTurnToNextPlayer()
} else { } else {
this.isMyTurn = false; this.isMyTurn = false;
} }