-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from samdems/develop
Develop
- Loading branch information
Showing
7 changed files
with
80 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,74 @@ | ||
<template> | ||
<button class="btn" onclick="newPlayerModal.showModal()"> Manage players | ||
</button> | ||
<dialog id="newPlayerModal" class="modal"> | ||
<div class="modal-box"> | ||
<h3 class="font-bold text-lg">Add new player</h3> | ||
<p>current players: </p> | ||
<span class="text-sm">press to remove</span> | ||
<div class="flex gap-2 flex-wrap items-center"> | ||
<div | ||
class="badge badge-primary cursor-pointer" | ||
v-for="player in playersStore.players" | ||
:key="player.id" | ||
@click="playersStore.removePlayer(player.id)" | ||
> | ||
{{player.name}} | ||
<button class="btn" onclick="newPlayerModal.showModal()"> | ||
Manage players | ||
</button> | ||
<dialog id="newPlayerModal" class="modal"> | ||
<div class="modal-box"> | ||
<h3 class="font-bold text-lg">Manage Players</h3> | ||
<table class="table table-compact table-zebra"> | ||
<tbody> | ||
<tr class="" v-for="player in playersStore.players" :key="player.id"> | ||
<td class="p-0" >{{ player.name }}</td> | ||
<td class="p-2"> | ||
<Selector | ||
:value="player.authority" | ||
color="primary" | ||
size="sm" | ||
:increment="() => playersStore.increment(player.id,'authority')" | ||
:decrement="() => playersStore.decrement(player.id,'authority')" | ||
/> | ||
</td> | ||
<td class="p-1"> | ||
<button class="btn btn-sm btn-error" @click="playersStore.removePlayer(player.id)"> | ||
X | ||
</button> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<div class="divider"></div> | ||
<div class="text-error mb-2">{{ alert }}</div> | ||
<div class="flex justify-around gap-2"> | ||
<input | ||
v-model="name" | ||
type="text" | ||
placeholder="Name" | ||
class="input input-bordered w-40" | ||
@keyup.enter="addPlayer" | ||
/> | ||
<input v-model="authority" type="number" placeholder="Authority" class="input input-bordered w-20" /> | ||
<button @click="addPlayer" class="btn btn-primary ms-2">Add</button> | ||
</div> | ||
<div class="modal-action"> | ||
<button class="btn" onclick="newPlayerModal.close()">Close</button> | ||
</div> | ||
</div> | ||
<div class="divider"></div> | ||
<div class="text-error">{{alert}}</div> | ||
<input v-model="name" type="text" placeholder="Name" class="input input-bordered" @keyup.enter="addPlayer" | ||
/> | ||
<div class="modal-action"> | ||
<button @click="addPlayer" class="btn btn-primary">Add</button> | ||
<button class="btn" onclick="newPlayerModal.close()">Close</button> | ||
</div> | ||
</div> | ||
</dialog> | ||
</dialog> | ||
</template> | ||
|
||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue'; | ||
import { usePlayersStore } from '../stores/playersStore'; | ||
import { ref } from "vue"; | ||
import { usePlayersStore } from "../stores/playersStore"; | ||
import Selector from "./Selector.vue"; | ||
const playersStore = usePlayersStore(); | ||
const name = ref(''); | ||
const alert = ref(''); | ||
const name = ref(""); | ||
const alert = ref(""); | ||
const authority = ref(50); | ||
const addPlayer = () => { | ||
if (!name.value) { | ||
alert.value = 'Name is required'; | ||
alert.value = "Name is required"; | ||
return; | ||
} | ||
const id = Math.random().toString(36).substr(2, 9) | ||
playersStore.addPlayer({id, name: name.value, authority: 50, combat: 0, trade: 0}); | ||
name.value = ''; | ||
const id = Math.random().toString(36).substr(2, 9); | ||
playersStore.addPlayer({ | ||
id, | ||
name: name.value, | ||
authority: authority.value , | ||
combat: 0, | ||
trade: 0, | ||
}); | ||
name.value = ""; | ||
}; | ||
</script> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters