mirror of
https://github.com/correl/mage.git
synced 2024-11-24 19:19:56 +00:00
[ORI] Implemented Renown keyword.
This commit is contained in:
parent
085870de1f
commit
c2bba588ff
5 changed files with 127 additions and 0 deletions
111
Mage/src/mage/abilities/keyword/RenownAbility.java
Normal file
111
Mage/src/mage/abilities/keyword/RenownAbility.java
Normal file
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.DamagedPlayerEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
|
||||
public class RenownAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private int renownValue;
|
||||
|
||||
public RenownAbility(int renownValue) {
|
||||
super(Zone.BATTLEFIELD, new BecomeRenownSourceEffect(renownValue), false);
|
||||
this.renownValue = renownValue;
|
||||
}
|
||||
|
||||
public RenownAbility(final RenownAbility ability) {
|
||||
super(ability);
|
||||
this.renownValue = ability.renownValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenownAbility copy() {
|
||||
return new RenownAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DAMAGED_PLAYER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return event.getSourceId().equals(getSourceId())
|
||||
&& ((DamagedPlayerEvent) event).isCombatDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever {this} deals combat damage to a player, " + super.getRule();
|
||||
}
|
||||
|
||||
public int getRenownValue() {
|
||||
return renownValue;
|
||||
}
|
||||
}
|
||||
|
||||
class BecomeRenownSourceEffect extends OneShotEffect {
|
||||
|
||||
public BecomeRenownSourceEffect(int renownValue) {
|
||||
super(Outcome.BoostCreature);
|
||||
this.staticText = setText(renownValue);
|
||||
}
|
||||
|
||||
public BecomeRenownSourceEffect(final BecomeRenownSourceEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BecomeRenownSourceEffect copy() {
|
||||
return new BecomeRenownSourceEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null && !permanent.isRenown() && source instanceof RenownAbility) {
|
||||
game.informPlayers(permanent.getLogName() + " is now renown");
|
||||
int renownValue = ((RenownAbility) source).getRenownValue();
|
||||
// handle renown = X
|
||||
if (renownValue == Integer.MAX_VALUE) {
|
||||
renownValue = source.getManaCostsToPay().getX();
|
||||
}
|
||||
new AddCountersSourceEffect(CounterType.P1P1.createInstance(renownValue),true).apply(game, source);
|
||||
permanent.setRenown(true);
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.BECOMES_RENOWN, source.getSourceId(), source.getSourceId(), source.getControllerId(), renownValue));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String setText(int renownValue) {
|
||||
// Renown 1 (When this creature deals combat damage to a player, if it isn't renowned, put a +1/+1 counter on it and it becomes renowned.)
|
||||
StringBuilder sb = new StringBuilder("Renown ");
|
||||
sb.append(renownValue == Integer.MAX_VALUE ? "X":renownValue)
|
||||
.append(". <i>(When this creature deals combat damage to a player, if it isn't renowned, put ")
|
||||
.append(renownValue == Integer.MAX_VALUE ? "X":CardUtil.numberToText(renownValue, "a"))
|
||||
.append(" +1/+1 counter on it and it becomes renowned.)</i>").toString();
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -185,6 +185,7 @@ public class GameEvent implements Serializable {
|
|||
UNFLIP, UNFLIPPED,
|
||||
TRANSFORM, TRANSFORMED,
|
||||
BECOMES_MONSTROUS,
|
||||
BECOMES_RENOWN,
|
||||
PHASE_OUT, PHASED_OUT,
|
||||
PHASE_IN, PHASED_IN,
|
||||
TURNFACEUP, TURNEDFACEUP,
|
||||
|
|
|
@ -75,6 +75,9 @@ public interface Permanent extends Card, Controllable {
|
|||
boolean isMonstrous();
|
||||
void setMonstrous(boolean value);
|
||||
|
||||
boolean isRenown();
|
||||
void setRenown(boolean value);
|
||||
|
||||
void setCardNumber(int cid);
|
||||
void setExpansionSetCode(String expansionSetCode);
|
||||
void setRarity(Rarity rarity);
|
||||
|
|
|
@ -91,6 +91,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
protected boolean flipped;
|
||||
protected boolean transformed;
|
||||
protected boolean monstrous;
|
||||
protected boolean renown;
|
||||
protected boolean manifested = false;
|
||||
protected boolean morphed = false;
|
||||
protected UUID originalControllerId;
|
||||
|
@ -1265,6 +1266,16 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
this.monstrous = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRenown() {
|
||||
return this.renown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRenown(boolean value) {
|
||||
this.renown = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPairedCard(UUID pairedCard) {
|
||||
this.pairedCard = pairedCard;
|
||||
|
|
|
@ -52,6 +52,7 @@ Provoke|new|
|
|||
Prowess|new|
|
||||
Reach|instance|
|
||||
Rebound|new|
|
||||
Renown|number|
|
||||
Scavenge|cost|
|
||||
Shadow|instance|
|
||||
Shroud|instance|
|
||||
|
|
Loading…
Reference in a new issue