Start adding in Dice Roll effects

This commit is contained in:
spjspj 2017-12-10 22:49:55 +11:00
parent 6fa2f70ad1
commit 8e3daf54a9
9 changed files with 424 additions and 1 deletions

View file

@ -2312,7 +2312,7 @@ public abstract class PlayerImpl implements Player, Serializable {
public boolean flipCoin(Game game) {
return this.flipCoin(game, null);
}
/**
* @param game
* @param appliedEffects
@ -2331,6 +2331,31 @@ public abstract class PlayerImpl implements Player, Serializable {
}
return event.getFlag();
}
@Override
public int rollDice(Game game, int numSides) {
return this.rollDice(game, null, numSides);
}
/**
* @param game
* @param appliedEffects
* @return the number that the player rolled
*/
@Override
public int rollDice(Game game, ArrayList<UUID> appliedEffects, int numSides) {
int result = RandomUtil.nextInt(numSides);
if (!game.isSimulation()) {
game.informPlayers("[Roll a dice] " + getLogName() + " rolled a " + result + " on a " + numSides + " sided dice");
}
GameEvent event = new GameEvent(GameEvent.EventType.ROLL_DICE, playerId, null, playerId, result, true);
event.setAppliedEffects(appliedEffects);
event.setAmount(result);
if (!game.replaceEvent(event)) {
game.fireEvent(new GameEvent(GameEvent.EventType.DICE_ROLLED, playerId, null, playerId, result, event.getFlag()));
}
return result;
}
@Override
public List<Permanent> getAvailableAttackers(Game game) {