11<template >
2- <div class =" properties player-info-box" >
3- <h4 style =" text-decoration : underline ; font-weight : bold ;" @click =" selectEntity(info)"
4- :class =" {'selected': info.selected, 'targetable': currentAction !== null && targets.indexOf(info.id) !== -1}" >{{info.name}}</h4 >
5- <ul style =" list-style : none outside none ; margin : 0 ; padding : 0 ;" >
6- <li v-for =" (value, name) in info.properties" :key =" name" >
7- <b >{{name | formatResourceName}}</b >: {{value}}
8- </li >
9- <li ><b >Cards: </b >{{ info.zones.Hand ? info.zones.Hand.length() : "?" }}</li >
10- </ul >
11- <!-- Action buttons -->
12- <div class =" player-actions" >
13- <div v-for =" action in actions" v-if =" action.isPlayer && action.id == info.id" :key =" action.action" >
14- <input @click =" startAction(action)" v-show =" currentAction === null" type =" button" :value =" action.action"
15- class =" btn btn-navbar csh-button" />
16- </div >
17- <div v-show =" showActions && currentAction != null" >
18- <input @click =" cancelAction()" type =" button" value =" Cancel"
19- class =" btn btn-navbar csh-button" />
20- <input @click =" performAction()" type =" button" :value =" currentAction ? currentAction.action : '(None)'"
21- class =" btn btn-navbar csh-button" />
2+ <div class =" properties player-info-box" >
3+ <h4 style =" font-weight : bold ;" @click =" selectEntity(info)"
4+ :class =" {'selected': info.selected, 'targetable': currentAction !== null && targets.indexOf(info.id) !== -1}" >
5+ {{info.name}}
6+ </h4 >
7+ <ul style =" list-style : none outside none ; margin : 0 ; padding : 0 ;" >
8+ <!-- HEALTH & MAX_HEALTH -->
9+ <li v-for =" (value, name) in arrangePlayerData(info.properties)" :key =" name" >
10+ <span v-if =" name === 'health'" style =" font-weight : bold ; font-size : 1.0em ;" >
11+ {{name | formatResourceName}}:
12+ </span >
13+ <span v-if =" name === 'health'" style =" font-size : 1.0em ;" >
14+ {{value["current"] + " / " + value["max"]}}
15+ </span >
16+ </li >
17+ <!-- MANA & MAX_MANA -->
18+ <li v-for =" (value, name) in arrangePlayerData(info.properties)" :key =" name" >
19+ <span v-if =" name === 'mana'" style =" font-weight : bold ; font-size : 1.0em ;" >
20+ {{name | formatResourceName}}:
21+ </span >
22+ <span v-if =" name === 'mana'" style =" font-size : 1.0em ;" >
23+ {{value["current"] + " / " + value["max"]}}
24+ </span >
25+ </li >
26+ <!-- SCRAP -->
27+ <li v-for =" (value, name) in arrangePlayerData(info.properties)" :key =" name" >
28+ <span v-if =" name === 'scrap'" style =" font-weight : bold ; font-size : 1.0em ;" >
29+ {{name | formatResourceName}}:
30+ </span >
31+ <span v-if =" name === 'scrap'" style =" font-size : 1.0em ;" >
32+ {{value["current"]}}
33+ </span >
34+ </li >
35+ <!-- CARDS -->
36+ <li >
37+ <span style =" font-weight : bold ; font-size : 1.0em ;" >
38+ Cards:
39+ </span >
40+ <span style =" font-size : 1.0em ;" >
41+ {{ info.zones.Hand ? info.zones.Hand.length() : "?" }}
42+ </span >
43+ </li >
44+ </ul >
45+ <!-- Action buttons -->
46+ <div class =" player-actions" >
47+ <div v-for =" action in actions" v-if =" action.isPlayer && action.id == info.id" :key =" action.action" >
48+ <input @click =" startAction(action)" v-show =" currentAction === null" type =" button" :value =" action.action"
49+ class =" btn btn-navbar csh-button" />
50+ </div >
51+ <div v-show =" showActions && currentAction != null" >
52+ <input @click =" cancelAction()" type =" button" value =" Cancel"
53+ class =" btn btn-navbar csh-button" />
54+ <input @click =" performAction()" type =" button" :value =" currentAction ? currentAction.action : '(None)'"
55+ class =" btn btn-navbar csh-button" />
56+ </div >
2257 </div >
2358 </div >
24- </div >
2559</template >
2660<script >
2761export default {
@@ -32,6 +66,36 @@ export default {
3266 input = input .replace (/ _/ g , ' ' );
3367 return input .substring (0 , 1 ).toUpperCase () + input .substring (1 ).toLowerCase ();
3468 }
69+ },
70+ methods: {
71+ arrangePlayerData (playerData ) {
72+ const rawData = playerData;
73+ const arrangedData = {
74+ health: {},
75+ mana: {},
76+ scrap: {}
77+ };
78+ for (let key in rawData) {
79+ console .log (key + " =" + rawData[key]);
80+ if (key === " HEALTH" ) {
81+ arrangedData .health [" current" ] = rawData[key];
82+ }
83+ if (key === " MAX_HEALTH" ) {
84+ arrangedData .health [" max" ] = rawData[key];
85+ }
86+ if (key === " MANA" ) {
87+ arrangedData .mana [" current" ] = rawData[key];
88+ }
89+ if (key === " MAX_MANA" ) {
90+ arrangedData .mana [" max" ] = rawData[key];
91+ }
92+ if (key === " SCRAP" ) {
93+ arrangedData .scrap [" current" ] = rawData[key];
94+ }
95+ }
96+ console .log (arrangedData);
97+ return arrangedData;
98+ }
3599 }
36100}
37101 </script >
0 commit comments