mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
start upgrading eslint
This commit is contained in:
@@ -16,9 +16,8 @@ import statsComputed from '../libs/statsComputed';
|
||||
|
||||
// Clone a drop object maintaining its functions so that we can change it without affecting the original item
|
||||
function cloneDropItem (drop) {
|
||||
return cloneDeepWith(drop, (val) => {
|
||||
return isFunction(val) ? val : undefined; // undefined will be handled by lodash
|
||||
});
|
||||
return cloneDeepWith(drop, val => (isFunction(val) ? val : undefined), // undefined will be handled by lodash
|
||||
);
|
||||
}
|
||||
|
||||
function trueRandom () {
|
||||
@@ -31,19 +30,19 @@ export default function randomDrop (user, options, req = {}, analytics) {
|
||||
let dropMultiplier;
|
||||
let rarity;
|
||||
|
||||
let predictableRandom = options.predictableRandom || trueRandom;
|
||||
let task = options.task;
|
||||
const predictableRandom = options.predictableRandom || trueRandom;
|
||||
const { task } = options;
|
||||
|
||||
let chance = min([Math.abs(task.value - 21.27), 37.5]) / 150 + 0.02;
|
||||
chance *= task.priority * // Task priority: +50% for Medium, +100% for Hard
|
||||
(1 + (task.streak / 100 || 0)) * // Streak bonus: +1% per streak
|
||||
(1 + statsComputed(user).per / 100) * // PERception: +1% per point
|
||||
(1 + (user.contributor.level / 40 || 0)) * // Contrib levels: +2.5% per level
|
||||
(1 + (user.achievements.rebirths / 20 || 0)) * // Rebirths: +5% per achievement
|
||||
(1 + (user.achievements.streak / 200 || 0)) * // Streak achievements: +0.5% per achievement
|
||||
(user._tmp.crit || 1) * (1 + 0.5 * (reduce(task.checklist, (m, i) => { // +50% per checklist item complete. TODO: make this into X individual drop chances instead
|
||||
return m + (i.completed ? 1 : 0); // eslint-disable-line indent
|
||||
}, 0) || 0)); // eslint-disable-line indent
|
||||
chance *= task.priority // Task priority: +50% for Medium, +100% for Hard
|
||||
* (1 + (task.streak / 100 || 0)) // Streak bonus: +1% per streak
|
||||
* (1 + statsComputed(user).per / 100) // PERception: +1% per point
|
||||
* (1 + (user.contributor.level / 40 || 0)) // Contrib levels: +2.5% per level
|
||||
* (1 + (user.achievements.rebirths / 20 || 0)) // Rebirths: +5% per achievement
|
||||
* (1 + (user.achievements.streak / 200 || 0)) // Streak achievements: +0.5% per achievement
|
||||
* (user._tmp.crit || 1) * (1 + 0.5 * (reduce(task.checklist, (m, i) => // +50% per checklist item complete. TODO: make this into X individual drop chances instead
|
||||
m + (i.completed ? 1 : 0), // eslint-disable-line indent
|
||||
0) || 0)); // eslint-disable-line indent
|
||||
chance = diminishingReturns(chance, 0.75);
|
||||
|
||||
if (predictableRandom() < chance) {
|
||||
@@ -60,8 +59,8 @@ export default function randomDrop (user, options, req = {}, analytics) {
|
||||
dropMultiplier = 1;
|
||||
}
|
||||
|
||||
if (daysSince(user.items.lastDrop.date, user.preferences) === 0 &&
|
||||
user.items.lastDrop.count >= dropMultiplier * (5 + Math.floor(statsComputed(user).per / 25) + (user.contributor.level || 0))) {
|
||||
if (daysSince(user.items.lastDrop.date, user.preferences) === 0
|
||||
&& user.items.lastDrop.count >= dropMultiplier * (5 + Math.floor(statsComputed(user).per / 25) + (user.contributor.level || 0))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -104,9 +103,7 @@ export default function randomDrop (user, options, req = {}, analytics) {
|
||||
} else { // common, 40% of 30%
|
||||
acceptableDrops = ['Base', 'White', 'Desert'];
|
||||
}
|
||||
drop = cloneDropItem(randomVal(pickBy(content.hatchingPotions, (v, k) => {
|
||||
return acceptableDrops.indexOf(k) >= 0;
|
||||
})));
|
||||
drop = cloneDropItem(randomVal(pickBy(content.hatchingPotions, (v, k) => acceptableDrops.indexOf(k) >= 0)));
|
||||
|
||||
user.items.hatchingPotions[drop.key] = user.items.hatchingPotions[drop.key] || 0;
|
||||
user.items.hatchingPotions[drop.key]++;
|
||||
|
||||
Reference in New Issue
Block a user