CrazyDave1/Troll-Hunter — pull request #42 by scmx (2014-03-07 22:40:31+00:00)
Title: Spawn troll at random cave

Kolla #41 först, denna PR innehåller ett commit från den

### Let spawnTroll set pos to midPos() of randomCave()
Add Level#randomCave() which returns a random cave
Add Cave#midPos() which returns the middle pos of the cave

Jag slumpar vilken grotta trollen skapas i, men lägger inte till fler
grottor, så det fungerar precis som innan.

### Add entityMixin
This introduce concept of *mixins*, they reside in the `js/mixins`
directory and are meant to be used to extend the prototypes of classes.

For example:
```javascript
entityMixin.call(Cave.prototype)
```
This extends `Cave.prototype` with more instance methods and attributes
from the entity mixin.

You can then let it extend another mixin
```javascript
awesomeMixin.call(Cave.prototype)
```

... and reuse the mixin for extending other prototypes

```javascript
entityMixin.call(Tree.prototype)
awesomeMixin.call(Tree.prototype)
```

But what the heck is `call()`, and why do we wanna use it?

Call executes a function differently by changing the caller to be the first
argument (the following arguments are sent to the function as normal).
By changing caller to `Cave.prototype`, we make `this` inside the
`entityMixin` point to `Cave.prototype`.
That means that every time in the mixin function when we say that `this.something = 'something else'` we actually define that `something`-method
directly on `Cave.prototype` !

Note that this is not inheritance. Inheritance is limited to one
"parent", while mixins allow you to reuse behaviour from multiple objects.

### Refactor away every "opts" in favor of "options"

### Refactor Spider spawning
Let Tree.prototype extend entityMixin so it gets Tree#midPos()