Last active
February 8, 2020 06:02
-
-
Save IntegerMan/15f7eb797fe6d0b25b0eec44e042e81c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {EventEmitter, Injectable} from '@angular/core'; | |
import {StoryEntry} from '../Model/StoryEntry'; | |
import {StoryEntryType} from '../Model/StoryEntryType'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class StoryService { | |
public EntryAdded: EventEmitter<StoryEntry> = new EventEmitter<StoryEntry>(); | |
constructor() { } | |
public handlePlayerInput(text: string): void { | |
// Log it if the console is available (won't be in all browsers) | |
if (console && console.log) { | |
console.log(`Command entered: ${text}`); | |
} | |
// Emit an event containing the player's command so we have a log of it in the UI | |
this.EntryAdded.emit(new StoryEntry(StoryEntryType.PlayerCommand, text)); | |
// Add a generic response since we're not actually parsing or responding to input yet | |
this.EntryAdded.emit(new StoryEntry(StoryEntryType.SystemText, 'I don\'t understand.')); } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment