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

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