"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.Inventory = void 0;
const JSONTemplate_1 = require("modloader64_api/JSONTemplate");
const Z64API = __importStar(require("../../API/imports"));
const Z64CORE = __importStar(require("../importsZ64"));
class Inventory extends JSONTemplate_1.JSONTemplate {
    emulator;
    instance = Z64CORE.Z64.Z64_SAVE;
    inventory_addr = this.instance + 0x0070;
    inventory_ammo_addr = this.instance + 0x00A0;
    inventory_upgrades_addr = this.instance + 0x00B8;
    log;
    jsonFields = [
        'wallet',
        'magicBeansCount',
        'dekuSticksCapacity',
        'dekuNutsCapacity',
        'bombBag',
        'quiver',
        'FIELD_OCARINA',
        'FIELD_HEROES_BOW',
        'FIELD_FIRE_ARROW',
        'FIELD_ICE_ARROW',
        'FIELD_LIGHT_ARROW',
        'FIELD_QUEST_ITEM_1',
        'FIELD_BOMB',
        'FIELD_BOMBCHU',
        'FIELD_DEKU_STICKS',
        'FIELD_DEKU_NUT',
        'FIELD_MAGIC_BEAN',
        'FIELD_QUEST_ITEM_2',
        'FIELD_POWDER_KEG',
        'FIELD_PICTOGRAPH_BOX',
        'FIELD_LENS_OF_TRUTH',
        'FIELD_HOOKSHOT',
        'FIELD_GREAT_FAIRYS_SWORD',
        'FIELD_QUEST_ITEM_3',
        'FIELD_BOTTLE1',
        'FIELD_BOTTLE2',
        'FIELD_BOTTLE3',
        'FIELD_BOTTLE4',
        'FIELD_BOTTLE5',
        'FIELD_BOTTLE6',
        'FIELD_MASK_POSTMAN',
        'FIELD_MASK_ALL_NIGHT',
        'FIELD_MASK_BLAST',
        'FIELD_MASK_STONE',
        'FIELD_MASK_GREAT_FAIRY',
        'FIELD_MASK_DEKU',
        'FIELD_MASK_KEATON',
        'FIELD_MASK_BREMEN',
        'FIELD_MASK_BUNNY_HOOD',
        'FIELD_MASK_DON_GERO',
        'FIELD_MASK_OF_SCENTS',
        'FIELD_MASK_GORON',
        'FIELD_MASK_ROMANI',
        'FIELD_MASK_CIRCUS_LEADER',
        'FIELD_MASK_KAFEI',
        'FIELD_MASK_COUPLES',
        'FIELD_MASK_OF_TRUTH',
        'FIELD_MASK_ZORA',
        'FIELD_MASK_KAMERO',
        'FIELD_MASK_GIBDO',
        'FIELD_MASK_GARO',
        'FIELD_MASK_CAPTAIN',
        'FIELD_MASK_GIANT',
        'FIELD_MASK_FIERCE_DEITY',
    ];
    constructor(emu, log) {
        super();
        this.emulator = emu;
        this.log = log;
    }
    get FIELD_OCARINA() {
        let val = this.getItemInSlot(0 /* Z64API.MM.InventorySlots.OCARINA_OF_TIME */);
        switch (val) {
            case Z64API.MM.InventoryItem.OCARINA_OF_TIME:
                return 2 /* Z64API.Z64.Ocarina.OCARINA_OF_TIME */;
            default:
                return 0 /* Z64API.Z64.Ocarina.NONE */;
        }
    }
    set FIELD_OCARINA(item) {
        if (item === this.FIELD_OCARINA)
            return;
        switch (item) {
            case 0 /* Z64API.Z64.Ocarina.NONE */:
                this.setItemInSlot(Z64API.MM.InventoryItem.NONE, 0 /* Z64API.MM.InventorySlots.OCARINA_OF_TIME */);
                break;
            case 2 /* Z64API.Z64.Ocarina.OCARINA_OF_TIME */:
                this.setItemInSlot(Z64API.MM.InventoryItem.OCARINA_OF_TIME, 0 /* Z64API.MM.InventorySlots.OCARINA_OF_TIME */);
                break;
        }
    }
    get FIELD_HEROES_BOW() {
        let val = this.getItemInSlot(1 /* Z64API.MM.InventorySlots.HEROES_BOW */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_HEROES_BOW(bow) {
        let value = bow ? Z64API.MM.InventoryItem.HEROES_BOW : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 1 /* Z64API.MM.InventorySlots.HEROES_BOW */);
    }
    get FIELD_FIRE_ARROW() {
        let val = this.getItemInSlot(2 /* Z64API.MM.InventorySlots.FIRE_ARROWS */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_FIRE_ARROW(bool) {
        let value = bool ? Z64API.MM.InventoryItem.FIRE_ARROW : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 2 /* Z64API.MM.InventorySlots.FIRE_ARROWS */);
    }
    get FIELD_ICE_ARROW() {
        let val = this.getItemInSlot(3 /* Z64API.MM.InventorySlots.ICE_ARROWS */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_ICE_ARROW(bool) {
        let value = bool ? Z64API.MM.InventoryItem.ICE_ARROW : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 3 /* Z64API.MM.InventorySlots.ICE_ARROWS */);
    }
    get FIELD_LIGHT_ARROW() {
        let val = this.getItemInSlot(4 /* Z64API.MM.InventorySlots.LIGHT_ARROWS */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_LIGHT_ARROW(lightA) {
        let value = lightA ? Z64API.MM.InventoryItem.LIGHT_ARROW : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 4 /* Z64API.MM.InventorySlots.LIGHT_ARROWS */);
    }
    get FIELD_BOMB() {
        let val = this.getItemInSlot(6 /* Z64API.MM.InventorySlots.BOMBS */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_BOMB(bool) {
        let value = bool ? Z64API.MM.InventoryItem.BOMB : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 6 /* Z64API.MM.InventorySlots.BOMBS */);
    }
    get FIELD_BOMBCHU() {
        let val = this.getItemInSlot(7 /* Z64API.MM.InventorySlots.BOMBCHUS */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_BOMBCHU(bool) {
        let value = bool ? Z64API.MM.InventoryItem.BOMBCHU : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 7 /* Z64API.MM.InventorySlots.BOMBCHUS */);
    }
    get FIELD_DEKU_STICKS() {
        let val = this.getItemInSlot(8 /* Z64API.MM.InventorySlots.DEKU_STICKS */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_DEKU_STICKS(bool) {
        let value = bool ? Z64API.MM.InventoryItem.DEKU_STICK : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 8 /* Z64API.MM.InventorySlots.DEKU_STICKS */);
    }
    get FIELD_DEKU_NUT() {
        let val = this.getItemInSlot(9 /* Z64API.MM.InventorySlots.DEKU_NUTS */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_DEKU_NUT(bool) {
        let value = bool ? Z64API.MM.InventoryItem.DEKU_NUT : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 9 /* Z64API.MM.InventorySlots.DEKU_NUTS */);
    }
    get FIELD_MAGIC_BEAN() {
        let val = this.getItemInSlot(10 /* Z64API.MM.InventorySlots.MAGIC_BEANS */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MAGIC_BEAN(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MAGIC_BEANS : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 10 /* Z64API.MM.InventorySlots.MAGIC_BEANS */);
    }
    get FIELD_POWDER_KEG() {
        let val = this.getItemInSlot(12 /* Z64API.MM.InventorySlots.POWDER_KEG */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_POWDER_KEG(bool) {
        let value = bool ? Z64API.MM.InventoryItem.POWDER_KEG : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 12 /* Z64API.MM.InventorySlots.POWDER_KEG */);
    }
    get FIELD_PICTOGRAPH_BOX() {
        let val = this.getItemInSlot(13 /* Z64API.MM.InventorySlots.PICTOGRAPH_BOX */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_PICTOGRAPH_BOX(bool) {
        let value = bool ? Z64API.MM.InventoryItem.PICTOGRAPH_BOX : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 13 /* Z64API.MM.InventorySlots.PICTOGRAPH_BOX */);
    }
    get FIELD_LENS_OF_TRUTH() {
        let val = this.getItemInSlot(14 /* Z64API.MM.InventorySlots.LENS_OF_TRUTH */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_LENS_OF_TRUTH(bool) {
        let value = bool ? Z64API.MM.InventoryItem.LENS_OF_TRUTH : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 14 /* Z64API.MM.InventorySlots.LENS_OF_TRUTH */);
    }
    get FIELD_HOOKSHOT() {
        let val = this.getItemInSlot(15 /* Z64API.MM.InventorySlots.HOOKSHOT */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_HOOKSHOT(bool) {
        let value = bool ? Z64API.MM.InventoryItem.HOOKSHOT : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 15 /* Z64API.MM.InventorySlots.HOOKSHOT */);
    }
    get FIELD_GREAT_FAIRYS_SWORD() {
        let val = this.getItemInSlot(16 /* Z64API.MM.InventorySlots.GREAT_FAIRYS_SWORD */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_GREAT_FAIRYS_SWORD(bool) {
        let value = bool ? Z64API.MM.InventoryItem.GREAT_FAIRYS_SWORD : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 16 /* Z64API.MM.InventorySlots.GREAT_FAIRYS_SWORD */);
    }
    get FIELD_MASK_POSTMAN() {
        let val = this.getItemInSlot(24 /* Z64API.MM.InventorySlots.MASK_POSTMAN */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_POSTMAN(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_POSTMAN : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 24 /* Z64API.MM.InventorySlots.MASK_POSTMAN */);
    }
    get FIELD_MASK_ALL_NIGHT() {
        let val = this.getItemInSlot(25 /* Z64API.MM.InventorySlots.MASK_ALL_NIGHT */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_ALL_NIGHT(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_ALL_NIGHT : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 25 /* Z64API.MM.InventorySlots.MASK_ALL_NIGHT */);
    }
    get FIELD_MASK_BLAST() {
        let val = this.getItemInSlot(26 /* Z64API.MM.InventorySlots.MASK_BLAST */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_BLAST(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_BLAST : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 26 /* Z64API.MM.InventorySlots.MASK_BLAST */);
    }
    get FIELD_MASK_STONE() {
        let val = this.getItemInSlot(27 /* Z64API.MM.InventorySlots.MASK_STONE */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_STONE(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_STONE : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 27 /* Z64API.MM.InventorySlots.MASK_STONE */);
    }
    get FIELD_MASK_GREAT_FAIRY() {
        let val = this.getItemInSlot(28 /* Z64API.MM.InventorySlots.MASK_GREAT_FAIRY */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_GREAT_FAIRY(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_GREAT_FAIRY : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 28 /* Z64API.MM.InventorySlots.MASK_GREAT_FAIRY */);
    }
    get FIELD_MASK_DEKU() {
        let val = this.getItemInSlot(29 /* Z64API.MM.InventorySlots.MASK_DEKU */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_DEKU(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_DEKU : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 29 /* Z64API.MM.InventorySlots.MASK_DEKU */);
    }
    get FIELD_MASK_KEATON() {
        let val = this.getItemInSlot(30 /* Z64API.MM.InventorySlots.MASK_KEATON */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_KEATON(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_KEATON : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 30 /* Z64API.MM.InventorySlots.MASK_KEATON */);
    }
    get FIELD_MASK_BREMEN() {
        let val = this.getItemInSlot(31 /* Z64API.MM.InventorySlots.MASK_BREMEN */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_BREMEN(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_BREMEN : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 31 /* Z64API.MM.InventorySlots.MASK_BREMEN */);
    }
    get FIELD_MASK_BUNNY_HOOD() {
        let val = this.getItemInSlot(32 /* Z64API.MM.InventorySlots.MASK_BUNNY_HOOD */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_BUNNY_HOOD(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_BUNNY_HOOD : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 32 /* Z64API.MM.InventorySlots.MASK_BUNNY_HOOD */);
    }
    get FIELD_MASK_DON_GERO() {
        let val = this.getItemInSlot(33 /* Z64API.MM.InventorySlots.MASK_DON_GERO */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_DON_GERO(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_DON_GERO : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 33 /* Z64API.MM.InventorySlots.MASK_DON_GERO */);
    }
    get FIELD_MASK_OF_SCENTS() {
        let val = this.getItemInSlot(34 /* Z64API.MM.InventorySlots.MASK_OF_SCENTS */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_OF_SCENTS(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_OF_SCENTS : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 34 /* Z64API.MM.InventorySlots.MASK_OF_SCENTS */);
    }
    get FIELD_MASK_GORON() {
        let val = this.getItemInSlot(35 /* Z64API.MM.InventorySlots.MASK_GORON */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_GORON(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_GORON : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 35 /* Z64API.MM.InventorySlots.MASK_GORON */);
    }
    get FIELD_MASK_ROMANI() {
        let val = this.getItemInSlot(36 /* Z64API.MM.InventorySlots.MASK_ROMANI */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_ROMANI(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_ROMANI : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 36 /* Z64API.MM.InventorySlots.MASK_ROMANI */);
    }
    get FIELD_MASK_CIRCUS_LEADER() {
        let val = this.getItemInSlot(37 /* Z64API.MM.InventorySlots.MASK_CIRCUS_LEADER */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_CIRCUS_LEADER(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_CIRCUS_LEADER : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 37 /* Z64API.MM.InventorySlots.MASK_CIRCUS_LEADER */);
    }
    get FIELD_MASK_KAFEI() {
        let val = this.getItemInSlot(38 /* Z64API.MM.InventorySlots.MASK_KAFEI */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_KAFEI(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_KAFEI : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 38 /* Z64API.MM.InventorySlots.MASK_KAFEI */);
    }
    get FIELD_MASK_COUPLES() {
        let val = this.getItemInSlot(39 /* Z64API.MM.InventorySlots.MASK_COUPLES */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_COUPLES(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_COUPLES : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 39 /* Z64API.MM.InventorySlots.MASK_COUPLES */);
    }
    get FIELD_MASK_OF_TRUTH() {
        let val = this.getItemInSlot(40 /* Z64API.MM.InventorySlots.MASK_OF_TRUTH */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_OF_TRUTH(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_OF_TRUTH : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 40 /* Z64API.MM.InventorySlots.MASK_OF_TRUTH */);
    }
    get FIELD_MASK_ZORA() {
        let val = this.getItemInSlot(41 /* Z64API.MM.InventorySlots.MASK_ZORA */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_ZORA(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_ZORA : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 41 /* Z64API.MM.InventorySlots.MASK_ZORA */);
    }
    get FIELD_MASK_KAMERO() {
        let val = this.getItemInSlot(42 /* Z64API.MM.InventorySlots.MASK_KAMERO */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_KAMERO(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_KAMERO : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 42 /* Z64API.MM.InventorySlots.MASK_KAMERO */);
    }
    get FIELD_MASK_GIBDO() {
        let val = this.getItemInSlot(43 /* Z64API.MM.InventorySlots.MASK_GIBDO */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_GIBDO(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_GIBDO : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 43 /* Z64API.MM.InventorySlots.MASK_GIBDO */);
    }
    get FIELD_MASK_GARO() {
        let val = this.getItemInSlot(44 /* Z64API.MM.InventorySlots.MASK_GARO */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_GARO(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_GARO : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 44 /* Z64API.MM.InventorySlots.MASK_GARO */);
    }
    get FIELD_MASK_CAPTAIN() {
        let val = this.getItemInSlot(45 /* Z64API.MM.InventorySlots.MASK_CAPTAIN */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_CAPTAIN(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_CAPTAIN : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 45 /* Z64API.MM.InventorySlots.MASK_CAPTAIN */);
    }
    get FIELD_MASK_GIANT() {
        let val = this.getItemInSlot(46 /* Z64API.MM.InventorySlots.MASK_GIANT */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_GIANT(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_GIANT : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 46 /* Z64API.MM.InventorySlots.MASK_GIANT */);
    }
    get FIELD_MASK_FIERCE_DEITY() {
        let val = this.getItemInSlot(47 /* Z64API.MM.InventorySlots.MASK_FIERCE_DEITY */);
        return !(val === Z64API.MM.InventoryItem.NONE);
    }
    set FIELD_MASK_FIERCE_DEITY(bool) {
        let value = bool ? Z64API.MM.InventoryItem.MASK_FIERCE_DEITY : Z64API.MM.InventoryItem.NONE;
        this.setItemInSlot(value, 47 /* Z64API.MM.InventorySlots.MASK_FIERCE_DEITY */);
    }
    isChildTradeFinished() {
        throw new Error("Method not implemented.");
    }
    isAdultTradeFinished() {
        throw new Error("Method not implemented.");
    }
    set bombBag(bb) {
        let buf = this.emulator.rdramReadBits8(this.inventory_upgrades_addr + 0x3);
        switch (bb) {
            case 0 /* Z64API.Z64.AmmoUpgrade.NONE */:
                buf[0x3] = 0x00;
                buf[0x4] = 0x00;
                break;
            case 1 /* Z64API.Z64.AmmoUpgrade.BASE */:
                buf[0x3] = 0x00;
                buf[0x4] = 0x01;
                break;
            case 2 /* Z64API.Z64.AmmoUpgrade.UPGRADED */:
                buf[0x3] = 0x01;
                buf[0x4] = 0x00;
                break;
            case 3 /* Z64API.Z64.AmmoUpgrade.MAX */:
                buf[0x3] = 0x01;
                buf[0x4] = 0x01;
                break;
        }
        this.emulator.rdramWriteBits8(this.inventory_upgrades_addr + 0x3, buf);
    }
    get bombBag() {
        let buf = this.emulator.rdramReadBits8(this.inventory_upgrades_addr + 0x3);
        let str = buf.slice(3, 5).toString('hex');
        switch (str) {
            case '0000':
                return 0 /* Z64API.Z64.AmmoUpgrade.NONE */;
            case '0001':
                return 1 /* Z64API.Z64.AmmoUpgrade.BASE */;
            case '0100':
                return 2 /* Z64API.Z64.AmmoUpgrade.UPGRADED */;
            case '0101':
                return 3 /* Z64API.Z64.AmmoUpgrade.MAX */;
        }
        return 0 /* Z64API.Z64.AmmoUpgrade.NONE */;
    }
    set dekuSticksCapacity(bb) {
        let buf = this.emulator.rdramReadBits8(this.inventory_upgrades_addr + 0x1);
        switch (bb) {
            case 0 /* Z64API.Z64.AmmoUpgrade.NONE */:
                buf[0x5] = 0x00;
                buf[0x6] = 0x00;
                break;
            case 1 /* Z64API.Z64.AmmoUpgrade.BASE */:
                buf[0x5] = 0x00;
                buf[0x6] = 0x01;
                break;
            case 2 /* Z64API.Z64.AmmoUpgrade.UPGRADED */:
                buf[0x5] = 0x01;
                buf[0x6] = 0x00;
                break;
            case 3 /* Z64API.Z64.AmmoUpgrade.MAX */:
                buf[0x5] = 0x01;
                buf[0x6] = 0x01;
                break;
        }
        this.emulator.rdramWriteBits8(this.inventory_upgrades_addr + 0x1, buf);
    }
    get dekuSticksCapacity() {
        let buf = this.emulator.rdramReadBits8(this.inventory_upgrades_addr + 0x1);
        let str = buf.slice(5, 7).toString('hex');
        switch (str) {
            case '0000':
                return 0 /* Z64API.Z64.AmmoUpgrade.NONE */;
            case '0001':
                return 1 /* Z64API.Z64.AmmoUpgrade.BASE */;
            case '0100':
                return 2 /* Z64API.Z64.AmmoUpgrade.UPGRADED */;
            case '0101':
                return 3 /* Z64API.Z64.AmmoUpgrade.MAX */;
        }
        return 0 /* Z64API.Z64.AmmoUpgrade.NONE */;
    }
    set dekuNutsCapacity(bb) {
        let buf = this.emulator.rdramReadBits8(this.inventory_upgrades_addr + 0x1);
        switch (bb) {
            case 0 /* Z64API.Z64.AmmoUpgrade.NONE */:
                buf[0x2] = 0x00;
                buf[0x3] = 0x00;
                break;
            case 1 /* Z64API.Z64.AmmoUpgrade.BASE */:
                buf[0x2] = 0x00;
                buf[0x3] = 0x01;
                break;
            case 2 /* Z64API.Z64.AmmoUpgrade.UPGRADED */:
                buf[0x2] = 0x01;
                buf[0x3] = 0x00;
                break;
            case 3 /* Z64API.Z64.AmmoUpgrade.MAX */:
                buf[0x2] = 0x01;
                buf[0x3] = 0x01;
                break;
        }
        this.emulator.rdramWriteBits8(this.inventory_upgrades_addr + 0x1, buf);
    }
    get dekuNutsCapacity() {
        let buf = this.emulator.rdramReadBits8(this.inventory_upgrades_addr + 0x1);
        let str = buf.slice(2, 4).toString('hex');
        switch (str) {
            case '0000':
                return 0 /* Z64API.Z64.AmmoUpgrade.NONE */;
            case '0001':
                return 1 /* Z64API.Z64.AmmoUpgrade.BASE */;
            case '0100':
                return 2 /* Z64API.Z64.AmmoUpgrade.UPGRADED */;
            case '0101':
                return 3 /* Z64API.Z64.AmmoUpgrade.MAX */;
        }
        return 0 /* Z64API.Z64.AmmoUpgrade.NONE */;
    }
    get quiver() {
        let buf = this.emulator.rdramReadBits8(this.inventory_upgrades_addr + 0x3);
        let str = buf.slice(6, 8).toString('hex');
        switch (str) {
            case '0000':
                return 0 /* Z64API.Z64.AmmoUpgrade.NONE */;
            case '0001':
                return 1 /* Z64API.Z64.AmmoUpgrade.BASE */;
            case '0100':
                return 2 /* Z64API.Z64.AmmoUpgrade.UPGRADED */;
            case '0101':
                return 3 /* Z64API.Z64.AmmoUpgrade.MAX */;
        }
        return 0 /* Z64API.Z64.AmmoUpgrade.NONE */;
    }
    set quiver(q) {
        let buf = this.emulator.rdramReadBits8(this.inventory_upgrades_addr + 0x3);
        switch (q) {
            case 0 /* Z64API.Z64.AmmoUpgrade.NONE */:
                buf[0x6] = 0x00;
                buf[0x7] = 0x00;
                break;
            case 1 /* Z64API.Z64.AmmoUpgrade.BASE */:
                buf[0x6] = 0x00;
                buf[0x7] = 0x01;
                break;
            case 2 /* Z64API.Z64.AmmoUpgrade.UPGRADED */:
                buf[0x6] = 0x01;
                buf[0x7] = 0x00;
                break;
            case 3 /* Z64API.Z64.AmmoUpgrade.MAX */:
                buf[0x6] = 0x01;
                buf[0x7] = 0x01;
                break;
        }
        this.emulator.rdramWriteBits8(this.inventory_upgrades_addr + 0x3, buf);
    }
    get wallet() {
        let buf = this.emulator.rdramReadBits8(this.inventory_upgrades_addr + 0x2);
        let str = buf.slice(2, 4).toString('hex');
        switch (str) {
            case '0000':
                return Z64API.Z64.Wallet.CHILD;
            case '0001':
                return Z64API.Z64.Wallet.ADULT;
            case '0100':
                return Z64API.Z64.Wallet.GIANT;
            case '0101':
                return Z64API.Z64.Wallet.ROYAL;
        }
        return Z64API.Z64.Wallet.CHILD;
    }
    set wallet(w) {
        let buf = this.emulator.rdramReadBits8(this.inventory_upgrades_addr + 0x2);
        switch (w) {
            case Z64API.Z64.Wallet.CHILD:
                buf[0x2] = 0x00;
                buf[0x3] = 0x00;
                break;
            case Z64API.Z64.Wallet.ADULT:
                buf[0x2] = 0x00;
                buf[0x3] = 0x01;
                break;
            case Z64API.Z64.Wallet.GIANT:
                buf[0x2] = 0x10;
                buf[0x3] = 0x00;
                break;
            case Z64API.Z64.Wallet.ROYAL:
                buf[0x2] = 0x01;
                buf[0x3] = 0x01;
                break;
        }
        this.emulator.rdramWriteBits8(this.inventory_upgrades_addr + 0x2, buf);
    }
    getMaxRupeeCount() {
        let addr = 0x801C1E2C;
        let capacities = [];
        for (let i = 0; i < 8; i += 2) {
            capacities.push(this.emulator.rdramRead16(addr + i));
        }
        return capacities[this.wallet];
    }
    get dekuSticksCount() {
        return this.getAmmoForSlot(8 /* Z64API.MM.InventorySlots.DEKU_STICKS */);
    }
    set dekuSticksCount(count) {
        this.setAmmoInSlot(8 /* Z64API.MM.InventorySlots.DEKU_STICKS */, count);
    }
    get bombsCount() {
        return this.getAmmoForSlot(6 /* Z64API.MM.InventorySlots.BOMBS */);
    }
    set bombsCount(count) {
        this.setAmmoInSlot(6 /* Z64API.MM.InventorySlots.BOMBS */, count);
    }
    get bombchuCount() {
        return this.getAmmoForSlot(7 /* Z64API.MM.InventorySlots.BOMBCHUS */);
    }
    set bombchuCount(count) {
        this.setAmmoInSlot(7 /* Z64API.MM.InventorySlots.BOMBCHUS */, count);
    }
    get powderKegCount() {
        return this.getAmmoForSlot(12 /* Z64API.MM.InventorySlots.POWDER_KEG */);
    }
    set powderKegCount(count) {
        this.setAmmoInSlot(12 /* Z64API.MM.InventorySlots.POWDER_KEG */, count);
    }
    get magicBeansCount() {
        return this.getAmmoForSlot(10 /* Z64API.MM.InventorySlots.MAGIC_BEANS */);
    }
    set magicBeansCount(count) {
        this.setAmmoInSlot(10 /* Z64API.MM.InventorySlots.MAGIC_BEANS */, count);
    }
    get arrows() {
        return this.getAmmoForSlot(1 /* Z64API.MM.InventorySlots.HEROES_BOW */);
    }
    set arrows(count) {
        this.setAmmoInSlot(1 /* Z64API.MM.InventorySlots.HEROES_BOW */, count);
    }
    get dekuNutsCount() {
        return this.getAmmoForSlot(9 /* Z64API.MM.InventorySlots.DEKU_NUTS */);
    }
    set dekuNutsCount(count) {
        this.setAmmoInSlot(9 /* Z64API.MM.InventorySlots.DEKU_NUTS */, count);
    }
    get photoCount() {
        return this.getAmmoForSlot(0x1C); //slot: save + inventoryCount + 0x1C
    }
    set photoCount(count) {
        this.setAmmoInSlot(0x1C, count);
    }
    get FIELD_BOTTLE1() {
        return this.getItemInSlot(18 /* Z64API.MM.InventorySlots.BOTTLE1 */);
    }
    set FIELD_BOTTLE1(content) {
        if (content < Z64API.MM.InventoryItem.BOTTLE_EMPTY ||
            content > Z64API.MM.InventoryItem.BOTTLE_CHATEAU_ROMANI) {
            return;
        }
        this.setItemInSlot(content, 18 /* Z64API.MM.InventorySlots.BOTTLE1 */);
    }
    get FIELD_BOTTLE2() {
        return this.getItemInSlot(19 /* Z64API.MM.InventorySlots.BOTTLE2 */);
    }
    set FIELD_BOTTLE2(content) {
        if (content < Z64API.MM.InventoryItem.BOTTLE_EMPTY ||
            content > Z64API.MM.InventoryItem.BOTTLE_CHATEAU_ROMANI) {
            return;
        }
        this.setItemInSlot(content, 19 /* Z64API.MM.InventorySlots.BOTTLE2 */);
    }
    get FIELD_BOTTLE3() {
        return this.getItemInSlot(20 /* Z64API.MM.InventorySlots.BOTTLE3 */);
    }
    set FIELD_BOTTLE3(content) {
        if (content < Z64API.MM.InventoryItem.BOTTLE_EMPTY ||
            content > Z64API.MM.InventoryItem.BOTTLE_CHATEAU_ROMANI) {
            return;
        }
        this.setItemInSlot(content, 20 /* Z64API.MM.InventorySlots.BOTTLE3 */);
    }
    get FIELD_BOTTLE4() {
        return this.getItemInSlot(21 /* Z64API.MM.InventorySlots.BOTTLE4 */);
    }
    set FIELD_BOTTLE4(content) {
        if (content < Z64API.MM.InventoryItem.BOTTLE_EMPTY ||
            content > Z64API.MM.InventoryItem.BOTTLE_CHATEAU_ROMANI) {
            return;
        }
        this.setItemInSlot(content, 21 /* Z64API.MM.InventorySlots.BOTTLE4 */);
    }
    get FIELD_BOTTLE5() {
        return this.getItemInSlot(22 /* Z64API.MM.InventorySlots.BOTTLE5 */);
    }
    set FIELD_BOTTLE5(content) {
        if (content < Z64API.MM.InventoryItem.BOTTLE_EMPTY ||
            content > Z64API.MM.InventoryItem.BOTTLE_CHATEAU_ROMANI) {
            return;
        }
        this.setItemInSlot(content, 22 /* Z64API.MM.InventorySlots.BOTTLE5 */);
    }
    get FIELD_BOTTLE6() {
        return this.getItemInSlot(23 /* Z64API.MM.InventorySlots.BOTTLE6 */);
    }
    set FIELD_BOTTLE6(content) {
        if (content < Z64API.MM.InventoryItem.BOTTLE_EMPTY ||
            content > Z64API.MM.InventoryItem.BOTTLE_CHATEAU_ROMANI) {
            return;
        }
        this.setItemInSlot(content, 23 /* Z64API.MM.InventorySlots.BOTTLE6 */);
    }
    hasBottle() {
        for (let i = 18 /* Z64API.MM.InventorySlots.BOTTLE1 */; i <= 23 /* Z64API.MM.InventorySlots.BOTTLE6 */; i++) {
            let item = this.getItemInSlot(i);
            if (item >= Z64API.MM.InventoryItem.BOTTLE_EMPTY &&
                item <= Z64API.MM.InventoryItem.BOTTLE_CHATEAU_ROMANI //TODO: Check if Big or Small Poe in-game
            ) {
                return true;
            }
        }
        return false;
    }
    getBottleCount() {
        let bottles = 0;
        for (let i = 18 /* Z64API.MM.InventorySlots.BOTTLE1 */; i <= 23 /* Z64API.MM.InventorySlots.BOTTLE6 */; i++) {
            let item = this.getItemInSlot(i);
            if (item >= Z64API.MM.InventoryItem.BOTTLE_EMPTY &&
                item <= Z64API.MM.InventoryItem.BOTTLE_CHATEAU_ROMANI) {
                bottles++;
            }
        }
        return bottles;
    }
    getBottledItems() {
        let bottles = new Array();
        for (let i = 18 /* Z64API.MM.InventorySlots.BOTTLE1 */; i <= 23 /* Z64API.MM.InventorySlots.BOTTLE6 */; i++) {
            let item = this.getItemInSlot(i);
            if (item >= Z64API.MM.InventoryItem.BOTTLE_EMPTY &&
                item <= Z64API.MM.InventoryItem.BOTTLE_CHATEAU_ROMANI) {
                bottles.push(item);
            }
        }
        return bottles;
    }
    get FIELD_QUEST_ITEM_1() {
        return this.getItemInSlot(5 /* Z64API.MM.InventorySlots.QUEST_ITEM_1 */);
    }
    set FIELD_QUEST_ITEM_1(item) {
        if (item < Z64API.MM.InventoryItem.QSLOT1_MOONS_TEAR || item > Z64API.MM.InventoryItem.QSLOT1_TITLE_DEED_OCEAN)
            return;
        this.setItemInSlot(item, 5 /* Z64API.MM.InventorySlots.QUEST_ITEM_1 */);
    }
    get FIELD_QUEST_ITEM_2() {
        return this.getItemInSlot(11 /* Z64API.MM.InventorySlots.QUEST_ITEM_2 */);
    }
    set FIELD_QUEST_ITEM_2(item) {
        if (item < Z64API.MM.InventoryItem.QSLOT2_ROOM_KEY || item > Z64API.MM.InventoryItem.QSLOT2_SPECIAL_DELIVERY_TO_MAMA) {
            return;
        }
        this.setItemInSlot(item, 11 /* Z64API.MM.InventorySlots.QUEST_ITEM_2 */);
    }
    get FIELD_QUEST_ITEM_3() {
        return this.getItemInSlot(17 /* Z64API.MM.InventorySlots.QUEST_ITEM_3 */);
    }
    set FIELD_QUEST_ITEM_3(item) {
        if (item < Z64API.MM.InventoryItem.QSLOT3_LETTER_TO_KAFEI || item > Z64API.MM.InventoryItem.QSLOT3_PENDANT_OF_MEMORIES) {
            return;
        }
        this.setItemInSlot(item, 17 /* Z64API.MM.InventorySlots.QUEST_ITEM_3 */);
    }
    isEvt1TradeFinished() {
        // This is going to require more complex flag checks
        return true;
    }
    isEvt2TradeFinished() {
        // This should be done with flags also
        return true;
    }
    isEvt3TradeFinished() {
        // This should be done with flags also
        return true;
    }
    getItemInSlot(slotId) {
        if (slotId < 0 || slotId > 47 /* Z64API.MM.InventorySlots.MASK_FIERCE_DEITY */) {
            return Z64API.MM.InventoryItem.NONE;
        }
        let itemId = this.emulator.rdramRead8(this.inventory_addr + slotId);
        return itemId;
    }
    getSlotForItem(item) {
        for (let i = 0; i <= 47 /* Z64API.MM.InventorySlots.MASK_FIERCE_DEITY */; i++) {
            if (this.getItemInSlot(i) == item) {
                return i;
            }
        }
        return -1;
    }
    getSlotsForItem(item) {
        let slots = new Array();
        for (let i = 0; i <= 47 /* Z64API.MM.InventorySlots.MASK_FIERCE_DEITY */; i++) {
            if (this.getItemInSlot(i) == item) {
                slots.push(i);
            }
        }
        return slots;
    }
    hasItem(item) {
        return this.getSlotForItem(item) != -1;
    }
    getAmmoForItem(item) {
        if (!this.hasAmmo(item))
            return 0;
        let ammo = 0;
        let slots = this.getSlotsForItem(item);
        for (let i = 0; i < slots.length; i++) {
            ammo += this.getAmmoForSlot(slots[i]);
        }
        return ammo;
    }
    hasAmmo(item) {
        switch (item) {
            case Z64API.MM.InventoryItem.DEKU_STICK:
            case Z64API.MM.InventoryItem.DEKU_NUT:
            case Z64API.MM.InventoryItem.HEROES_BOW:
            case Z64API.MM.InventoryItem.BOMB:
            case Z64API.MM.InventoryItem.BOMBCHU:
            case Z64API.MM.InventoryItem.POWDER_KEG:
            case Z64API.MM.InventoryItem.MAGIC_BEANS:
                return true;
        }
        return false;
    }
    getAmmoForSlot(slotId) {
        if (slotId < 0 || slotId > 0xf)
            return 0;
        return this.emulator.rdramRead8(this.inventory_ammo_addr + slotId);
    }
    setAmmoInSlot(slot, amount) {
        if (slot < 0 || slot >= 0xf)
            return;
        this.emulator.rdramWrite8(this.inventory_ammo_addr + slot, amount);
    }
    setItemInSlot(item, slot) {
        if (slot < 0 || slot > 47 /* Z64API.MM.InventorySlots.MASK_FIERCE_DEITY */) {
            return;
        }
        this.emulator.rdramWrite8(this.inventory_addr + slot, item.valueOf());
    }
    giveItem(item, desiredSlot) {
        if (this.getItemInSlot(desiredSlot) == Z64API.MM.InventoryItem.NONE ||
            this.getItemInSlot(desiredSlot) == item) {
            this.setItemInSlot(item, desiredSlot);
        }
    }
    removeItem(item) {
        let slots = this.getSlotsForItem(item);
        for (let i = 0; i < slots.length; i++) {
            this.setItemInSlot(Z64API.MM.InventoryItem.NONE, i);
        }
    }
    getEmptySlots() {
        let slots = new Array();
        for (let i = 0; i <= 47 /* Z64API.MM.InventorySlots.MASK_FIERCE_DEITY */; i++) {
            if (this.getItemInSlot(i) == Z64API.MM.InventoryItem.NONE) {
                slots.push(i);
            }
        }
        return slots;
    }
}
exports.Inventory = Inventory;
//# sourceMappingURL=Inventory.js.map