add segments to round class

This commit is contained in:
James 2024-04-21 11:36:53 +01:00
parent 06b61bdcbb
commit f95a1e9260
2 changed files with 15 additions and 7 deletions

View file

@ -29,7 +29,7 @@ public class Game extends ApplicationAdapter {
private double tickProgress = 0; private double tickProgress = 0;
private RoundData roundData; private Round round;
private UI ui; private UI ui;
@Override @Override
@ -40,7 +40,7 @@ public class Game extends ApplicationAdapter {
img = new Texture("badlogic.jpg"); img = new Texture("badlogic.jpg");
ui = new UI(50, 280, 10); ui = new UI(50, 280, 10);
roundData = new RoundData(10); round = new Round(10);
Face.setBlankFaceSprite(new Texture("blank_die_face.png")); Face.setBlankFaceSprite(new Texture("blank_die_face.png"));
Face.setPipSprite(new Texture("pip.png")); Face.setPipSprite(new Texture("pip.png"));
@ -66,15 +66,15 @@ public class Game extends ApplicationAdapter {
public void tick() { public void tick() {
processInput(); processInput();
ui.setRemainingRerolls(roundData.getRerolls()); ui.setRemainingRerolls(round.getRerolls());
} }
public void processInput() { public void processInput() {
Input input = Gdx.input; Input input = Gdx.input;
if (input.isKeyJustPressed(Input.Keys.R) && roundData.getRerolls() > 0) { //reroll dice that aren't locked if (input.isKeyJustPressed(Input.Keys.R) && round.getRerolls() > 0) { //reroll dice that aren't locked
dice.stream().filter(d -> !d.isSelected()).forEach(Die::roll); dice.stream().filter(d -> !d.isSelected()).forEach(Die::roll);
roundData.reduceRerolls(1); round.reduceRerolls(1);
} }
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

View file

@ -1,10 +1,17 @@
package com.monjaro.gamejam.main; package com.monjaro.gamejam.main;
public class RoundData { import com.monjaro.gamejam.segment.Segment;
import java.util.List;
public class Round {
private final List<Segment> segments;
private int rerolls; private int rerolls;
public RoundData(int rerolls){ public Round(List<Segment> segments, int rerolls){
this.rerolls = rerolls; this.rerolls = rerolls;
this.segments = segments;
} }
public int getRerolls() { public int getRerolls() {
@ -18,4 +25,5 @@ public class RoundData {
public void reduceRerolls(int i) { public void reduceRerolls(int i) {
rerolls -= i; rerolls -= i;
} }
} }