From b34b175acde71c2e2eec0509c403aa775e5e0952 Mon Sep 17 00:00:00 2001 From: James <150948866+jameslaight@users.noreply.github.com> Date: Sat, 20 Apr 2024 16:59:47 +0100 Subject: [PATCH] move check for locked dice when rerolling --- core/src/com/monjaro/gamejam/Die.java | 4 +--- core/src/com/monjaro/gamejam/Game.java | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/core/src/com/monjaro/gamejam/Die.java b/core/src/com/monjaro/gamejam/Die.java index b73e40a..18ebcea 100644 --- a/core/src/com/monjaro/gamejam/Die.java +++ b/core/src/com/monjaro/gamejam/Die.java @@ -52,9 +52,7 @@ public class Die extends Actor { } public void roll() { - if (!locked) { - faceIndex = random.nextInt(6); - } + faceIndex = random.nextInt(6); } public void decay() { //remove a pip from all faces of this die diff --git a/core/src/com/monjaro/gamejam/Game.java b/core/src/com/monjaro/gamejam/Game.java index f457a32..9be2d61 100644 --- a/core/src/com/monjaro/gamejam/Game.java +++ b/core/src/com/monjaro/gamejam/Game.java @@ -46,8 +46,8 @@ public class Game extends ApplicationAdapter { public void processInput() { Input input = Gdx.input; - if (input.isKeyJustPressed(Input.Keys.R)) { //reroll dice - dice.forEach(Die::roll); + if (input.isKeyJustPressed(Input.Keys.R)) { //reroll dice that aren't locked + dice.stream().filter(d -> !d.isLocked()).forEach(Die::roll); } for (int i = 0; i < dice.size(); i++) { //lock dice, iterating over for each keycode