-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37a78b9
commit 33030aa
Showing
9 changed files
with
218 additions
and
38 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// TrackerCommandHandler.swift | ||
// Outlander | ||
// | ||
// Created by Joseph McBride on 3/12/19. | ||
// Copyright © 2019 Joe McBride. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
@objc | ||
class TrackerCommandHandler : NSObject, CommandHandler { | ||
|
||
class func newInstance() -> TrackerCommandHandler { | ||
return TrackerCommandHandler() | ||
} | ||
|
||
func canHandle(command: String) -> Bool { | ||
return command.lowercaseString.hasPrefix("/tracker") | ||
} | ||
|
||
func handle(command: String, withContext: GameContext) { | ||
|
||
let text = command | ||
.substringFromIndex(command.startIndex.advancedBy(8)) | ||
.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()) | ||
|
||
if text.characters.count == 0 { | ||
withContext.events.echoText("\nExperience Tracker", mono: true, preset: "default") | ||
withContext.events.echoText("Available commands:", mono: true, preset: "default") | ||
withContext.events.echoText(" orderby: order skills by skillset, name, name desc, ranks, ranks desc.", mono: true, preset: "default") | ||
withContext.events.echoText(" report: display a report of skills with field experience or earned ranks.", mono: true, preset: "default") | ||
withContext.events.echoText(" reset: resets the tracking data.", mono: true, preset: "default") | ||
withContext.events.echoText(" update: refreshes the experience window.", mono: true, preset: "default") | ||
withContext.events.echoText("", mono: true, preset: "default") | ||
|
||
} else { | ||
|
||
var commands = text.componentsSeparatedByString(" ") | ||
let cmd = commands.removeFirst() | ||
let value = commands.joinWithSeparator(" ") | ||
withContext.events.publish("OL:tracker", data: ["command":cmd, "value": value]) | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.