move check for locked dice when rerolling

This commit is contained in:
James 2024-04-20 16:59:47 +01:00
parent d98d9ece8b
commit b34b175acd
2 changed files with 3 additions and 5 deletions

View file

@ -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

View file

@ -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