Feast 2.0!
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

287 行
7.3 KiB

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