Improve ids.ts #471

Closed
opened 2026-02-05 12:11:55 +00:00 by LunarTides · 0 comments
LunarTides commented 2026-02-05 12:11:55 +00:00 (Migrated from github.com)

Old:

export const cardIds = {
    null: "00000000-0000-0000-0000-000000000000",
    plant_019bc665_4f7f_7000_87d1_7bcf9ffd1fdc: "019bc665-4f7f-7000-87d1-7bcf9ffd1fdc",
    // ...
}

New:

export const cardIds = {
    // Is this needed? If so, prevent users from making a user / group with the name "null".
    null: "00000000-0000-0000-0000-000000000000",
    OwnerName: {
        pack_name: {
            // All are arrays just in case more are added.
            plant: ["019bc665-4f7f-7000-87d1-7bcf9ffd1fdc"],
            // Arrays are used in case there are multiple cards with the same name.
            // The array will be sorted based on the uuid, oldest first.
            // That way, we don't have to worry about anything breaking.
            sheep: [
                "019c2da7-c9a2-79b4-9d57-e4467a61a0b9",
                "019c2da7-eab7-72f0-929a-6fe6d4015b88",
            ],
        },
    },
    Official: {
        builtin: {
            the_coin: ["019bc665-4f7f-7003-9fbe-be72400ab84e"],
        },
    },
    // Old version. Incase the user doesn't know which pack a card came from.
    all: {
        plant_019bc665_4f7f_7000_87d1_7bcf9ffd1fdc: "019bc665-4f7f-7000-87d1-7bcf9ffd1fdc",
        // ...
    }
}

This makes it so that instead of referencing cards like this:

game.cardIds.theCoin_019bc665_4f7f_7003_9fbe_be72400ab84e

We can reference them like this:

game.ids.Official.builtin.the_coin[0]
game.ids.all.the_coin_019bc665_4f7f_7003_9fbe_be72400ab84e

Official is the working name for the group that the builtin and examples packs should be under.
Rename cardIds to ids for brevity.

Old: ```ts export const cardIds = { null: "00000000-0000-0000-0000-000000000000", plant_019bc665_4f7f_7000_87d1_7bcf9ffd1fdc: "019bc665-4f7f-7000-87d1-7bcf9ffd1fdc", // ... } ``` New: ```ts export const cardIds = { // Is this needed? If so, prevent users from making a user / group with the name "null". null: "00000000-0000-0000-0000-000000000000", OwnerName: { pack_name: { // All are arrays just in case more are added. plant: ["019bc665-4f7f-7000-87d1-7bcf9ffd1fdc"], // Arrays are used in case there are multiple cards with the same name. // The array will be sorted based on the uuid, oldest first. // That way, we don't have to worry about anything breaking. sheep: [ "019c2da7-c9a2-79b4-9d57-e4467a61a0b9", "019c2da7-eab7-72f0-929a-6fe6d4015b88", ], }, }, Official: { builtin: { the_coin: ["019bc665-4f7f-7003-9fbe-be72400ab84e"], }, }, // Old version. Incase the user doesn't know which pack a card came from. all: { plant_019bc665_4f7f_7000_87d1_7bcf9ffd1fdc: "019bc665-4f7f-7000-87d1-7bcf9ffd1fdc", // ... } } ``` This makes it so that instead of referencing cards like this: ```ts game.cardIds.theCoin_019bc665_4f7f_7003_9fbe_be72400ab84e ``` We can reference them like this: ```ts game.ids.Official.builtin.the_coin[0] game.ids.all.the_coin_019bc665_4f7f_7003_9fbe_be72400ab84e ``` > Official is the working name for the group that the `builtin` and `examples` packs should be under. > Rename `cardIds` to `ids` for brevity.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
LunarTides/Hearthstone.js#471
No description provided.