mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-05-22 21:57:03 +00:00
Merge branch 'mounts'
This commit is contained in:
commit
9863ca0ce5
7 changed files with 278 additions and 284 deletions
|
|
@ -1,13 +1,17 @@
|
|||
.Mount_Head_Lion, .Mount_Body_Lion, .Mount_Head_PolarBear, .Mount_Body_PolarBear, .Mount_Head_Panda, .Mount_Body_Panda, .Mount_Head_Tiger, .Mount_Body_Tiger, .Mount_Head_Bear, .Mount_Body_Bear, .Mount_Head_EtherealLion, .Mount_Body_EtherealLion {background: url('../img/sprites/Mount-SpriteSheet.png') no-repeat; }
|
||||
.Mount_Head_Lion {background-position: 0 0; width: 105px; height: 123px}
|
||||
.Mount_Body_Lion {background-position: -105 0; width: 105px; height: 123px}
|
||||
.Mount_Head_PolarBear {background-position: -210 0; width: 105px; height: 123px}
|
||||
.Mount_Body_PolarBear {background-position: -315 0; width: 105px; height: 123px}
|
||||
.Mount_Head_Panda {background-position: -420 0; width: 105px; height: 123px}
|
||||
.Mount_Body_Panda {background-position: -525 0; width: 105px; height: 123px}
|
||||
.Mount_Head_Tiger {background-position: -630 0; width: 105px; height: 123px}
|
||||
.Mount_Body_Tiger {background-position: -735 0; width: 105px; height: 123px}
|
||||
.Mount_Head_Bear {background-position: -840 0; width: 105px; height: 123px}
|
||||
.Mount_Body_Bear {background-position: -945 0; width: 105px; height: 123px}
|
||||
.Mount_Head_EtherealLion {background-position: -1050 0; width: 105px; height: 123px}
|
||||
.Mount_Body_EtherealLion {background-position: -1155 0; width: 105px; height: 123px}
|
||||
.Mount_Head_LionCub-Base, .Mount_Body_LionCub-Base, .Mount_Head_BearCub-Polar, .Mount_Body_BearCub-Polar, .Mount_Head_PandaCub-Base, .Mount_Body_PandaCub-Base, .Mount_Head_TigerCub-Base, .Mount_Body_TigerCub-Base, .Mount_Head_BearCub-Base, .Mount_Body_BearCub-Base, .Mount_Head_LionCub-Ethereal, .Mount_Body_LionCub-Ethereal {
|
||||
background: url('../img/sprites/Mount-SpriteSheet.png') no-repeat;
|
||||
width: 105px;
|
||||
height: 123px;
|
||||
}
|
||||
.Mount_Head_LionCub-Base {background-position: 0px 0px;}
|
||||
.Mount_Body_LionCub-Base {background-position: -105px 0px;}
|
||||
.Mount_Head_BearCub-Polar {background-position: -210px 0px;}
|
||||
.Mount_Body_BearCub-Polar {background-position: -315px 0px;}
|
||||
.Mount_Head_PandaCub-Base {background-position: -420px 0px;}
|
||||
.Mount_Body_PandaCub-Base {background-position: -525px 0px;}
|
||||
.Mount_Head_TigerCub-Base {background-position: -630px 0px;}
|
||||
.Mount_Body_TigerCub-Base {background-position: -735px 0px;}
|
||||
.Mount_Head_BearCub-Base {background-position: -840px 0px;}
|
||||
.Mount_Body_BearCub-Base {background-position: -945px 0px;}
|
||||
.Mount_Head_LionCub-Ethereal {background-position: -1050px 0px;}
|
||||
.Mount_Body_LionCub-Ethereal {background-position: -1155px 0px;}
|
||||
|
|
|
|||
293
dist/habitrpg-shared.js
vendored
293
dist/habitrpg-shared.js
vendored
|
|
@ -8131,7 +8131,7 @@ if(typeof module != 'undefined' && module.exports){
|
|||
|
||||
},{}],5:[function(require,module,exports){
|
||||
(function() {
|
||||
var HP, XP, hatchingPotions, helpers, items, moment, obj, pets, preenHistory, randomDrop, updateStats, _, _ref,
|
||||
var HP, XP, eggs, hatchingPotions, helpers, items, moment, obj, preenHistory, randomDrop, updateStats, _, _ref,
|
||||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
|
||||
moment = require('moment');
|
||||
|
|
@ -8142,7 +8142,7 @@ if(typeof module != 'undefined' && module.exports){
|
|||
|
||||
items = require('./items.coffee');
|
||||
|
||||
_ref = items.items, pets = _ref.pets, hatchingPotions = _ref.hatchingPotions;
|
||||
_ref = items.items, eggs = _ref.eggs, hatchingPotions = _ref.hatchingPotions;
|
||||
|
||||
XP = 15;
|
||||
|
||||
|
|
@ -8304,7 +8304,7 @@ if(typeof module != 'undefined' && module.exports){
|
|||
|
||||
|
||||
randomDrop = function(user, delta, priority, streak, options) {
|
||||
var acceptableDrops, chanceMultiplier, drop, paths, rarity, reachedDropLimit, _base, _base1, _base2, _ref1;
|
||||
var acceptableDrops, chanceMultiplier, drop, paths, rarity, reachedDropLimit, _base, _base1, _base2, _name, _name1, _ref1;
|
||||
if (streak == null) {
|
||||
streak = 0;
|
||||
}
|
||||
|
|
@ -8318,7 +8318,6 @@ if(typeof module != 'undefined' && module.exports){
|
|||
count: 0
|
||||
};
|
||||
}
|
||||
paths['items.lastDrop'] = true;
|
||||
reachedDropLimit = (helpers.daysSince(user.items.lastDrop.date, user.preferences) === 0) && (user.items.lastDrop.count >= 2);
|
||||
if (reachedDropLimit) {
|
||||
return;
|
||||
|
|
@ -8329,36 +8328,28 @@ if(typeof module != 'undefined' && module.exports){
|
|||
if (((_ref1 = user.flags) != null ? _ref1.dropsEnabled : void 0) && Math.random() < (.05 * chanceMultiplier)) {
|
||||
rarity = Math.random();
|
||||
if (rarity > .5) {
|
||||
drop = helpers.randomVal(pets);
|
||||
((_base1 = user.items).eggs != null ? (_base1 = user.items).eggs : _base1.eggs = []).push(drop);
|
||||
paths['items.eggs'] = true;
|
||||
drop = helpers.randomVal(eggs);
|
||||
if ((_base1 = user.items.eggs)[_name = drop.name] == null) {
|
||||
_base1[_name] = 0;
|
||||
}
|
||||
user.items.eggs[drop.name]++;
|
||||
drop.type = 'Egg';
|
||||
drop.dialog = "You've found a " + drop.text + " Egg! " + drop.notes;
|
||||
} else {
|
||||
acceptableDrops = [];
|
||||
if (rarity < .1) {
|
||||
acceptableDrops = ['Base', 'White', 'Desert', 'Red', 'Shade', 'Skeleton', 'Zombie', 'CottonCandyPink', 'CottonCandyBlue', 'Golden'];
|
||||
} else if (rarity < .2) {
|
||||
acceptableDrops = ['Base', 'White', 'Desert', 'Red', 'Shade', 'Skeleton', 'Zombie', 'CottonCandyPink', 'CottonCandyBlue'];
|
||||
} else if (rarity < .3) {
|
||||
acceptableDrops = ['Base', 'White', 'Desert', 'Red', 'Shade', 'Skeleton'];
|
||||
} else {
|
||||
acceptableDrops = ['Base', 'White', 'Desert'];
|
||||
acceptableDrops = rarity < .05 ? ['Golden'] : rarity < .1 ? ['Zombie', 'CottonCandyPink', 'CottonCandyBlue'] : rarity < .15 ? ['Red', 'Shade', 'Skeleton'] : ['Base', 'White', 'Desert'];
|
||||
drop = helpers.randomVal(_.pick(hatchingPotions, (function(v, k) {
|
||||
return __indexOf.call(acceptableDrops, k) >= 0;
|
||||
})));
|
||||
if ((_base2 = user.items.hatchingPotions)[_name1 = drop.name] == null) {
|
||||
_base2[_name1] = 0;
|
||||
}
|
||||
acceptableDrops = hatchingPotions.filter(function(hatchingPotion) {
|
||||
var _ref2;
|
||||
return _ref2 = hatchingPotion.name, __indexOf.call(acceptableDrops, _ref2) >= 0;
|
||||
});
|
||||
drop = helpers.randomVal(acceptableDrops);
|
||||
((_base2 = user.items).hatchingPotions != null ? (_base2 = user.items).hatchingPotions : _base2.hatchingPotions = []).push(drop.name);
|
||||
paths['items.hatchingPotions'] = true;
|
||||
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);
|
||||
user.items.lastDrop.count++;
|
||||
return paths['items.lastDrop'] = true;
|
||||
return user.items.lastDrop.count++;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -8514,11 +8505,9 @@ if(typeof module != 'undefined' && module.exports){
|
|||
if (newStats.hp != null) {
|
||||
if (newStats.hp <= 0) {
|
||||
user.stats.hp = 0;
|
||||
paths['stats.hp'] = true;
|
||||
return;
|
||||
} else {
|
||||
user.stats.hp = newStats.hp;
|
||||
paths['stats.hp'] = true;
|
||||
}
|
||||
}
|
||||
if (newStats.exp != null) {
|
||||
|
|
@ -8542,28 +8531,21 @@ if(typeof module != 'undefined' && module.exports){
|
|||
}
|
||||
}
|
||||
user.stats.exp = newStats.exp;
|
||||
paths["stats.exp"] = true;
|
||||
paths['stats.lvl'] = true;
|
||||
paths['stats.gp'] = true;
|
||||
paths['stats.hp'] = true;
|
||||
if (user.flags == null) {
|
||||
user.flags = {};
|
||||
}
|
||||
if (!user.flags.customizationsNotification && (user.stats.exp > 10 || user.stats.lvl > 1)) {
|
||||
user.flags.customizationsNotification = true;
|
||||
paths['flags.customizationsNotification'] = true;
|
||||
}
|
||||
if (!user.flags.itemsEnabled && user.stats.lvl >= 2) {
|
||||
user.flags.itemsEnabled = true;
|
||||
paths['flags.itemsEnabled'] = true;
|
||||
}
|
||||
if (!user.flags.partyEnabled && user.stats.lvl >= 3) {
|
||||
user.flags.partyEnabled = true;
|
||||
paths['flags.partyEnabled'] = true;
|
||||
}
|
||||
if (!user.flags.dropsEnabled && user.stats.lvl >= 4) {
|
||||
user.flags.dropsEnabled = true;
|
||||
paths['flags.dropsEnabled'] = true;
|
||||
user.items.eggs["Wolf"] = 1;
|
||||
}
|
||||
}
|
||||
if (newStats.gp != null) {
|
||||
|
|
@ -8936,7 +8918,12 @@ var process=require("__browserify_process");(function() {
|
|||
lastDrop: {
|
||||
date: +(new Date),
|
||||
count: 0
|
||||
}
|
||||
},
|
||||
eggs: {},
|
||||
food: {},
|
||||
hatchingPotions: {},
|
||||
pets: {},
|
||||
mounts: {}
|
||||
},
|
||||
preferences: {
|
||||
gender: 'm',
|
||||
|
|
@ -9262,13 +9249,6 @@ var process=require("__browserify_process");(function() {
|
|||
}
|
||||
return classes;
|
||||
},
|
||||
/*
|
||||
Does the user own this pet?
|
||||
*/
|
||||
|
||||
ownsPet: function(pet, userPets) {
|
||||
return _.isArray(userPets) && userPets.indexOf(pet) !== -1;
|
||||
},
|
||||
/*
|
||||
Friendly timestamp
|
||||
*/
|
||||
|
|
@ -9706,98 +9686,128 @@ try {
|
|||
notes: "Resets your task values back to 0 (yellow). Useful when everything's red and it's hard to stay alive.",
|
||||
value: 0
|
||||
},
|
||||
pets: [
|
||||
{
|
||||
text: 'Wolf',
|
||||
name: 'Wolf',
|
||||
value: 3
|
||||
}, {
|
||||
eggs: {
|
||||
Wolf: {
|
||||
text: 'Wolf'
|
||||
},
|
||||
TigerCub: {
|
||||
text: 'Tiger Cub',
|
||||
name: 'TigerCub',
|
||||
value: 3
|
||||
}, {
|
||||
mountText: 'Tiger'
|
||||
},
|
||||
PandaCub: {
|
||||
text: 'Panda Cub',
|
||||
name: 'PandaCub',
|
||||
value: 3
|
||||
}, {
|
||||
mountText: 'Panda'
|
||||
},
|
||||
LionCub: {
|
||||
text: 'Lion Cub',
|
||||
name: 'LionCub',
|
||||
value: 3
|
||||
}, {
|
||||
text: 'Fox',
|
||||
name: 'Fox',
|
||||
value: 3
|
||||
}, {
|
||||
text: 'Flying Pig',
|
||||
name: 'FlyingPig',
|
||||
value: 3
|
||||
}, {
|
||||
text: 'Dragon',
|
||||
name: 'Dragon',
|
||||
value: 3
|
||||
}, {
|
||||
text: 'Cactus',
|
||||
name: 'Cactus',
|
||||
value: 3
|
||||
}, {
|
||||
mountText: 'Lion'
|
||||
},
|
||||
Fox: {
|
||||
text: 'Fox'
|
||||
},
|
||||
FlyingPig: {
|
||||
text: 'Flying Pig'
|
||||
},
|
||||
Dragon: {
|
||||
text: 'Dragon'
|
||||
},
|
||||
Cactus: {
|
||||
text: 'Cactus'
|
||||
},
|
||||
BearCub: {
|
||||
text: 'Bear Cub',
|
||||
name: 'BearCub',
|
||||
value: 3
|
||||
mountText: 'Bear'
|
||||
}
|
||||
],
|
||||
hatchingPotions: [
|
||||
{
|
||||
text: 'Base',
|
||||
name: 'Base',
|
||||
notes: "Hatches your pet in it's base form.",
|
||||
value: 1
|
||||
}, {
|
||||
text: 'White',
|
||||
name: 'White',
|
||||
notes: 'Turns your animal into a White pet.',
|
||||
value: 2
|
||||
}, {
|
||||
text: 'Desert',
|
||||
name: 'Desert',
|
||||
notes: 'Turns your animal into a Desert pet.',
|
||||
value: 2
|
||||
}, {
|
||||
text: 'Red',
|
||||
name: 'Red',
|
||||
notes: 'Turns your animal into a Red pet.',
|
||||
value: 3
|
||||
}, {
|
||||
text: 'Shade',
|
||||
name: 'Shade',
|
||||
notes: 'Turns your animal into a Shade pet.',
|
||||
value: 3
|
||||
}, {
|
||||
text: 'Skeleton',
|
||||
name: 'Skeleton',
|
||||
notes: 'Turns your animal into a Skeleton.',
|
||||
value: 3
|
||||
}, {
|
||||
text: 'Zombie',
|
||||
name: 'Zombie',
|
||||
notes: 'Turns your animal into a Zombie.',
|
||||
value: 4
|
||||
}, {
|
||||
text: 'Cotton Candy Pink',
|
||||
name: 'CottonCandyPink',
|
||||
notes: 'Turns your animal into a Cotton Candy Pink pet.',
|
||||
value: 4
|
||||
}, {
|
||||
text: 'Cotton Candy Blue',
|
||||
name: 'CottonCandyBlue',
|
||||
notes: 'Turns your animal into a Cotton Candy Blue pet.',
|
||||
value: 4
|
||||
}, {
|
||||
text: 'Golden',
|
||||
name: 'Golden',
|
||||
notes: 'Turns your animal into a Golden pet.',
|
||||
value: 5
|
||||
},
|
||||
hatchingPotions: {
|
||||
Base: {
|
||||
value: 2,
|
||||
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'
|
||||
},
|
||||
Milk: {
|
||||
text: 'Milk',
|
||||
target: 'White'
|
||||
},
|
||||
Potatoe: {
|
||||
text: 'Potatoe',
|
||||
target: 'Desert'
|
||||
},
|
||||
Strawberry: {
|
||||
text: 'Strawberry',
|
||||
target: 'Red'
|
||||
},
|
||||
Chocolate: {
|
||||
text: 'Chocolate',
|
||||
target: 'Shade'
|
||||
},
|
||||
Fish: {
|
||||
text: 'Fish',
|
||||
target: 'Skeleton'
|
||||
},
|
||||
RottenMeat: {
|
||||
text: 'Rotten Meat',
|
||||
target: 'Zombie'
|
||||
},
|
||||
CottonCandyPink: {
|
||||
text: 'Pink Cotton Candy',
|
||||
target: 'CottonCandyPink'
|
||||
},
|
||||
CottonCandyBlue: {
|
||||
text: 'Blue Cotton Candy',
|
||||
target: 'CottonCandyBlue'
|
||||
},
|
||||
Honey: {
|
||||
text: 'Honey',
|
||||
target: 'Golden'
|
||||
},
|
||||
Saddle: {
|
||||
text: 'Saddle',
|
||||
value: 5,
|
||||
notes: 'Instantly raises your pet into a mount.'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
reversed = {};
|
||||
|
|
@ -9814,12 +9824,29 @@ try {
|
|||
});
|
||||
});
|
||||
|
||||
_.each(items.pets, function(pet) {
|
||||
return pet.notes = 'Find a hatching potion to pour on this egg, and it will hatch into a loyal pet.';
|
||||
_.each(items.eggs, function(egg, k) {
|
||||
return _.defaults(egg, {
|
||||
value: 3,
|
||||
name: k,
|
||||
notes: 'Find a hatching potion to pour on this egg, and it will hatch into a loyal pet.',
|
||||
mountText: egg.text
|
||||
});
|
||||
});
|
||||
|
||||
_.each(items.hatchingPotions, function(hatchingPotion) {
|
||||
return hatchingPotion.notes = "Pour this on an egg, and it will hatch as a " + hatchingPotion.text + " pet.";
|
||||
_.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."
|
||||
});
|
||||
});
|
||||
|
||||
_.each(items.food, function(food, k) {
|
||||
return _.defaults(food, {
|
||||
value: 1,
|
||||
name: k,
|
||||
notes: "Feed this to a pet and it may grown into a sturdy steed."
|
||||
});
|
||||
});
|
||||
|
||||
module.exports.buyItem = function(user, type) {
|
||||
|
|
|
|||
2
dist/spritesheets.css
vendored
2
dist/spritesheets.css
vendored
File diff suppressed because one or more lines are too long
|
|
@ -1,59 +0,0 @@
|
|||
// FIXME this needs to be ported into algos.cron so it's run for each individual user on the server. It used to be a migration script
|
||||
/**
|
||||
* Preen history for users with > 7 history entries
|
||||
* This takes an infinite array of single day entries [day day day day day...], and turns it into a condensed array
|
||||
* of averages, condensing more the further back in time we go. Eg, 7 entries each for last 7 days; 4 entries for last
|
||||
* 4 weeks; 12 entries for last 12 months; 1 entry per year before that: [day*7 week*4 month*12 year*infinite]
|
||||
*/
|
||||
function preenHistory(history) {
|
||||
history = _.filter(history, function(h) {return !!h}); // discard nulls (corrupted somehow)
|
||||
var newHistory = [];
|
||||
function preen(amount, groupBy) {
|
||||
var groups, avg, start;
|
||||
groups = _(history)
|
||||
.groupBy(function(h) { return moment(h.date).format(groupBy) }) // get date groupings to average against
|
||||
.sortBy(function(h,k) {return k;}) // sort by date
|
||||
.value(); // turn into an array
|
||||
amount++; // if we want the last 4 weeks, we're going 4 weeks back excluding this week. so +1 to account for exclusion
|
||||
start = (groups.length - amount > 0) ? groups.length - amount : 0;
|
||||
groups = groups.slice(start, groups.length - 1)
|
||||
_.each(groups, function(group){
|
||||
avg = _.reduce(group, function(mem, obj){ return mem + obj.value }, 0) / group.length;
|
||||
newHistory.push({date: +moment(group[0].date), value: avg});
|
||||
return true;
|
||||
})
|
||||
}
|
||||
|
||||
preen(50, 'YYYY'); // last 50 years
|
||||
preen(12, 'YYYYMM'); // last 12 months
|
||||
preen(4, 'YYYYww'); // last 4 weeks
|
||||
newHistory = newHistory.concat(history.slice(-7)); // last 7 days
|
||||
return newHistory;
|
||||
}
|
||||
|
||||
var minHistLen = 7;
|
||||
db.users.find({
|
||||
|
||||
// Registered users with some history
|
||||
$or: [
|
||||
{ 'auth.local': { $exists: true }},
|
||||
{ 'auth.facebook': { $exists: true }}
|
||||
],
|
||||
'history': {$exists: true}
|
||||
|
||||
}).forEach(function(user) {
|
||||
var update = {$set:{}};
|
||||
|
||||
_.each(user.tasks, function(task) {
|
||||
if ( task.history && task.history.length > minHistLen )
|
||||
update['$set']['tasks.' + task.id + '.history'] = preenHistory(task.history);
|
||||
return true;
|
||||
})
|
||||
|
||||
if (user.history.exp && user.history.exp.length > minHistLen)
|
||||
update['$set']['history.exp'] = preenHistory(user.history.exp);
|
||||
if (user.history.todos && user.history.todos.length > minHistLen)
|
||||
update['$set']['history.todos'] = preenHistory(user.history.todos);
|
||||
|
||||
if (!_.isEmpty(update['$set'])) db.users.update({_id: user._id}, update);
|
||||
});
|
||||
|
|
@ -2,7 +2,7 @@ moment = require('moment')
|
|||
_ = require('lodash')
|
||||
helpers = require('./helpers.coffee')
|
||||
items = require('./items.coffee')
|
||||
{pets, hatchingPotions} = items.items
|
||||
{eggs, hatchingPotions} = items.items
|
||||
|
||||
XP = 15
|
||||
HP = 2
|
||||
|
|
@ -118,7 +118,6 @@ randomDrop = (user, delta, priority, streak = 0, options={}) ->
|
|||
user.items.lastDrop ?=
|
||||
date: +moment().subtract('d', 1) # trick - set it to yesterday on first run, that way they can get drops today
|
||||
count: 0
|
||||
paths['items.lastDrop'] = true
|
||||
|
||||
reachedDropLimit = (helpers.daysSince(user.items.lastDrop.date, user.preferences) is 0) and (user.items.lastDrop.count >= 2)
|
||||
return if reachedDropLimit
|
||||
|
|
@ -133,45 +132,40 @@ randomDrop = (user, delta, priority, streak = 0, options={}) ->
|
|||
# If they got a drop: 50% chance of egg, 50% Hatching Potion. If hatchingPotion, broken down further even further
|
||||
rarity = Math.random()
|
||||
|
||||
# Egg, 50% chance
|
||||
# # 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
|
||||
# drop.type = 'Food'
|
||||
# drop.dialog = "You've found a #{drop.text} Food! #{drop.notes}"
|
||||
|
||||
# Eggs: 30% chance
|
||||
if rarity > .5
|
||||
drop = helpers.randomVal(pets)
|
||||
(user.items.eggs ?= []).push drop; paths['items.eggs'] = true
|
||||
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, 50% chance - break down by rarity even more. FIXME this may not be the best method, so revisit
|
||||
# Hatching Potion, 30% chance - break down by rarity.
|
||||
else
|
||||
acceptableDrops = []
|
||||
acceptableDrops =
|
||||
# Very Rare: 10% (of 30%)
|
||||
if rarity < .05 then ['Golden']
|
||||
# Rare: 20% (of 30%)
|
||||
else if rarity < .1 then ['Zombie', 'CottonCandyPink', 'CottonCandyBlue']
|
||||
# Uncommon: 30% (of 30%)
|
||||
else if rarity < .15 then ['Red', 'Shade', 'Skeleton']
|
||||
# Common: 40% (of 30%)
|
||||
else ['Base', 'White', 'Desert']
|
||||
|
||||
# Tier 5 (Blue Moon Rare)
|
||||
if rarity < .1
|
||||
acceptableDrops =
|
||||
['Base', 'White', 'Desert', 'Red', 'Shade', 'Skeleton', 'Zombie', 'CottonCandyPink', 'CottonCandyBlue',
|
||||
'Golden']
|
||||
# No Rarity (@see https://github.com/HabitRPG/habitrpg/issues/1048, we may want to remove rareness when we add mounts)
|
||||
#drop = helpers.randomVal hatchingPotions
|
||||
drop = helpers.randomVal _.pick(hatchingPotions, ((v,k) -> k in acceptableDrops))
|
||||
|
||||
# Tier 4 (Very Rare)
|
||||
else if rarity < .2
|
||||
acceptableDrops =
|
||||
['Base', 'White', 'Desert', 'Red', 'Shade', 'Skeleton', 'Zombie', 'CottonCandyPink', 'CottonCandyBlue']
|
||||
|
||||
# Tier 3 (Rare)
|
||||
else if rarity < .3
|
||||
acceptableDrops = ['Base', 'White', 'Desert', 'Red', 'Shade', 'Skeleton']
|
||||
|
||||
# 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 = hatchingPotions.filter (hatchingPotion) ->
|
||||
hatchingPotion.name in acceptableDrops
|
||||
drop = helpers.randomVal acceptableDrops
|
||||
(user.items.hatchingPotions ?= []).push drop.name; paths['items.hatchingPotions'] = true
|
||||
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}"
|
||||
|
||||
|
|
@ -181,7 +175,6 @@ randomDrop = (user, delta, priority, streak = 0, options={}) ->
|
|||
|
||||
user.items.lastDrop.date = +new Date
|
||||
user.items.lastDrop.count++
|
||||
paths['items.lastDrop'] = true
|
||||
|
||||
|
||||
# {task} task you want to score
|
||||
|
|
@ -313,10 +306,10 @@ updateStats = (user, newStats, options={}) ->
|
|||
if newStats.hp?
|
||||
# Game Over
|
||||
if newStats.hp <= 0
|
||||
user.stats.hp = 0; paths['stats.hp'] = true # signifies dead
|
||||
user.stats.hp = 0
|
||||
return
|
||||
else
|
||||
user.stats.hp = newStats.hp; paths['stats.hp'] = true
|
||||
user.stats.hp = newStats.hp
|
||||
|
||||
if newStats.exp?
|
||||
tnl = obj.tnl(user.stats.lvl)
|
||||
|
|
@ -341,21 +334,17 @@ updateStats = (user, newStats, options={}) ->
|
|||
|
||||
user.stats.exp = newStats.exp
|
||||
|
||||
paths["stats.exp"]=true; paths['stats.lvl']=true; paths['stats.gp']=true; paths['stats.hp']=true;
|
||||
#if silent
|
||||
#console.log("pushing silent :" + obj.stats.exp)
|
||||
|
||||
|
||||
# Set flags when they unlock features
|
||||
user.flags ?= {}
|
||||
if !user.flags.customizationsNotification and (user.stats.exp > 10 or user.stats.lvl > 1)
|
||||
user.flags.customizationsNotification = true; paths['flags.customizationsNotification']=true;
|
||||
user.flags.customizationsNotification = true
|
||||
if !user.flags.itemsEnabled and user.stats.lvl >= 2
|
||||
user.flags.itemsEnabled = true; paths['flags.itemsEnabled']=true;
|
||||
user.flags.itemsEnabled = true
|
||||
if !user.flags.partyEnabled and user.stats.lvl >= 3
|
||||
user.flags.partyEnabled = true; paths['flags.partyEnabled']=true;
|
||||
user.flags.partyEnabled = true
|
||||
if !user.flags.dropsEnabled and user.stats.lvl >= 4
|
||||
user.flags.dropsEnabled = true; paths['flags.dropsEnabled']=true;
|
||||
user.flags.dropsEnabled = true
|
||||
user.items.eggs["Wolf"] = 1
|
||||
|
||||
if newStats.gp?
|
||||
#FIXME what was I doing here? I can't remember, gp isn't defined
|
||||
|
|
|
|||
|
|
@ -81,7 +81,18 @@ module.exports =
|
|||
# _id / id handled by Racer
|
||||
stats: { gp: 0, exp: 0, lvl: 1, hp: 50 }
|
||||
invitations: {party:null, guilds: []}
|
||||
items: { weapon: 0, armor: 0, head: 0, shield: 0, lastDrop: { date: +new Date, count: 0 } }
|
||||
items:
|
||||
weapon: 0
|
||||
armor: 0
|
||||
head: 0
|
||||
shield: 0
|
||||
lastDrop: { date: +new Date, count: 0 }
|
||||
eggs: {}
|
||||
food: {}
|
||||
hatchingPotions: {}
|
||||
pets: {}
|
||||
mounts: {}
|
||||
|
||||
preferences: { gender: 'm', skin: 'white', hair: 'blond', armorSet: 'v1', dayStart:0, showHelm: true }
|
||||
apiToken: uuid() # set in newUserObject below
|
||||
lastCron: +new Date #this will be replaced with `+new Date` on first run
|
||||
|
|
@ -274,11 +285,6 @@ module.exports =
|
|||
classes += ' color-best'
|
||||
return classes
|
||||
|
||||
###
|
||||
Does the user own this pet?
|
||||
###
|
||||
ownsPet: (pet, userPets) -> _.isArray(userPets) and userPets.indexOf(pet) != -1
|
||||
|
||||
###
|
||||
Friendly timestamp
|
||||
###
|
||||
|
|
|
|||
|
|
@ -45,31 +45,48 @@ items = module.exports.items =
|
|||
potion: {type: 'potion', text: "Potion", notes: "Recover 15 HP (Instant Use)", value: 25, classes: 'potion'}
|
||||
reroll: {type: 'reroll', text: "Re-Roll", classes: 'reroll', notes: "Resets your task values back to 0 (yellow). Useful when everything's red and it's hard to stay alive.", value:0 }
|
||||
|
||||
pets: [
|
||||
{text: 'Wolf', name: 'Wolf', value: 3}
|
||||
{text: 'Tiger Cub', name: 'TigerCub', value: 3}
|
||||
#{text: 'Polar Bear Cub', name: 'PolarBearCub', value: 3} #commented out because there are no polarbear modifiers yet, special drop?
|
||||
{text: 'Panda Cub', name: 'PandaCub', value: 3}
|
||||
{text: 'Lion Cub', name: 'LionCub', value: 3}
|
||||
{text: 'Fox', name: 'Fox', value: 3}
|
||||
{text: 'Flying Pig', name: 'FlyingPig', value: 3}
|
||||
{text: 'Dragon', name: 'Dragon', value: 3}
|
||||
{text: 'Cactus', name: 'Cactus', value: 3}
|
||||
{text: 'Bear Cub', name: 'BearCub', value: 3}
|
||||
]
|
||||
eggs:
|
||||
# value & other defaults set below
|
||||
Wolf: text: 'Wolf'
|
||||
TigerCub: text: 'Tiger Cub', mountText: 'Tiger'
|
||||
PandaCub: text: 'Panda Cub', mountText: 'Panda'
|
||||
LionCub: text: 'Lion Cub', mountText: 'Lion'
|
||||
Fox: text: 'Fox'
|
||||
FlyingPig: text: 'Flying Pig'
|
||||
Dragon: text: 'Dragon'
|
||||
Cactus: text: 'Cactus'
|
||||
BearCub: text: 'Bear Cub', mountText: 'Bear'
|
||||
#{text: 'Polar Bear Cub', name: 'PolarBearCub', value: 3}
|
||||
|
||||
hatchingPotions: [
|
||||
{text: 'Base', name: 'Base', notes: "Hatches your pet in it's base form.", value: 1}
|
||||
{text: 'White', name: 'White', notes: 'Turns your animal into a White pet.', value: 2}
|
||||
{text: 'Desert', name: 'Desert', notes: 'Turns your animal into a Desert pet.', value: 2}
|
||||
{text: 'Red', name: 'Red', notes: 'Turns your animal into a Red pet.', value: 3}
|
||||
{text: 'Shade', name: 'Shade', notes: 'Turns your animal into a Shade pet.', value: 3}
|
||||
{text: 'Skeleton', name: 'Skeleton', notes: 'Turns your animal into a Skeleton.', value: 3}
|
||||
{text: 'Zombie', name: 'Zombie', notes: 'Turns your animal into a Zombie.', value: 4}
|
||||
{text: 'Cotton Candy Pink', name: 'CottonCandyPink', notes: 'Turns your animal into a Cotton Candy Pink pet.', value: 4}
|
||||
{text: 'Cotton Candy Blue', name: 'CottonCandyBlue', notes: 'Turns your animal into a Cotton Candy Blue pet.', value: 4}
|
||||
{text: 'Golden', name: 'Golden', notes: 'Turns your animal into a Golden pet.', value: 5}
|
||||
]
|
||||
hatchingPotions:
|
||||
Base: value: 2, 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'
|
||||
Milk: text: 'Milk', target: 'White'
|
||||
Potatoe: text: 'Potatoe', target: 'Desert'
|
||||
Strawberry: text: 'Strawberry', target: 'Red'
|
||||
Chocolate: text: 'Chocolate', target: 'Shade'
|
||||
Fish: text: 'Fish', target: 'Skeleton'
|
||||
RottenMeat: text: 'Rotten Meat', target: 'Zombie'
|
||||
CottonCandyPink: text: 'Pink Cotton Candy', target: 'CottonCandyPink'
|
||||
CottonCandyBlue: text: 'Blue Cotton Candy', target: 'CottonCandyBlue'
|
||||
Honey: text: 'Honey', target: 'Golden'
|
||||
# FIXME what to do with these extra items? Should we add "targets" (plural) for food instead of singular, so we don't have awkward extras?
|
||||
#Cheese: text: 'Cheese', target: 'Golden'
|
||||
#Watermelon: text: 'Watermelon', target: 'Golden'
|
||||
#SeaWeed: text: 'SeaWeed', target: 'Golden'
|
||||
|
||||
Saddle: text: 'Saddle', value: 5, notes: 'Instantly raises your pet into a mount.'
|
||||
|
||||
# we somtimes want item arrays above in reverse order, for backward lookups (you'll see later in the code)
|
||||
reversed = {}
|
||||
|
|
@ -80,8 +97,18 @@ _.each ['weapon', 'armor', 'head', 'shield'], (type) ->
|
|||
# Also add canOwn(), which we use when comparing if user is a backer or contributor - but defaulted to `return true`
|
||||
_.each items[type], (item) -> _.defaults(item, {type, canOwn: ->true})
|
||||
|
||||
_.each items.pets, (pet) -> pet.notes = 'Find a hatching potion to pour on this egg, and it will hatch into a loyal pet.'
|
||||
_.each items.hatchingPotions, (hatchingPotion) -> hatchingPotion.notes = "Pour this on an egg, and it will hatch as a #{hatchingPotion.text} pet."
|
||||
_.each items.eggs, (egg,k) ->
|
||||
_.defaults egg,
|
||||
value: 3
|
||||
name: k
|
||||
notes: 'Find a hatching potion to pour on this egg, and it will hatch into a loyal pet.'
|
||||
mountText: egg.text
|
||||
|
||||
_.each items.hatchingPotions, (pot,k) ->
|
||||
_.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."}
|
||||
|
||||
module.exports.buyItem = (user, type) ->
|
||||
nextItem =
|
||||
|
|
|
|||
Loading…
Reference in a new issue