Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
KSneijders committed May 25, 2024
2 parents e1bb5b6 + 1686e00 commit b619b94
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 18 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Update Versions for publishing
run: |
TAG=$(echo $GITHUB_REF_NAME | sed 's|v||')
sed -i 's|<VERSION_HERE>|'${TAG}'|' $GITHUB_WORKSPACE/pyproject.toml
sed -i 's|<VERSION_HERE>|'${TAG}'|' $GITHUB_WORKSPACE/AoE2ScenarioRms/version.py
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.8"

- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
Expand All @@ -29,11 +38,13 @@ jobs:
--wheel
--outdir dist/
.
- name: Publish AoE2ScenarioRms 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/

- name: Publish AoE2ScenarioRms 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
15 changes: 3 additions & 12 deletions AoE2ScenarioRms/core/aoe2_scenario_rms.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,11 @@ def _verify_no_debug(self) -> None:
)

def _register_scenario_write_to_file_event(self) -> None:
"""
Overwrites the ``write_to_file`` function of the scenario to add custom functionality like adding the necessary
XS scripts to the scenario.
"""
original_write_to_file = self.scenario.write_to_file

def write_to_file_wrapper(filename: str, skip_reconstruction: bool = False):
@self.scenario.on_write
def func(scenario: AoE2DEScenario):
variable_count = str(len(self.xs_container.get(XsKey.RESOURCE_VARIABLE_DECLARATION)))
self.xs_container.append(XsKey.RESOURCE_VARIABLE_COUNT, variable_count)

xs_string = self.xs_container.resolve(XsUtil.file('main.xs'))
self.scenario.xs_manager.add_script(xs_string=xs_string)

original_write_to_file(filename, skip_reconstruction)

self.scenario.write_to_file = write_to_file_wrapper
self._debug_all_visible_enabled = True
scenario.xs_manager.add_script(xs_string=xs_string)
2 changes: 1 addition & 1 deletion AoE2ScenarioRms/util/locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def create_groups(config: 'CreateObjectConfig', grid_map: 'GridMap') -> List[Lis
if amount * 2 > len(available_tiles):
warn(f"For group '{name}', the amount of groups requested is really high. "
f"({amount} groups compared to {len(available_tiles)} available tiles).\n"
f"Consider lowering the max amount of necessary groups for '{name}'.", SpawnFailureWarning)
f"Consider lowering the max amount of necessary groups for '{name}'.", SpawnFailureWarning, 3)

# starting_tiles = self.find_random_locations(amount)
starting_tiles = available_tiles[:amount]
Expand Down
2 changes: 1 addition & 1 deletion AoE2ScenarioRms/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Expose version """

__version__ = "0.2.19" # << Also change `/pyproject.toml`
__version__ = "<VERSION_HERE>"
VERSION = __version__.split(".")
2 changes: 1 addition & 1 deletion AoE2ScenarioRms/xs/random.xs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void ShuffleVectorArray(int arr = -1, int indexArr = -1) {

int n = xsArrayGetSize(arr);
for (i = 0; < n) {
int j = GetRandomRange(0, n);
int j = GetRandomRange(0, n - 1);
Vector v = xsArrayGetVector(arr, j);
int index = xsArrayGetInt(indexArr, j);
xsArraySetVector(arr, j, xsArrayGetVector(arr, i));
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

---

## 0.2.20 - 2024-May-25

### Fixed

- The `xs` `ShuffleVectorArray` function

---

## 0.2.19 - 2024-Januari-04

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "AoE2ScenarioRms"
version = "0.2.19" # << Also change `AoE2ScenarioRms/version.py`
version = "<VERSION_HERE>"
authors = [
{ name = "Kerwin Sneijders", email = "[email protected]" },
]
Expand All @@ -12,7 +12,7 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
dependencies = ["AoE2ScenarioParser>=0.1.60"]
dependencies = ["AoE2ScenarioParser>=0.1.68"]

[project.urls]
"Homepage" = "https://github.com/KSneijders/AoE2ScenarioRms"
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
AoE2ScenarioParser~=0.1.60
AoE2ScenarioParser~=0.1.68
PyTest~=7.2.1

0 comments on commit b619b94

Please sign in to comment.