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,10 +52,8 @@ public class Die extends Actor {
} }
public void roll() { 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 public void decay() { //remove a pip from all faces of this die
for (Face face : faces) { for (Face face : faces) {

View file

@ -46,8 +46,8 @@ public class Game extends ApplicationAdapter {
public void processInput() { public void processInput() {
Input input = Gdx.input; Input input = Gdx.input;
if (input.isKeyJustPressed(Input.Keys.R)) { //reroll dice if (input.isKeyJustPressed(Input.Keys.R)) { //reroll dice that aren't locked
dice.forEach(Die::roll); dice.stream().filter(d -> !d.isLocked()).forEach(Die::roll);
} }
for (int i = 0; i < dice.size(); i++) { //lock dice, iterating over for each keycode for (int i = 0; i < dice.size(); i++) { //lock dice, iterating over for each keycode