diff --git a/.github/workflows/build-test-publish.yml b/.github/workflows/build-test-publish.yml index 07d089794..1d7eb3a07 100644 --- a/.github/workflows/build-test-publish.yml +++ b/.github/workflows/build-test-publish.yml @@ -93,6 +93,10 @@ jobs: run: | /opt/python/$PYBIN/bin/pip install poetry cmake conan==1.59.0 + # Install Ninja + - name: Install Ninja + run: yum install -y ninja-build + # Configure conan for release build - name: Build run: | @@ -112,6 +116,7 @@ jobs: - name: Poetry install run: | cd python + /opt/python/$PYBIN/bin/poetry lock /opt/python/$PYBIN/bin/poetry install # Run python tests @@ -152,7 +157,7 @@ jobs: id: py with: python-version: ${{ matrix.windows_config.python-version }} - + # Setup MSVC - name: Setup MSVC uses: ilammy/msvc-dev-cmd@v1 @@ -178,6 +183,7 @@ jobs: - name: Poetry install run: | cd python + poetry lock poetry install # Run python tests @@ -240,6 +246,7 @@ jobs: - name: Poetry install run: | cd python + poetry lock poetry install # Run python tests diff --git a/build_release.sh b/build_release.sh new file mode 100755 index 000000000..1e65ecafd --- /dev/null +++ b/build_release.sh @@ -0,0 +1,11 @@ +./configure.sh + +conan install deps/conanfile.txt --profile default \ + --profile deps/build.profile \ + -s build_type=Release --build missing -if build + +cmake . -B build -GNinja -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake + +cmake --build build --config Release + diff --git a/deps/build.profile b/deps/build.profile index 11b07fd08..06f9be69b 100644 --- a/deps/build.profile +++ b/deps/build.profile @@ -2,4 +2,4 @@ ninja/1.11.1 [conf] -tools.cmake.cmaketoolchain:generator=Ninja \ No newline at end of file +tools.cmake.cmaketoolchain:generator=Ninja diff --git a/js/griddlyjs-app/package-lock.json b/js/griddlyjs-app/package-lock.json index 23a1994d9..17f4b4a07 100644 --- a/js/griddlyjs-app/package-lock.json +++ b/js/griddlyjs-app/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "griddlyjs-app", - "version": "1.6.3", + "version": "1.6.7", "dependencies": { "@fortawesome/fontawesome-svg-core": "^6.1.1", "@fortawesome/free-brands-svg-icons": "^6.1.1", diff --git a/js/griddlyjs-app/src/renderer/Sprite2DRenderer.js b/js/griddlyjs-app/src/renderer/Sprite2DRenderer.js index 16333e75c..a97168cf8 100644 --- a/js/griddlyjs-app/src/renderer/Sprite2DRenderer.js +++ b/js/griddlyjs-app/src/renderer/Sprite2DRenderer.js @@ -123,7 +123,7 @@ class Sprite2DRenderer extends RendererBase { sprite.setDisplaySize( this.renderConfig.TileSize, - this.renderConfig.TileSize + this.renderConfig.TileSize ); } @@ -141,7 +141,12 @@ class Sprite2DRenderer extends RendererBase { if (!sprite) { return; } - const objectTemplate = this.objectTemplates[objectTemplateName]; + var objectTemplate = this.objectTemplates[objectTemplateName]; + if (!objectTemplate) { + // pick the first one + objectTemplate = this.objectTemplates[Object.keys(this.objectTemplates)[0]]; + } + sprite.setPosition(this.getCenteredX(x), this.getCenteredY(y)); sprite.setTexture(this.getTilingImage(objectTemplate, x, y)); @@ -228,6 +233,10 @@ class Sprite2DRenderer extends RendererBase { }; getTilingImage = (objectTemplate, x, y) => { + if (objectTemplate === undefined) { + console.log("Undefined object template"); + }; + if (objectTemplate.tilingMode === "WALL_16") { const objectLeft = this.tileLocations.get( this.getObjectLocationKey(x - 1, y) diff --git a/js/griddlyjs-app/src/renderer/level_player/scenes/HumanPlayerScene.js b/js/griddlyjs-app/src/renderer/level_player/scenes/HumanPlayerScene.js index 050f6cde0..6189df36d 100644 --- a/js/griddlyjs-app/src/renderer/level_player/scenes/HumanPlayerScene.js +++ b/js/griddlyjs-app/src/renderer/level_player/scenes/HumanPlayerScene.js @@ -454,12 +454,57 @@ class HumanPlayerScene extends Phaser.Scene { this.keyMap = new Map(); + const mapKeyToAction = (key, actionName, actionTypeId, actionId, mapping) => { + const mappedKey = this.input.keyboard.addKey(key, false); + mappedKey.on("down", this.processUserKeydown); + mappedKey.on("up", this.processUserKeyup); + + this.keyMap.set(key, { + actionName, + actionTypeId, + actionId, + description: mapping.description, + }); + }; + + const presetActionKeys = { + "move": [ Phaser.Input.Keyboard.KeyCodes.E, Phaser.Input.Keyboard.KeyCodes.R ], + "rotate": [ Phaser.Input.Keyboard.KeyCodes.S, Phaser.Input.Keyboard.KeyCodes.A, + Phaser.Input.Keyboard.KeyCodes.D, Phaser.Input.Keyboard.KeyCodes.W ], + "pickup": [ Phaser.Input.Keyboard.KeyCodes.Y ], + "use": [ Phaser.Input.Keyboard.KeyCodes.U ], + "shield": [ Phaser.Input.Keyboard.KeyCodes.O ], + "prestige": [ Phaser.Input.Keyboard.KeyCodes.PLUS ], + "attack": [ Phaser.Input.Keyboard.KeyCodes.NUMPAD_ONE, + Phaser.Input.Keyboard.KeyCodes.NUMPAD_TWO, + Phaser.Input.Keyboard.KeyCodes.NUMPAD_THREE, + Phaser.Input.Keyboard.KeyCodes.NUMPAD_FOUR, + Phaser.Input.Keyboard.KeyCodes.NUMPAD_FIVE, + Phaser.Input.Keyboard.KeyCodes.NUMPAD_SIX, + Phaser.Input.Keyboard.KeyCodes.NUMPAD_SEVEN, + Phaser.Input.Keyboard.KeyCodes.NUMPAD_EIGHT, + Phaser.Input.Keyboard.KeyCodes.NUMPAD_NINE, + ] + }; + actionNames.forEach((actionName, actionTypeId) => { const actionMapping = actionInputMappings[actionName]; if (!actionMapping.internal) { const inputMappings = Object.entries(actionMapping.inputMappings); console.log(inputMappings); + // If the action is one of the preset actions, use the preset keys + if (actionName in presetActionKeys) { + const keys = presetActionKeys[actionName]; + inputMappings.forEach((inputMapping) => { + const actionId = Number(inputMapping[0]); + const key = keys[actionId - 1]; + const mapping = inputMapping[1]; + mapKeyToAction(key, actionName, actionTypeId, actionId, mapping); + }); + return; + } + const actionDirections = new Set(); inputMappings.forEach((inputMapping) => { // check that all the vectorToDest are different @@ -485,36 +530,16 @@ class HumanPlayerScene extends Phaser.Scene { key = movementKeys[this.toMovementKey(mapping.orientationVector)]; } - const mappedKey = this.input.keyboard.addKey(key, false); - mappedKey.on("down", this.processUserKeydown); - mappedKey.on("up", this.processUserKeyup); - - this.keyMap.set(key, { - actionName, - actionTypeId, - actionId, - description: mapping.description, - }); + mapKeyToAction(key, actionName, actionTypeId, actionId, mapping); }); } else { // We have an action Key - inputMappings.forEach((inputMapping) => { const key = actionKeyOrder.pop(); const actionId = Number(inputMapping[0]); const mapping = inputMapping[1]; - - const mappedKey = this.input.keyboard.addKey(key, false); - mappedKey.on("down", this.processUserKeydown); - mappedKey.on("up", this.processUserKeyup); - - this.keyMap.set(key, { - actionName, - actionTypeId, - actionId, - description: mapping.description, - }); + mapKeyToAction(key, actionName, actionTypeId, actionId, mapping); }); } } diff --git a/resources/games/RTS/Stratega/heal-or-die.yaml b/resources/games/RTS/Stratega/heal-or-die.yaml index ede044a43..96e63f45c 100644 --- a/resources/games/RTS/Stratega/heal-or-die.yaml +++ b/resources/games/RTS/Stratega/heal-or-die.yaml @@ -2,8 +2,8 @@ Version: "0.1" Environment: Name: Heal Or Die Description: | - Game environment ported from https://github.com/GAIGResearch/Stratega. - You have units that heal and units that perform close combat. + Game environment ported from https://github.com/GAIGResearch/Stratega. + You have units that heal and units that perform close combat. Additionally, on every turn, the health of your units decreases. Win the game by killing your opponents pieces first. Observers: Sprite2D: diff --git a/src/Griddly/Core/Grid.cpp b/src/Griddly/Core/Grid.cpp index c15b26fde..427dcce56 100644 --- a/src/Griddly/Core/Grid.cpp +++ b/src/Griddly/Core/Grid.cpp @@ -497,6 +497,10 @@ void Grid::initObject(std::string objectName, std::vector variableN objectCounters_.insert({objectName, {{0, std::make_shared(0)}}}); for (auto& variableName : variableNames) { + objectVariables_.insert(variableName); + } + objectVariableMap_.clear(); + for (auto& variableName : objectVariables_) { objectVariableIds_.insert({variableName, objectVariableIds_.size()}); } @@ -739,4 +743,4 @@ const std::unordered_map>& Grid::ge return collisionObjectActionNames_; } -} // namespace griddly \ No newline at end of file +} // namespace griddly diff --git a/src/Griddly/Core/Grid.hpp b/src/Griddly/Core/Grid.hpp index c3ad8b3f2..21b996e21 100644 --- a/src/Griddly/Core/Grid.hpp +++ b/src/Griddly/Core/Grid.hpp @@ -110,7 +110,7 @@ class Grid : public std::enable_shared_from_this { virtual const std::unordered_set>& getObjects(); virtual void addPlayerDefaultEmptyObject(std::shared_ptr emptyObject); - + virtual void addPlayerDefaultBoundaryObject(std::shared_ptr boundaryObject); virtual std::shared_ptr getPlayerDefaultEmptyObject(uint32_t playerId) const; @@ -199,6 +199,7 @@ class Grid : public std::enable_shared_from_this { std::vector> updatedLocations_; std::unordered_map objectIds_; + std::set objectVariables_; std::unordered_map objectVariableIds_; std::unordered_map> objectVariableMap_; std::unordered_set> objects_; @@ -248,4 +249,4 @@ class Grid : public std::enable_shared_from_this { std::shared_ptr randomGenerator_ = std::make_shared(RandomGenerator()); }; -} // namespace griddly \ No newline at end of file +} // namespace griddly