cheerful mode support and list update

This commit is contained in:
Laetitia (O-01-67) 2022-12-19 10:25:22 -05:00 committed by GitHub
parent 6fe67f09df
commit 195a71cbc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 47 additions and 9 deletions

View File

@ -93,7 +93,7 @@ if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(libraryMod)
fairyIncludeRandom = false
}
//Generate creepers
//Generate fairies
if(urlParams.get('generateFairies') !== null) { //if the variable exists at all
generateFairies = true
} else { //if it doesn't (and it returns null)
@ -115,6 +115,21 @@ if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(libraryMod)
};
};
runAfterLoad(function() {
if(typeof(eLists.FAIRY) === "undefined") { eLists.FAIRY = [] };
eLists.FAIRY.push("acid_fairy");
eLists.FAIRY.push("oil_fairy");
eLists.FAIRY.push("honey_fairy");
fairyChoices = eLists.FAIRY;
for(i = 0; i < eLists.FAIRY.length; i++) {
var fairyName = eLists.FAIRY[i];
if(!fairyChoices.includes(fairyName)) {
fairyChoices.push(fairyName);
};
};
});
//Standalone generator
function generateFairy(fairyElements,isAfterScriptLoading=false) {//it can be a single element, though
//To specify an array fairy, have the array be inside another array.
@ -136,6 +151,7 @@ if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(libraryMod)
var elementOfFairy = fairyElements[aaf];
var startColor;
var randomExcl = 0;
var isNocheer = 0;
//console.log("randomExcl set")
//console.log(elementOfFairy);
@ -165,6 +181,17 @@ if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(libraryMod)
//console.log(elementOfFairy[ll]);
startColor = startColor.concat(elements[elementOfFairy[ll]].color);
};
for(ll = 0; ll < elementOfFairy.length; ll++) {
if(typeof(elements[elementOfFairy[ll]].nocheer !== "undefined")) { //if excludeRandom exists (prevent TypeError)
if(elements[elementOfFairy[ll]].nocheer) { //it it's true
isNocheer = 1; //the whole array fairy is excluded
//console.log("array nyet" + elementOfFairy);
};
};
//console.log(elementOfFairy[ll]);
startColor = startColor.concat(elements[elementOfFairy[ll]].color);
};
} else { //they should all be strings, so here
fairyName = `${elementOfFairy}_fairy`; //auto placer element name
startColor = elements[elementOfFairy].color;
@ -177,6 +204,16 @@ if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(libraryMod)
randomExcl = 0;
};
};
if(typeof(elements[elementOfFairy].nocheer !== "undefined")) { //if excludeRandom exists (prevent TypeError)
if(elements[elementOfFairy].nocheer) { //it it's true
//console.log("nyet " + elementOfFairy);
isNocheer = 1; //the fairy is excluded
} else {
//console.log("allow " + elementOfFairy);
isNocheer = 0;
};
};
};
//Color gen
if(Array.isArray(startColor)) { //Average arrays, make colors rgb()
@ -251,6 +288,9 @@ if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(libraryMod)
fairyChoices.push(fairyName);
};
}
if(isNocheer) {
elements[fairyName].nocheer = true;
}
if(fairyIncludeRandom) {
randomExcl ? elements[fairyName].excludeRandom = true : elements[fairyName].excludeRandom = false;
} else {
@ -259,7 +299,12 @@ if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(libraryMod)
if(isAfterScriptLoading) {
elements[fairyName].flippableX = true;
elementCount++; //increment for new fairy element
createElementButton(fairyName);
if (settings.cheerful && elements[element].nocheer) {
elements[element].hidden = true;
hiddenCount++;
} else {
createElementButton(fairyName);
};
elements[fairyName].id = nextid++;
document.getElementById("extraInfo").innerHTML = "<small><p>There are " + elementCount + " elements, including " + hiddenCount + " hidden ones.</p><p>©2021-" + new Date().getFullYear() + ". All Rights Reserved. <a href='https://r74n.com'>R74n</a></p></small>"; //update extra info counts (and the copyright year, due to the method used)
};
@ -288,13 +333,6 @@ if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(libraryMod)
};
//Post-generation tasks
//Manual eLists.FAIRY updates
runAfterLoad(function() {
eLists.FAIRY.push("acid_fairy");
eLists.FAIRY.push("oil_fairy");
eLists.FAIRY.push("honey_fairy");
});
//Revamp fairykill
behaviors.FAIRYKILL_OLD = behaviors.FAIRYKILL;
behaviors.FAIRYKILL = function(pixel) {