Skip to content
Snippets Groups Projects
Commit 54d65809 authored by Travis Savo's avatar Travis Savo
Browse files

Adding user test

parent 8fc71a64
No related branches found
No related tags found
No related merge requests found
Pipeline #
global.$game = {} if not global.$game
global.$game.common = {} if not global.$game.common
 
global.$game.common.move = (what, to)->
Loading
Loading
Loading
Loading
@@ -128,7 +128,7 @@ body.say = body.says = (what) ->
@location.everyoneExcept(this).stimulate(stimulus)
body.contextualizeLanguage = (message, language)->
_ = require("./node_modules/underscore")
_ = require("underscore")
understanding = @info.knownLanguages[language] or 0.0
return message if understanding is 1
_(stimulus.value.split(" ")).chain().map (word)->
Loading
Loading
@@ -165,7 +165,7 @@ body.contextualizeStimulus = (stimulus)->
stimulus.value
 
body.stimulate = (stimulus)->
_ = require("./node_modules/underscore")
_ = require("underscore")
@tell _(stimulus).chain().map(@contextualizeStimulus).join("").value()
 
body.getPart = (name)->
Loading
Loading
@@ -248,7 +248,7 @@ body.resolve = (what) ->
return found if found.length > 1
groups = /^([\w-]+)\s(.*)$/i.exec what
return undefined if not groups
ordinal = require("./src/ordinal")
ordinal = require("ordinal")
position = ordinal(groups[1])
rest = groups[2]
regexp = new RegExp("^(.*)\b(" + rest + ")(.*)$", "i")
Loading
Loading
require("./src/proportionate")
require("proportionate")
 
global.$game.$index = {} if not global.$game.$index
global.$game.$index.players = {} if not global.$game.$index.players
Loading
Loading
@@ -17,7 +17,7 @@ player.init = (@name, @user, @info, @location = global.$game.$index.rooms.$nowhe
throw new Error("Player names must be unique.") if global.$game.$index.players[@name]
throw new Error("Player must be associated with a user.") if not @user
global.$game.$index.players[@name] = this
@salt = require("./node_modules/uuid").v4()
@salt = require("uuid").v4()
@user.player = this
@description = "Someone who needs a better description."
@doing = ""
Loading
Loading
@@ -90,7 +90,7 @@ player.handleCommand = (command)->
self = this
func = @matchCommand(command)
return @tell("I don't understand that.") if not func
_ = require("./node_modules/underscore")
_ = require("underscore")
test = _(func.tests).find (test)->
test.regexp.test command
args = [self]
Loading
Loading
@@ -104,14 +104,14 @@ player.handleCommand = (command)->
func.func.apply(func.source, args)
 
player.matchCommand = (command)->
_ = require("./node_modules/underscore")
_ = require("underscore")
self = this
_(@getCommands(self)).find (options)->
_(options.tests).find (test)->
test.regexp.test command
 
player.getCommands = (who)->
_ = require("./node_modules/underscore")
_ = require("underscore")
commands = [
{
name:"l~ook"
Loading
Loading
@@ -140,7 +140,7 @@ player.getCommands = (who)->
 
 
player.resolve = (what) ->
_ = require("./node_modules/underscore")
_ = require("underscore")
what = what.trim().toLowerCase()
return this if what is "me"
return @location if what is "here"
Loading
Loading
@@ -152,7 +152,7 @@ player.resolve = (what) ->
return found if found.length > 1
groups = /^([\w-]+)\s(.*)$/i.exec what
return undefined if not groups
ordinal = require("./src/ordinal")
ordinal = require("ordinal")
position = ordinal(groups[1])
rest = groups[2]
regexp = new RegExp("^(.*)\b(" + rest + ")(.*)$", "i")
Loading
Loading
require("base")
global.$game = {} if not global.$game
global.$game.classes = {} if not global.$game.classes
global.$game.$index = {} if not global.$game.$index
global.$game.$index.users = {} if not global.$game.$index.users
 
if not global.$game.classes.User
global.$game.classes.User = class User
Loading
Loading
@@ -8,11 +13,10 @@ if not global.$game.classes.User
 
user = global.$game.classes.User.prototype
 
global.$game.$index.users = {} if not global.$game.$index.users
 
user.init = (@name, @email, password, @lastIp) ->
throw new Error("Username already in use.") if global.$game.$index.users[@name]
@salt = require("./node_modules/uuid").v4()
@salt = require("uuid").v4()
global.$game.$index.users[@name] = this
crypto = require "crypto"
hash = crypto.createHash "sha256"
Loading
Loading
chai = require "chai"
spies = require('chai-spies')
chai.use spies
chai.should()
require('app-module-path').addPath(__dirname + '/../src')
require("user")
describe "User", ->
it "should be constructable", ->
user = new global.$game.classes.User()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment