diff --git a/src/App.vue b/src/App.vue index b82bf49..2b8e10e 100644 --- a/src/App.vue +++ b/src/App.vue @@ -3,7 +3,7 @@
- +
@@ -23,6 +23,7 @@ import { Encounter, Side } from './game/combat' import { LogLine, nilLog } from './game/interface' import { InstantKillEffect } from './game/combat/effects' import moment from 'moment' +import { Town } from './game/maps/town' @Component({ components: { @@ -30,9 +31,7 @@ import moment from 'moment' }, data () { return { - encounter: null, world: null, - mode: 'explore', props: { Explore: { world: this @@ -41,15 +40,19 @@ import moment from 'moment' } } }) + export default class App extends Vue { constructor () { super() } + get mode () { + return this.$data.world.encounter === null ? "Explore" : "Combat" + } + @Emit('startFight') startFight (encounter: Encounter) { - this.$data.encounter = encounter - this.$data.mode = 'Combat' + this.$data.world.encounter = encounter } created () { @@ -57,34 +60,9 @@ export default class App extends Vue { player.perspective = POV.Second player.side = Side.Heroes - const bonusBosses = [] - bonusBosses.push(new Encounter({ name: 'Boss Fight' }, this.makeParty().concat([new Creatures.Withers(), new Creatures.Kenzie()]))) - bonusBosses.push(new Encounter({ name: 'Cafat' }, this.makeParty().concat([new Creatures.Cafat()]))) - bonusBosses.push(new Encounter({ name: 'Large Wah' }, this.makeParty().concat([new Creatures.Shingo()]))) - bonusBosses.push(new Encounter({ name: 'Goldeneye' }, this.makeParty().concat([new Creatures.Goldeneye()]))) - - const home = new Place(new ProperNoun('your home'), 'This is not not home') - - const street = new Place(new ImproperNoun('street'), 'The street') - const bosses = new Place(new ProperNoun('The Boss Zone'), 'Death time lmao') - home.biconnect(Direction.North, street) - street.biconnect(Direction.West, bosses) - - bonusBosses.forEach((encounter: Encounter) => bosses.choices.push(new Choice( - encounter.desc.name, - 'Fight time!', - (world, executor) => { - this.startFight( - encounter - ) - return nilLog - } - ))) - - const bar = new Place(new ProperNoun('Dave\'s Bar'), 'This is the bar') - street.biconnect(Direction.East, bar) - player.location = home this.$data.world = new World(player) + + player.location = Town() } makeParty (): Creature[] { diff --git a/src/game/maps/town.ts b/src/game/maps/town.ts new file mode 100644 index 0000000..74a4168 --- /dev/null +++ b/src/game/maps/town.ts @@ -0,0 +1,48 @@ +import { Place, Choice, Direction } from '../world' +import { ProperNoun, ImproperNoun } from '../language' +import { Encounter } from '../combat' +import * as Creatures from '../creatures' +import { LogLine } from '../interface' + +export const Town = (): Place => { + const home = new Place( + new ProperNoun('Your home'), + "A very home-y place" + ) + + const westAve = new Place( + new ImproperNoun('West Avenue'), + "Streets of Sim City" + ) + + const westRoad = new Place( + new ImproperNoun('road'), + "West of town" + ) + + const woods = new Place( + new ImproperNoun('woods'), + "Scary woods" + ) + + woods.choices.push( + new Choice( + "Fight a wolf", + "yolo", + (world, executor) => { + world.encounter = new Encounter( + { name: "You punched a wolf" }, + [executor, new Creatures.Wolf()] + ) + + return new LogLine(`FIGHT TIME`) + } + ) + ) + + home.biconnect(Direction.North, westAve) + westAve.biconnect(Direction.West, westRoad) + westRoad.biconnect(Direction.South, woods) + + return home +} diff --git a/src/game/world.ts b/src/game/world.ts index fd9fec9..1d74c37 100644 --- a/src/game/world.ts +++ b/src/game/world.ts @@ -3,6 +3,7 @@ import { Entity } from './entity' import { Creature } from './creature' import moment, { Moment, Duration } from 'moment' import { LogEntry, LogLine } from './interface' +import { Encounter } from './combat' export enum Direction { Northwest = "Northwest", @@ -90,6 +91,7 @@ export const Nowhere = new Place( export class World { time: Moment creatures: Creature[] = [] + encounter: Encounter|null = null constructor (public player: Creature) { this.time = moment.utc([500, 1, 1, 9, 0, 0, 0])