using System.Collections.Generic; using System; public class ChangeCostClass : ICardEffect, IChangeCostEffect { Func, int> _changeCostFunc { get; set; } Func _cardSourceCondition { get; set; } Func _rootCondition { get; set; } Func _isUpDown { get; set; } Func _isCheckAvailability { get; set; } Func _isChangePayingCost { get; set; } public void SetUpChangeCostClass(Func, int> changeCostFunc, Func cardSourceCondition, Func rootCondition, Func isUpDown, Func isCheckAvailability, Func isChangePayingCost) { _changeCostFunc = changeCostFunc; _cardSourceCondition = cardSourceCondition; _rootCondition = rootCondition; _isUpDown = isUpDown; _isCheckAvailability = isCheckAvailability; _isChangePayingCost = isChangePayingCost; } public int GetCost(int cost, CardSource cardSource, SelectCardEffect.Root root, List targetPermanents) { if (cardSource != null) { if (CardCondition(cardSource)) { if (_changeCostFunc != null) { if (_rootCondition != null) { if (_rootCondition(root)) { int newCost = _changeCostFunc(cardSource, cost, root, targetPermanents); if (IsUpDown()) { if (newCost < cost) { if (!cardSource.Owner.CanReduceCost(targetPermanents, cardSource)) { newCost = cost; } } } cost = newCost; } } } } } return cost; } public bool CardCondition(CardSource cardSource) { if (_cardSourceCondition != null) { if (_cardSourceCondition(cardSource)) { return true; } } return false; } public bool IsUpDown() { if (_isUpDown != null) { return _isUpDown(); } return false; } public bool IsCheckAvailability() { if (_isCheckAvailability != null) { return _isCheckAvailability(); } return false; } public bool IsChangePayingCost() { if (_isChangePayingCost != null) { return _isChangePayingCost(); } return true; } }