Refactor Devour ability; [LTC] Implement Feasting Hobbit (#10708)

* [LTC] Implement Feasting Hobbit

Refactor DevourEffect and its text generation, to be more permissive in the future.

* change DevourAbility to have the constructor parameters of DevourEffect

* only pluralize when there is more than 1 devoured permanent.

* added more unit tests than there are cards with devour

* public -> private filter of Caprichrome.
This commit is contained in:
Susucre 2023-08-01 15:49:32 +02:00 committed by GitHub
parent 3d3358cd05
commit 40e508ac19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 535 additions and 132 deletions

View file

@ -3,8 +3,9 @@ package mage.abilities.keyword;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.DevourEffect;
import mage.abilities.effects.common.DevourEffect.DevourFactor;
import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterControlledPermanent;
/**
* 502.82. Devour
@ -40,15 +41,28 @@ import mage.constants.Zone;
* can't sacrifice the same creature to satisfy multiple devour abilities.) All
* creatures devoured this way are sacrificed at the same time.
*
* @author LevelX2
* @author LevelX2, Susucr
*/
public class DevourAbility extends SimpleStaticAbility {
public DevourAbility(DevourFactor devourFactor) {
super(Zone.ALL, new DevourEffect(devourFactor));
private static final FilterControlledPermanent filterCreature = new FilterControlledCreaturePermanent("creature");
// Integer.MAX_VALUE is a special value
// for "devour X, where X is the number of devored permanents"
// see DevourEffect for the full details.
public static DevourAbility DevourX() {
return new DevourAbility(Integer.MAX_VALUE);
}
public DevourAbility(final DevourAbility ability) {
public DevourAbility(int devourFactor) {
this(devourFactor, filterCreature);
}
public DevourAbility(int devourFactor, FilterControlledPermanent filterDevoured) {
super(Zone.ALL, new DevourEffect(devourFactor, filterDevoured));
}
private DevourAbility(final DevourAbility ability) {
super(ability);
}