mounts: more item DRY-ing and cleanup

This commit is contained in:
Tyler Renelle
2013-11-14 12:12:49 -08:00
parent d124968273
commit ba548ed67b
3 changed files with 84 additions and 97 deletions
+39 -50
View File
@@ -8335,37 +8335,35 @@ if(typeof module != 'undefined' && module.exports){
user.items.food[drop.name] += 1;
drop.type = 'Food';
drop.dialog = "You've found a " + drop.text + " Food! " + drop.notes;
} else {
if (rarity > .3) {
drop = helpers.randomVal(eggs);
if ((_base2 = user.items.eggs)[_name1 = drop.name] == null) {
_base2[_name1] = 0;
}
user.items.eggs[drop.name]++;
drop.type = 'Egg';
drop.dialog = "You've found a " + drop.text + " Egg! " + drop.notes;
} else {
acceptableDrops = [];
if (rarity < .15) {
acceptableDrops = 'Base White Desert Red Shade Skeleton Zombie CottonCandyPink CottonCandyBlue Golden'.split(' ');
} else if (rarity < .2) {
acceptableDrops = 'Base White Desert Red Shade Skeleton Zombie CottonCandyPink CottonCandyBlue'.split(' ');
} else if (rarity < .25) {
acceptableDrops = 'Base White Desert Red Shade Skeleton'.split(' ');
} else {
acceptableDrops = ['Base', 'White', 'Desert'];
}
acceptableDrops = _.pick(hatchingPotions, (function(v, k) {
return __indexOf.call(acceptableDrops, k) >= 0;
}));
drop = helpers.randomVal(acceptableDrops);
if ((_base3 = user.items.hatchingPotions)[_name2 = drop.name] == null) {
_base3[_name2] = 0;
}
user.items.hatchingPotions[drop.name]++;
drop.type = 'HatchingPotion';
drop.dialog = "You've found a " + drop.text + " Hatching Potion! " + drop.notes;
} else if (rarity > .3) {
drop = helpers.randomVal(eggs);
if ((_base2 = user.items.eggs)[_name1 = drop.name] == null) {
_base2[_name1] = 0;
}
user.items.eggs[drop.name]++;
drop.type = 'Egg';
drop.dialog = "You've found a " + drop.text + " Egg! " + drop.notes;
} else {
acceptableDrops = [];
if (rarity < .15) {
acceptableDrops = 'Base White Desert Red Shade Skeleton Zombie CottonCandyPink CottonCandyBlue Golden'.split(' ');
} else if (rarity < .2) {
acceptableDrops = 'Base White Desert Red Shade Skeleton Zombie CottonCandyPink CottonCandyBlue'.split(' ');
} else if (rarity < .25) {
acceptableDrops = 'Base White Desert Red Shade Skeleton'.split(' ');
} else {
acceptableDrops = ['Base', 'White', 'Desert'];
}
acceptableDrops = _.pick(hatchingPotions, (function(v, k) {
return __indexOf.call(acceptableDrops, k) >= 0;
}));
drop = helpers.randomVal(acceptableDrops);
if ((_base3 = user.items.hatchingPotions)[_name2 = drop.name] == null) {
_base3[_name2] = 0;
}
user.items.hatchingPotions[drop.name]++;
drop.type = 'HatchingPotion';
drop.dialog = "You've found a " + drop.text + " Hatching Potion! " + drop.notes;
}
user._tmp.drop = drop;
user.items.lastDrop.date = +(new Date);
@@ -9742,53 +9740,43 @@ try {
hatchingPotions: {
Base: {
value: 1,
text: 'Base',
notes: "Hatches your pet in it's base form."
text: 'Base'
},
White: {
value: 2,
text: 'White',
notes: 'Turns your animal into a White pet.'
text: 'White'
},
Desert: {
value: 2,
text: 'Desert',
notes: 'Turns your animal into a Desert pet.'
text: 'Desert'
},
Red: {
value: 3,
text: 'Red',
notes: 'Turns your animal into a Red pet.'
text: 'Red'
},
Shade: {
value: 3,
text: 'Shade',
notes: 'Turns your animal into a Shade pet.'
text: 'Shade'
},
Skeleton: {
value: 3,
text: 'Skeleton',
notes: 'Turns your animal into a Skeleton.'
text: 'Skeleton'
},
Zombie: {
value: 4,
text: 'Zombie',
notes: 'Turns your animal into a Zombie.'
text: 'Zombie'
},
CottonCandyPink: {
value: 4,
text: 'Cotton Candy Pink',
notes: 'Turns your animal into a Cotton Candy Pink pet.'
text: 'Cotton Candy Pink'
},
CottonCandyBlue: {
value: 4,
text: 'Cotton Candy Blue',
notes: 'Turns your animal into a Cotton Candy Blue pet.'
text: 'Cotton Candy Blue'
},
Golden: {
value: 5,
text: 'Golden',
notes: 'Turns your animal into a Golden pet.'
text: 'Golden'
}
},
food: {
@@ -9866,6 +9854,7 @@ try {
_.each(items.hatchingPotions, function(pot, k) {
return _.defaults(pot, {
name: k,
value: 2,
notes: "Pour this on an egg, and it will hatch as a " + pot.text + " pet."
});
});
+34 -36
View File
@@ -134,7 +134,6 @@ randomDrop = (user, delta, priority, streak = 0, options={}) ->
# Food: 40% chance
if rarity > .6
drop = helpers.randomVal _.omit(items.items.food, 'Saddle')
user.items.food[drop.name] ?= 0
user.items.food[drop.name]+= 1
@@ -142,45 +141,44 @@ randomDrop = (user, delta, priority, streak = 0, options={}) ->
drop.dialog = "You've found a #{drop.text} Food! #{drop.notes}"
# Eggs & hatchingPotions: 60% chance
else if rarity > .3
drop = helpers.randomVal eggs
user.items.eggs[drop.name] ?= 0
user.items.eggs[drop.name]++
drop.type = 'Egg'
drop.dialog = "You've found a #{drop.text} Egg! #{drop.notes}"
# Hatching Potion, 30% chance - break down by rarity even more.
else
if rarity > .3
drop = helpers.randomVal(eggs)
user.items.eggs[drop.name] ?= 0
user.items.eggs[drop.name]++
drop.type = 'Egg'
drop.dialog = "You've found a #{drop.text} Egg! #{drop.notes}"
acceptableDrops = []
# Hatching Potion, 30% chance - break down by rarity even more.
# Tier 5 (Blue Moon Rare)
if rarity < .15
acceptableDrops = 'Base White Desert Red Shade Skeleton Zombie CottonCandyPink CottonCandyBlue Golden'.split(' ')
# Tier 4 (Very Rare)
else if rarity < .2
acceptableDrops = 'Base White Desert Red Shade Skeleton Zombie CottonCandyPink CottonCandyBlue'.split(' ')
# Tier 3 (Rare)
else if rarity < .25
acceptableDrops = 'Base White Desert Red Shade Skeleton'.split(' ')
# Commented out for testing with increased egg drop, delete if successful
# Tier 2 (Scarce)
# else if rarity < .4
# acceptableDrops = ['Base', 'White', 'Desert']
# Tier 1 (Common)
else
acceptableDrops = []
acceptableDrops = ['Base', 'White', 'Desert']
# Tier 5 (Blue Moon Rare)
if rarity < .15
acceptableDrops = 'Base White Desert Red Shade Skeleton Zombie CottonCandyPink CottonCandyBlue Golden'.split(' ')
# Tier 4 (Very Rare)
else if rarity < .2
acceptableDrops = 'Base White Desert Red Shade Skeleton Zombie CottonCandyPink CottonCandyBlue'.split(' ')
# Tier 3 (Rare)
else if rarity < .25
acceptableDrops = 'Base White Desert Red Shade Skeleton'.split(' ')
# Commented out for testing with increased egg drop, delete if successful
# Tier 2 (Scarce)
# else if rarity < .4
# acceptableDrops = ['Base', 'White', 'Desert']
# Tier 1 (Common)
else
acceptableDrops = ['Base', 'White', 'Desert']
acceptableDrops = _.pick hatchingPotions, ((v,k) -> k in acceptableDrops)
drop = helpers.randomVal acceptableDrops
user.items.hatchingPotions[drop.name] ?= 0
user.items.hatchingPotions[drop.name]++
drop.type = 'HatchingPotion'
drop.dialog = "You've found a #{drop.text} Hatching Potion! #{drop.notes}"
acceptableDrops = _.pick hatchingPotions, ((v,k) -> k in acceptableDrops)
drop = helpers.randomVal acceptableDrops
user.items.hatchingPotions[drop.name] ?= 0
user.items.hatchingPotions[drop.name]++
drop.type = 'HatchingPotion'
drop.dialog = "You've found a #{drop.text} Hatching Potion! #{drop.notes}"
# if they've dropped something, we want the consuming client to know so they can notify the user. See how the Derby
# app handles it for example. Would this be better handled as an emit() ?
+11 -11
View File
@@ -59,16 +59,16 @@ items = module.exports.items =
#{text: 'Polar Bear Cub', name: 'PolarBearCub', value: 3}
hatchingPotions:
Base: value: 1, text: 'Base', notes: "Hatches your pet in it's base form."
White: value: 2, text: 'White', notes: 'Turns your animal into a White pet.'
Desert: value: 2, text: 'Desert', notes: 'Turns your animal into a Desert pet.'
Red: value: 3, text: 'Red', notes: 'Turns your animal into a Red pet.'
Shade: value: 3, text: 'Shade', notes: 'Turns your animal into a Shade pet.'
Skeleton: value: 3, text: 'Skeleton', notes: 'Turns your animal into a Skeleton.'
Zombie: value: 4, text: 'Zombie', notes: 'Turns your animal into a Zombie.'
CottonCandyPink: value: 4, text: 'Cotton Candy Pink', notes: 'Turns your animal into a Cotton Candy Pink pet.'
CottonCandyBlue: value: 4, text: 'Cotton Candy Blue', notes: 'Turns your animal into a Cotton Candy Blue pet.'
Golden: value: 5, text: 'Golden', notes: 'Turns your animal into a Golden pet.'
Base: value: 1, text: 'Base'
White: value: 2, text: 'White'
Desert: value: 2, text: 'Desert'
Red: value: 3, text: 'Red'
Shade: value: 3, text: 'Shade'
Skeleton: value: 3, text: 'Skeleton'
Zombie: value: 4, text: 'Zombie'
CottonCandyPink: value: 4, text: 'Cotton Candy Pink'
CottonCandyBlue: value: 4, text: 'Cotton Candy Blue'
Golden: value: 5, text: 'Golden'
food:
Meat: text: 'Meat', target: 'Base'
@@ -105,7 +105,7 @@ _.each items.eggs, (egg,k) ->
mountText: egg.text
_.each items.hatchingPotions, (pot,k) ->
_.defaults pot, {name: k, notes: "Pour this on an egg, and it will hatch as a #{pot.text} pet."}
_.defaults pot, {name: k, value: 2, notes: "Pour this on an egg, and it will hatch as a #{pot.text} pet."}
_.each items.food, (food,k) ->
_.defaults food, {value: 1, name: k, notes: "Feed this to a pet and it may grown into a sturdy steed."}