lorcana-api
Version:
JavaScript / TypeScript client for https://lorcana-api.com/
18 lines • 653 B
JavaScript
/**
* Parses an ability that looks like "<ability> N", e.g. "Shift 4". Note that the cost may not be present if the card
* simply talks about the ability instead of having it, e.x. Morph - Space Goo having "Shift".
* @param abilityName The name of the ability itself
*/
export const inkCostParser = (abilityName) => {
const regex = new RegExp(`${abilityName}(?: (\\d+))?`);
return (ability) => {
const match = ability.match(regex);
if (!match) {
return false;
}
return {
inkCost: match[1] ? parseInt(match[1]) : undefined,
};
};
};
//# sourceMappingURL=inkCostParser.js.map