Browse Source

Add a Town map creator

vintage
Fen Dweller 5 years ago
parent
commit
f4053dcf57
3 changed files with 60 additions and 32 deletions
  1. +10
    -32
      src/App.vue
  2. +48
    -0
      src/game/maps/town.ts
  3. +2
    -0
      src/game/world.ts

+ 10
- 32
src/App.vue View File

@@ -3,7 +3,7 @@
<Header /> <Header />
<div id="main-area"> <div id="main-area">
<transition name="component-fade" mode='out-in'> <transition name="component-fade" mode='out-in'>
<component @leaveCombat="mode = 'Explore'" v-bind:is="mode" :world="world" :encounter="encounter" />
<component @leaveCombat="world.encounter = null" v-bind:is="mode" :world="world" :encounter="world.encounter" />
</transition> </transition>
</div> </div>
</div> </div>
@@ -23,6 +23,7 @@ import { Encounter, Side } from './game/combat'
import { LogLine, nilLog } from './game/interface' import { LogLine, nilLog } from './game/interface'
import { InstantKillEffect } from './game/combat/effects' import { InstantKillEffect } from './game/combat/effects'
import moment from 'moment' import moment from 'moment'
import { Town } from './game/maps/town'


@Component({ @Component({
components: { components: {
@@ -30,9 +31,7 @@ import moment from 'moment'
}, },
data () { data () {
return { return {
encounter: null,
world: null, world: null,
mode: 'explore',
props: { props: {
Explore: { Explore: {
world: this world: this
@@ -41,15 +40,19 @@ import moment from 'moment'
} }
} }
}) })

export default class App extends Vue { export default class App extends Vue {
constructor () { constructor () {
super() super()
} }


get mode () {
return this.$data.world.encounter === null ? "Explore" : "Combat"
}

@Emit('startFight') @Emit('startFight')
startFight (encounter: Encounter) { startFight (encounter: Encounter) {
this.$data.encounter = encounter
this.$data.mode = 'Combat'
this.$data.world.encounter = encounter
} }


created () { created () {
@@ -57,34 +60,9 @@ export default class App extends Vue {
player.perspective = POV.Second player.perspective = POV.Second
player.side = Side.Heroes 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) this.$data.world = new World(player)

player.location = Town()
} }


makeParty (): Creature[] { makeParty (): Creature[] {


+ 48
- 0
src/game/maps/town.ts View File

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

+ 2
- 0
src/game/world.ts View File

@@ -3,6 +3,7 @@ import { Entity } from './entity'
import { Creature } from './creature' import { Creature } from './creature'
import moment, { Moment, Duration } from 'moment' import moment, { Moment, Duration } from 'moment'
import { LogEntry, LogLine } from './interface' import { LogEntry, LogLine } from './interface'
import { Encounter } from './combat'


export enum Direction { export enum Direction {
Northwest = "Northwest", Northwest = "Northwest",
@@ -90,6 +91,7 @@ export const Nowhere = new Place(
export class World { export class World {
time: Moment time: Moment
creatures: Creature[] = [] creatures: Creature[] = []
encounter: Encounter|null = null


constructor (public player: Creature) { constructor (public player: Creature) {
this.time = moment.utc([500, 1, 1, 9, 0, 0, 0]) this.time = moment.utc([500, 1, 1, 9, 0, 0, 0])


Loading…
Cancel
Save