From 9dae8265af0bc03617a090d8367d52e96f006c74 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Fri, 31 Jul 2020 14:05:44 -0400 Subject: [PATCH] Add time library; name connections --- package-lock.json | 5 +++ package.json | 1 + src/App.vue | 2 +- src/components/Explore.vue | 46 ++++++++----------------- src/components/NavButton.vue | 67 ++++++++++++++++++++++++++++++++++++ src/game/world.ts | 18 ++++++---- 6 files changed, 100 insertions(+), 39 deletions(-) create mode 100644 src/components/NavButton.vue diff --git a/package-lock.json b/package-lock.json index f91ba38..bb828d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7681,6 +7681,11 @@ "minimist": "^1.2.5" } }, + "moment": { + "version": "2.27.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.27.0.tgz", + "integrity": "sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ==" + }, "move-concurrently": { "version": "1.0.1", "resolved": "https://registry.npm.taobao.org/move-concurrently/download/move-concurrently-1.0.1.tgz", diff --git a/package.json b/package.json index de2ed84..399e993 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ }, "dependencies": { "core-js": "^3.6.5", + "moment": "^2.27.0", "tippy.js": "^6.2.5", "vue": "^2.6.11", "vue-class-component": "^7.2.5", diff --git a/src/App.vue b/src/App.vue index 1f48030..06a7008 100644 --- a/src/App.vue +++ b/src/App.vue @@ -55,7 +55,7 @@ export default class App extends Vue { const other = new Place('Bar', 'The bar') foo.biconnect(Direction.North, other) - const something = new Place('Baz', 'BAZZZZZZZZZZ') + const something = new Place('Baz', 'Despacito 3') foo.biconnect(Direction.East, something) const player = new Creatures.Wolf() diff --git a/src/components/Explore.vue b/src/components/Explore.vue index 845c5d8..69c8a93 100644 --- a/src/components/Explore.vue +++ b/src/components/Explore.vue @@ -4,16 +4,15 @@
-

Time: {{ world.time }}

+

{{ world.time.format("MMMM Do YYYY") }}

+

{{ world.time.format("h:mm:ss A")}}

{{ location.name }}

{{ location.desc }}

- +
@@ -25,8 +24,13 @@ import { Component, Prop, Vue } from 'vue-property-decorator' import { Direction, World, Place } from '@/game/world' +import NavButton from './NavButton.vue' -@Component({}) +@Component({ + components: { + NavButton + } +}) export default class Explore extends Vue { get location () { @@ -37,7 +41,7 @@ export default class Explore extends Vue { this.world.player.location = loc } - @Prop() + @Prop({ type: World }) world!: World navBtnCss (dir: Direction) { @@ -74,6 +78,10 @@ export default class Explore extends Vue { background: #111; } +.worldinfo-date, +.worldinfo-time { + font-size: 125%; +} .explore-info { grid-area: info; background: #333; @@ -104,32 +112,6 @@ export default class Explore extends Vue { grid-template-columns: 1fr 1fr 1fr; } -.nav-direction { - grid-area: var(--nav-direction); - margin: 5%; - background: #555; - color: #ccc; - font-size: 200%; - border-color: #ccc; - border-width: 3px; - border-radius: 8px; - border-style: outset; - outline: none; -} - -.nav-direction:hover { - background: #666; -} - -.nav-direction:active { - background: #777; - border-style: inset; -} - -.nav-direction:focus { - background: #666; -} - .explore-actions { grid-area: actions; background: #555; diff --git a/src/components/NavButton.vue b/src/components/NavButton.vue new file mode 100644 index 0000000..bd1d180 --- /dev/null +++ b/src/components/NavButton.vue @@ -0,0 +1,67 @@ + + + + + diff --git a/src/game/world.ts b/src/game/world.ts index b884a9d..ea15607 100644 --- a/src/game/world.ts +++ b/src/game/world.ts @@ -1,6 +1,7 @@ import { TextLike } from './language' import { Entity } from './entity' import { Creature } from './creature' +import moment, { Moment, Duration } from 'moment' export enum Direction { Northwest = "Northwest", @@ -27,25 +28,25 @@ export function reverse (dir: Direction): Direction { } export class Connection { - constructor (public src: Place, public dst: Place) { + constructor (public src: Place, public dst: Place, public name: TextLike = "Travel", public desc: TextLike = "Go there lol") { } } export class Place { - connections: {[key in Direction]?: Place} = {} + connections: {[key in Direction]?: Connection} = {} constructor (public name: TextLike, public desc: TextLike) { } connect (dir: Direction, dst: Place) { - this.connections[dir] = dst + this.connections[dir] = new Connection(this, dst) } biconnect (dir: Direction, dst: Place) { - this.connections[dir] = dst - dst.connections[reverse(dir)] = this + this.connect(dir, dst) + dst.connect(reverse(dir), this) } } @@ -55,10 +56,15 @@ export const Nowhere = new Place( ) export class World { - time = "It's time!" + time: Moment creatures: Creature[] = [] constructor (public player: Creature) { + this.time = moment.utc([500, 1, 1, 9, 0, 0, 0]) this.creatures.push(player) } + + advance (dt: Duration) { + this.time.add(dt) + } }