Skip to content

Commit

Permalink
v0.6.15
Browse files Browse the repository at this point in the history
- Exposed the "outcomes" of rolls performed via the Pirate Borg API to allow for better integration with other modules and/or macros.
  • Loading branch information
sneat authored Apr 21, 2024
2 parents e0c3a49 + 5a56307 commit 6721bd6
Show file tree
Hide file tree
Showing 28 changed files with 99 additions and 27 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v0.6.15

- Exposed the "outcomes" of rolls performed via the Pirate Borg API to allow for better integration with other modules and/or macros.

# v0.6.14

- Updated Rapscallion class. Changes made to:
Expand Down
27 changes: 27 additions & 0 deletions how-to-use-this-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,30 @@ This is an implementation of the PIRATE BORG rules, with limited adaptations to
- Allowed classes: edit the classes in the character generator.
- Apply overcapacity Penalty: +2 STR/AGI DR when carrying more than STR+8 items.
- Track ammo: Select and auto-decrement ammo for ranged weapons.

## API

- An API is exposed at `game.pirateborg.api` for developers and GMs to use.

The following are some examples provided by `Ashendar` on the Discord server.
- An example of how to use the API to roll a character's attack is:
```javascript
const outcome = game.pirateborg.api.characterAttackAction(actor, weapon);
```
- An example of how to roll a character strength check and test the outcome against a DR 18 is:
```javascript
const outcome = await game.pirateborg.api.actions.actorRollAbilityAction(actor, "strength", ["Mining DR18"]);
return outcome.roll.total >= 18;
```
- An example of combining this with the multiple [landings feature](https://github.com/ironmonk88/monks-module-wiki/wiki/MATT-Landing) of [Monk's Active Tile Triggers](https://foundryvtt.com/packages/monks-active-tiles) is:
```javascript
const outcome = await game.pirateborg.api.actions.actorRollAbilityAction(actor, "strength", ["Mining DR18"]);
let goto = [];
if (outcome.roll.total >= 18) {
goto.push({ tokens: arguments[0].tokens, tag: "Success" });
} else {
goto.push({ tokens: arguments[0].tokens, tag: "Fail" });
}
goto = goto.filter(g => g.tokens.length > 0);
return {goto: goto};
```
4 changes: 3 additions & 1 deletion module/api/action/actor/actor-initiative-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createInitiativeOutcome } from "../../outcome/actor/initiative-outcome.

/**
* @param {PBActor} actor
* @returns {Promise.<void>}
* @returns {Promise<Object>}
*/
export const actorInitiativeAction = async (actor) => {
const outcome = await createInitiativeOutcome({ actor });
Expand All @@ -20,4 +20,6 @@ export const actorInitiativeAction = async (actor) => {
combatant.update({ initiative: outcome.roll.total });
}
}

return outcome;
};
4 changes: 3 additions & 1 deletion module/api/action/actor/actor-party-initiative-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { showGenericCard } from "../../../chat-message/generic-card.js";
import { createPartyInitiativeOutcome } from "../../outcome/actor/party-initiative-outcome.js";

/**
* @returns {Promise.<void>}
* @returns {Promise<Object>}
*/
export const actorPartyInitiativeAction = async () => {
const outcome = await createPartyInitiativeOutcome();
Expand All @@ -15,4 +15,6 @@ export const actorPartyInitiativeAction = async () => {
if (game.combats && game.combat) {
await game.combat.setPartyInitiative(outcome.roll.total);
}

return outcome;
};
4 changes: 3 additions & 1 deletion module/api/action/actor/actor-roll-ability-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { createTestAbilityOutcome } from "../../outcome/actor/test-ability-outco
* @param {PBActor} actor
* @param {String} ability
* @param {Array.<String>} drModifiers
* @returns {Promise.<void>}
* @returns {Promise<Object>}
*/
export const actorRollAbilityAction = async (actor, ability, drModifiers = []) => {
const outcome = await createTestAbilityOutcome({ actor, ability });
Expand All @@ -16,6 +16,8 @@ export const actorRollAbilityAction = async (actor, ability, drModifiers = []) =
actor,
outcomes: [outcome],
});

return outcome;
};

/**
Expand Down
4 changes: 3 additions & 1 deletion module/api/action/character/character-broken-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createBrokenOutcome } from "../../outcome/character/broken-outcome.js";

/**
* @param {PBActor} actor
* @returns {Promise.<ChatMessage>}
* @returns {Promise<Object>}
*/
export const characterBrokenAction = async (actor) => {
const outcome = await createBrokenOutcome({ actor });
Expand All @@ -13,4 +13,6 @@ export const characterBrokenAction = async (actor) => {
actor,
outcomes: [outcome],
});

return outcome;
};
4 changes: 3 additions & 1 deletion module/api/action/character/character-defend-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createDefendOutcome } from "../../outcome/character/defend-outcome.js";

/**
* @param {PBActor} actor
* @returns {Promise.<void>}
* @returns {Promise<Object>}
*/
export const characterDefendAction = async (actor) => {
const { defendArmor, defendDR, incomingAttack, targetToken } = await showDefendDialog({ actor });
Expand All @@ -24,4 +24,6 @@ export const characterDefendAction = async (actor) => {
items: [actor.equippedArmor, actor.equippedHat].filter((item) => item),
target: targetToken,
});

return outcome;
};
4 changes: 3 additions & 1 deletion module/api/action/character/character-get-better-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { outcome } from "../../outcome/outcome.js";

/**
* @param {PBActor} actor
* @returns {Promise.<void>}
* @returns {Promise<Object[]>}
*/
export const characterGetBetterAction = async (actor) => {
const outcomes = [
Expand All @@ -29,6 +29,8 @@ export const characterGetBetterAction = async (actor) => {
});

await invokeGettingBetterMacro(actor);

return outcomes;
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ export const characterInvokeExtraResourceAction = async (actor, item) => {
});

await characterUseItemAction(actor, item, outcome, chatMessage);

return outcome;
};
4 changes: 3 additions & 1 deletion module/api/action/character/character-invoke-relic-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { characterUseItemAction } from "./character-use-item-action.js";
/**
* @param {PBActor} actor
* @param {PBItem} item
* @returns {Promise.<void>}
* @returns {Promise<Object>}
*/
export const characterInvokeRelicAction = async (actor, item) => {
const outcome = await createInvokeRelicOutcome({ actor });
Expand All @@ -18,4 +18,6 @@ export const characterInvokeRelicAction = async (actor, item) => {
});

await characterUseItemAction(actor, item, outcome, chatMessage);

return outcome;
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { characterUseItemAction } from "./character-use-item-action.js";
/**
* @param {PBActor} actor
* @param {PBItem} item
* @returns {Promise.<void>}
* @returns {Promise<Object>}
*/
export const characterInvokeRitualAction = async (actor, item) => {
if (actor.rituals.value < 1) {
Expand All @@ -27,4 +27,6 @@ export const characterInvokeRitualAction = async (actor, item) => {
});

await characterUseItemAction(actor, item, outcome, chatMessage);

return outcome;
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { createLuckPerDayOutcome } from "../../outcome/character/luck-per-day-ou
* @param {PBActor} actor
* @param {Object} options
* @param {Boolean} options.silent
* @returns {Promise.<void>}
* @returns {Promise<Object>}
*/
export const characterLuckPerDayAction = async (actor, { silent = false } = {}) => {
const outcome = await createLuckPerDayOutcome({ actor });
Expand Down
3 changes: 3 additions & 0 deletions module/api/action/character/character-reload-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { createReloadingOutcome } from "../../outcome/character/reloading-outcom
/**
* @param {PBActor} actor
* @param {PBItem} item
* @returns {Promise<Object>}
*/
export const characterReloadAction = async (actor, item) => {
const reloadTime = item.reloadTime || 1;
Expand All @@ -27,4 +28,6 @@ export const characterReloadAction = async (actor, item) => {
}),
outcomes: [outcome],
});

return outcome;
};
4 changes: 2 additions & 2 deletions module/api/action/character/character-rest-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const canRest = (foodAndDrink, infected) => ![REST_FOOD_AND_DRINK.STARVE, REST_F
*/
const shortRest = async (actor, foodAndDrink, infected) => {
const isResting = canRest(foodAndDrink, infected);
await showGenericCard({
return showGenericCard({
actor,
title: game.i18n.localize("PB.Rest"),
description: !isResting ? game.i18n.localize("PB.NoEffect") : "",
Expand Down Expand Up @@ -92,7 +92,7 @@ const longRest = async (actor, foodAndDrink, infected) => {
outcomes.push(await characterLuckPerDayAction(actor, { silent: true }));
}

await showGenericCard({
return showGenericCard({
actor,
title: game.i18n.localize("PB.Rest"),
outcomes,
Expand Down
4 changes: 3 additions & 1 deletion module/api/action/creature/creature-morale-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createMoraleOutcome } from "../../outcome/creature/morale-outcome.js";

/**
* @param {PBActor} actor
* @returns {Promise.<void>}
* @returns {Promise<Object>}
*/
export const creatureMoraleAction = async (actor) => {
if (!actor.attributes.morale || actor.attributes.morale === "-") {
Expand All @@ -18,4 +18,6 @@ export const creatureMoraleAction = async (actor) => {
actor,
outcomes: [outcome],
});

return outcome;
};
4 changes: 3 additions & 1 deletion module/api/action/creature/creature-reaction-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createReactionOutcome } from "../../outcome/creature/reaction-outcome.j

/**
* @param {PBActor} actor
* @returns {Promise.<ChatMessage>}
* @returns {Promise<Object>}
*/
export const creatureReactionAction = async (actor) => {
const outcome = await createReactionOutcome();
Expand All @@ -13,4 +13,6 @@ export const creatureReactionAction = async (actor) => {
actor,
outcomes: [outcome],
});

return outcome;
};
2 changes: 1 addition & 1 deletion module/api/action/ship/ship-broadsides-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { showGenericCard } from "../../../chat-message/generic-card.js";
/**
* @param {PBActor} actor
* @param {Boolean} isPCAction
* @returns {Promise.<void>}
* @returns {Promise<Object>}
*/
export const shipBroadsidesAction = async (actor, isPCAction) => {
const { selectedActor, selectedDR, selectedArmor, targetToken } = await showCrewActionDialog({
Expand Down
2 changes: 1 addition & 1 deletion module/api/action/ship/ship-come-about-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { createComeAboutOutcome } from "../../outcome/ship/ship-come-about-outco
/**
* @param {PBActor} actor
* @param {Boolean} isPCAction
* @returns {Promise.<void>}
* @returns {Promise<Object>}
*/
export const shipComeAboutAction = async (actor, isPCAction) => {
const { selectedActor, selectedDR } = await showCrewActionDialog({
Expand Down
2 changes: 1 addition & 1 deletion module/api/action/ship/ship-full-sail-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { showGenericCard } from "../../../chat-message/generic-card.js";
/**
* @param {PBActor} actor
* @param {Boolean} isPCAction
* @returns {Promise.<void>}
* @returns {Promise<Object>}
*/
export const shipFullSailAction = async (actor, isPCAction) => {
const { selectedActor, selectedDR } = await showCrewActionDialog({
Expand Down
5 changes: 3 additions & 2 deletions module/api/action/ship/ship-invoke-shanty-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createInvokeShantyOutcome } from "../../outcome/ship/ship-invoke-shanty
/**
* @param {PBActor} actor
* @param {PBItem} item
* @returns {Promise.<void>}
* @returns {Promise<Object>}
*/
export const shipInvokeShantyAction = async (actor, item) => {
if (actor.shanties.value < 1) {
Expand All @@ -22,5 +22,6 @@ export const shipInvokeShantyAction = async (actor, item) => {
description: item.getData().description,
outcomes: [outcome],
});
// await this.useActionMacro(item.id);

return outcome;
};
2 changes: 1 addition & 1 deletion module/api/action/ship/ship-ram-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createRamOutcome } from "../../outcome/ship/ship-ram-outcome.js";

/**
* @param {PBActor} actor
* @returns {Promise.<void>}
* @returns {Promise<Object>}
*/
export const shipRamAction = async (actor) => {
const { selectedArmor, selectedMovement, targetToken } = await showCrewActionDialog({
Expand Down
2 changes: 1 addition & 1 deletion module/api/action/ship/ship-repair-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { showGenericCard } from "../../../chat-message/generic-card.js";
/**
* @param {PBActor} actor
* @param {Boolean} isPCAction
* @returns {Promise.<void>}
* @returns {Promise<Object>}
*/
export const shipRepairAction = async (actor, isPCAction) => {
const { selectedActor, selectedDR } = await showCrewActionDialog({
Expand Down
4 changes: 3 additions & 1 deletion module/api/action/ship/ship-shanties-per-day-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createShantiesPerDayOutcome } from "../../outcome/ship/ship-shanties-pe

/**
* @param {PBActor} actor
* @returns {Promise.<void>}
* @returns {Promise<Object>}
*/
export const shipShantiesPerDayAction = async (actor) => {
const captain = game.actors.get(actor.captain);
Expand All @@ -17,4 +17,6 @@ export const shipShantiesPerDayAction = async (actor) => {
title: game.i18n.localize("PB.ShipMysticShanties"),
outcomes: [outcome],
});

return outcome;
};
4 changes: 3 additions & 1 deletion module/api/action/ship/ship-sink-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createSinkingOutcome } from "../../outcome/ship/ship-sinking-outcome.js

/**
* @param {PBActor} actor
* @returns {Promise.<void>}
* @returns {Promise<Object>}
*/
export const shipSinkAction = async (actor) => {
const outcome = await createSinkingOutcome({ actor });
Expand All @@ -14,4 +14,6 @@ export const shipSinkAction = async (actor) => {
actor,
outcomes: [outcome],
});

return outcome;
};
4 changes: 3 additions & 1 deletion module/api/action/ship/ship-small-arms-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { showGenericCard } from "../../../chat-message/generic-card.js";
/**
* @param {PBActor} actor
* @param {Boolean} isPCAction
* @returns {Promise.<void>}
* @returns {Promise<Object>}
*/
export const shipSmallArmsAction = async (actor, isPCAction) => {
const { selectedActor, selectedDR, selectedArmor, targetToken } = await showCrewActionDialog({
Expand Down Expand Up @@ -33,4 +33,6 @@ export const shipSmallArmsAction = async (actor, isPCAction) => {
outcomes: [outcome],
target: targetToken,
});

return outcome;
};
Loading

0 comments on commit 6721bd6

Please sign in to comment.