Feast 2.0!
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

416 lignes
10 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 marching-ants"></div>
  5. <div class="statblock-shader statblock-shader-selected-ally marching-ants"></div>
  6. <div class="statblock-shader statblock-shader-current-turn marching-ants"></div>
  7. <div class="statblock-shader statblock-shader-dead">
  8. <i class="fas fa-skull-crossbones" />
  9. </div>
  10. <div class="statblock-shader statblock-shader-eaten"></div>
  11. <div class="statblock-content">
  12. <h2 class="name">
  13. {{subject.name.all.capital.objective}}
  14. <div class="tooltip-template">
  15. <div class="tooltip-title">{{ subject.title }}</div>
  16. <div class="tooltip-body">{{ subject.desc }}</div>
  17. </div>
  18. </h2>
  19. <div> Initiative: {{ (initiative).toFixed(0) }}%</div>
  20. <div class="statblock-status-icons">
  21. <i :class="status.icon" v-for="(status, index) in subject.status" :key="'status' + index">
  22. <div class="statblock-status-icon-topleft">{{ status.topLeft }}</div>
  23. <div class="statblock-status-icon-bottomright">{{ status.bottomRight }}</div>
  24. <div class="tooltip-template">
  25. <div class="tooltip-title">{{ status.name }}</div>
  26. <div class="tooltip-body">{{ status.desc }}</div>
  27. </div>
  28. </i>
  29. </div>
  30. <div class="stat-entry" v-for="vigor in Object.keys(subject.vigors)" v-bind:key="vigor">
  31. <div class="healthbar" v-bind:style="{'--fullness': (subject.vigors[vigor]/subject.maxVigors[vigor]*100) + '%', '--color': vigorColor(subject.vigors[vigor], subject.maxVigors[vigor]) }">
  32. <i :class="vigorIcons[vigor]" />
  33. <div class="healthbar-value"> {{ subject.vigors[vigor].toFixed(0) + '/' + subject.maxVigors[vigor].toFixed(0) }}</div>
  34. </div>
  35. <div class="tooltip-template">
  36. <div class="tooltip-title">{{ vigor }}</div>
  37. <div class="tooltip-body">{{ vigorDescs[vigor] }}</div>
  38. </div>
  39. </div>
  40. <div class="stat-line stats">
  41. <div :class="statClass(subject.stats[stat], subject.baseStats[stat])" v-for="stat in Object.keys(subject.stats)" v-bind:key="stat">
  42. <i :class="statIcons[stat]" />
  43. <div class="stat-value">{{subject.stats[stat].toFixed(0)}}</div>
  44. <div class="tooltip-template">
  45. <div class="tooltip-title">{{ stat }}</div>
  46. <div class="tooltip-body">{{ statDescs[stat] }}</div>
  47. </div>
  48. </div>
  49. </div>
  50. <div class="stat-line vore-stats">
  51. <div class="stat-entry" v-for="stat in Object.keys(subject.voreStats)" v-bind:key="stat">
  52. <i :class="voreStatIcons[stat]" />
  53. <div class="stat-value">{{subject.voreStats[stat].toFixed(0)}}</div>
  54. <div class="tooltip-template">
  55. <div class="tooltip-title">{{ stat }}</div>
  56. <div class="tooltip-body">{{ voreStatDescs[stat] }}</div>
  57. </div>
  58. </div>
  59. </div>
  60. <button @click.stop="$emit('selectPredator')" v-if="subject.containedIn !== null">Select predator</button>
  61. <button v-if="subject.perspective === POV.Third" @click.stop="subject.perspective = POV.Second">Second-person</button>
  62. <button v-if="subject.perspective === POV.First" @click.stop="subject.perspective = POV.Third">Third-person</button>
  63. <button v-if="subject.perspective === POV.Second" @click.stop="subject.perspective = POV.First">First-person</button>
  64. </div>
  65. </div>
  66. </template>
  67. <script lang="ts">
  68. import { Component, Prop, Vue, Watch, Emit } from 'vue-property-decorator'
  69. import { Creature } from '@/game/creature'
  70. import { POV } from '@/game/language'
  71. import { Stats, Stat, StatIcons, StatDescs, Vigor, VigorIcons, VigorDescs, VoreStatDescs, VoreStatIcons, VisibleStatus } from '@/game/combat'
  72. import ContainerView from './ContainerView.vue'
  73. import tippy, { delegate, createSingleton } from 'tippy.js'
  74. import 'tippy.js/dist/tippy.css'
  75. @Component({
  76. components: {
  77. ContainerView
  78. },
  79. data () {
  80. return {
  81. POV: POV
  82. }
  83. },
  84. methods: {
  85. vigorColor (value: number, max: number) {
  86. if (value * 5 <= max) {
  87. return 'red'
  88. } else if (value * 3 <= max) {
  89. return 'yellow'
  90. } else {
  91. return 'green'
  92. }
  93. },
  94. statClass (value: number, normal: number) {
  95. if (value < normal) {
  96. return 'stat-entry crit'
  97. } else if (value > normal) {
  98. return 'stat-entry buff'
  99. } else {
  100. return 'stat-entry'
  101. }
  102. }
  103. }
  104. })
  105. export default class Statblock extends Vue {
  106. @Prop({ type: Creature, required: true })
  107. subject!: Creature
  108. @Prop()
  109. initiative!: number
  110. firstperson: POV = POV.First
  111. thirdperson: POV = POV.Third
  112. private vigorIcons = VigorIcons
  113. private statIcons = StatIcons
  114. private voreStatIcons = VoreStatIcons
  115. private vigorDescs = VigorDescs
  116. private statDescs = StatDescs
  117. private voreStatDescs = VoreStatDescs
  118. private vigor = Vigor
  119. @Watch('subject.status')
  120. private statusChanged (a: Array<VisibleStatus>) {
  121. this.$nextTick(() => {
  122. const icons = Array.from(this.$el.querySelectorAll(".statblock-status-icons i")) as Array<HTMLElement>
  123. icons.map(elem => {
  124. const tooltip = elem.querySelector(".tooltip-template") as HTMLElement
  125. console.log(elem, tooltip)
  126. return tippy(elem, {
  127. content: tooltip
  128. })
  129. })
  130. })
  131. }
  132. mounted () {
  133. const statEntries = Array.from(this.$el.querySelectorAll(".stat-entry"))
  134. const name = Array.from(this.$el.querySelectorAll(".name"))
  135. const tippyInstances = statEntries.concat(name).map(elem => {
  136. const tooltip = elem.querySelector(".tooltip-template") as HTMLElement
  137. return tippy(elem, {
  138. content: tooltip
  139. })
  140. })
  141. createSingleton(tippyInstances, { delay: 500 })
  142. this.statusChanged([])
  143. }
  144. }
  145. </script>
  146. <!-- Add "scoped" attribute to limit CSS to this component only -->
  147. <style scoped>
  148. h2 {
  149. margin-bottom: 8pt;
  150. font-size: 200%;
  151. }
  152. ul {
  153. list-style-type: none;
  154. padding: 0;
  155. }
  156. li {
  157. display: inline-block;
  158. margin: 0 10px;
  159. }
  160. a {
  161. color: #42b983;
  162. }
  163. .statblock {
  164. flex: 1 0;
  165. flex-basis: 100pt;
  166. margin: 0pt 4pt 0pt;
  167. user-select: none;
  168. position: relative;
  169. overflow: hidden;
  170. background: none;
  171. border-radius: 10px;
  172. }
  173. .stat-line {
  174. width: 100%;
  175. display: flex;
  176. justify-content: space-evenly;
  177. flex-wrap: wrap;
  178. }
  179. .stat-entry {
  180. position: relative;
  181. font-size: 10pt;
  182. padding-top: 2pt;
  183. padding-bottom: 2pt;
  184. display: flex;
  185. flex-direction: column;
  186. justify-content: space-evenly;
  187. align-items: center;
  188. user-select: none;
  189. text-align: center;
  190. }
  191. .stat-value {
  192. position: absolute;
  193. transform: translate(0, 8pt);
  194. padding-top: 4pt;
  195. padding-bottom: 4pt;
  196. }
  197. .healthbar {
  198. display: flex;
  199. align-items: center;
  200. justify-content: space-between;
  201. --color: green;
  202. --fullness: 100%;
  203. position: relative;
  204. width: 90%;
  205. margin: 0% 5% 0%;
  206. height: 14pt;
  207. border-radius: 2pt;
  208. border-width: 2pt;
  209. border-color: gray;
  210. border-style: outset;
  211. background: linear-gradient(90deg, var(--color) var(--fullness), black var(--fullness), black);
  212. }
  213. .stat-entry .healthbar i {
  214. flex: 0 1;
  215. flex-basis: 20pt;
  216. font-size: 14pt;
  217. }
  218. .healthbar .healthbar-value {
  219. flex: 1 0;
  220. font-size: 12pt;
  221. color: #bbb;
  222. }
  223. .stat-entry > i {
  224. font-size: 16pt;
  225. width: 16pt;
  226. margin-bottom: 18pt;
  227. }
  228. .stat-entry.low {
  229. color: yellow;
  230. }
  231. .stat-entry.crit {
  232. color: red;
  233. }
  234. .stat-entry.buff {
  235. color: green;
  236. }
  237. .statblock-content {
  238. position: relative;
  239. width: 100%;
  240. height: 100%;
  241. background: none;
  242. }
  243. .statblock-shader {
  244. position: absolute;
  245. width: 100%;
  246. height: 100%;
  247. opacity: 0%;
  248. pointer-events: none;
  249. z-index: 0;
  250. }
  251. .statblock[data-destroyed] .statblock-content,
  252. .statblock[data-destroyed] .stat-entry {
  253. animation: destroyed 1s;
  254. animation-fill-mode: both;
  255. overflow: hidden;
  256. }
  257. @keyframes destroyed {
  258. from {
  259. opacity: 1;
  260. }
  261. to {
  262. opacity: 0.25;
  263. }
  264. }
  265. .statblock[data-eaten] .statblock-shader-eaten {
  266. background: repeating-linear-gradient(45deg, transparent, transparent 20px, green 20px, green 40px, transparent 40px);
  267. opacity: 0.5;
  268. }
  269. /* yoinked from https://codepen.io/danichk/pen/PPRxrR?editors=0110 */
  270. .marching-ants {
  271. background: linear-gradient(#111, #111) padding-box, repeating-linear-gradient(-45deg, var(--ants-color) 0, var(--ants-color) 25%, transparent 0, transparent 50%) 0 / 20px 20px;
  272. animation: marching-ants 12s infinite linear;
  273. border: 4px solid transparent;
  274. }
  275. .statblock[data-active] .statblock-shader-selected {
  276. --ants-color: #f88;
  277. border-radius: 8px;
  278. width: calc(100% - 8px);
  279. height: calc(100% - 8px);
  280. opacity: 0.75;
  281. }
  282. .statblock[data-active-ally] .statblock-shader-selected-ally {
  283. --ants-color: #88f;
  284. border: 4px solid transparent;
  285. border-radius: 8px;
  286. width: calc(100% - 8px);
  287. height: calc(100% - 8px);
  288. opacity: 0.75;
  289. }
  290. .statblock[data-current-turn] .statblock-shader-current-turn {
  291. --ants-color: #fff;
  292. border: 4px solid transparent;
  293. border-radius: 8px;
  294. width: calc(100% - 8px);
  295. height: calc(100% - 8px);
  296. opacity: 0.75;
  297. }
  298. @keyframes marching-ants {
  299. to {
  300. background-position: 100% 100%;
  301. }
  302. }
  303. .statblock-shader-dead i {
  304. font-size: 100px;
  305. position: absolute;
  306. top: 50%;
  307. transform: translate(-50%, -50%);
  308. }
  309. .statblock[data-dead] .statblock-shader-dead {
  310. background: repeating-linear-gradient(45deg, red, red 20px, transparent 20px, transparent 40px, red 40px);
  311. opacity: 0.50;
  312. }
  313. .statblock:hover[data-active] .statblock-shader-hover {
  314. opacity: 0;
  315. }
  316. .statblock:hover .statblock-shader-hover {
  317. background: white;
  318. opacity: 0.20;
  319. }
  320. .statblock[data-active] .if-not-selected {
  321. display: none;
  322. }
  323. .statblock .if-ally {
  324. display: none;
  325. }
  326. .statblock[data-ally] .if-ally {
  327. display: block;
  328. }
  329. .statblock-status-icons {
  330. display: flex;
  331. justify-content: space-evenly;
  332. min-height: 16pt;
  333. }
  334. .statblock-status-icons > i {
  335. font-size: 16pt;
  336. position: relative;
  337. }
  338. .statblock-status-icon-topleft,
  339. .statblock-status-icon-bottomright {
  340. position: absolute;
  341. font-family: sans-serif;
  342. font-weight: 300;
  343. color: #999;
  344. }
  345. .statblock-status-icon-topleft {
  346. top: -12pt;
  347. }
  348. .statblock-status-icon-bottomright {
  349. top: 4pt;
  350. right: -12pt;
  351. }
  352. </style>
  353. <style>
  354. .left-stats .stat-entry::after {
  355. transform: translate(calc(0% + 16pt), -100%);
  356. }
  357. .left-stats .stat-entry::before {
  358. transform: translate(calc(0% + 16pt), calc(-100% + 18pt + 16pt));
  359. }
  360. .right-stats .stat-entry::after {
  361. transform: translate(calc(-100% + 16pt), -100%);
  362. }
  363. .right-stats .stat-entry::before {
  364. transform: translate(calc(-100% + 16pt), calc(-100% + 18pt + 16pt));
  365. }
  366. </style>