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

Adding more body tests

parent fa744591
No related branches found
No related tags found
No related merge requests found
Pipeline #
Loading
Loading
@@ -4,6 +4,3 @@ node_js:
- "7"
script:
- npm test
addons:
code_climate:
repo_token: 6b82adabb394686a5f688e12e09772f89d3636045a19f23067f1757fed1b55d9
\ No newline at end of file
Loading
Loading
@@ -66,6 +66,7 @@ body.tell = (what)->
@owner.tell(what)
 
body.see = body.sees = (what)->
console.log(@canSee())
@tell(what) if @concious and @canSee()
 
body.hear = body.hears = (what)->
Loading
Loading
@@ -75,6 +76,7 @@ body.feel = body.feels = (what)->
@tell(what) if @concious and @canFeel()
 
body.smells = (what)->
console.log(@canSmell())
@tell(what) if @concious and @canSmell()
 
body.tastes = (what)->
Loading
Loading
@@ -99,29 +101,26 @@ body.resolveAllContents = ->
@contents.concat(@torso.resolveAllContents())
 
body.canSee = ->
@torso?.head?.canSee?()
@torso.parts.head?.canSee?()
 
body.canHear = ->
@torso?.head?.canHear?()
@torso.parts.head?.canHear?()
 
body.canSpeak = ->
@torso?.head?.canSpeak?()
@torso.parts.head?.canSpeak?()
body.canThink = ->
@torso?.head?.canThink()
@torso.parts.head?.canThink?()
 
body.canSmell = ->
@torso?.head?.canSmell()
@torso.parts.head?.canSmell?()
body.canTaste = ->
@torso?.head?.canTaste()
@torso.parts.head?.canTaste?()
body.canFeel = ->
@torso?.head?.canFeel()
@torso.canFeel?()
body.getTorso = ->
@torso
body.say = body.says = (what) ->
return @tell "You try to speak but you cant!" if not @canSpeak()
@tell "You say, \"" + what + "\""
Loading
Loading
Loading
Loading
@@ -19,10 +19,12 @@ part.init = (@name, @bones, @coverable, @removable, @critical, @parts = {})->
@contents = []
 
part.findPart = (name)->
return this if name is @name or @name.indexOf(name) is 0 or name.test?(@name)
console.log(name, @name)
return this if name is @name
_ = require("underscore")
_(@parts).find (part)->
part.findPart(name)
_(@parts).chain().map (myPart)->
myPart.findPart(name)
.flatten().without(undefined).first().value()
 
part.coverageMap = (map = {})->
return map if not @coverable
Loading
Loading
@@ -79,16 +81,23 @@ global.$game.common.makeHead = ->
true
head.parts.face.parts.mouth.parts.tongue.canTaste = ->
true
head.parts.face.parts.nose.canSmell = ->
not @contents.length
head.canSee = ->
head.parts.face?.parts?.leftEye?.canSee?() or head.parts?.face?.parts?.rightEye?.canSee?()
@parts.face?.parts?.leftEye?.canSee?() or head.parts?.face?.parts?.rightEye?.canSee?()
head.canHear = ->
head.parts.face?.parts?.leftEar?.canHear?() or head.parts.face?.rightEar?.canHear?()
@parts.face?.parts?.leftEar?.canHear?() or head.parts.face?.rightEar?.canHear?()
head.canThink = ->
true
head.canTaste = ->
head.parts.face?.parts?.mouth?.parts?.tongue?.canTaste?()
@parts.face?.parts?.mouth?.parts?.tongue?.canTaste?()
head.canSpeak = ->
head.parts.face?.parts?.mouth?.isEmpty?() and head.parts.face?.parts?.mouth?.parts?.tongue?.canSpeak?()
@parts.face?.parts?.mouth?.isEmpty?() and head.parts.face?.parts?.mouth?.parts?.tongue?.canSpeak?()
head.canSmell = ->
@parts.face?.parts?.nose?.canSmell()
head
 
global.$game.common.makeArm = (leftOrRight)->
Loading
Loading
@@ -130,12 +139,12 @@ global.$game.common.makeEye = (leftOrRight) ->
makeBodyPart = global.$game.common.makeBodyPart
eye = makeBodyPart leftOrRight + " eye", [], true, true, false
eye.canSee = ->
not Object.keys(eye.condition).length
not Object.keys(@condition).length
eye
 
global.$game.common.makeEar = (leftOrRight) ->
makeBodyPart = global.$game.common.makeBodyPart
ear = makeBodyPart leftOrRight + " ear", [], true, true, false
ear.canHear = ->
not ear.contents.length
not @contents.length
ear
require('app-module-path').addPath(__dirname + '/src')
require('app-module-path').addPath(__dirname)
serializer = require('./serialize')
loader = require("./loader")
watchr = require("watchr")
Loading
Loading
Loading
Loading
@@ -44,7 +44,6 @@ room.getCommands = (who)->
).flatten(true).value()
 
 
global.$game.$nowhere = new global.$game.classes.Room("$nowhere", "Nowhere. Literally. The place where things go when they are not in the game.") if not global.$game.$nowhere
 
if not global.$game.classes.RoomExit
Loading
Loading
chai = require "chai"
spies = require('chai-spies')
chai.use spies
expect = chai.expect
chai.should()
require('app-module-path').addPath(__dirname + '/../src')
require("body")
Loading
Loading
@@ -9,16 +8,80 @@ require("body")
describe "Human Body", ->
 
harnessBody = ->
new global.$game.classes.HumanBody({}, {language:"English"})
new global.$game.classes.HumanBody
tell:chai.spy()
,
language:"English"
 
it "should be constructable", ->
harnessBody().should.not.be.undefined
 
it "should tell it's owner what it's told", ->
owner =
tell:chai.spy ->
body = new global.$game.classes.HumanBody owner,
language:"English"
body = harnessBody()
body.tell "what"
owner.tell.should.have.been.called.with "what"
body.owner.tell.should.have.been.called.with "what"
it "should tell it's owner what it sees, unless it's not conscious", ->
body = harnessBody()
body.sees "what"
body.owner.tell.should.have.been.called.with "what"
body.owner.tell.reset()
body.concious = false
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"
body.owner.tell.should.have.been.called.with "what"
body.owner.tell.reset()
body.concious = false
body.hears "what"
body.owner.tell.should.not.have.been.called()
it "should tell it's owner what it feels, unless it's not conscious", ->
body = harnessBody()
body.feel "what"
body.owner.tell.should.have.been.called.with "what"
body.owner.tell.reset()
body.concious = false
body.feel "what"
body.owner.tell.should.not.have.been.called()
it "should tell it's owner what it smells, unless it's not conscious", ->
body = harnessBody()
body.smells "what"
body.owner.tell.should.have.been.called.with "what"
body.owner.tell.reset()
body.concious = false
body.smells "what"
body.owner.tell.should.not.have.been.called()
it "should tell it's owner what it tastes, unless it's not conscious", ->
body = harnessBody()
body.tastes "what"
body.owner.tell.should.have.been.called.with "what"
body.owner.tell.reset()
body.concious = false
body.tastes "what"
body.owner.tell.should.not.have.been.called()
it "should tell it's owner what it thinks, unless it's not conscious", ->
body = harnessBody()
body.thinks "what"
body.owner.tell.should.have.been.called.with "what"
body.owner.tell.reset()
body.concious = false
body.thinks "what"
body.owner.tell.should.not.have.been.called()
it "should produce a random body part", ->
harnessBody().randomPart().should.not.be.undefined
it "should find parts of it by name", ->
body = harnessBody()
#body.findPart("head").should.equal body.torso.parts.head
body.findPart("left eye").should.equal body.torso.parts.head.parts.face.parts.leftEye
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