
Changed the colors of the network graph to match the color of the differents houses (the color will probably be in the database in the future). Reactivate the panel swipe (there are still some problems but it's better to keep the swipe for the user). Added various comments and fixed the missing logo in the about page when using the phone app.
57 lines
1.9 KiB
JavaScript
57 lines
1.9 KiB
JavaScript
/*
|
|
File name : feclass.js
|
|
Description : Methods related to the classes of characters
|
|
*/
|
|
|
|
const NB_STATS = 9;
|
|
const ID_CLASS_IS_AVAILABLE_FOR_ALL = 1;
|
|
|
|
function getAvailableClassesForCharacter(char) {
|
|
const availableClasses = [];
|
|
|
|
feData.classes.forEach(feClass => {
|
|
if (feClass.isAvailableForAll == ID_CLASS_IS_AVAILABLE_FOR_ALL
|
|
&& (feClass.idGender == ID_GENDER_NON_RESTRICTED || feClass.idGender == char.idGender)) {
|
|
availableClasses.push(feClass);
|
|
} else if (feData.restrictedClasses.find(x => x.idClass == feClass.id && x.idCharacter == char.id)) {
|
|
availableClasses.push(feClass);
|
|
}
|
|
});
|
|
return availableClasses;
|
|
}
|
|
|
|
function displayAllClasses() {
|
|
feData.classes.forEach(feClass => {
|
|
const tr = $$(`<tr></tr>`)
|
|
const td = $$(`<td id="feclass-${feClass.id}">${feClass.name}</td>`);
|
|
tr.append(td);
|
|
$$("#table-classes-content").append(tr);
|
|
|
|
td.on("click", (event) => {
|
|
const feclassId = event.target.id // Get the string who contains the id of the class
|
|
.match(/\d/g) // Extract all digits
|
|
.join(""); // Join the digits to get the id number
|
|
|
|
app.views.main.router.navigate("/class/" + feclassId);
|
|
});
|
|
});
|
|
}
|
|
|
|
function getClassGrowthRates(idClass) {
|
|
const classGrowthRates = [];
|
|
const partialClassGrowthRates = feData.classGrowthRates.map(x => (x.idClass == idClass) ? x : null).filter(x => x != null);
|
|
|
|
for (let i = 0; i < NB_STATS; i++) {
|
|
let gr = partialClassGrowthRates.find(x => (x.idStat == i + 1) ? x : null);
|
|
if (gr == null) {
|
|
// Create a default growth rate to avoid missing stats
|
|
gr = {
|
|
idClass: idClass,
|
|
idStat: i + 1,
|
|
value: 0,
|
|
}
|
|
}
|
|
classGrowthRates.push(gr);
|
|
}
|
|
return classGrowthRates;
|
|
} |