Skip to content

Commit

Permalink
Mana card queueing works + fixed bugs + goblins still OP
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleWhole committed May 30, 2022
1 parent c71555f commit 5422088
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 22 deletions.
Binary file modified out/production/Threnody/combat/artes/Arte.class
Binary file not shown.
Binary file modified out/production/Threnody/entities/units/Unit.class
Binary file not shown.
Binary file modified out/production/Threnody/gamestates/BattleState.class
Binary file not shown.
Binary file modified out/production/Threnody/gamestates/Game.class
Binary file not shown.
4 changes: 2 additions & 2 deletions src/combat/artes/support/Elixir.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public void activation(Unit target) {

@Override
public void queue() {
owner.setManaAdd(owner.getManaAdd() + 1);
owner.addManaAdd(manaValue);
}

@Override
public void unqueue() {
owner.setManaAdd(owner.getManaAdd() - 1);
owner.addManaAdd(-manaValue);
}
}
11 changes: 4 additions & 7 deletions src/combat/artes/support/Mana.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,26 @@

@SuppressWarnings({"rawtypes"})
public class Mana extends Arte<Player> {
private final int healingValue = 10;
private final int manaValue = 2;

public Mana(Player owner) throws SlickException {
super(owner);
name = "Mana";
arteType = ArteType.SUPPORT;
aniType = AnimationType.OWNER;
cost = 0;
castDuration = 75;
}

@Override
public void activation(Unit target) {
target.generateMana(healingValue);
}
public void activation(Unit target) {}

@Override
public void queue() {

owner.addQueuedManaExtra(manaValue);
}

@Override
public void unqueue() {

owner.addQueuedManaExtra(-manaValue);
}
}
25 changes: 25 additions & 0 deletions src/entities/units/Unit.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public Unit() {
this.mana = 1;
this.turnMana = 1;
this.queuedManaRemoval = 0;
this.queuedManaExtra = 0;
this.manaAdd = 0;
this.level = 1;
this.health = 1;
Expand Down Expand Up @@ -285,6 +286,11 @@ public T setManaAdd(int manaAdd) {
return (T) this;
}

public T addManaAdd(int amt) {
this.manaAdd += amt;
return (T) this;
}

public int getQueuedManaRemoval() {
return queuedManaRemoval;
}
Expand All @@ -294,6 +300,25 @@ public T setQueuedManaRemoval(int queuedManaRemoval) {
return (T) this;
}

public T addQueuedManaRemoval(int amt) {
this.queuedManaRemoval += amt;
return (T) this;
}

public int getQueuedManaExtra() {
return queuedManaExtra;
}

public T setQueuedManaExtra(int queuedManaExtra) {
this.queuedManaExtra = queuedManaExtra;
return (T) this;
}

public T addQueuedManaExtra(int amt) {
this.queuedManaExtra += amt;
return (T) this;
}

public int calculateDamage(ElementType element) {
return attack * (1 + eAffinity.get(element) / 100) * (1 + (Math.random() <= critRate ? critDamage : 0));
}
Expand Down
2 changes: 1 addition & 1 deletion src/entities/units/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public Arte<? extends Unit> selection(int i) {
Arte<? extends Unit> selected = null;
try {
selected = arteHand.get(i);
if (selected.getCost() > mana - queuedManaRemoval) throw new ThrenodyException("Insufficient mana");
if (selected.getCost() > mana + queuedManaExtra - queuedManaRemoval) throw new ThrenodyException("Insufficient mana");
selected.reset();
queuedManaRemoval += selected.getCost();
selected.queue();
Expand Down
29 changes: 18 additions & 11 deletions src/gamestates/BattleState.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,17 @@ public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
g.setFont(gc.getDefaultFont());
battlefield.render(1000, -600);
for(Player p : plrs) {
p.battleRender(g, 0,0);

}
for(int i = enemies.size() - 1; i >= 0; i--) {
plrs.forEach(p -> p.battleRender(g, 0,0));
for (int i = enemies.size() - 1; i >= 0; i--) {
enemies.get(i).render(g, 0,0);
}
try {
result = combat.combat(g, gc);
} catch (InterruptedException | IndexOutOfBoundsException e) {
e.printStackTrace();
}

// Render the UI
try { renderUI(g); } catch (IndexOutOfBoundsException ignored) {}

try { result = combat.combat(g, gc); }
catch (InterruptedException | IndexOutOfBoundsException e) { e.printStackTrace(); }

switch (result) {
case WIN -> {
Expand Down Expand Up @@ -103,12 +102,20 @@ public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws Slic
g.drawString("" + combat.getRound(), 0, 0);
}
super.render(gc, sbg, g);
}

private void renderUI(Graphics g) {
Image mana = ImageManager.getImage("mana").getScaledCopy(2f);
mana.drawCentered(Main.RESOLUTION_X / 17, Main.RESOLUTION_Y / 20 * 17);
DrawUtilities.drawStringCentered(g, String.valueOf(plrs.get(turn()).getMana()), Main.fonts.VariableWidth.B60, Main.RESOLUTION_X / 17, Main.RESOLUTION_Y / 20 * 17 + 15);
if (plrs.get(turn()).getQueuedManaExtra() > 0) {
g.setColor(Color.green);
DrawUtilities.drawStringCentered(g, "+" + plrs.get(turn()).getQueuedManaExtra(), Main.fonts.VariableWidth.B60, Main.RESOLUTION_X / 17, Main.RESOLUTION_Y / 20 * 17 - 55);
g.setColor(Color.white);
}
if (plrs.get(turn()).getQueuedManaRemoval() > 0) {
g.setColor(Color.red);
DrawUtilities.drawStringCentered(g, String.valueOf(-plrs.get(turn()).getQueuedManaRemoval()), Main.fonts.VariableWidth.B60, Main.RESOLUTION_X / 17, Main.RESOLUTION_Y / 20 * 17 + 70);
DrawUtilities.drawStringCentered(g, "-" + plrs.get(turn()).getQueuedManaRemoval(), Main.fonts.VariableWidth.B60, Main.RESOLUTION_X / 17, Main.RESOLUTION_Y / 20 * 17 + 70);
g.setColor(Color.white);
}
if (plrs.get(turn()).getManaAdd() > 0) {
Expand Down Expand Up @@ -169,7 +176,7 @@ public void keyPressed(int key, char c) {
@Override
public void mousePressed(int button, int x, int y) {
try { for (var i = 0; i < 6; i++) if (plrs.get(turn()).onCard(gc.getInput(), i)) plrs.get(turn()).getClickArteQueue().offer(plrs.get(turn()).selection(i)); }
catch (NullPointerException ignored) {};
catch (IndexOutOfBoundsException | NullPointerException ignored) {};
}

public int turn() {
Expand Down
2 changes: 1 addition & 1 deletion src/gamestates/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
));

// Initialize the Player
plr = (Player) new Player(plrPosition).setAttack(10);
plr = (Player) new Player(plrPosition).setAttack(20);
plrTeam.add(plr);
System.out.println("[VERBOSE] Player initialized");
enemy = new Enemy(10, 0);
Expand Down

0 comments on commit 5422088

Please sign in to comment.