mirror of
https://github.com/magefree/mage.git
synced 2025-12-27 05:52:06 -08:00
[DRC] Implement Prophet of the Scarab
Also adds a DynamicValue that finds the largest of multiple DynamicValues.
This commit is contained in:
parent
9172a9eba8
commit
7bfb0d2dec
4 changed files with 125 additions and 45 deletions
|
|
@ -0,0 +1,49 @@
|
|||
package mage.abilities.dynamicvalue;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MaximumDynamicValue implements DynamicValue {
|
||||
|
||||
private final List<DynamicValue> dynamicValues;
|
||||
|
||||
/**
|
||||
* Creates a {@link DynamicValue} that finds the maximum of multiple
|
||||
* {@link DynamicValue}s.
|
||||
*
|
||||
* @param dynamicValues The dynamic values to add together.
|
||||
*/
|
||||
public MaximumDynamicValue(DynamicValue... dynamicValues) {
|
||||
this.dynamicValues = Arrays.asList(dynamicValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link DynamicValue} that finds the maximum of multiple
|
||||
* {@link DynamicValue}s.
|
||||
*
|
||||
* @param dynamicValues The dynamic values to add together.
|
||||
*/
|
||||
public MaximumDynamicValue(List<DynamicValue> dynamicValues) {
|
||||
this.dynamicValues = dynamicValues;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
return dynamicValues.stream().mapToInt(d -> d.calculate(game, sourceAbility, effect)).max().orElse(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaximumDynamicValue copy() {
|
||||
return new MaximumDynamicValue(this.dynamicValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return this.dynamicValues.stream().map(DynamicValue::getMessage).collect(Collectors.joining(" "));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue