adds dummy impls for targeted behaviours
This commit is contained in:
@@ -19,6 +19,13 @@ export const store = {
|
|||||||
state: {
|
state: {
|
||||||
player_id: 0,
|
player_id: 0,
|
||||||
show_player_chest: false,
|
show_player_chest: false,
|
||||||
|
// methods
|
||||||
|
isPlayer () {
|
||||||
|
this.player_id != 0
|
||||||
|
},
|
||||||
|
isGroup () {
|
||||||
|
this.player_id == 0
|
||||||
|
},
|
||||||
},
|
},
|
||||||
setActivePlayer (newPlayerId) {
|
setActivePlayer (newPlayerId) {
|
||||||
if (this.debug) console.log('setActivePlayer to ', newPlayerId)
|
if (this.debug) console.log('setActivePlayer to ', newPlayerId)
|
||||||
|
|||||||
@@ -1,22 +1,54 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<div class="container">
|
||||||
|
<p class="notification is-paddingless is-info" v-show="canAdd">Peut ajouter</p>
|
||||||
|
<p class="notification is-paddingless is-warning" v-show="canSell">Peut vendre</p>
|
||||||
|
<p class="notification is-paddingless is-primary" v-show="canGrab">Peut prendre</p>
|
||||||
<table class="table is-fullwidth is-striped">
|
<table class="table is-fullwidth is-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr><th>Objets de {{ player_id }}</th></tr>
|
<tr><th>Objets de {{ player }}</th></tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr><td>Nom 1</td></tr>
|
<template v-for="(item, idx) in content">
|
||||||
<tr><td>Nom 2</td></tr>
|
<tr :key="idx"><td>{{item.name}}</td></tr>
|
||||||
<tr><td>Nom 3</td></tr>
|
</template>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { store } from '../App.vue'
|
||||||
export default {
|
export default {
|
||||||
props: ["player_id"],
|
props: {
|
||||||
|
player: {
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
default: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
app_state: store.state,
|
||||||
|
content: [
|
||||||
|
{id: 10, name: "Épée longue +2 acérée"},
|
||||||
|
{id: 5, name: "Ceinture de force +6"},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
}
|
},
|
||||||
|
computed: {
|
||||||
|
// Can the active user sell items from this chest ?
|
||||||
|
canSell () {
|
||||||
|
return this.player == this.app_state.player_id;
|
||||||
|
},
|
||||||
|
// Can the user grab items from this chest ?
|
||||||
|
canGrab () {
|
||||||
|
return (this.app_state.player_id != 0 // User is not the group
|
||||||
|
&& this.player == 0); // This is the group chest
|
||||||
|
},
|
||||||
|
canAdd () {
|
||||||
|
return (this.app_state.player_id == 0
|
||||||
|
&& this.player == 0);
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<section id="main" class="section">
|
<section id="main" class="section">
|
||||||
<div id="main-heading" class="columns is-mobile is-vcentered">
|
<div id="main-heading" class="notification is-dark is-paddingless columns is-mobile is-vcentered">
|
||||||
<div class="column is-narrow">
|
<div class="column is-narrow">
|
||||||
<span class="icon is-large"><i class="fas fa-3x fa-gem"></i></span>
|
<span class="icon is-large"><i class="fas fa-2x fa-dragon"></i></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="column has-text-left">
|
<div class="column has-text-left">
|
||||||
<h1 class="title">Coffre de groupe</h1>
|
<h1 class="title">Coffre de groupe</h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Chest player_id="0"></Chest>
|
<Chest player="0"></Chest>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<div class="column is-one-third-desktop">
|
<div class="column is-one-third-desktop">
|
||||||
<div id="sidebar" class="card">
|
<div id="sidebar" class="card">
|
||||||
<header id="sidebar-heading" class="card-header">
|
<header id="sidebar-heading" class="card-header">
|
||||||
<p class="card-header-title">{{ player.name }}</p>
|
<p class="card-header-title">{{ name }}</p>
|
||||||
<div class="dropdown is-right"
|
<div class="dropdown is-right"
|
||||||
:class="{ 'is-active': show_dropdown }">
|
:class="{ 'is-active': show_dropdown }">
|
||||||
<div class="dropdown-trigger" ref="dropdown_btn">
|
<div class="dropdown-trigger" ref="dropdown_btn">
|
||||||
@@ -17,25 +17,30 @@
|
|||||||
<div class="dropdown-menu" id="dropdown-menu" role="menu"
|
<div class="dropdown-menu" id="dropdown-menu" role="menu"
|
||||||
v-closable="{ exclude: ['dropdown_btn'], handler: 'closeDropdown' }">
|
v-closable="{ exclude: ['dropdown_btn'], handler: 'closeDropdown' }">
|
||||||
<div class="dropdown-content">
|
<div class="dropdown-content">
|
||||||
<a href="#" class="dropdown-item">Féfi</a>
|
<a v-for="(p,i) in player_list" :key="i"
|
||||||
<a href="#" class="dropdown-item">Lomion</a>
|
@click="setActivePlayer(i)"
|
||||||
<a href="#" class="dropdown-item">Oilossë</a>
|
href="#" class="dropdown-item">
|
||||||
|
{{ p.name }}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<Wealth v-bind:wealth="player.wealth"></Wealth>
|
<Wealth v-bind:wealth="player.wealth"></Wealth>
|
||||||
|
<p class="notification is-warning" v-show="!playerIsGroup">Dette : {{ player.debt }}gp</p>
|
||||||
</div>
|
</div>
|
||||||
<footer class="card-footer">
|
<footer class="card-footer">
|
||||||
<a @click="switchPlayerChestVisibility" href="#" class="card-footer-item is-dark">Coffre</a>
|
<a @click="switchPlayerChestVisibility" v-show="!playerIsGroup"
|
||||||
|
href="#" class="card-footer-item is-dark">
|
||||||
|
Coffre
|
||||||
|
</a>
|
||||||
<a href="#" class="card-footer-item">Argent</a>
|
<a href="#" class="card-footer-item">Argent</a>
|
||||||
<a href="#" class="card-footer-item disabled">Historique</a>
|
<a href="#" class="card-footer-item disabled">Historique</a>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
<div class="card" v-show="app_state.show_player_chest" style="margin-top: 1em;">
|
<div class="card" v-show="app_state.show_player_chest" style="margin-top: 1em;">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<Chest player_id="0"></Chest>
|
<Chest :player="app_state.player_id"></Chest>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -55,15 +60,42 @@
|
|||||||
return {
|
return {
|
||||||
app_state: store.state,
|
app_state: store.state,
|
||||||
player: {
|
player: {
|
||||||
name: "Player name",
|
name: "Groupe",
|
||||||
wealth: [1000,100,10,1],
|
wealth: [1000,100,10,1],
|
||||||
|
debt: 0,
|
||||||
},
|
},
|
||||||
|
player_list: [
|
||||||
|
{id: 0, name: "Groupe"},
|
||||||
|
{id: 1, name: "Lomion"},
|
||||||
|
{id: 4, name: "Oilosse"},
|
||||||
|
{id: 3, name: "Fefi"},
|
||||||
|
],
|
||||||
show_dropdown: false,
|
show_dropdown: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
name () {
|
||||||
|
return this.player.name;
|
||||||
|
},
|
||||||
|
// Check if the active player is the special 'Group' player
|
||||||
|
playerIsGroup () {
|
||||||
|
return this.app_state.player_id == 0;
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
switchPlayerChestVisibility () {
|
switchPlayerChestVisibility () {
|
||||||
store.switchPlayerChestVisibility()
|
store.switchPlayerChestVisibility();
|
||||||
|
},
|
||||||
|
hidePlayerChest () {
|
||||||
|
if (this.app_state.show_player_chest) {
|
||||||
|
this.switchPlayerChestVisibility();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setActivePlayer (playerIdx) {
|
||||||
|
const newId = this.player_list[playerIdx].id;
|
||||||
|
store.setActivePlayer(newId);
|
||||||
|
if (newId == 0) { this.hidePlayerChest() }
|
||||||
|
this.player.name = this.player_list[playerIdx].name
|
||||||
},
|
},
|
||||||
closeDropdown () {
|
closeDropdown () {
|
||||||
this.show_dropdown = false
|
this.show_dropdown = false
|
||||||
@@ -84,7 +116,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!el.contains(e.target) && !excludedElClicked) {
|
if (!excludedElClicked) {
|
||||||
console.log('outsideCloseDropdown');
|
console.log('outsideCloseDropdown');
|
||||||
vnode.context[handler]()
|
vnode.context[handler]()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="container">
|
<div class="container is-fluid">
|
||||||
<span class="icon is-large">
|
<span class="icon is-large">
|
||||||
<i class="fas fa-2x fa-piggy-bank"></i>
|
<i class="fas fa-2x fa-piggy-bank"></i>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user