Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cairn gear packages #83

Closed
fjallnari opened this issue Jan 27, 2023 · 3 comments · Fixed by #87
Closed

Add Cairn gear packages #83

fjallnari opened this issue Jan 27, 2023 · 3 comments · Fixed by #87

Comments

@fjallnari
Copy link
Owner

fjallnari commented Jan 27, 2023

Add https://cairnrpg.com/cairn-srd/#optional-gear-packages as ItemCairn arrays
to allow for more flexible character generation.

@fjallnari fjallnari changed the title Add optional gear packages for Cairn as ItemCairn arrays Add Cairn gear packages Jan 31, 2023
@fjallnari
Copy link
Owner Author

Refactoring Cairn items like armors #88, would allow for us to save Gear packages using something like this:

export const GEAR_PACKAGES = {
    cleric: [
        WEAPONS['War Hammer'],
        ARMORS['Chainmail'],
        ARMORS['Gauntlets'],
        ... createWeapon('Cleansing Blade', 'd6') // can be used for custom non-SRD items, which are not repeated elsewhere
        ... createItem('Holy Symbol (Ward once per day)'),
        ... createItem('Cloak of the Order')
    ]
}

@ptaranat
Copy link
Collaborator

ptaranat commented Jan 31, 2023

I have a preference for the following:

const createItem = ({ name, description, bulky, stacks }: {
    name: string,
    description?: string,
    bulky?: boolean,
    stacks?: boolean,
}
): ItemCairn => {
    return { name: name, type: 'item', description: description, bulky, stacks: stacks, };
}

This allows createItem({ name: "Dice Set", stacks: true }) instead of createItem("Dice Set", "", false, true).

We could also import GEARS, TOOLS, and TRINKETS under ITEMS, so that we can add createItem in one file.

@fjallnari
Copy link
Owner Author

I like the createItem function, and we can for sure merge the TOOLS etc. under one file. However, I've noticed a flaw in my approach. If we use createArmor the way it works now, the resulting gear package would be inconsistent if we add it from the SRD items vs. if we create it from scratch.

cleric: [
    WEAPONS["War Hammer"],
    createWeapon("Cleansing Blade", "d6"),
]

results in this:

cleric: [
  {
    name: 'War Hammer (d10, bulky)',
    type: 'weapon',
    bulky: true,
    damage: 'd10'
  },
  { 'Cleansing Blade': [Object] },

I think it would be best if we just used simple classes for armor and weapons, like so:

export class ArmorCairn {
    public record: Record<string, Partial<ItemCairn>>;

    constructor ({ name, armor, bulky }: { name: string, armor: string, bulky?: boolean }) {
        const prettyName = `${name} (${armor} Armor${bulky ? ', bulky': ''})`;
        this.record = {[name]: { name: prettyName, type: 'armor', bulky, armor: armor }};
        return this;
    }

    public getItem() {
        return this.record[Object.keys(this.record)[0]];
    }
}

Then we can use e.g. ... new ArmorCairn({ name: 'Shield', armor: '+1' }).record to generate the SRD armors, and new ArmorCairn({ name: 'Shield', armor: '+1' }).getItem() to create custom armor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants