Skip to content

Commit

Permalink
If a loot table is set on a monster type, it is now propagated to the…
Browse files Browse the repository at this point in the history
… individual monster when instantiated.
  • Loading branch information
jonoxia committed Aug 27, 2015
1 parent c400acc commit 033485b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions rpgbase-client/encounterClasses.js
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,8 @@ function MonsterType(img, name, statBlock, commandList) {
this._commandList = [];
}
this._effectHandlers = {};

this._loot = null; // loot table
}
MonsterType.prototype = {
onEffect: function(effectName, callback) {
Expand All @@ -1202,6 +1204,10 @@ MonsterType.prototype = {
knowsCommand: function(cmd) {
this._commandList.push(cmd);
},

setLootTable: function(lootTable) {
this._loot = lootTable;
},

instantiate: function() {
// return a Monster instance
Expand All @@ -1210,8 +1216,12 @@ MonsterType.prototype = {
cloneStats[name] = this.statBlock[name];
}
var cloneCmds = this._commandList.slice();
return new Monster(this.img, cloneStats, cloneCmds,
this._effectHandlers);
var instance = new Monster(this.img, cloneStats, cloneCmds,
this._effectHandlers);
if (this._loot) {
instance.loot = this._loot;
}
return instance;
}
};

Expand Down

0 comments on commit 033485b

Please sign in to comment.