we ball I guess

This commit is contained in:
2026-06-07 19:51:54 -05:00
parent f8c9d33df2
commit 51388c90d5
42 changed files with 2233 additions and 30 deletions
+63
View File
@@ -0,0 +1,63 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
/** The player's item backpack (a fixed 20-slot inventory). */
interface BackpackNamespace {
/** `true` when all 20 storage slots are occupied by distinct items. */
readonly isFull: boolean;
/**
* Returns the quantity of `itemId` in the backpack (0 if absent).
* @param itemId - An `ITEM_ID_*` constant.
*/
getCount(itemId: ItemId): number;
/**
* Returns `true` if `itemId` is present with quantity greater than 0.
* @param itemId - An `ITEM_ID_*` constant.
*/
has(itemId: ItemId): boolean;
/**
* Returns `true` if the stack for `itemId` is at maximum quantity (255).
* @param itemId - An `ITEM_ID_*` constant.
*/
isItemFull(itemId: ItemId): boolean;
/**
* Sets the quantity of `itemId`; passing 0 removes the stack entirely.
* @param itemId - An `ITEM_ID_*` constant.
* @param quantity - New quantity, 0255.
*/
set(itemId: ItemId, quantity: number): void;
/**
* Adds `quantity` units of `itemId` to the backpack.
* @param itemId - An `ITEM_ID_*` constant.
* @param quantity - Amount to add, 1255.
*/
add(itemId: ItemId, quantity: number): void;
/**
* Removes `itemId` entirely from the backpack.
* @param itemId - An `ITEM_ID_*` constant.
*/
remove(itemId: ItemId): void;
/**
* Sorts the backpack contents.
* @param sortBy - `INVENTORY_SORT_BY_ID` or `INVENTORY_SORT_BY_TYPE`.
* @param reverse - Optional; pass `true` to reverse the sort order.
*/
sort(sortBy: number, reverse?: boolean): void;
}
declare var Backpack: BackpackNamespace;
// Inventory sort constants — injected as globals by the engine at startup.
declare var INVENTORY_SORT_BY_ID: number;
declare var INVENTORY_SORT_BY_TYPE: number;
+39
View File
@@ -0,0 +1,39 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
/** Opaque type alias for item identifier constants. */
type ItemId = number;
/** Opaque type alias for item type constants. */
type ItemType = number;
/** Item data lookup. */
interface ItemNamespace {
/**
* Returns the string name for the given item ID.
* @param itemId - An `ITEM_ID_*` constant.
*/
getName(itemId: ItemId): string;
/**
* Returns the type constant for the given item ID.
* @param itemId - An `ITEM_ID_*` constant.
* @returns An `ITEM_TYPE_*` constant.
*/
getType(itemId: ItemId): ItemType;
}
declare var Item: ItemNamespace;
// Item ID constants — injected as globals by the engine at startup.
declare var ITEM_ID_POTION: ItemId;
declare var ITEM_ID_POTATO: ItemId;
declare var ITEM_ID_APPLE: ItemId;
// Item type constants — injected as globals by the engine at startup.
declare var ITEM_TYPE_MEDICINE: ItemType;
declare var ITEM_TYPE_FOOD: ItemType;