Feast 2.0!
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

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