Spaces:
Running
Running
File size: 4,752 Bytes
5c2ed06 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var dex_items_exports = {};
__export(dex_items_exports, {
DexItems: () => DexItems,
Item: () => Item
});
module.exports = __toCommonJS(dex_items_exports);
var import_dex_data = require("./dex-data");
var import_utils = require("../lib/utils");
class Item extends import_dex_data.BasicEffect {
constructor(data) {
super(data);
this.fullname = `item: ${this.name}`;
this.effectType = "Item";
this.fling = data.fling || void 0;
this.onDrive = data.onDrive || void 0;
this.onMemory = data.onMemory || void 0;
this.megaStone = data.megaStone || void 0;
this.megaEvolves = data.megaEvolves || void 0;
this.zMove = data.zMove || void 0;
this.zMoveType = data.zMoveType || void 0;
this.zMoveFrom = data.zMoveFrom || void 0;
this.itemUser = data.itemUser || void 0;
this.isBerry = !!data.isBerry;
this.ignoreKlutz = !!data.ignoreKlutz;
this.onPlate = data.onPlate || void 0;
this.isGem = !!data.isGem;
this.isPokeball = !!data.isPokeball;
this.isPrimalOrb = !!data.isPrimalOrb;
if (!this.gen) {
if (this.num >= 1124) {
this.gen = 9;
} else if (this.num >= 927) {
this.gen = 8;
} else if (this.num >= 689) {
this.gen = 7;
} else if (this.num >= 577) {
this.gen = 6;
} else if (this.num >= 537) {
this.gen = 5;
} else if (this.num >= 377) {
this.gen = 4;
} else {
this.gen = 3;
}
}
if (this.isBerry)
this.fling = { basePower: 10 };
if (this.id.endsWith("plate"))
this.fling = { basePower: 90 };
if (this.onDrive)
this.fling = { basePower: 70 };
if (this.megaStone)
this.fling = { basePower: 80 };
if (this.onMemory)
this.fling = { basePower: 50 };
(0, import_dex_data.assignMissingFields)(this, data);
}
}
const EMPTY_ITEM = import_utils.Utils.deepFreeze(new Item({ name: "", exists: false }));
class DexItems {
constructor(dex) {
this.itemCache = /* @__PURE__ */ new Map();
this.allCache = null;
this.dex = dex;
}
get(name) {
if (name && typeof name !== "string")
return name;
const id = name ? (0, import_dex_data.toID)(name.trim()) : "";
return this.getByID(id);
}
getByID(id) {
if (id === "")
return EMPTY_ITEM;
let item = this.itemCache.get(id);
if (item)
return item;
if (this.dex.data.Aliases.hasOwnProperty(id)) {
item = this.get(this.dex.data.Aliases[id]);
if (item.exists) {
this.itemCache.set(id, item);
}
return item;
}
if (id && !this.dex.data.Items[id] && this.dex.data.Items[id + "berry"]) {
item = this.getByID(id + "berry");
this.itemCache.set(id, item);
return item;
}
if (id && this.dex.data.Items.hasOwnProperty(id)) {
const itemData = this.dex.data.Items[id];
const itemTextData = this.dex.getDescs("Items", id, itemData);
item = new Item({
name: id,
...itemData,
...itemTextData
});
if (item.gen > this.dex.gen) {
item.isNonstandard = "Future";
}
if (this.dex.parentMod) {
const parent = this.dex.mod(this.dex.parentMod);
if (itemData === parent.data.Items[id]) {
const parentItem = parent.items.getByID(id);
if (item.isNonstandard === parentItem.isNonstandard && item.desc === parentItem.desc && item.shortDesc === parentItem.shortDesc) {
item = parentItem;
}
}
}
} else {
item = new Item({ name: id, exists: false });
}
if (item.exists)
this.itemCache.set(id, this.dex.deepFreeze(item));
return item;
}
all() {
if (this.allCache)
return this.allCache;
const items = [];
for (const id in this.dex.data.Items) {
items.push(this.getByID(id));
}
this.allCache = Object.freeze(items);
return this.allCache;
}
}
//# sourceMappingURL=dex-items.js.map
|