-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathloot.js
More file actions
62 lines (52 loc) · 1.89 KB
/
Copy pathloot.js
File metadata and controls
62 lines (52 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
*
* Mouse Pro
*
* loot.js
*/
(function (Shop, Display, Loot) {
Loot.categories = [
{
category: 'knifepart',
baseLootChance: 1/5,
getLootChance: function() { return this.baseLootChance; },
boosts: []
},
];
Loot.category = function(category) {
return Loot.categories.filter(c => c.category == category)[0];
}
Loot.addBoostToCategory = function(boost, category) {
if (!Shop.has(boost)) {
let lootCategory = Loot.category(category);
lootCategory.boosts.push(boost);
}
}
let knifeparts = [ 'serratedblade', 'rubypommel', 'dragongrip', 'diamondbladetip', 'cheatersscabbard' ];
knifeparts.forEach(boost => {
if (!Shop.has(boost)) {
Loot.addBoostToCategory(boost, 'knifepart');
}
});
Loot.tryLootCategory = function(category) {
let lootCategory = Loot.category(category);
if (lootCategory.boosts.length == 0) return;
let lootChance = lootCategory.getLootChance();
let roll = Math.random();
if (roll <= lootChance) {
let looted = false;
while (!looted && lootCategory.boosts.length != 0) {
let lootedBoost = lootCategory.boosts[Math.floor(Math.random()*lootCategory.boosts.length)];
lootCategory.boosts = lootCategory.boosts.filter(b => b != lootedBoost);
if (Shop.boost(lootedBoost) == undefined){
console.debug('invalid loot', lootedBoost);
}
else if (!Shop.has(lootedBoost)) {
Display.notifyLoot(lootedBoost);
Shop.unlock(lootedBoost);
looted = true;
}
}
}
}
})(gameObjects.Shop, gameObjects.Display, gameObjects.Loot);