mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Merge pull request #4753 from jpgunter/master
Implement Multani, Yavimaya's Avatar
This commit is contained in:
commit
c9a6903253
3 changed files with 148 additions and 0 deletions
|
|
@ -0,0 +1,46 @@
|
|||
package mage.abilities.dynamicvalue;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class AdditiveDynamicValue implements DynamicValue {
|
||||
|
||||
private List<DynamicValue> dynamicValues;
|
||||
|
||||
/**
|
||||
* Creates a {@link DynamicValue} from that adds together multiple {@link DynamicValue}s.
|
||||
* @param dynamicValues The dynamic values to add together.
|
||||
*/
|
||||
public AdditiveDynamicValue(DynamicValue...dynamicValues){
|
||||
this.dynamicValues = Arrays.asList(dynamicValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link DynamicValue} from that adds together multiple {@link DynamicValue}s.
|
||||
* @param dynamicValues The dynamic values to add together.
|
||||
*/
|
||||
public AdditiveDynamicValue(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)).sum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicValue copy() {
|
||||
return new AdditiveDynamicValue(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