merge conflict vanished
This commit is contained in:
commit
bd02582186
8 changed files with 142 additions and 60 deletions
15
core/src/com/monjaro/gamejam/main/Decay.java
Normal file
15
core/src/com/monjaro/gamejam/main/Decay.java
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
package com.monjaro.gamejam.main;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public abstract class Decay {
|
||||||
|
|
||||||
|
protected String description;
|
||||||
|
|
||||||
|
public abstract List<Die> getDecayed(List<Die> dice);
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -61,7 +61,8 @@ public class Die extends Actor {
|
||||||
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) {
|
||||||
List<Face.Pip> pips = face.getPips();
|
List<Face.Pip> pips = face.getPips();
|
||||||
Face.Pip decayed = pips.get(random.nextInt());
|
if (pips.isEmpty()) continue;
|
||||||
|
Face.Pip decayed = pips.get(random.nextInt(pips.size()));
|
||||||
face.removePip(decayed);
|
face.removePip(decayed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import com.badlogic.gdx.Input;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
|
||||||
import com.badlogic.gdx.utils.ScreenUtils;
|
import com.badlogic.gdx.utils.ScreenUtils;
|
||||||
import com.monjaro.gamejam.SegmentUI;
|
import com.monjaro.gamejam.SegmentUI;
|
||||||
import com.monjaro.gamejam.segment.DualSegment;
|
import com.monjaro.gamejam.segment.DualSegment;
|
||||||
|
@ -20,7 +19,6 @@ import java.util.List;
|
||||||
public class Game extends ApplicationAdapter {
|
public class Game extends ApplicationAdapter {
|
||||||
|
|
||||||
private final List<Die> dice = new ArrayList<>();
|
private final List<Die> dice = new ArrayList<>();
|
||||||
private final List<Segment> segments = new ArrayList<>();
|
|
||||||
|
|
||||||
private SpriteBatch batch;
|
private SpriteBatch batch;
|
||||||
private BitmapFont font;
|
private BitmapFont font;
|
||||||
|
@ -29,8 +27,7 @@ public class Game extends ApplicationAdapter {
|
||||||
private final static int TICKS_PER_SECOND = 60;
|
private final static int TICKS_PER_SECOND = 60;
|
||||||
private double tickProgress = 0;
|
private double tickProgress = 0;
|
||||||
|
|
||||||
|
private Round round;
|
||||||
private RoundData roundData;
|
|
||||||
private UI ui;
|
private UI ui;
|
||||||
private SegmentUI segUi;
|
private SegmentUI segUi;
|
||||||
|
|
||||||
|
@ -41,55 +38,67 @@ public class Game extends ApplicationAdapter {
|
||||||
font.getData().markupEnabled = true;
|
font.getData().markupEnabled = true;
|
||||||
img = new Texture("badlogic.jpg");
|
img = new Texture("badlogic.jpg");
|
||||||
|
|
||||||
ui = new UI(50, 280, 10);
|
|
||||||
roundData = new RoundData(10);
|
|
||||||
segUi = new SegmentUI();
|
segUi = new SegmentUI();
|
||||||
|
|
||||||
|
ui = new UI(this, 50, 280);
|
||||||
|
round = new Round(List.of(new OlympicSegment(1), new OlympicSegment(3), new KinSegment(3), new DualSegment(false)), List.of(new ParityDecay(true)), 5);
|
||||||
|
|
||||||
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"));
|
||||||
Die.setLockedSprite(new Texture("locked_die_border.png"));
|
Die.setLockedSprite(new Texture("locked_die_border.png"));
|
||||||
UI.setRerollTexture(new Texture("reroll_symbol.png"));
|
UI.setRerollTexture(new Texture("reroll_symbol.png"));
|
||||||
|
|
||||||
Vector2 dieSize = new Vector2();
|
|
||||||
float divide = Gdx.graphics.getWidth() / 6f;
|
float divide = Gdx.graphics.getWidth() / 6f;
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
dice.add(new Die(divide * (i + 1), 350, 64, 64));
|
dice.add(new Die(divide * (i + 1), 350, 64, 64));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 1; i <= 5; i++) {
|
|
||||||
segments.add(new KinSegment(i));
|
|
||||||
}
|
|
||||||
for (int i = 2; i <= 5; i++) {
|
|
||||||
segments.add(new OlympicSegment(i));
|
|
||||||
}
|
|
||||||
segments.add(new DualSegment(false));
|
|
||||||
segments.add(new DualSegment(true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tick() {
|
public void tick() {
|
||||||
processInput();
|
processInput();
|
||||||
|
|
||||||
ui.setRemainingRerolls(roundData.getRerolls());
|
ui.setRerolls(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);
|
reroll();
|
||||||
roundData.reduceRerolls(1);
|
round.reduceRerolls(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < dice.size(); i++) { //lock dice, iterating over for each keycode
|
if (input.isKeyPressed(Input.Keys.SHIFT_LEFT)) {
|
||||||
Die die = dice.get(i); //die iterator is looking at
|
for (int i = 0; i < round.getSegments().size(); i++) {
|
||||||
int keyCode = Input.Keys.NUM_1 + i; //keycode for the current die, 1, 2...9, 0 on keyboard
|
int keyCode = Input.Keys.NUM_1 + i; //keycode for the current segment, shift + 1, 2...9, 0 on keyboard
|
||||||
|
|
||||||
if (input.isKeyJustPressed(keyCode)) { //if key corresponding to die has been pressed
|
if (input.isKeyJustPressed(keyCode)) {
|
||||||
die.setSelected(!die.isSelected()); //flip lock state
|
Segment segment = round.getSegments().get(i);
|
||||||
|
|
||||||
|
if (segment.isDestroyedBy(getSelectedDice())) { //if can be destroyed with selected
|
||||||
|
segment.destroy();
|
||||||
|
round.getDecays().forEach(d -> d.getDecayed(getSelectedDice()).forEach(Die::decay)); //apply all decay rules
|
||||||
|
dice.forEach(d -> d.setSelected(false));
|
||||||
|
// reroll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < dice.size(); i++) { //lock dice, iterating over for each keycode
|
||||||
|
int keyCode = Input.Keys.NUM_1 + i; //keycode for the current die, 1, 2...9, 0 on keyboard
|
||||||
|
|
||||||
|
if (input.isKeyJustPressed(keyCode)) { //if key corresponding to die has been pressed
|
||||||
|
Die die = dice.get(i); //die iterator is looking at
|
||||||
|
die.setSelected(!die.isSelected()); //flip lock state
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reroll() {
|
||||||
|
dice.stream().filter(d -> !d.isSelected()).forEach(Die::roll);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render() {
|
public void render() {
|
||||||
tickProgress += Gdx.graphics.getDeltaTime() * TICKS_PER_SECOND;
|
tickProgress += Gdx.graphics.getDeltaTime() * TICKS_PER_SECOND;
|
||||||
|
@ -107,13 +116,17 @@ public class Game extends ApplicationAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
int y = Gdx.graphics.getHeight() - 50;
|
int y = Gdx.graphics.getHeight() - 50;
|
||||||
for (Segment segment : segments) {
|
for (Segment segment : round.getSegments()) {
|
||||||
String prefix = "[#9E65A8]";
|
String prefix = "[#9E65A8]";
|
||||||
if (segment.isDestroyed()) prefix = "[#EBE5EC]";
|
if (segment.isDestroyed()) prefix = "[#EBE5EC]";
|
||||||
else if (segment.isDestroyedBy(getSelectedDice())) prefix = "[#528154]";
|
else if (segment.isDestroyedBy(getSelectedDice())) prefix = "[#528154]";
|
||||||
|
|
||||||
font.draw(batch, prefix + segment.getName(), 100, y -= 20);
|
font.draw(batch, prefix + segment.getName(), 100, y -= 20);
|
||||||
}
|
}
|
||||||
|
y -= 50;
|
||||||
|
for (Decay decay : round.getDecays()) {
|
||||||
|
font.draw(batch, "[#9E65A8]" + decay.getDescription(), 100, y -= 20);
|
||||||
|
}
|
||||||
//-----
|
//-----
|
||||||
|
|
||||||
ui.render(batch);
|
ui.render(batch);
|
||||||
|
@ -135,4 +148,8 @@ public class Game extends ApplicationAdapter {
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Round getRound() {
|
||||||
|
return round;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
22
core/src/com/monjaro/gamejam/main/ParityDecay.java
Normal file
22
core/src/com/monjaro/gamejam/main/ParityDecay.java
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
package com.monjaro.gamejam.main;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ParityDecay extends Decay {
|
||||||
|
|
||||||
|
private final int parity;
|
||||||
|
|
||||||
|
public ParityDecay(boolean odd) {
|
||||||
|
parity = odd ? 1 : 0;
|
||||||
|
description = "All used dice with " + (odd ? "ODD" : "EVEN") + " value decay.";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Die> getDecayed(List<Die> dice) {
|
||||||
|
return dice.stream()
|
||||||
|
.filter(d -> !d.isFaceBlank())
|
||||||
|
.filter(d -> d.getFaceValue() % 2 == parity)
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
45
core/src/com/monjaro/gamejam/main/Round.java
Normal file
45
core/src/com/monjaro/gamejam/main/Round.java
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
package com.monjaro.gamejam.main;
|
||||||
|
|
||||||
|
import com.monjaro.gamejam.segment.Segment;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Round {
|
||||||
|
|
||||||
|
private final List<Segment> segments;
|
||||||
|
private final List<Decay> decays;
|
||||||
|
private final int maxRerolls;
|
||||||
|
private int rerolls;
|
||||||
|
|
||||||
|
public Round(List<Segment> segments, List<Decay> decays, int rerolls) {
|
||||||
|
this.segments = segments;
|
||||||
|
this.decays = decays;
|
||||||
|
maxRerolls = rerolls;
|
||||||
|
this.rerolls = rerolls;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Segment> getSegments() {
|
||||||
|
return segments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Decay> getDecays() {
|
||||||
|
return decays;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxRerolls() {
|
||||||
|
return maxRerolls;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRerolls() {
|
||||||
|
return rerolls;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRerolls(int rerolls) {
|
||||||
|
this.rerolls = rerolls;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reduceRerolls(int i) {
|
||||||
|
rerolls -= i;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,21 +0,0 @@
|
||||||
package com.monjaro.gamejam.main;
|
|
||||||
|
|
||||||
public class RoundData {
|
|
||||||
private int rerolls;
|
|
||||||
|
|
||||||
public RoundData(int rerolls){
|
|
||||||
this.rerolls = rerolls;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRerolls() {
|
|
||||||
return rerolls;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRerolls(int rerolls) {
|
|
||||||
this.rerolls = rerolls;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reduceRerolls(int i) {
|
|
||||||
rerolls -= i;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,17 +5,16 @@ import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
|
|
||||||
public class UI extends Actor{
|
public class UI extends Actor{
|
||||||
private Transform position;
|
|
||||||
|
private final Game game;
|
||||||
|
private final Transform position;
|
||||||
private static Texture rerollTexture;
|
private static Texture rerollTexture;
|
||||||
|
|
||||||
private int rerolls;
|
private int rerolls;
|
||||||
private int remainingRerolls;
|
|
||||||
|
|
||||||
public UI(int x, int y, int rerolls)
|
public UI(Game game, int x, int y) {
|
||||||
{
|
this.game = game;
|
||||||
position = new Transform(x, y, 0, 0);
|
position = new Transform(x, y, 0, 0);
|
||||||
this.rerolls = rerolls;
|
|
||||||
this.remainingRerolls = rerolls;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPosition(int x, int y){
|
public void setPosition(int x, int y){
|
||||||
|
@ -23,7 +22,9 @@ public class UI extends Actor{
|
||||||
position.y = y;
|
position.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRemainingRerolls(int x){remainingRerolls = x;}
|
public void setRerolls(int x){
|
||||||
|
rerolls = x;
|
||||||
|
}
|
||||||
|
|
||||||
public static void setRerollTexture(Texture texture){rerollTexture = texture;}
|
public static void setRerollTexture(Texture texture){rerollTexture = texture;}
|
||||||
|
|
||||||
|
@ -34,8 +35,8 @@ public class UI extends Actor{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(SpriteBatch batch) {
|
public void render(SpriteBatch batch) {
|
||||||
for (int i = 0; i < rerolls; i++) {
|
for (int i = 0; i < game.getRound().getMaxRerolls(); i++) {
|
||||||
if (i > remainingRerolls-1)
|
if (i >= game.getRound().getRerolls())
|
||||||
batch.setColor(Color.GRAY);
|
batch.setColor(Color.GRAY);
|
||||||
batch.draw(rerollTexture, (position.x + (40f*i)), (position.y));
|
batch.draw(rerollTexture, (position.x + (40f*i)), (position.y));
|
||||||
batch.setColor(Color.WHITE);
|
batch.setColor(Color.WHITE);
|
||||||
|
|
|
@ -30,15 +30,17 @@ public class OlympicSegment extends Segment {
|
||||||
.sorted()
|
.sorted()
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
int last = -1, run = 1, best = run;
|
int last = -1, run = 1, best = 0;
|
||||||
|
|
||||||
for (int value : values) {
|
for (int value : values) {
|
||||||
if (value == last + 1) {
|
if (value == last + 1) {
|
||||||
if (++run > best) best = run;
|
run++;
|
||||||
} else {
|
} else {
|
||||||
run = 1;
|
run = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (run > best) best = run;
|
||||||
|
|
||||||
last = value;
|
last = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue