CardEffect remakeCardIntoModel(double cardPoints, CostType costType, double newCost, CardModel cardModel, bool isNewModel) { Card remadeCard = null; switch (cardModel) { case CardModel.INSTANT_DICE: remadeCard = CardFactory.generateRandomCardInstantDice(cardPoints, costType, newCost); break; case CardModel.INSTANT_HEALTH: remadeCard = CardFactory.generateRandomCardInstantHealth(cardPoints, costType, newCost); break; case CardModel.LAST: remadeCard = isNewModel ? CardFactory.generateRandomCardLast(cardPoints, costType, newCost) : CardFactory.generateRandomCardLast(cardPoints, conditionNumber, costType, newCost); break; case CardModel.FIRST: remadeCard = isNewModel ? CardFactory.generateRandomCardFirst(cardPoints, costType, newCost) : CardFactory.generateRandomCardFirst(cardPoints, conditionNumber, costType, newCost); break; case CardModel.MULTIPLIER: remadeCard = isNewModel ? CardFactory.generateRandomCardMultiplier(cardPoints, costType, newCost) : CardFactory.generateRandomCardMultiplier(cardPoints, conditionNumber, costType, newCost); break; case CardModel.DICE_DERIVATIVE: remadeCard = isNewModel ? CardFactory.generateRandomCardDerivative(cardPoints, costType, newCost) : CardFactory.generateRandomCardDerivative(cardPoints, conditionNumber, costType, newCost); break; case CardModel.LOWER_MAX: remadeCard = CardFactory.generateRandomCardLowerMax(cardPoints, costType, newCost); break; case CardModel.IMPROVE: remadeCard = CardFactory.generateRandomCardImprove(cardPoints, costType, newCost); break; case CardModel.FIXED_DICE: remadeCard = isNewModel ? CardFactory.generateRandomCardFixedDice(cardPoints): CardFactory.generateRandomCardFixedDice(cardPoints, (int)effectNumber); break; case CardModel.FORBID_NUMBER: remadeCard = isNewModel ? CardFactory.generateRandomCardForbidNumber(cardPoints): CardFactory.generateRandomCardForbidNumber(cardPoints, (int)effectNumber, cost); break; case CardModel.ADD_ATTACK_ROLL: remadeCard = isNewModel ? CardFactory.generateRandomCardAddAttackRoll(cardPoints): CardFactory.generateRandomCardAddAttackRoll(cardPoints, (int)effectNumber); break; } return((remadeCard != null) ? remadeCard.cardEffect : this); }
public CardEffect remakeCardEffect(double cardPoints, double alteration, bool forceDifferentModel) { CardEffect remadeCardEffect = null; CardModel cardModel = CardFactory.getCardModel(this); // The cost of "forbid number" cards has no association with the card points, so consider it low CostType costType = (effect != Effect.FORBID_NUMBER) ? CardFactory.getCostType(cardPoints, cost) : (cost > 0) ? CostType.LOW : CostType.NONE; // 6 and values under 3 give trouble when reconverting costs, so return those without changing if (cost > 0 && cardPoints < 7 && alteration < 0) { return(this); } cardPoints += alteration; if (cardPoints < 3) { cardPoints = 3; // Should be the minimum } if (cost > 0 && cardPoints < 7) { cardPoints = 7; // 6 and values under 3 give trouble when reconverting costs } double newCost = CardFactory.getCost(costType, cardPoints); if (forceDifferentModel) // If true, pick any random model other than the current one { List <CardModel> availableCardModels = new List <CardModel>(); // Get all possible models foreach (CardModel model in System.Enum.GetValues(typeof(CardModel))) { availableCardModels.Add(model); } availableCardModels.Remove(cardModel); // Remove model of this card, then pick one at random cardModel = availableCardModels[Random.Range(0, availableCardModels.Count)]; } // Get card effect remadeCardEffect = remakeCardIntoModel(cardPoints, costType, newCost, cardModel, forceDifferentModel); // Return if not null, otherwise return default card effect (should not happen) return(remadeCardEffect ?? this); }