Feast 2.0!
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 

425 řádky
11 KiB

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