From 91e4adb4b6d8987d665c3bff756fffd2b315c312 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Wed, 5 Aug 2020 23:46:54 -0400 Subject: [PATCH] Start working on item views --- src/App.vue | 8 +++-- src/components/ContainerView.vue | 14 ++++---- src/components/Explore.vue | 2 +- src/components/ItemView.vue | 59 ++++++++++++++++++++++++++++++++ src/components/Profile.vue | 23 ++++++++++++- src/game/items.ts | 26 ++++++++------ 6 files changed, 110 insertions(+), 22 deletions(-) create mode 100644 src/components/ItemView.vue diff --git a/src/App.vue b/src/App.vue index 6c268fa..3bfbd7f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -3,7 +3,7 @@
- +
@@ -67,7 +67,11 @@ export default class App extends Vue { const player = new Creatures.Wolf() player.perspective = POV.Second player.side = Side.Heroes - + player.equipment.set(Items.EquipmentSlot.MainHand, new Items.Sword()) + player.items.push(new Items.Sword()) + player.items.push(new Items.Mace()) + player.items.push(new Items.Dagger()) + player.items.push(new Items.Sword()) this.$data.world = new World(player) player.location = Town() diff --git a/src/components/ContainerView.vue b/src/components/ContainerView.vue index bf8f889..dec9278 100644 --- a/src/components/ContainerView.vue +++ b/src/components/ContainerView.vue @@ -74,17 +74,15 @@ function draw (delta: number, dt: number, total: number, parent: HTMLElement, ca @Component export default class ContainerView extends Vue { @Prop({ required: true }) - container!: Container + container!: VoreContainer mounted () { - if ((this.container as VoreContainer).fluidColor !== undefined) { - const canvas = this.$el.querySelector('.container-waves') as HTMLCanvasElement + const canvas = this.$el.querySelector('.container-waves') as HTMLCanvasElement - canvas.width = (this.$el as HTMLElement).clientWidth - canvas.height = (this.$el as HTMLElement).clientHeight - canvas.width = canvas.width + 0 - requestAnimationFrame((delta: number) => draw(delta, delta, Math.random() * 1000, this.$el as HTMLElement, canvas, (this.container as VoreContainer), 0, 0)) - } + canvas.width = (this.$el as HTMLElement).clientWidth + canvas.height = (this.$el as HTMLElement).clientHeight + canvas.width = canvas.width + 0 + requestAnimationFrame((delta: number) => draw(delta, delta, Math.random() * 1000, this.$el as HTMLElement, canvas, (this.container as VoreContainer), 0, 0)) wiggle(this.$el.querySelector(".container-contents") as HTMLElement) } diff --git a/src/components/Explore.vue b/src/components/Explore.vue index 26f8339..af6d099 100644 --- a/src/components/Explore.vue +++ b/src/components/Explore.vue @@ -58,7 +58,7 @@ export default class Explore extends Vue { @Prop({ type: World }) world!: World - navBtnCss (dir: Direction) { + navBtnCss (dir: string) { return { '--nav-direction': dir } diff --git a/src/components/ItemView.vue b/src/components/ItemView.vue new file mode 100644 index 0000000..0464617 --- /dev/null +++ b/src/components/ItemView.vue @@ -0,0 +1,59 @@ + + + + + + diff --git a/src/components/Profile.vue b/src/components/Profile.vue index 0cb03de..869b8af 100644 --- a/src/components/Profile.vue +++ b/src/components/Profile.vue @@ -2,6 +2,7 @@
+
@@ -17,11 +18,12 @@ import { Component, Prop, Vue } from 'vue-property-decorator' import Statblock from './Statblock.vue' import ContainerView from './ContainerView.vue' +import ItemView from './ItemView.vue' import { Creature } from '@/game/creature' import { World } from '@/game/world' @Component({ components: { - Statblock, ContainerView + Statblock, ContainerView, ItemView } }) @@ -53,6 +55,25 @@ export default class Explore extends Vue { .character-items { background: #222; grid-area: items; + display: grid; + grid-template-columns: repeat(3, 1fr); + grid-template-rows: repeat(100, 1fr); + justify-items: center; + align-items: start; +} + +@media (max-width: 800px) { + .character-items { + grid-template-columns: repeat(2, 1fr); + } +} + +.character-items > .item-view { + flex: 1 1; + height: 4rem; + max-height: 4rem; + width: 6rem; + max-width: 6rem; } .character-containers { diff --git a/src/game/items.ts b/src/game/items.ts index 18600fe..24e0f9e 100644 --- a/src/game/items.ts +++ b/src/game/items.ts @@ -3,9 +3,15 @@ import { Actionable, Action, DamageFormula, ConstantDamageFormula, Damage, Damag import { AttackAction } from './combat/actions' export enum ItemKind { - Key, - Consumable, - Equipment + Key = "Key Item", + Consumable = "Consumable", + Equipment = "Equipment" +} + +export const ItemKindIcons: {[key in ItemKind]: string} = { + [ItemKind.Key]: "fas fa-key", + [ItemKind.Consumable]: "fas fa-wine-bottle", + [ItemKind.Equipment]: "fas fa-hammer" } export abstract class Item implements Actionable { @@ -18,13 +24,13 @@ export abstract class Item implements Actionable { } export enum EquipmentSlot { - Head, - Chest, - Legs, - Arms, - MainHand, - OffHand, - Feet + Head = "Head", + Chest = "Chest", + Legs = "Legs", + Arms = "Arms", + MainHand = "MainHand", + OffHand = "OffHand", + Feet = "Feet" } export abstract class Equipment extends Item {