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

92 строки
1.9 KiB

  1. <template>
  2. <button @focus="describe" @mouseover="describe" @mouseleave="undescribe" class="action-button" @click="execute">
  3. <div class="action-title">{{ action.name }}</div>
  4. <div class="action-desc">{{ action.desc }}</div>
  5. </button>
  6. </template>
  7. <script lang="ts">
  8. import { Component, Prop, Vue, Watch, Emit } from 'vue-property-decorator'
  9. import { Action, GroupAction } from '@/game/combat'
  10. import { Creature } from '@/game/creature'
  11. import { nilLog } from '@/game/interface'
  12. @Component({})
  13. export default class ActionButton extends Vue {
  14. @Prop()
  15. action!: Action
  16. @Prop()
  17. user!: Creature
  18. @Prop()
  19. target!: Creature
  20. @Prop()
  21. combatants!: Array<Creature>
  22. @Emit("execute")
  23. execute () {
  24. if ((this.action as GroupAction).executeGroup !== undefined) {
  25. const action = (this.action as GroupAction)
  26. this.$emit('executed', (this.action as GroupAction).executeGroup(this.user, action.allowedGroup(this.user, this.combatants)))
  27. } else {
  28. this.$emit('executed', this.user.executeAction(this.action, this.target))
  29. }
  30. this.undescribe()
  31. }
  32. @Emit("describe")
  33. describe () {
  34. if ((this.action as GroupAction).describeGroup !== undefined) {
  35. const action = (this.action as GroupAction)
  36. this.$emit('described', action.describeGroup(this.user, action.allowedGroup(this.user, this.combatants)))
  37. } else {
  38. this.$emit('described', this.action.describe(this.user, this.target))
  39. }
  40. }
  41. @Emit("undescribe")
  42. undescribe () {
  43. this.$emit('described', nilLog)
  44. }
  45. }
  46. </script>
  47. <style scoped>
  48. .action-button {
  49. width: 100%;
  50. max-width: 300px;
  51. padding: 4pt;
  52. flex: 0 1;
  53. background: #333;
  54. border-color: #666;
  55. border-style: outset;
  56. user-select: none;
  57. outline: none;
  58. }
  59. .action-button:focus {
  60. background: #444;
  61. }
  62. .action-button:hover {
  63. background: #555;
  64. }
  65. .action-title {
  66. font-size: 125%;
  67. color: #eee;
  68. pointer-events: none;
  69. }
  70. .action-desc {
  71. color: #ccc;
  72. pointer-events: none;
  73. }
  74. </style>