AD1_019.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Matt Ishida & T.K. Takaishi
  6. namespace DCGO.CardEffects.AD1
  7. {
  8. public class AD1_019 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Start of Your Main Phase
  14. if (timing == EffectTiming.OnStartMainPhase)
  15. {
  16. cardEffects.Add(CardEffectFactory.Gain1MemoryTamerOpponentDigimonEffect(card));
  17. }
  18. #endregion
  19. #region Your Turn
  20. if (timing == EffectTiming.OnEnterFieldAnyone)
  21. {
  22. ActivateClass activateClass = new ();
  23. activateClass.SetUpICardEffect("By suspending this tamer, you may play 1[ADVENTURE] Digimon for -1 cost per 2 colors on your Tamers.", CanUseCondition, card);
  24. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  25. cardEffects.Add(activateClass);
  26. string EffectDescription()
  27. => "[Your Turn] When any of your Digimon digivolve into an [ADVENTURE] trait Digimon, by suspending this Tamer, you may play 1 [ADVENTURE] trait card from your hand. For every 2 of your Tamers' colors, reduce this effect's play cost by 1.";
  28. bool CanUseCondition(Hashtable hashtable)
  29. {
  30. return CardEffectCommons.IsExistOnBattleArea(card)
  31. && CardEffectCommons.IsOwnerTurn(card)
  32. && CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, PermanentCondition);
  33. }
  34. bool PermanentCondition(Permanent permanent)
  35. {
  36. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  37. && permanent.TopCard.EqualsTraits("ADVENTURE");
  38. }
  39. bool CanActivateCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.IsExistOnBattleArea(card)
  42. && CardEffectCommons.CanActivateSuspendCostEffect(card);
  43. }
  44. bool IsAdventureDigimon(CardSource cardSource, int reduction)
  45. {
  46. return cardSource.HasPlayCost
  47. && cardSource.EqualsTraits("ADVENTURE")
  48. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, true, activateClass, fixedCost: Math.Max(0, cardSource.GetCostItself - reduction));
  49. }
  50. IEnumerator ActivateCoroutine(Hashtable hashtable)
  51. {
  52. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SuspendPeremanentAndProcessAccordingToResult(
  53. new List<Permanent>() { card.PermanentOfThisCard() },
  54. activateClass,
  55. SuccessProcess,
  56. null));
  57. IEnumerator SuccessProcess(List<Permanent> suspendedPermaments)
  58. {
  59. List<CardSource> tamerCards = new List<CardSource>();
  60. foreach (Permanent permanent in card.Owner.GetBattleAreaPermanents())
  61. {
  62. if (permanent.IsTamer)
  63. {
  64. tamerCards.Add(permanent.TopCard);
  65. }
  66. }
  67. int reduceCost = Combinations.GetDifferenetColorCardCount(tamerCards) / 2;
  68. if (CardEffectCommons.HasMatchConditionOwnersHand(card, cardSource => IsAdventureDigimon(cardSource, reduceCost)))
  69. {
  70. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayByEffect(
  71. canTargetCondition: cardSource => IsAdventureDigimon(cardSource, reduceCost),
  72. SelectCardEffect.Root.Hand,
  73. activateClass,
  74. payCost: true,
  75. reduceCostTuple: (reduceCost, null)
  76. ));
  77. }
  78. }
  79. }
  80. }
  81. #endregion
  82. #region Security
  83. if (timing == EffectTiming.SecuritySkill)
  84. {
  85. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  86. }
  87. #endregion
  88. return cardEffects;
  89. }
  90. }
  91. }