Feast 2.0!
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

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