Przeglądaj źródła

Don't allow the items of enemies to be touched

vintage
Fen Dweller 5 lat temu
rodzic
commit
2371c33888
3 zmienionych plików z 24 dodań i 12 usunięć
  1. +7
    -1
      src/components/EquipmentView.vue
  2. +16
    -11
      src/components/Profile.vue
  3. +1
    -0
      src/game/maps/town.ts

+ 7
- 1
src/components/EquipmentView.vue Wyświetl plik

@@ -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) {


+ 16
- 11
src/components/Profile.vue Wyświetl plik

@@ -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
}
} }
} }
} }


+ 1
- 0
src/game/maps/town.ts Wyświetl plik

@@ -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",


Ładowanie…
Anuluj
Zapisz