mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
Start adding in Dice Roll effects
This commit is contained in:
parent
6fa2f70ad1
commit
8e3daf54a9
9 changed files with 424 additions and 1 deletions
|
|
@ -229,6 +229,7 @@ public class GameEvent implements Serializable {
|
|||
ENCHANT_PLAYER, ENCHANTED_PLAYER,
|
||||
CAN_TAKE_MULLIGAN,
|
||||
FLIP_COIN, COIN_FLIPPED, SCRY, FATESEAL,
|
||||
ROLL_DICE, DICE_ROLLED,
|
||||
PAID_CUMULATIVE_UPKEEP,
|
||||
DIDNT_PAY_CUMULATIVE_UPKEEP,
|
||||
//permanent events
|
||||
|
|
|
|||
|
|
@ -417,6 +417,10 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
|
||||
boolean flipCoin(Game game, ArrayList<UUID> appliedEffects);
|
||||
|
||||
int rollDice(Game game, int numSides);
|
||||
|
||||
int rollDice(Game game, ArrayList<UUID> appliedEffects, int numSides);
|
||||
|
||||
@Deprecated
|
||||
void discard(int amount, Ability source, Game game);
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue