Skip to content

Commit

Permalink
Feat/flat modifiers to attacks 135 (#189)
Browse files Browse the repository at this point in the history
* chore(github actions): add release and pre-release pipelines (#182)

* feat(attack roll mods): Added an input for arbitrary modifiers to attack rolls via a formula string.

* feat(attack roll mods): added ability to include a temporary mod formula within the roll configuration dialog.
Applied all changes for both global and temp modifiers to attack rolls and general skill rolls.
Also fixed global modifiers for non-attack rolls

* feat(attack roll mods): allowed roll config dialog to support None attribute (attacks only atm, also possibly inelegant)

* feat(skill roll mods): extended "None" attribute support to all skill rolls.
Extracted "None" logic into shared code.

* chore: updated missed none check

* feat(skill roll mods): Updated logic to not short-circuit when no skill was selected (no-skill rolls are now possible).
Switched from "none" to null in the code for ease.
Refactored some common code into generic functions.

* feat(skill roll mods): reverted enum changes

* chore: tidy up formula output

* chore: removed redundant isNull function

---------

Co-authored-by: stanavdb <[email protected]>
  • Loading branch information
zithith and stanavdb authored Jan 23, 2025
1 parent c54358d commit 29f36db
Show file tree
Hide file tree
Showing 18 changed files with 503 additions and 97 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: prerelease
run-name: Create prerelease
on:
push:
branches:
- 'release-*'

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

# Load the manifest into memory
- name: Load system manifest
id: manifest
uses: zoexx/github-action-json-file-properties@release
with:
file_path: "./src/system.json"

# Set up variables
- name: Set up vars
run: |
BRANCH=${{github.ref_name}}
RELEASE_VERSION=$(echo ${{github.ref_name}} | cut -d'-' -f2)
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
echo "ZIP_NAME=cosmere-rpg-prerelease-$RELEASE_VERSION.zip" >> $GITHUB_ENV
echo "DOWNLOAD_URL=https://github.com/${{github.repository}}/releases/download/prerelease-$RELEASE_VERSION/cosmere-rpg-prerelease-$RELEASE_VERSION.zip" >> $GITHUB_ENV
echo "MANIFEST_URL=https://github.com/${{github.repository}}/releases/download/prerelease-$RELEASE_VERSION/system.json" >> $GITHUB_ENV
# Verify manifest
- name: Verify manifest
run: |
# Verify that the manifest version matches the branch
if [[ ! "${{env.RELEASE_VERSION}}" == $PACKAGE_VERSION ]]; then
echo "Manifest version does not match tag brach."
echo "Manifest version: $PACKAGE_VERSION"
echo "Branch: ${{env.RELEASE_VERSION}}"
echo "Please update the manifest version to match the branch."
exit 1
fi
env:
PACKAGE_VERSION: ${{ steps.manifest.outputs.version }}

# Update manifest
- name: Update manifest
uses: TomaszKandula/[email protected]
with:
files: "./src/system.json"
env:
version: "prerelease-${{ env.RELEASE_VERSION }}"
manifest: ${{ env.MANIFEST_URL }}
download: ${{ env.DOWNLOAD_URL }}

# Set up node
- name: Use Node 20
uses: actions/setup-node@v4
with:
node-version: '20'

# Install dependencies
- name: NPM install
run: |
npm ci
# Build
- name: Build release
run: |
npm run build:release
# Create release
- name: Create release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: "Pre-release ${{ env.RELEASE_VERSION }}"
tag: prerelease-${{ env.RELEASE_VERSION }}
artifacts: "./src/system.json, ./${{ env.ZIP_NAME }}"
draft: false
prerelease: true
allowUpdates: true
body: |
Pre-release build of ${{ env.RELEASE_VERSION }}.
This build is automatically generated from the latest changes targeting the ${{ env.RELEASE_VERSION }} release.
⚠️ **This is a pre-release build and may contain bugs or incomplete features.** ⚠️
**Manifest url:** ${{ env.MANIFEST_URL }}
123 changes: 123 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: release
run-name: Create release
on:
push:
tags:
- 'release-*'

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

# Load the manifest into memory
- name: Load system manifest
id: manifest
uses: zoexx/github-action-json-file-properties@release
with:
file_path: "./src/system.json"

# Set up variables
- name: Set up vars
run: |
TAG=${{github.ref_name}}
echo "ZIP_NAME=cosmere-rpg-$TAG.zip" >> $GITHUB_ENV
echo "DOWNLOAD_URL=https://github.com/${{github.repository}}/releases/download/$TAG/cosmere-rpg-$TAG.zip" >> $GITHUB_ENV
# Verify manifest
- name: Verify manifest
run: |
# Verify that the manifest version matches the tag
if [[ ! "${{github.ref_name}}" == release-$PACKAGE_VERSION ]]; then
echo "Manifest version does not match tag name."
echo "Manifest version: $PACKAGE_VERSION"
echo "Tag name: $TAG"
echo "Please update the manifest version to match the tag name."
exit 1
fi
# Verify that the download URL matches the release asset
if [[ ! "${{ env.DOWNLOAD_URL }}" == $PACKAGE_DOWNLOAD ]]; then
echo "Download URL does not match release asset."
echo "Download URL: $DOWNLOAD_URL"
echo "Release asset: $PACKAGE_DOWNLOAD"
echo "Please update the manifest download URL to match the release asset."
exit 1
fi
env:
PACKAGE_VERSION: ${{ steps.manifest.outputs.version }}
PACKAGE_DOWNLOAD: ${{ steps.manifest.outputs.download }}

# Set up node
- name: Use Node 20
uses: actions/setup-node@v4
with:
node-version: '20'

# Install dependencies
- name: NPM install
run: |
npm ci
# Build
- name: Build release
run: |
npm run build:release
# Fetch latest release
- name: Fetch latest release
id: latest_release
uses: cardinalby/git-get-release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
latest: true
doNotFailIfNotFound: true

# Determine whether this is a patch or a major/minor release
- name: Determine release type
id: release_type
run: |
if [[ -z "${{ steps.latest_release.outputs.tag_name }}" ]]; then
echo "RELEASE_TYPE=major-minor" >> $GITHUB_ENV
echo "RELEASE_NOTES=./src/release-notes.md" >> $GITHUB_ENV
echo "No previous releases found. Release is a major or minor release."
else
# Get the current version info
CURRENT_VERSION=$(echo ${{github.ref_name}} | cut -d'-' -f2)
CURRENT_VERSION_MAJOR=$(echo $CURRENT_VERSION | cut -d'.' -f1)
CURRENT_VERSION_MINOR=$(echo $CURRENT_VERSION | cut -d'.' -f2)
CURRENT_VERSION_PATCH=$(echo $CURRENT_VERSION | cut -d'.' -f3)
# Get the latest version info
LATEST_VERSION=$(echo ${{steps.latest_release.outputs.tag_name}} | cut -d'-' -f2)
LATEST_VERSION_MAJOR=$(echo $LATEST_VERSION | cut -d'.' -f1)
LATEST_VERSION_MINOR=$(echo $LATEST_VERSION | cut -d'.' -f2)
LATEST_VERSION_PATCH=$(echo $LATEST_VERSION | cut -d'.' -f3)
# Determine the release type
if [[ $CURRENT_VERSION_MAJOR -gt $LATEST_VERSION_MAJOR ]] || [[ $CURRENT_VERSION_MINOR -gt $LATEST_VERSION_MINOR ]]; then
echo "RELEASE_TYPE=major-minor" >> $GITHUB_ENV
echo "RELEASE_NOTES=./src/release-notes.md" >> $GITHUB_ENV
echo "Release is a major or minor release."
else
echo "RELEASE_TYPE=patch" >> $GITHUB_ENV
echo "RELEASE_NOTES=./src/patch-notes.md" >> $GITHUB_ENV
echo "Release is a patch release."
fi
fi
# Create release
- name: Create release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${{ github.ref_name }}
tag: ${{ github.ref_name }}
bodyFile: ${{ env.RELEASE_NOTES }}
artifacts: "./${{ env.ZIP_NAME }}"
draft: true
8 changes: 6 additions & 2 deletions src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,9 @@
"Cost": "Activation Cost",
"Consume": "Resource Consumption",
"Uses": "Limited Uses",
"Recharge": "Recharge"
"Recharge": "Recharge",
"AdditionalFormula": "Roll Formula Extension",
"AdditionalFormulaDescription": "Input any extra modifiers you wish to add to this item's d20 Skill Roll. This input will be treated as a dice formula, but any die you add won't be available for advantage/disadvantage currently. Paramters you can use: @mod, @attribute & @skill.rank refer to the values of the skills selected here, but the whole list of skills and attributes can be accessed - ask on the discord for help!"
},
"Attack": {
"Title": "Attack",
Expand Down Expand Up @@ -904,7 +906,8 @@
"Apply": "Apply",
"Graze": "Graze",
"Full": "Full"
}
},
"TemporaryBonus": "Temporary Modifiers (formula)"
},
"ROLLS": {
"Recovery": "[character] rolls their recovery die.",
Expand Down Expand Up @@ -1007,6 +1010,7 @@
"GENERIC": {
"Unknown": "Unknown",
"None": "None",
"Custom": "Custom",
"Default": "Default",
"Document": "Document",
"Formula": "Formula",
Expand Down
Loading

0 comments on commit 29f36db

Please sign in to comment.