Skip to content

Commit

Permalink
Implement a few dice types
Browse files Browse the repository at this point in the history
  • Loading branch information
bendem committed Oct 18, 2014
1 parent 44ad489 commit 0a0b1a6
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/main/java/be/bendem/bot/dices/AttackDice.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package be.bendem.bot.dices;

import be.bendem.bot.entities.Entity;

/**
* @author bendem
*/
public class AttackDice extends Dice {

public AttackDice() {
this(1, 6);
}

public AttackDice(int min, int max) {
super(min, max, true);
}

/**
* {@inheritDoc}
*/
@Override
public void applyTo(Entity target, int result) {
target.damage(result);
}

}
26 changes: 26 additions & 0 deletions src/main/java/be/bendem/bot/dices/HealDice.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package be.bendem.bot.dices;

import be.bendem.bot.entities.Entity;

/**
* @author bendem
*/
public class HealDice extends Dice {

public HealDice() {
this(1, 6);
}

public HealDice(int min, int max) {
super(min, max, false);
}

/**
* {@inheritDoc}
*/
@Override
public void applyTo(Entity target, int result) {
target.heal(result);
}

}
29 changes: 29 additions & 0 deletions src/main/java/be/bendem/bot/dices/PoisonDice.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package be.bendem.bot.dices;

import be.bendem.bot.entities.Entity;

/**
* @author bendem
*/
public class PoisonDice extends Dice {

private final int damage;

public PoisonDice(int damage) {
this(damage, 1, 6);
}

protected PoisonDice(int damage, int min, int max) {
super(min, max, true);
this.damage = damage;
}

/**
* {@inheritDoc}
*/
@Override
public void applyTo(Entity target, int result) {
target.poison(damage, result);
}

}
21 changes: 21 additions & 0 deletions src/main/java/be/bendem/bot/dices/ShieldDice.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package be.bendem.bot.dices;

import be.bendem.bot.entities.Entity;

/**
* @author bendem
*/
public class ShieldDice extends Dice {

public ShieldDice(int min, int max) {
super(min, max, true);
}

/**
* {@inheritDoc}
*/
@Override
public void applyTo(Entity target, int result) {
target.shield(result);
}
}
3 changes: 3 additions & 0 deletions src/main/java/be/bendem/bot/entities/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public void heal(int heal) {
currentHealth += heal;
}

public abstract void shield(int shield);
public abstract void poison(int damage, int turns);

public boolean isDead() {
return currentHealth == 0;
}
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/be/bendem/bot/entities/Monster.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,14 @@ public int getMaxHealth() {
return maxHealth;
}

@Override
public void shield(int shield) {
// TODO
}

@Override
public void poison(int damage, int turns) {
// TODO
}

}
10 changes: 10 additions & 0 deletions src/main/java/be/bendem/bot/entities/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ public int getMaxHealth() {
return BASE_HEALTH + level * HEALTH_PER_LEVEL;
}

@Override
public void shield(int shield) {
// TODO
}

@Override
public void poison(int damage, int turns) {
// TODO
}

public int getLevel() {
return level;
}
Expand Down

0 comments on commit 0a0b1a6

Please sign in to comment.