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

More body and user tests

parent da5073a0
No related branches found
No related tags found
No related merge requests found
Pipeline #
require("bodyPart")
require "bodyPart"
require "proportionate"
 
global.$game = {} if not global.$game
global.$game.constants = {} if not global.$game.constants
Loading
Loading
@@ -34,7 +35,7 @@ human.stats.luck = ["non-existant", "doomed", "terrible", "unfortunate", "not th
global.$game.constants.body.human.formatHeight = (height)->
global.$game.constants.body.human.height.proportionate(height, global.$game.constants.body.human.maxHeight)
 
global.$game.constants.body.human.formatWeight = (weight, height = 1.7)->
global.$game.constants.body.human.formatWeight = (weight, height = @getHeight())->
return global.$game.constants.body.human.weight.proportionate(weight, 100 * height)
 
if not global.$game.classes.HumanBody
Loading
Loading
@@ -136,7 +137,7 @@ body.say = body.says = (what) ->
@tell "You say, \"" + what + "\""
stimulus = new global.$game.classes.StimulusBuilder(what, what.location).visual(this).visual(" says, ").quoted(what).visual(".").build()
@location.everyoneExcept(this).stimulate(stimulus)
body.contextualizeLanguage = (message, language)->
_ = require("underscore")
understanding = @info.knownLanguages[language] or 0.0
Loading
Loading
@@ -234,7 +235,7 @@ body.moveTo = ->
global.$game.common.moveTo.apply(this, arguments)
 
body.look = ()->
@sees(if @location.asSeenBy then @location?.asSeenBy(this) else @location.description)
@sees @location?.asSeenBy?(this) || @location?.description || "There doesn't seem to be anything to see."
 
body.lookAt = (who, what) ->
listify = require("listify")
Loading
Loading
@@ -283,7 +284,7 @@ body.getCommands = ->
]
description:"Describes the room you're presently in."
func:@look
source:self
source:this
},
{
name:"l~ook [at/in] <something>"
Loading
Loading
@@ -298,5 +299,5 @@ body.getCommands = ->
source:this
}
]
commands = commands.concat(@location?.getCommands(this)) if @location.getCommands
commands = commands.concat(@location?.getCommands?(this)) if @location?.getCommands
_(commands).flatten()
require("base")
require "base"
require "body"
 
global.$game = {} if not global.$game
global.$game.classes = {} if not global.$game.classes
Loading
Loading
@@ -25,10 +26,10 @@ user.init = (@name, @email, password, @lastIp) ->
user.moveTo = global.$game.common.moveTo
 
user.getSocket = ->
global.$driver.getSocket(this)
global?.$driver?.getSocket?(this)
 
user.tell = (what) ->
@getSocket()?.tell(what) if typeof what is "string"
@getSocket().tell?(what) if typeof what is "string"
 
user.isConnected = ->
!!global.$driver.getSocket(this)
Loading
Loading
@@ -36,6 +37,9 @@ user.isConnected = ->
user.goIC = () ->
@commandLoop()
 
user.createBody = (info)->
@body = new global.$game.classes.HumanBody this, info
user.commandLoop = ->
if not @isConnected() then return console.log("Not connected")
self = this
Loading
Loading
@@ -71,5 +75,3 @@ user.matchCommand = (command)->
_(@body.getCommands(self)).find (options)->
_(options.tests).find (test)->
test.regexp.test command
Loading
Loading
@@ -12,6 +12,9 @@ describe "Human Body", ->
tell:chai.spy()
,
language:"English"
appearance:
height:1.7
weight:80
 
 
it "should be constructable", ->
Loading
Loading
@@ -31,7 +34,6 @@ describe "Human Body", ->
body.sees "what"
body.owner.tell.should.not.have.been.called()
 
it "should tell it's owner what it hears, unless it's not conscious", ->
body = harnessBody()
body.hears "what"
Loading
Loading
@@ -77,6 +79,12 @@ describe "Human Body", ->
body.thinks "what"
body.owner.tell.should.not.have.been.called()
 
it "should know it's height and weight", ->
body = harnessBody()
body.getHeight().should.equal 1.7
body.getWeight().should.equal 80
body.getHeightString().should.equal "of average height"
body.getWeightString().should.equal "of average weight"
 
it "should produce a random body part", ->
harnessBody().randomPart().should.not.be.undefined
Loading
Loading
Loading
Loading
@@ -45,4 +45,7 @@ describe "User", ->
harnessUser().goIC()
 
it "should handle a command", ->
#harnessUser().handleCommand("look")
\ No newline at end of file
user = harnessUser()
user.createBody({language:"English"})
user.handleCommand("look")
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