P_169.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.P
  6. {
  7. public class P_169 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Start of Your Main Phase
  13. if (timing == EffectTiming.OnStartMainPhase)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  18. cardEffects.Add(activateClass);
  19. string EffectDescription()
  20. {
  21. return "[Start of Your Main Phase] If your opponent has a Digimon, gain 1 memory.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.IsExistOnBattleArea(card) &&
  26. CardEffectCommons.IsOwnerTurn(card);
  27. }
  28. bool CanActivateCondition(Hashtable hashtable)
  29. {
  30. return CardEffectCommons.IsExistOnBattleArea(card) &&
  31. card.Owner.Enemy.GetBattleAreaDigimons().Count >= 1 &&
  32. card.Owner.CanAddMemory(activateClass);
  33. }
  34. IEnumerator ActivateCoroutine(Hashtable hashtable)
  35. {
  36. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  37. }
  38. }
  39. #endregion
  40. #region All Turns
  41. if (timing == EffectTiming.OnDigivolutionCardDiscarded)
  42. {
  43. Permanent trashedFromPermanent = null;
  44. ActivateClass activateClass = new ActivateClass();
  45. activateClass.SetUpICardEffect("Place 1 digivolution card", CanUseCondition, card);
  46. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  47. cardEffects.Add(activateClass);
  48. string EffectDescription()
  49. {
  50. return "[All Turns] When effects trash digivolution cards from any of your [Mineral] or [Rock] trait Digimon, by suspending this Tamer, place 1 card with the [Mineral] or [Rock] trait from your trash as any of those Digimon's bottom digivolution card.";
  51. }
  52. bool IsRockMineralDigimon(Permanent permanent)
  53. {
  54. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  55. permanent.TopCard.EqualsTraits("Mineral") || permanent.TopCard.EqualsTraits("Rock");
  56. }
  57. bool HasProperTraits(CardSource source)
  58. {
  59. return (source.EqualsTraits("Mineral") || source.EqualsTraits("Rock"));
  60. }
  61. bool CanSelectDigimonToAddSources(Permanent permanent)
  62. {
  63. return permanent == trashedFromPermanent;
  64. }
  65. bool CanUseCondition(Hashtable hashtable)
  66. {
  67. trashedFromPermanent = CardEffectCommons.GetPermanentFromHashtable(hashtable);
  68. return isExistOnField(card) &&
  69. CardEffectCommons.IsOwnerPermanent(trashedFromPermanent, card) &&
  70. IsRockMineralDigimon(trashedFromPermanent);
  71. }
  72. bool CanActivateCondition(Hashtable hashtable)
  73. {
  74. return isExistOnField(card) && CardEffectCommons.CanActivateSuspendCostEffect(card);
  75. }
  76. IEnumerator ActivateCoroutine(Hashtable hashtable)
  77. {
  78. Permanent selectedPermanent = null;
  79. List<CardSource> selectedCards = new List<CardSource>();
  80. yield return ContinuousController.instance.StartCoroutine(
  81. new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() },
  82. CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  83. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  84. selectPermanentEffect.SetUp(
  85. selectPlayer: card.Owner,
  86. canTargetCondition: CanSelectDigimonToAddSources,
  87. canTargetCondition_ByPreSelecetedList: null,
  88. canEndSelectCondition: null,
  89. maxCount: 1,
  90. canNoSelect: true,
  91. canEndNotMax: false,
  92. selectPermanentCoroutine: SelectPermanentCoroutine,
  93. afterSelectPermanentCoroutine: null,
  94. mode: SelectPermanentEffect.Mode.Custom,
  95. cardEffect: activateClass);
  96. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card.");
  97. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  98. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  99. {
  100. if (permanent != null)
  101. selectedPermanent = permanent;
  102. yield return null;
  103. }
  104. if(selectedPermanent != null)
  105. {
  106. if(CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, HasProperTraits))
  107. {
  108. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  109. selectCardEffect.SetUp(
  110. canTargetCondition: HasProperTraits,
  111. canTargetCondition_ByPreSelecetedList: null,
  112. canEndSelectCondition: CanEndSelectCondition,
  113. canNoSelect: () => true,
  114. selectCardCoroutine: SelectCardCoroutine,
  115. afterSelectCardCoroutine: null,
  116. message: "Select [Mineral] or [Rock] to place on bottom of digivolution cards.",
  117. maxCount: 1,
  118. canEndNotMax: true,
  119. isShowOpponent: true,
  120. mode: SelectCardEffect.Mode.Custom,
  121. root: SelectCardEffect.Root.Trash,
  122. customRootCardList: null,
  123. canLookReverseCard: true,
  124. selectPlayer: card.Owner,
  125. cardEffect: activateClass);
  126. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  127. selectCardEffect.SetUpCustomMessage("Select [Mineral] or [Rock] to place on bottom of digivolution cards.", "The opponent is selecting [Mineral] or [Rock] to place on bottom of digivolution cards.");
  128. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  129. bool CanEndSelectCondition(List<CardSource> cardSources)
  130. {
  131. if (CardEffectCommons.HasNoElement(cardSources))
  132. {
  133. return false;
  134. }
  135. return true;
  136. }
  137. IEnumerator SelectCardCoroutine(CardSource cardSource)
  138. {
  139. selectedCards.Add(cardSource);
  140. yield return null;
  141. }
  142. if (selectedCards.Count >= 1)
  143. {
  144. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  145. }
  146. }
  147. }
  148. }
  149. }
  150. #endregion
  151. #region Security Effect
  152. if (timing == EffectTiming.SecuritySkill)
  153. {
  154. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  155. }
  156. #endregion
  157. return cardEffects;
  158. }
  159. }
  160. }