Coder Social home page Coder Social logo

xethya / framework Goto Github PK

View Code? Open in Web Editor NEW
11.0 3.0 1.0 3.1 MB

Official monorepo for Xethya, an RPG mechanics framework built in TypeScript.

License: MIT License

JavaScript 11.08% TypeScript 88.92%
xethya game-mechanics typescript rpg rpg-toolkit hacktoberfest

framework's People

Contributors

dependabot[bot] avatar greenkeeper[bot] avatar joelalejandro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

markpol

framework's Issues

[race] Implement a Race object

According to the Race specs from the SRD, a Race has the following properties:

Ability Score Increase

Every race increases one or more of a character's ability scores.

Age

The age entry notes the age when a member of the race is considered an adult, as well as the race's expected lifespan. This information can help you decide how old your character is at the start of the game. You can choose any age for your character, which could provide an explanation for some of your ability scores. For example, if you play a young or very old character, your age could explain a particularly low Strength or Constitution score, while advanced age could account for a high Intelligence or Wisdom.

Alignment

Most races have tendencies toward certain alignments, described in this entry. These are not binding for player characters, but considering why your dwarf is chaotic, for example, in defiance of lawful dwarf society can help you better define your character.

Size

Characters of most races are Medium, a size category including creatures that are roughly 4 to 8 feet tall. Members of a few races are Small (between 2 and 4 feet tall), which means that certain rules of the game affect them differently. The most important of these rules is that Small characters have trouble wielding heavy weapons, as explained in “Equipment.”

Speed

Your speed determines how far you can move when traveling (“Adventuring”) and fighting (“Combat”).

Languages

By virtue of your race, your character can speak, read, and write certain languages.

Subraces

Some races have subraces. Members of a subrace have the traits of the parent race in addition to the traits specified for their subrace. Relationships among subraces vary significantly from race to race and world to world.

Tasks

  • Create Alignment enum
  • Create Size enum
  • Implement the object

[creature] Add support for Hit Points

When a creature dies, it means it has no hit points left. It is determined by the size of the creature. If constitution is part of the creature's definition, its modifier is factored in the calculation.

[testing] [utils] Add a `matchesUUIDFormat()` function

Tests will usually check that some classes implement an identifier that matches a UUID format.

To avoid repeating the regex required for it all over the place, we'll add a function to check if a string matches this regex:

/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/

[utils] A WeightedStack should be resizable

When using the WeightedStack for the inventory, we noticed it's not enough to have a capacity, but we'll also need a mutable capacity.

Usually, in RPGs, the amount of weight a character can store in inventory is calculated using their strength or constitution, or some other basic calculation. While, initially, we might not want to be opinionated about how the capacity is calculated, we definitely want to support a way to update it.

We should extend WeightedStack with a new class called DynamicWeightedStack, that removes the readonly constraint from WeightedStack and adds a resize() method.

[definitions] Morality and Attitude enums should be exposed to perform bitwise operations with them

Since these enums are implemented as bitwise operators, if we want to do an action based only on a part of the CreatureAlignment, right now we need:

// Do something if the creature is Lawful.
if (
  creature.alignment === CreatureAlignment.LawfulGood 
  || creature.alignment === CreatureAlignment.LawfulNeutral
  || creature.alignment === CreatureAlignment.LawfulEvil
) {
  // ...
}

While we could have a simpler, shorter form:

// Do something if the creature is Lawful.
if (creature.alignment & CreatureAttitude.Lawful) {
  // ...
}

We would need to export the CreatureMorality and CreatureAttitude enumerables in the @xethya/definitions package.

[creature] Add support for Speed

By default, it refers to any ground-based movement the creature can do. According to the type of creature, it can also burrow, climb, fly or swim. With enough movement, a Creature can combine multiple movements if their speed is available.

[sponsor] Add funding links in README.md

While we now have the 💜 Sponsor button to allow for donations, since we're using non-default payment processors, it'd be nice to have a page on GitBook to better present this, while also adding it to the monorepo's readme.

[creature] Define dominance pattern for traits in multi-racial creatures

Suppose we have a creature that is half-human, half-cat.

We want to create it using multiple races, as described in #28. So we define Human and Feline as races:

const HumanRace = new Race({ 
  age: 90, 
  alignment: CreatureAlignment.Neutral, 
  size: CreatureSize.Medium 
});
const CatRace = new Race({ 
  age: 15, 
  alignment: CreatureAlignment.NeutralEvil, 
  size: CreatureSize.Small 
});

Such hybrid creature could be expressed as:

const FelineHumanoid = new Creature({
  races: [HumanRace, CatRace],
  name: "Feline Humanoid"
});

How would the traits be defined for this instance?

  • A possible way would randomize between the ranges of possibilities defined by each race. So, for the age, any feline humanoid creature would have a maximum age between 15 and 90, they could be either Small or Medium in size and be aligned as Neutral or NeutralEvil.

  • We could cascade the values from race A to race B (which would make the races list order-sensitive).

  • We could drop "multi-racial" support in terms of defining hybrid races as specific races, such as:

    const FelineHumanoid = new Race({ /* ... */ });

[point] Implement a Point system

Points are cumulative units that can reflect different features of a creature.

Some examples would be hit points (how many hits a creature can take before dying or being destroyed), magic points (how much magical energy a creature is holding) or experience points (how much has a creature progressed in its life, raising its "level" and therefore other points).

  • Points have a denomination.
  • Points can be increased or decreased arbitrarily (#37)
  • Points can be the result of a calculation of several depending variables, such as ability score modifiers (#38).

[build process] Use projext for bundling the packages

It'd be nice to start using projext to simplify the framework's bundling process.

@homer0, what'd be the best way to implement your bundler? This monorepo is entirely built with TypeScript, and currently using Rollup to bundle the packages. The idea is to output each package as an importable library or as an IIFE (see this file for reference).

[inventory] Add an Inventory system

An inventory represents a container of items. Such containers can be attached to other objects, like creatures or inanimate objects (i.e. chests).

  • An inventory has a capacity.
  • An inventory can store items.
  • Items can be retrieved from an inventory.
  • Items can stacked to occupy a single inventory space.

[bridge-phaser] Should expand Phaser declarations with plugin additions

Currently, on the test suite for the Phaser bridge, we have something like this:

type XethyaGameObjectFactory = XethyaDiceGameObjects & XethyaInventoryGameObjects;

type XethyaInventoryGameObjects = {
  inventory(options?: InventoryOptions): InventoryGameObject;
};

type XethyaDiceGameObjects = {
  die(faces?: number): DieGameObject;
  coinFlip(): DieGameObject;
  d4(): DieGameObject;
  d6(): DieGameObject;
  d8(): DieGameObject;
  d10(): DieGameObject;
  d12(): DieGameObject;
  d20(): DieGameObject;
  d100(): DieGameObject;
};

declare module "phaser" {
  namespace GameObjects {
    interface GameObjectFactory extends XethyaGameObjectFactory {}
  }
}

This should be exportable as a type declaration as well.

[creature] Implement a Creature system

Based on the SRD page for Creatures.

  • A Creature should be the base template of a Character. It has a Size, an Alignment, and other attributes applicable from a Race.
  • A Creature has a name.
  • A Creature has a unique identifier.
  • A Creature can be multi-racial -- that is, it can have multiple races.
  • A Creature has abilities (if using the 5E gamebook, it could be Strength, Dexterity, etc.)
  • A Creature has hit points (#50).
  • A Creature has a speed (#51).
  • A Creature can talk/understand languages.
  • A Creature has a challenge rating, a number that describes how much of a threat the creature is.
  • A Creature can have skills, such as melee attack or ranged attacks.
  • A Creature can have an inventory.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.