Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:Raynos/wizard-game

  • Loading branch information...
commit 7da33eb97a4e84074a780e5544e765c3dfb7972e 2 parents 0d81175 + 3f40f77
@substack substack authored
Showing with 25 additions and 2 deletions.
  1. +4 −1 browser/ui/index.js
  2. +18 −0 help.json
  3. +3 −1 logic.js
View
5 browser/ui/index.js
@@ -13,7 +13,10 @@ module.exports = UI
function UI(doc) {
var world = World(doc)
var source = "// I am a wizard \n// self.say(self.id())" +
- "\n// self.say(Object.keys(self))"
+ "\n// self.say(Object.keys(self))" +
+ "\n// self.hear(function (message) {" +
+ "\n// self.say(message)" +
+ "\n// })"
var player = {
id: "wizard:" + NAME.name
View
18 help.json
@@ -38,4 +38,22 @@
, "or pass it an `{ x: x, y: y }` to move"
, ""
, "Try `self.move(self.whatDist(id))`"
+ , ""
+ , "## self.think(cb)"
+ , ""
+ , "You can't have timers or anything fancy"
+ , "But you can think. this will call your"
+ , "callback every half second"
+ , ""
+ , "## self.hear(cb)"
+ , ""
+ , "Listen on anyone saying messages. You"
+ , "will need to be near them and your"
+ , "callback gets called with message and"
+ , "id"
+ , ""
+ , "If you want to be an echo player try"
+ , "self.hear(function (message) {"
+ , " self.say(message)"
+ , "})"
]
View
4 logic.js
@@ -168,7 +168,9 @@ function api (row) {
hear: createListener('say', function (f) {
return function (message, id) {
- if(self.whatDist(id).length < 1000) f(message, id)
+ if(self.whatDist(id).length < 1000 && id !== self.id()) {
+ f(message, id)
+ }
}
}),
Please sign in to comment.
Something went wrong with that request. Please try again.