mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Common reorg (#8025)
* Re-organize common folder * fix: Correct paths in tests * fix: move new content to proper folder * chore: Move audio folder to assets * Move sprites to sprites assets directory * Move css sprites to assets directory * Split out readmes for common code and sprites * Move images to assets directory * Move destinatin of shared browserified file * remove unused file * move compiled js to client-old * Fix karma tests * fix: Correct paths for sprites
This commit is contained in:
committed by
Matteo Pagliazzi
parent
d971e673af
commit
81b7eeeb71
76
website/common/script/count.js
Normal file
76
website/common/script/count.js
Normal file
@@ -0,0 +1,76 @@
|
||||
import {
|
||||
each,
|
||||
filter,
|
||||
keys,
|
||||
size,
|
||||
} from 'lodash';
|
||||
import content from './content/index';
|
||||
|
||||
const DROP_ANIMALS = keys(content.pets);
|
||||
|
||||
function beastMasterProgress (pets = {}) {
|
||||
let count = 0;
|
||||
|
||||
each(DROP_ANIMALS, (animal) => {
|
||||
if (pets[animal] > 0 || pets[animal] === -1)
|
||||
count++;
|
||||
});
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
function dropPetsCurrentlyOwned (pets = {}) {
|
||||
let count = 0;
|
||||
|
||||
each(DROP_ANIMALS, (animal) => {
|
||||
if (pets[animal] > 0)
|
||||
count++;
|
||||
});
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
function mountMasterProgress (mounts = {}) {
|
||||
let count = 0;
|
||||
|
||||
each(DROP_ANIMALS, (animal) => {
|
||||
if (mounts[animal])
|
||||
count++;
|
||||
});
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
function remainingGearInSet (userGear = {}, set) {
|
||||
let gear = filter(content.gear.flat, (item) => {
|
||||
let setMatches = item.klass === set;
|
||||
let hasItem = userGear[item.key];
|
||||
|
||||
return setMatches && !hasItem;
|
||||
});
|
||||
|
||||
let count = size(gear);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
function questsOfCategory (userQuests = {}, category) {
|
||||
let quests = filter(content.quests, (quest) => {
|
||||
let categoryMatches = quest.category === category;
|
||||
let hasQuest = userQuests[quest.key];
|
||||
|
||||
return categoryMatches && hasQuest;
|
||||
});
|
||||
|
||||
let count = size(quests);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
beastMasterProgress,
|
||||
dropPetsCurrentlyOwned,
|
||||
mountMasterProgress,
|
||||
remainingGearInSet,
|
||||
questsOfCategory,
|
||||
};
|
||||
Reference in New Issue
Block a user