Feast 2.0!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

288 line
7.3 KiB

  1. <template>
  2. <div @click="$emit('select')" class="statblock">
  3. <div class="statblock-shader statblock-shader-hover"></div>
  4. <div class="statblock-shader statblock-shader-selected"></div>
  5. <div class="statblock-shader statblock-shader-selected-ally"></div>
  6. <div class="statblock-shader statblock-shader-dead"></div>
  7. <div class="statblock-shader statblock-shader-eaten"></div>
  8. <div class="statblock-content">
  9. <h2 class="name">
  10. {{subject.name.all.capital}}
  11. <div class="tooltip-template">
  12. <div class="tooltip-title">{{ subject.title }}</div>
  13. <div class="tooltip-body">{{ subject.desc }}</div>
  14. </div>
  15. </h2>
  16. <div class="stat-entry" v-for="vigor in Object.keys(subject.vigors)" v-bind:key="vigor">
  17. <div class="healthbar" v-bind:style="{'--fullness': (subject.vigors[vigor]/subject.maxVigors[vigor]*100) + '%', '--color': vigorColor(subject.vigors[vigor], subject.maxVigors[vigor]) }">
  18. <i :class="vigorIcons[vigor]" />
  19. <div class="healthbar-value"> {{ subject.vigors[vigor].toFixed(0) + '/' + subject.maxVigors[vigor].toFixed(0) }}</div>
  20. </div>
  21. <div class="tooltip-template">
  22. <div class="tooltip-title">{{ vigor }}</div>
  23. <div class="tooltip-body">{{ vigorDescs[vigor] }}</div>
  24. </div>
  25. </div>
  26. <div class="stat-line stats">
  27. <div :class="statClass(subject.stats[stat], subject.baseStats[stat])" v-for="stat in Object.keys(subject.stats)" v-bind:key="stat">
  28. <i :class="statIcons[stat]" />
  29. <div class="stat-value">{{subject.stats[stat].toFixed(0)}}</div>
  30. <div class="tooltip-template">
  31. <div class="tooltip-title">{{ stat }}</div>
  32. <div class="tooltip-body">{{ statDescs[stat] }}</div>
  33. </div>
  34. </div>
  35. </div>
  36. <div class="stat-line vore-stats">
  37. <div class="stat-entry" v-for="stat in Object.keys(subject.voreStats)" v-bind:key="stat">
  38. <i :class="voreStatIcons[stat]" />
  39. <div class="stat-value">{{subject.voreStats[stat].toFixed(0)}}</div>
  40. <div class="tooltip-template">
  41. <div class="tooltip-title">{{ stat }}</div>
  42. <div class="tooltip-body">{{ voreStatDescs[stat] }}</div>
  43. </div>
  44. </div>
  45. </div>
  46. <div>Status: {{subject.status}}</div>
  47. <button v-if="subject.perspective === POV.Third" @click.stop="subject.perspective = POV.Second">Second-person</button>
  48. <button v-if="subject.perspective === POV.First" @click.stop="subject.perspective = POV.Third">Third-person</button>
  49. <button v-if="subject.perspective === POV.Second" @click.stop="subject.perspective = POV.First">First-person</button>
  50. <button class="if-not-selected" @click.stop="$emit('selectAlly')">Select ally as target</button>
  51. </div>
  52. </div>
  53. </template>
  54. <script lang="ts">
  55. import { Component, Prop, Vue, Watch, Emit } from 'vue-property-decorator'
  56. import { Creature, POV } from '@/game/entity'
  57. import { Stats, Stat, StatIcons, StatDescs, Vigor, VigorIcons, VigorDescs, VoreStatDescs, VoreStatIcons } from '@/game/combat'
  58. import ContainerView from './ContainerView.vue'
  59. import tippy, { createSingleton } from 'tippy.js'
  60. import 'tippy.js/dist/tippy.css'
  61. @Component({
  62. components: {
  63. ContainerView
  64. },
  65. data () {
  66. return {
  67. POV: POV
  68. }
  69. },
  70. methods: {
  71. vigorColor (value: number, max: number) {
  72. if (value * 5 <= max) {
  73. return 'red'
  74. } else if (value * 3 <= max) {
  75. return 'yellow'
  76. } else {
  77. return 'green'
  78. }
  79. },
  80. statClass (value: number, normal: number) {
  81. if (value < normal) {
  82. return 'stat-entry crit'
  83. } else if (value > normal) {
  84. return 'stat-entry buff'
  85. } else {
  86. return 'stat-entry'
  87. }
  88. }
  89. }
  90. })
  91. export default class Statblock extends Vue {
  92. @Prop({ type: Creature, required: true })
  93. subject!: Creature
  94. private vigorIcons = VigorIcons
  95. private statIcons = StatIcons
  96. private voreStatIcons = VoreStatIcons
  97. private vigorDescs = VigorDescs
  98. private statDescs = StatDescs
  99. private voreStatDescs = VoreStatDescs
  100. private vigor = Vigor
  101. firstperson: POV = POV.First
  102. thirdperson: POV = POV.Third
  103. mounted () {
  104. const statEntries = Array.from(this.$el.querySelectorAll(".stat-entry"))
  105. const name = Array.from(this.$el.querySelectorAll(".name"))
  106. const tippyInstances = statEntries.concat(name).map(elem => {
  107. const tooltip = elem.querySelector(".tooltip-template") as HTMLElement
  108. return tippy(elem, {
  109. content: tooltip
  110. })
  111. })
  112. createSingleton(tippyInstances, { delay: 500 })
  113. }
  114. }
  115. </script>
  116. <!-- Add "scoped" attribute to limit CSS to this component only -->
  117. <style scoped>
  118. h2 {
  119. margin-bottom: 8pt;
  120. font-size: 200%;
  121. }
  122. ul {
  123. list-style-type: none;
  124. padding: 0;
  125. }
  126. li {
  127. display: inline-block;
  128. margin: 0 10px;
  129. }
  130. a {
  131. color: #42b983;
  132. }
  133. .statblock {
  134. flex: 1 0;
  135. flex-basis: 100pt;
  136. margin: 0pt 4pt 0pt;
  137. user-select: none;
  138. position: relative;
  139. overflow: hidden;
  140. background: none;
  141. border-radius: 10px;
  142. }
  143. .stat-line {
  144. width: 100%;
  145. display: flex;
  146. justify-content: space-evenly;
  147. flex-wrap: wrap;
  148. }
  149. .stat-entry {
  150. position: relative;
  151. font-size: 10pt;
  152. padding-top: 2pt;
  153. padding-bottom: 2pt;
  154. display: flex;
  155. flex-direction: column;
  156. justify-content: space-evenly;
  157. align-items: center;
  158. user-select: none;
  159. text-align: center;
  160. }
  161. .stat-value {
  162. position: absolute;
  163. transform: translate(0, 8pt);
  164. padding-top: 4pt;
  165. padding-bottom: 4pt;
  166. }
  167. .healthbar {
  168. display: flex;
  169. align-items: center;
  170. justify-content: space-between;
  171. --color: green;
  172. --fullness: 100%;
  173. position: relative;
  174. width: 90%;
  175. margin: 0% 5% 0%;
  176. height: 14pt;
  177. border-radius: 2pt;
  178. border-width: 2pt;
  179. border-color: gray;
  180. border-style: outset;
  181. background: linear-gradient(90deg, var(--color) var(--fullness), black var(--fullness), black);
  182. }
  183. .stat-entry .healthbar i {
  184. flex: 0 1;
  185. flex-basis: 20pt;
  186. font-size: 14pt;
  187. }
  188. .healthbar .healthbar-value {
  189. flex: 1 0;
  190. font-size: 12pt;
  191. color: #bbb;
  192. }
  193. .stat-entry > i {
  194. font-size: 16pt;
  195. width: 16pt;
  196. margin-bottom: 18pt;
  197. }
  198. .stat-entry.low {
  199. color: yellow;
  200. }
  201. .stat-entry.crit {
  202. color: red;
  203. }
  204. .stat-entry.buff {
  205. color: green;
  206. }
  207. .statblock-content {
  208. position: relative;
  209. width: 100%;
  210. height: 100%;
  211. background: none;
  212. }
  213. .statblock-shader {
  214. position: absolute;
  215. width: 100%;
  216. height: 100%;
  217. opacity: 0%;
  218. pointer-events: none;
  219. z-index: 0;
  220. }
  221. .statblock[data-eaten] .statblock-shader-eaten {
  222. background: green;
  223. opacity: 0.35;
  224. }
  225. .statblock[data-active] .statblock-shader-selected {
  226. background: white;
  227. opacity: 0.15;
  228. }
  229. .statblock[data-active-ally] .statblock-shader-selected-ally {
  230. background: #88f;
  231. opacity: 0.20;
  232. }
  233. .statblock[data-dead] .statblock-shader-dead {
  234. background: red;
  235. opacity: 0.50;
  236. }
  237. .statblock:hover .statblock-shader-hover {
  238. background: white;
  239. opacity: 0.20;
  240. }
  241. .statblock[data-active] .if-not-selected {
  242. display: none;
  243. }
  244. </style>
  245. <style>
  246. .left-stats .stat-entry::after {
  247. transform: translate(calc(0% + 16pt), -100%);
  248. }
  249. .left-stats .stat-entry::before {
  250. transform: translate(calc(0% + 16pt), calc(-100% + 18pt + 16pt));
  251. }
  252. .right-stats .stat-entry::after {
  253. transform: translate(calc(-100% + 16pt), -100%);
  254. }
  255. .right-stats .stat-entry::before {
  256. transform: translate(calc(-100% + 16pt), calc(-100% + 18pt + 16pt));
  257. }
  258. </style>