Feast 2.0!
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

245 wiersze
6.3 KiB

  1. <template>
  2. <div @click="$emit('select')" class="statblock">
  3. <h2 class="name" v-if="subject.perspective === firstperson">
  4. You
  5. <div class="tooltip-template">
  6. <div class="tooltip-title">{{ subject.title }}</div>
  7. <div class="tooltip-body">{{ subject.desc }}</div>
  8. </div>
  9. </h2>
  10. <h2 class="name" v-if="subject.perspective !== firstperson">
  11. {{subject.name.all.capital}}
  12. <div class="tooltip-template">
  13. <div class="tooltip-title">{{ subject.title }}</div>
  14. <div class="tooltip-body">{{ subject.desc }}</div>
  15. </div>
  16. </h2>
  17. <div class="stat-entry" v-for="vigor in Object.keys(subject.vigors)" v-bind:key="vigor">
  18. <div class="healthbar" v-bind:style="{'--fullness': (subject.vigors[vigor]/subject.maxVigors[vigor]*100) + '%', '--color': vigorColor(subject.vigors[vigor], subject.maxVigors[vigor]) }">
  19. <i :class="vigorIcons[vigor]" />
  20. <div class="healthbar-value"> {{ subject.vigors[vigor].toFixed(0) + '/' + subject.maxVigors[vigor].toFixed(0) }}</div>
  21. </div>
  22. <div class="tooltip-template">
  23. <div class="tooltip-title">{{ vigor }}</div>
  24. <div class="tooltip-body">{{ vigorDescs[vigor] }}</div>
  25. </div>
  26. </div>
  27. <div class="stat-line stats">
  28. <div :class="statClass(subject.stats[stat], subject.baseStats[stat])" v-for="stat in Object.keys(subject.stats)" v-bind:key="stat">
  29. <i :class="statIcons[stat]" />
  30. <div class="stat-value">{{subject.stats[stat].toFixed(0)}}</div>
  31. <div class="tooltip-template">
  32. <div class="tooltip-title">{{ stat }}</div>
  33. <div class="tooltip-body">{{ statDescs[stat] }}</div>
  34. </div>
  35. </div>
  36. </div>
  37. <div class="stat-line vore-stats">
  38. <div class="stat-entry" v-for="stat in Object.keys(subject.voreStats)" v-bind:key="stat">
  39. <i :class="voreStatIcons[stat]" />
  40. <div class="stat-value">{{subject.voreStats[stat].toFixed(0)}}</div>
  41. <div class="tooltip-template">
  42. <div class="tooltip-title">{{ stat }}</div>
  43. <div class="tooltip-body">{{ voreStatDescs[stat] }}</div>
  44. </div>
  45. </div>
  46. </div>
  47. <div>Status: {{subject.status}}</div>
  48. <button v-if="subject.perspective !== firstperson" @click="subject.perspective = firstperson">First-person</button>
  49. <button v-if="subject.perspective !== thirdperson" @click="subject.perspective = thirdperson">Third-person</button>
  50. <button class="if-not-selected" @click.stop="$emit('selectAlly')">Select ally as target</button>
  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. }
  133. .stat-line {
  134. width: 100%;
  135. display: flex;
  136. justify-content: space-evenly;
  137. flex-wrap: wrap;
  138. }
  139. .stat-entry {
  140. position: relative;
  141. font-size: 10pt;
  142. padding-top: 2pt;
  143. padding-bottom: 2pt;
  144. display: flex;
  145. flex-direction: column;
  146. justify-content: space-evenly;
  147. user-select: none;
  148. }
  149. .stat-value {
  150. padding-top: 4pt;
  151. padding-bottom: 4pt;
  152. }
  153. .healthbar {
  154. display: flex;
  155. align-items: center;
  156. justify-content: space-between;
  157. --color: green;
  158. --fullness: 100%;
  159. position: relative;
  160. width: 90%;
  161. margin: 0% 5% 0%;
  162. height: 14pt;
  163. border-radius: 2pt;
  164. border-width: 2pt;
  165. border-color: gray;
  166. border-style: outset;
  167. background: linear-gradient(90deg, var(--color) var(--fullness), black var(--fullness), black);
  168. }
  169. .stat-entry .healthbar i {
  170. flex: 0 1;
  171. flex-basis: 20pt;
  172. font-size: 14pt;
  173. }
  174. .healthbar .healthbar-value {
  175. flex: 1 0;
  176. font-size: 12pt;
  177. color: #bbb;
  178. }
  179. .stat-entry i {
  180. font-size: 150%;
  181. }
  182. .stat-entry.low {
  183. color: yellow;
  184. }
  185. .stat-entry.crit {
  186. color: red;
  187. }
  188. .stat-entry.buff {
  189. color: green;
  190. }
  191. .statblock[data-active] {
  192. background: #444;
  193. border-radius: 4px;
  194. }
  195. .statblock[data-active-ally] {
  196. background: #744;
  197. border-radius: 4px;
  198. }
  199. .statblock[data-active] .stats,
  200. .statblock[data-active] .vore-stats {
  201. display: flex;
  202. }
  203. .statblock[data-active] .if-not-selected {
  204. display: none;
  205. }
  206. </style>
  207. <style>
  208. .left-stats .stat-entry::after {
  209. transform: translate(calc(0% + 16pt), -100%);
  210. }
  211. .left-stats .stat-entry::before {
  212. transform: translate(calc(0% + 16pt), calc(-100% + 18pt + 16pt));
  213. }
  214. .right-stats .stat-entry::after {
  215. transform: translate(calc(-100% + 16pt), -100%);
  216. }
  217. .right-stats .stat-entry::before {
  218. transform: translate(calc(-100% + 16pt), calc(-100% + 18pt + 16pt));
  219. }
  220. </style>