forked from External/mage
Fix DIE_ROLLED event to set targetID to player who rolled the die (#11993)
* Fix DIE_ROLLED event to set targetID to player who rolled the die * Fix DieRolledEvent instantiation
This commit is contained in:
parent
50d8be1924
commit
c8383649df
14 changed files with 32 additions and 16 deletions
|
|
@ -4,6 +4,8 @@ import mage.abilities.Ability;
|
|||
import mage.constants.PlanarDieRollResult;
|
||||
import mage.constants.RollDieType;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801, JayDi85
|
||||
*/
|
||||
|
|
@ -20,8 +22,22 @@ public class DieRolledEvent extends GameEvent {
|
|||
private final int naturalResult; // planar die returns 0 values in result and natural result
|
||||
private final PlanarDieRollResult planarResult;
|
||||
|
||||
public DieRolledEvent(Ability source, RollDieType rollDieType, int sides, int naturalResult, int modifier, PlanarDieRollResult planarResult) {
|
||||
super(EventType.DIE_ROLLED, source.getControllerId(), source, source.getControllerId(), naturalResult + modifier, false);
|
||||
/**
|
||||
* The target ID is used to keep track of the distinction between the player who controls the ability that
|
||||
* started the dice roll and the player who does the rolling.
|
||||
* <p>
|
||||
* The only times this distinction matters is for Chaos Dragon and Ricochet.
|
||||
*
|
||||
* @param source The ability causing the die roll
|
||||
* @param targetId The player who rolled the die
|
||||
* @param rollDieType
|
||||
* @param sides
|
||||
* @param naturalResult the result of the die roll before any modifiers
|
||||
* @param modifier the sum of all modifiers
|
||||
* @param planarResult
|
||||
*/
|
||||
public DieRolledEvent(Ability source, UUID targetId, RollDieType rollDieType, int sides, int naturalResult, int modifier, PlanarDieRollResult planarResult) {
|
||||
super(EventType.DIE_ROLLED, targetId, source, source.getControllerId(), naturalResult + modifier, false);
|
||||
this.rollDieType = rollDieType;
|
||||
this.sides = sides;
|
||||
this.naturalResult = naturalResult;
|
||||
|
|
|
|||
|
|
@ -3293,7 +3293,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
|
||||
// raise affected roll events
|
||||
for (RollDieResult result : dieRolls) {
|
||||
game.fireEvent(new DieRolledEvent(source, rollDiceEvent.getRollDieType(), rollDiceEvent.getSides(), result.naturalResult, result.modifier, result.planarResult));
|
||||
game.fireEvent(new DieRolledEvent(source, this.getId(), rollDiceEvent.getRollDieType(), rollDiceEvent.getSides(), result.naturalResult, result.modifier, result.planarResult));
|
||||
}
|
||||
game.fireEvent(new DiceRolledEvent(rollDiceEvent.getSides(), dieResults, source, this.getId()));
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class PlanarRollWatcher extends Watcher {
|
|||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.DIE_ROLLED) {
|
||||
DieRolledEvent drEvent = (DieRolledEvent) event;
|
||||
UUID playerId = drEvent.getPlayerId();
|
||||
UUID playerId = drEvent.getTargetId();
|
||||
if (playerId != null && drEvent.getRollDieType() == RollDieType.PLANAR) {
|
||||
Integer amount = numberTimesPlanarDieRolled.get(playerId);
|
||||
if (amount == null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue