Add hat to save data

This commit is contained in:
Idrees Hassan
2026-01-19 20:38:00 -05:00
parent 3227167cb5
commit 7628ee2c87
7 changed files with 48 additions and 18 deletions

View File

@@ -54,6 +54,7 @@ import { HAT, HAT_METADATA } from './hats.js';
* @typedef {Object} BirbSaveData
* @property {string[]} unlockedSpecies
* @property {string} currentSpecies
* @property {string} currentHat
* @property {Partial<Settings>} settings
* @property {SavedStickyNote[]} [stickyNotes]
*/
@@ -87,6 +88,7 @@ const FEATHER_ID = "birb-feather";
const WARDROBE_ID = "birb-wardrobe";
const DEFAULT_BIRD = "bluebird";
const DEFAULT_HAT = HAT.NONE;
// Birb movement
const HOP_SPEED = 0.07;
@@ -239,7 +241,7 @@ function startApplication(birbPixels, featherPixels, hatsPixels) {
let petStack = [];
let currentSpecies = DEFAULT_BIRD;
let unlockedSpecies = [DEFAULT_BIRD];
let currentHat = HAT.TOP_HAT;
let currentHat = DEFAULT_HAT;
// let visible = true;
let lastPetTimestamp = 0;
/** @type {StickyNote[]} */
@@ -258,6 +260,7 @@ function startApplication(birbPixels, featherPixels, hatsPixels) {
userSettings = saveData.settings ?? {};
unlockedSpecies = saveData.unlockedSpecies ?? [DEFAULT_BIRD];
currentSpecies = saveData.currentSpecies ?? DEFAULT_BIRD;
currentHat = saveData.currentHat ?? DEFAULT_HAT;
stickyNotes = [];
if (saveData.stickyNotes) {
@@ -270,13 +273,15 @@ function startApplication(birbPixels, featherPixels, hatsPixels) {
log(stickyNotes.length + " sticky notes loaded");
switchSpecies(currentSpecies);
switchHat(currentHat);
}
function save() {
/** @type {BirbSaveData} */
const saveData = {
unlockedSpecies,
currentSpecies,
unlockedSpecies: unlockedSpecies,
currentSpecies: currentSpecies,
currentHat: currentHat,
settings: userSettings
};