mirror of
https://github.com/NohamR/Pocket-Bird.git
synced 2026-05-25 12:17:22 +00:00
Save data when switching birds
This commit is contained in:
8
birb.js
8
birb.js
@@ -638,7 +638,7 @@ const species = {
|
|||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
const DEFAULT_BIRD = "carolinaWren";
|
const DEFAULT_BIRD = "bluebird";
|
||||||
|
|
||||||
|
|
||||||
const Directions = {
|
const Directions = {
|
||||||
@@ -932,6 +932,7 @@ Promise.all([loadSpritesheetPixels(SPRITE_SHEET_URI), loadSpritesheetPixels(DECO
|
|||||||
log("Loaded data: " + JSON.stringify(saveData));
|
log("Loaded data: " + JSON.stringify(saveData));
|
||||||
unlockedSpecies = saveData.unlockedSpecies ?? [DEFAULT_BIRD];
|
unlockedSpecies = saveData.unlockedSpecies ?? [DEFAULT_BIRD];
|
||||||
currentSpecies = saveData.currentSpecies ?? DEFAULT_BIRD;
|
currentSpecies = saveData.currentSpecies ?? DEFAULT_BIRD;
|
||||||
|
switchSpecies(currentSpecies);
|
||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
@@ -1292,7 +1293,7 @@ Promise.all([loadSpritesheetPixels(SPRITE_SHEET_URI), loadSpritesheetPixels(DECO
|
|||||||
content.appendChild(speciesElement);
|
content.appendChild(speciesElement);
|
||||||
if (unlocked) {
|
if (unlocked) {
|
||||||
onClick(speciesElement, () => {
|
onClick(speciesElement, () => {
|
||||||
switchspecies(id);
|
switchSpecies(id);
|
||||||
document.querySelectorAll(".birb-grid-item").forEach((element) => {
|
document.querySelectorAll(".birb-grid-item").forEach((element) => {
|
||||||
element.classList.remove("birb-grid-item-selected");
|
element.classList.remove("birb-grid-item-selected");
|
||||||
});
|
});
|
||||||
@@ -1392,8 +1393,9 @@ Promise.all([loadSpritesheetPixels(SPRITE_SHEET_URI), loadSpritesheetPixels(DECO
|
|||||||
/**
|
/**
|
||||||
* @param {string} species
|
* @param {string} species
|
||||||
*/
|
*/
|
||||||
function switchspecies(species) {
|
function switchSpecies(species) {
|
||||||
currentSpecies = species;
|
currentSpecies = species;
|
||||||
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user