From 0f8449d58cdd070c35d462d170946c0519d6a6b6 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Sun, 9 Aug 2020 07:09:27 -0400 Subject: [PATCH] Add money --- src/components/Explore.vue | 13 +++++- src/components/WalletView.vue | 77 +++++++++++++++++++++++++++++++++++ src/game/creature.ts | 3 +- src/game/items.ts | 20 ++++++++- src/game/maps/town.ts | 30 ++++++++++++++ 5 files changed, 139 insertions(+), 4 deletions(-) create mode 100644 src/components/WalletView.vue diff --git a/src/components/Explore.vue b/src/components/Explore.vue index f5e4401..78c432c 100644 --- a/src/components/Explore.vue +++ b/src/components/Explore.vue @@ -11,6 +11,9 @@ +
+ +
@@ -37,11 +40,12 @@ import NavButton from './NavButton.vue' import ChoiceButton from './ChoiceButton.vue' import Statblock from './Statblock.vue' import ContainerView from './ContainerView.vue' +import WalletView from './WalletView.vue' import { LogEntry } from '@/game/interface' @Component({ components: { - NavButton, ChoiceButton, Statblock, ContainerView + NavButton, ChoiceButton, Statblock, ContainerView, WalletView }, data () { return { @@ -102,8 +106,9 @@ export default class Explore extends Vue { display: grid; grid-template-areas: "info log log statblock" "worldinfo log log statblock" + "worldinfo log log wallet" "nav nav choices containers "; - grid-template-rows: fit-content(50%) 1fr 18rem; + grid-template-rows: fit-content(50%) 1fr fit-content(10%) 18rem; grid-template-columns: 1fr 1fr 1fr 1fr; width: 100%; height: 100%; @@ -151,6 +156,10 @@ export default class Explore extends Vue { grid-area: statblock; } +.explore-wallet { + grid-area: wallet; +} + .explore-info { grid-area: info; background: #333; diff --git a/src/components/WalletView.vue b/src/components/WalletView.vue new file mode 100644 index 0000000..05a86d9 --- /dev/null +++ b/src/components/WalletView.vue @@ -0,0 +1,77 @@ + + + + + + diff --git a/src/game/creature.ts b/src/game/creature.ts index d6fef26..3be4175 100644 --- a/src/game/creature.ts +++ b/src/game/creature.ts @@ -2,7 +2,7 @@ import { Damage, Combatant, Stats, Action, Vigor, Side, GroupAction, VisibleStat import { Noun, Pronoun } from './language' import { LogEntry, LogLines } from './interface' import { Vore, VoreContainer, VoreType } from './vore' -import { Item, EquipmentSlot, Equipment, ItemKind } from './items' +import { Item, EquipmentSlot, Equipment, ItemKind, Currency } from './items' import { PassAction } from './combat/actions' import { AI, NoAI } from './ai' @@ -22,6 +22,7 @@ export class Creature extends Vore implements Combatant { statusEffects: Array = []; groupActions: Array = []; items: Array = []; + wallet: { [key in Currency]: number } = Object.keys(Currency).reduce((total: any, key) => { total[key] = 0; return total }, {}); otherActions: Array = []; side: Side; title = "Lv. 1 Creature"; diff --git a/src/game/items.ts b/src/game/items.ts index 00a1368..c7211e8 100644 --- a/src/game/items.ts +++ b/src/game/items.ts @@ -1,4 +1,4 @@ -import { TextLike, LiveText, DynText, Word, ImproperNoun, Verb } from './language' +import { TextLike, LiveText, DynText, Word, ImproperNoun, Verb, Noun } from './language' import { Actionable, Action, DamageFormula, ConstantDamageFormula, Damage, DamageType, Vigor, StatDamageFormula, Stat, Effective, CompositionAction, Condition, CompositeDamageFormula } from './combat' import { AttackAction } from './combat/actions' import { Resistances } from './entity' @@ -8,6 +8,16 @@ import { SoloCondition } from './combat/conditions' import { LogLine, LogEntry } from './interface' import { Creature } from './creature' +export enum Currency { + Gold = "Gold" +} + +export const CurrencyData: {[key in Currency]: { name: Noun }} = { + [Currency.Gold]: { + name: new ImproperNoun("gold piece", "gold pieces") + } +} + export enum ItemKind { Key = "Key Item", Consumable = "Consumable", @@ -31,6 +41,14 @@ export abstract class Item implements Actionable { } } +export class KeyItem extends Item { + kind = ItemKind.Key + + constructor (name: Word, desc: TextLike) { + super(name, desc) + } +} + export enum EquipmentSlot { Head = "Head", Chest = "Chest", diff --git a/src/game/maps/town.ts b/src/game/maps/town.ts index 6c58ff7..49f6bc4 100644 --- a/src/game/maps/town.ts +++ b/src/game/maps/town.ts @@ -248,6 +248,25 @@ export const Town = (): Place => { ) ) + square.choices.push( + new Choice( + "Buy a shiny rock", + "This rock has no use.", + (world, executor) => { + if (executor.wallet.Gold >= 500) { + executor.wallet.Gold -= 500 + executor.items.push( + new Items.KeyItem(new ProperNoun("Shiny Rock"), "Very shiny") + ) + + return new LogLine(`You buy a shiny rock`) + } else { + return new LogLine(`Shiny rocks are 500 gold coins, loser!`) + } + } + ) + ) + alley.choices.push( new Choice( "Kuro", @@ -351,6 +370,17 @@ export const Town = (): Place => { ) ) + debug.choices.push( + new Choice( + "Add money", + "Get some money", + (world, executor) => { + executor.wallet.Gold += 1000 + return new LogLine(`$$$$$$$$$$$$$$$$$`) + } + ) + ) + home.biconnect(Direction.South, debug) home.biconnect(Direction.North, westAve) westAve.biconnect(Direction.West, westRoad)