"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScarecrowSongNoteStruct = exports.SceneStruct = exports.UpgradeCountLookup = exports.NO_KEYS = exports.Z64Events = exports.Wallet = exports.Sword = void 0;
const Z64API = __importStar(require("../../API/imports"));
var Sword;
(function (Sword) {
    Sword[Sword["NONE"] = 0] = "NONE";
    //OoT
    Sword[Sword["KOKIRI_OOT"] = 1] = "KOKIRI_OOT";
    Sword[Sword["MASTER"] = 2] = "MASTER";
    Sword[Sword["GIANT_KNIFE"] = 3] = "GIANT_KNIFE";
    Sword[Sword["BIGGORON"] = 4] = "BIGGORON";
    //MM
    Sword[Sword["KOKIRI_MM"] = 1] = "KOKIRI_MM";
    Sword[Sword["RAZOR"] = 2] = "RAZOR";
    Sword[Sword["GILDED"] = 3] = "GILDED";
})(Sword = exports.Sword || (exports.Sword = {}));
var Wallet;
(function (Wallet) {
    Wallet[Wallet["CHILD"] = 0] = "CHILD";
    Wallet[Wallet["ADULT"] = 1] = "ADULT";
    Wallet[Wallet["GIANT"] = 2] = "GIANT";
    Wallet[Wallet["TYCOON"] = 3] = "TYCOON";
    Wallet[Wallet["ROYAL"] = 4] = "ROYAL";
})(Wallet = exports.Wallet || (exports.Wallet = {}));
// Note: ON_ACTOR_SPAWN/ON_ACTOR_DESPAWN won't detect anything created by ICommandBuffer. This is intentional behavior.
var Z64Events;
(function (Z64Events) {
    Z64Events["ON_SAVE_LOADED"] = "onSaveLoaded";
    Z64Events["ON_SCENE_CHANGE"] = "onSceneChange";
    Z64Events["ON_LOADING_ZONE"] = "onLoadingZone";
    Z64Events["ON_ACTOR_SPAWN"] = "onActorSpawn";
    Z64Events["ON_ACTOR_DESPAWN"] = "onActorDespawn";
    Z64Events["ON_ACTOR_ADDED_TO_CATEGORY"] = "onActorAddedToCategory";
    Z64Events["ON_ACTOR_REMOVED_FROM_CATEGORY"] = "onActorRemovedFromCategory";
    Z64Events["ON_ROOM_CHANGE"] = "onRoomChange";
    Z64Events["ON_ROOM_CHANGE_PRE"] = "onPreRoomChange";
    Z64Events["ON_AGE_CHANGE"] = "onAgeChange";
    Z64Events["ON_SAVE_FLAG_CHANGE"] = "onSaveFlagChange";
    Z64Events["ON_LOCAL_FLAG_CHANGE"] = "onLocalFlagChange";
    Z64Events["ON_DAY_TRANSITION"] = "onDayTransition";
    Z64Events["ON_NIGHT_TRANSITION"] = "onNightTransition";
    Z64Events["ON_HEALTH_CHANGE"] = "onHealthChange";
    Z64Events["ON_TUNIC_CHANGE"] = "onTunicChanged";
    Z64Events["ON_ACTOR_UPDATE"] = "onActorUpdate";
    Z64Events["ON_UNPAUSE"] = "onUnpause";
})(Z64Events = exports.Z64Events || (exports.Z64Events = {}));
exports.NO_KEYS = 0xff;
class UpgradeCount {
    item;
    level;
    count;
    constructor(item, level, count) {
        this.item = item;
        this.level = level;
        this.count = count;
    }
    isMatch(inst) {
        return inst.item === this.item && inst.level === this.level;
    }
}
const UpgradeCountLookupTable = [
    // Bombs
    new UpgradeCount(2 /* Z64API.OoT.InventoryItem.BOMB */ | Z64API.MM.InventoryItem.BOMB, 0 /* AmmoUpgrade.NONE */, 0),
    new UpgradeCount(2 /* Z64API.OoT.InventoryItem.BOMB */ | Z64API.MM.InventoryItem.BOMB, 1 /* AmmoUpgrade.BASE */, 20),
    new UpgradeCount(2 /* Z64API.OoT.InventoryItem.BOMB */ | Z64API.MM.InventoryItem.BOMB, 2 /* AmmoUpgrade.UPGRADED */, 30),
    new UpgradeCount(2 /* Z64API.OoT.InventoryItem.BOMB */ | Z64API.MM.InventoryItem.BOMB, 3 /* AmmoUpgrade.MAX */, 40),
    // Sticks
    new UpgradeCount(0 /* Z64API.OoT.InventoryItem.DEKU_STICK */ | Z64API.MM.InventoryItem.DEKU_STICK, 0 /* AmmoUpgrade.NONE */, 0),
    new UpgradeCount(0 /* Z64API.OoT.InventoryItem.DEKU_STICK */ | Z64API.MM.InventoryItem.DEKU_STICK, 1 /* AmmoUpgrade.BASE */, 10),
    new UpgradeCount(0 /* Z64API.OoT.InventoryItem.DEKU_STICK */ | Z64API.MM.InventoryItem.DEKU_STICK, 2 /* AmmoUpgrade.UPGRADED */, 20),
    new UpgradeCount(0 /* Z64API.OoT.InventoryItem.DEKU_STICK */ | Z64API.MM.InventoryItem.DEKU_STICK, 3 /* AmmoUpgrade.MAX */, 30),
    // Nuts
    new UpgradeCount(1 /* Z64API.OoT.InventoryItem.DEKU_NUT */ | Z64API.MM.InventoryItem.DEKU_NUT, 0 /* AmmoUpgrade.NONE */, 0),
    new UpgradeCount(1 /* Z64API.OoT.InventoryItem.DEKU_NUT */ | Z64API.MM.InventoryItem.DEKU_NUT, 1 /* AmmoUpgrade.BASE */, 20),
    new UpgradeCount(1 /* Z64API.OoT.InventoryItem.DEKU_NUT */ | Z64API.MM.InventoryItem.DEKU_NUT, 2 /* AmmoUpgrade.UPGRADED */, 30),
    new UpgradeCount(1 /* Z64API.OoT.InventoryItem.DEKU_NUT */ | Z64API.MM.InventoryItem.DEKU_NUT, 3 /* AmmoUpgrade.MAX */, 40),
    // Seeds
    new UpgradeCount(6 /* Z64API.OoT.InventoryItem.FAIRY_SLINGSHOT */ | Z64API.MM.InventoryItem.FAIRY_SLINGSHOT, 0 /* AmmoUpgrade.NONE */, 0),
    new UpgradeCount(6 /* Z64API.OoT.InventoryItem.FAIRY_SLINGSHOT */ | Z64API.MM.InventoryItem.FAIRY_SLINGSHOT, 1 /* AmmoUpgrade.BASE */, 30),
    new UpgradeCount(6 /* Z64API.OoT.InventoryItem.FAIRY_SLINGSHOT */ | Z64API.MM.InventoryItem.FAIRY_SLINGSHOT, 2 /* AmmoUpgrade.UPGRADED */, 40),
    new UpgradeCount(6 /* Z64API.OoT.InventoryItem.FAIRY_SLINGSHOT */ | Z64API.MM.InventoryItem.FAIRY_SLINGSHOT, 3 /* AmmoUpgrade.MAX */, 50),
    // Arrows
    new UpgradeCount(3 /* Z64API.OoT.InventoryItem.FAIRY_BOW */ | Z64API.MM.InventoryItem.HEROES_BOW, 0 /* AmmoUpgrade.NONE */, 0),
    new UpgradeCount(3 /* Z64API.OoT.InventoryItem.FAIRY_BOW */ | Z64API.MM.InventoryItem.HEROES_BOW, 1 /* AmmoUpgrade.BASE */, 30),
    new UpgradeCount(3 /* Z64API.OoT.InventoryItem.FAIRY_BOW */ | Z64API.MM.InventoryItem.HEROES_BOW, 2 /* AmmoUpgrade.UPGRADED */, 40),
    new UpgradeCount(3 /* Z64API.OoT.InventoryItem.FAIRY_BOW */ | Z64API.MM.InventoryItem.HEROES_BOW, 3 /* AmmoUpgrade.MAX */, 50),
    // Bombchu
    new UpgradeCount(9 /* Z64API.OoT.InventoryItem.BOMBCHU */ | Z64API.MM.InventoryItem.BOMBCHU, 0 /* AmmoUpgrade.NONE */, 0),
    new UpgradeCount(9 /* Z64API.OoT.InventoryItem.BOMBCHU */ | Z64API.MM.InventoryItem.BOMBCHU, 1 /* AmmoUpgrade.BASE */, 5),
    new UpgradeCount(9 /* Z64API.OoT.InventoryItem.BOMBCHU */ | Z64API.MM.InventoryItem.BOMBCHU, 2 /* AmmoUpgrade.UPGRADED */, 10),
    new UpgradeCount(9 /* Z64API.OoT.InventoryItem.BOMBCHU */ | Z64API.MM.InventoryItem.BOMBCHU, 3 /* AmmoUpgrade.MAX */, 20),
];
function UpgradeCountLookup(item, level) {
    let inst = new UpgradeCount(item, level, -1);
    for (let i = 0; i < UpgradeCountLookupTable.length; i++) {
        if (inst.isMatch(UpgradeCountLookupTable[i])) {
            return UpgradeCountLookupTable[i].count;
        }
    }
    return 0;
}
exports.UpgradeCountLookup = UpgradeCountLookup;
class SceneStruct {
    buf;
    constructor(buf) {
        this.buf = buf;
    }
    get chests() {
        return this.buf.slice(0x0, 0x4);
    }
    get switches() {
        return this.buf.slice(0x4, 0x8);
    }
    get room_clear() {
        return this.buf.slice(0x8, 0xC);
    }
    get collectible() {
        return this.buf.slice(0xC, 0x10);
    }
    get unused() {
        return this.buf.slice(0x10, 0x14);
    }
    get visited_rooms() {
        return this.buf.slice(0x14, 0x18);
    }
    get visited_floors() {
        return this.buf.slice(0x18, 0x1C);
    }
}
exports.SceneStruct = SceneStruct;
class ScarecrowSongNoteStruct {
    buf;
    constructor(buf) {
        this.buf = buf;
    }
    get note() {
        return this.buf.slice(0x0, 0x1);
    }
    get unused() {
        return this.buf.slice(0x1, 0x2);
    }
    get duration() {
        return this.buf.slice(0x2, 0x4);
    }
    get volume() {
        return this.buf.slice(0x4, 0x5);
    }
    get vibrato() {
        return this.buf.slice(0x5, 0x6);
    }
    get pitch() {
        return this.buf.slice(0x6, 0x7);
    }
    get special() {
        return this.buf.slice(0x7, 0x8);
    }
}
exports.ScarecrowSongNoteStruct = ScarecrowSongNoteStruct;
//# sourceMappingURL=Z64API.js.map