Procházet zdrojové kódy

Add a Town map creator

master
Fen Dweller před 5 roky
rodič
revize
f4053dcf57
3 změnil soubory, kde provedl 60 přidání a 32 odebrání
  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 Zobrazit soubor

@@ -3,7 +3,7 @@
<Header />
<div id="main-area">
<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>
</div>
</div>
@@ -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[] {


+ 48
- 0
src/game/maps/town.ts Zobrazit soubor

@@ -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 Zobrazit soubor

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


Načítá se…
Zrušit
Uložit