| @@ -10,6 +10,7 @@ import { Creature } from '@/game/creature' | |||||
| import { POV } from '@/game/language' | import { POV } from '@/game/language' | ||||
| import { Stats, Stat } from '@/game/combat' | import { Stats, Stat } from '@/game/combat' | ||||
| import { Item, ItemKindIcons, ItemKind, EquipmentSlot } from '@/game/items' | import { Item, ItemKindIcons, ItemKind, EquipmentSlot } from '@/game/items' | ||||
| import { World } from '@/game/world' | |||||
| @Component({ | @Component({ | ||||
| data () { | data () { | ||||
| @@ -21,11 +22,16 @@ import { Item, ItemKindIcons, ItemKind, EquipmentSlot } from '@/game/items' | |||||
| }) | }) | ||||
| export default class ItemView extends Vue { | export default class ItemView extends Vue { | ||||
| @Prop() | |||||
| world!: World | |||||
| @Prop({ required: true }) | @Prop({ required: true }) | ||||
| subject!: Creature | subject!: Creature | ||||
| unequip (slot: EquipmentSlot) { | unequip (slot: EquipmentSlot) { | ||||
| this.subject.unequip(slot) | |||||
| if (this.subject.side === this.world.player.side) { | |||||
| this.subject.unequip(slot) | |||||
| } | |||||
| } | } | ||||
| equipmentClass (slot: EquipmentSlot) { | equipmentClass (slot: EquipmentSlot) { | ||||
| @@ -22,7 +22,7 @@ | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| <EquipmentView class="character-equipment" :subject="subject" /> | |||||
| <EquipmentView class="character-equipment" :world="world" :subject="subject" /> | |||||
| </div> | </div> | ||||
| </template> | </template> | ||||
| @@ -44,20 +44,25 @@ import { Item, ItemKind, Equipment } from '@/game/items' | |||||
| }) | }) | ||||
| export default class Profile extends Vue { | export default class Profile extends Vue { | ||||
| @Prop() | |||||
| world!: World | |||||
| @Prop() | @Prop() | ||||
| subject!: Creature | subject!: Creature | ||||
| useItem (item: Item): void { | useItem (item: Item): void { | ||||
| switch (item.kind) { | |||||
| case ItemKind.Key: | |||||
| break | |||||
| case ItemKind.Consumable: | |||||
| item.actions[0].execute(this.subject, this.subject) | |||||
| break | |||||
| case ItemKind.Equipment: | |||||
| this.subject.equip(item as Equipment, (item as Equipment).slot) | |||||
| this.subject.items = this.subject.items.filter(i => item !== i) | |||||
| break | |||||
| if (this.subject.side === this.world.player.side) { | |||||
| switch (item.kind) { | |||||
| case ItemKind.Key: | |||||
| break | |||||
| case ItemKind.Consumable: | |||||
| item.actions[0].execute(this.subject, this.subject) | |||||
| break | |||||
| case ItemKind.Equipment: | |||||
| this.subject.equip(item as Equipment, (item as Equipment).slot) | |||||
| this.subject.items = this.subject.items.filter(i => item !== i) | |||||
| break | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -264,6 +264,7 @@ export const Town = (): Place => { | |||||
| const enemy = new Creatures.Human(new ProperNoun("Nerd"), TheyPronouns) | const enemy = new Creatures.Human(new ProperNoun("Nerd"), TheyPronouns) | ||||
| enemy.side = Side.Monsters | enemy.side = Side.Monsters | ||||
| enemy.ai = new VoreAI() | enemy.ai = new VoreAI() | ||||
| enemy.equip(new Items.Sword(), Items.EquipmentSlot.MainHand) | |||||
| const encounter = new Encounter( | const encounter = new Encounter( | ||||
| { | { | ||||
| name: "Fight some nerd", | name: "Fight some nerd", | ||||