using System.Collections; using System.Collections.Generic; using System.Linq; namespace DCGO.CardEffects.BT18 { public class BT18_078 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); #region Alternate Digivolution // Any purple if (timing == EffectTiming.None) { bool PermanentCondition(Permanent targetPermanent) { return targetPermanent.IsTamer && targetPermanent.TopCard.CardColors.Contains(CardColor.Purple); } cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect( permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null)); } // Koichi Kimura if (timing == EffectTiming.None) { bool PermanentCondition(Permanent targetPermanent) { return targetPermanent.TopCard.EqualsCardName("Koichi Kimura"); } cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect( permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null)); } // Velgrmon if (timing == EffectTiming.None) { bool PermanentCondition(Permanent targetPermanent) { return targetPermanent.TopCard.EqualsCardName("Velgrmon"); } cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect( permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false, card: card, condition: null)); } #endregion #region On Play/ When Digivolving Shared bool CanSelectPermanentConditionShared(Permanent permanent) { return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card) && (permanent.IsDigimon || permanent.IsTamer); } bool CanActivateConditionShared(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentConditionShared); } #endregion #region On Play if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Change the color of 1 of your opponent's Digimon or Tamer", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription()); cardEffects.Add(activateClass); string EffectDescription() { return "[On Play] Until the end of your opponent's turn, change 1 of their Digimon or Tamers into a color other than white."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerOnPlay(hashtable, card); } IEnumerator ActivateCoroutine(Hashtable hashtable) { Permanent selectedPermanent = null; SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectPermanentConditionShared, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: 1, canNoSelect: false, canEndNotMax: false, selectPermanentCoroutine: SelectPermanentCoroutine, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Custom, cardEffect: activateClass); selectPermanentEffect.SetUpCustomMessage( "Select 1 Digimon that will change color.", "The opponent is selecting 1 Digimon that will change color."); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); IEnumerator SelectPermanentCoroutine(Permanent permanent) { selectedPermanent = permanent; yield return null; } if (selectedPermanent != null) { List> selectionElements = new List>() { new(message: $"Red", value: (int)CardColor.Red, spriteIndex: 0), new(message: $"Blue", value: (int)CardColor.Blue, spriteIndex: 0), new(message: $"Yellow", value: (int)CardColor.Yellow, spriteIndex: 0), new(message: $"Green", value: (int)CardColor.Green, spriteIndex: 0), new(message: $"Black", value: (int)CardColor.Black, spriteIndex: 0), new(message: $"Purple", value: (int)CardColor.Purple, spriteIndex: 0), }; string selectPlayerMessage = "Select a color."; string notSelectPlayerMessage = "The opponent is selecting a color."; GManager.instance.userSelectionManager.SetIntSelection( selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage); yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager .WaitForEndSelect()); CardColor chosenColor = (CardColor)GManager.instance.userSelectionManager.SelectedIntValue; ChangeBaseCardColorClass changeBaseCardNameClass = new ChangeBaseCardColorClass(); changeBaseCardNameClass.SetUpICardEffect($"Original card color is changed: {chosenColor}", CanUseChangeColorCondition, card); changeBaseCardNameClass.SetUpChangeBaseCardColorClass(ChangeBaseCardColors: ChangeBaseCardColors); selectedPermanent.UntilOwnerTurnEndEffects.Add(_ => changeBaseCardNameClass); #region Log string log = ""; log += $"\nChanged Card Color to {chosenColor}:"; log += $"\n{selectedPermanent.TopCard.BaseENGCardNameFromEntity}({selectedPermanent.TopCard.CardID})"; log += "\n"; PlayLog.OnAddLog?.Invoke(log); #endregion bool CanUseChangeColorCondition(Hashtable hashtableColor) { return selectedPermanent.TopCard != null && !selectedPermanent.TopCard.CanNotBeAffected(activateClass); } List ChangeBaseCardColors(CardSource cardSource, List cardColors) { if (cardSource == selectedPermanent.TopCard) { cardColors = new List() { chosenColor }; } return cardColors; } } } } #endregion #region When Digivolving if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Change the color of 1 of your opponent's Digimon or Tamer", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription()); cardEffects.Add(activateClass); string EffectDescription() { return "[When Digivolving] Until the end of your opponent's turn, change 1 of their Digimon or Tamers into a color other than white."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card); } IEnumerator ActivateCoroutine(Hashtable hashtable) { Permanent selectedPermanent = null; SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectPermanentConditionShared, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: 1, canNoSelect: false, canEndNotMax: false, selectPermanentCoroutine: SelectPermanentCoroutine, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Custom, cardEffect: activateClass); selectPermanentEffect.SetUpCustomMessage( "Select 1 Digimon that will change color.", "The opponent is selecting 1 Digimon that will change color."); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); IEnumerator SelectPermanentCoroutine(Permanent permanent) { selectedPermanent = permanent; yield return null; } if (selectedPermanent != null) { List> selectionElements = new List>() { new(message: $"Red", value: (int)CardColor.Red, spriteIndex: 0), new(message: $"Blue", value: (int)CardColor.Blue, spriteIndex: 0), new(message: $"Yellow", value: (int)CardColor.Yellow, spriteIndex: 0), new(message: $"Green", value: (int)CardColor.Green, spriteIndex: 0), new(message: $"Black", value: (int)CardColor.Black, spriteIndex: 0), new(message: $"Purple", value: (int)CardColor.Purple, spriteIndex: 0), }; string selectPlayerMessage = "Select a color."; string notSelectPlayerMessage = "The opponent is selecting a color."; GManager.instance.userSelectionManager.SetIntSelection( selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage); yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager .WaitForEndSelect()); CardColor chosenColor = (CardColor)GManager.instance.userSelectionManager.SelectedIntValue; ChangeBaseCardColorClass changeBaseCardNameClass = new ChangeBaseCardColorClass(); changeBaseCardNameClass.SetUpICardEffect($"Original card color is changed: {chosenColor}", CanUseChangeColorCondition, card); changeBaseCardNameClass.SetUpChangeBaseCardColorClass(ChangeBaseCardColors: ChangeBaseCardColors); selectedPermanent.UntilOwnerTurnEndEffects.Add(_ => changeBaseCardNameClass); #region Log string log = ""; log += $"\nChanged Card Color to {chosenColor}:"; log += $"\n{selectedPermanent.TopCard.BaseENGCardNameFromEntity}({selectedPermanent.TopCard.CardID})"; log += "\n"; PlayLog.OnAddLog?.Invoke(log); #endregion bool CanUseChangeColorCondition(Hashtable hashtableColor) { return selectedPermanent.TopCard != null && !selectedPermanent.TopCard.CanNotBeAffected(activateClass); } List ChangeBaseCardColors(CardSource cardSource, List cardColors) { if (cardSource == selectedPermanent.TopCard) { cardColors = new List() { chosenColor }; } return cardColors; } } } } #endregion #region When Attacking if (timing == EffectTiming.OnAllyAttack) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("1 of your Digimon or Tamers digivolves", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription()); cardEffects.Add(activateClass); string EffectDescription() { return "[When Attacking] 1 of your Digimon or Tamers may digivolve into a level 4 card with the [Hybrid] trait in the trash with the digivolution cost reduced by 1."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerOnAttack(hashtable, card); } bool DigivolveFromPermanentCondition(Permanent permanent) { return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) && (permanent.IsDigimon || permanent.IsTamer) && card.Owner.TrashCards.Where(DigivolveToCardCondition).Any(cardSource => cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass, SelectCardEffect.Root.Trash)); } bool DigivolveToCardCondition(CardSource cardSource) { return cardSource.IsDigimon && cardSource.ContainsTraits("Hybrid") && cardSource.HasLevel && cardSource.Level == 4; } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.HasMatchConditionPermanent(DigivolveFromPermanentCondition); } IEnumerator ActivateCoroutine(Hashtable hashtable) { Permanent selectedPermanent = null; SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: DigivolveFromPermanentCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: 1, canNoSelect: true, canEndNotMax: false, selectPermanentCoroutine: SelectPermanentCoroutine, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Custom, cardEffect: activateClass); selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve."); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); IEnumerator SelectPermanentCoroutine(Permanent permanent) { selectedPermanent = permanent; yield return null; } if (selectedPermanent != null) { yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard( targetPermanent: selectedPermanent, cardCondition: DigivolveToCardCondition, payCost: true, reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null), fixedCostTuple: null, ignoreDigivolutionRequirementFixedCost: -1, isHand: false, activateClass: activateClass, successProcess: null)); } } } #endregion #region On Deletion - ESS if (timing == EffectTiming.OnDestroyedAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Play Tamer card from trash", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription()); activateClass.SetIsInheritedEffect(true); cardEffects.Add(activateClass); string EffectDescription() { return "[On Deletion] You may play 1 Tamer card with a play cost of 4 or less from your trash without paying the cost."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass); } bool CanSelectCardCondition(CardSource cardSource) { return cardSource.IsTamer && cardSource.HasPlayCost && cardSource.GetCostItself <= 4 && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass); } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.CanActivateOnDeletion(card, activateClass) && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition); } IEnumerator ActivateCoroutine(Hashtable hashtable) { List selectedCards = new List(); SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); selectCardEffect.SetUp( canTargetCondition: CanSelectCardCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => true, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, message: "Select 1 card to play.", maxCount: 1, canEndNotMax: false, isShowOpponent: true, mode: SelectCardEffect.Mode.Custom, root: SelectCardEffect.Root.Trash, customRootCardList: null, canLookReverseCard: true, selectPlayer: card.Owner, cardEffect: activateClass); selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play."); selectCardEffect.SetUpCustomMessage_ShowCard("Played Card"); yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate()); IEnumerator SelectCardCoroutine(CardSource cardSource) { selectedCards.Add(cardSource); yield return null; } yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards( cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true)); } } #endregion return cardEffects; } } }