BT16_010.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT16
  6. {
  7. public class BT16_010 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. # region Alternate Digivolution Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. if (targetPermanent.TopCard.ContainsTraits("SoC"))
  18. {
  19. if (targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4)
  20. return true;
  21. }
  22. return false;
  23. }
  24. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  25. permanentCondition: PermanentCondition,
  26. digivolutionCost: 3,
  27. ignoreDigivolutionRequirement: false,
  28. card: card,
  29. condition: null));
  30. }
  31. #endregion
  32. #region Retaliation
  33. if (timing == EffectTiming.OnDestroyedAnyone)
  34. {
  35. cardEffects.Add(CardEffectFactory.RetaliationSelfEffect(isInheritedEffect: false, card: card, condition: null));
  36. }
  37. #endregion
  38. #region End of Opponent's Turn
  39. if (timing == EffectTiming.OnEndTurn)
  40. {
  41. ActivateClass activateClass = new ActivateClass();
  42. activateClass.SetUpICardEffect("Delete 1 Digimon", CanUseCondition, card);
  43. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  44. cardEffects.Add(activateClass);
  45. string EffectDiscription()
  46. {
  47. return "[End of Opponent's Turn] By deleting this Digimon, delete one of your opponent's Digimon with the lowest DP.";
  48. }
  49. bool CanUseCondition(Hashtable hashtable)
  50. {
  51. if (CardEffectCommons.IsOpponentTurn(card))
  52. {
  53. return true;
  54. }
  55. return false;
  56. }
  57. bool CanSelectPermanentCondition(Permanent permanent)
  58. {
  59. if (CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy))
  60. {
  61. if (permanent.IsDigimon)
  62. {
  63. return true;
  64. }
  65. }
  66. return false;
  67. }
  68. bool CanActivateCondition(Hashtable hashtable)
  69. {
  70. return CardEffectCommons.IsExistOnBattleArea(card);
  71. }
  72. IEnumerator ActivateCoroutine(Hashtable hashtable)
  73. {
  74. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  75. new List<Permanent>() { card.PermanentOfThisCard() },
  76. CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  77. List<Permanent> deleteTargetPermanents = new List<Permanent>();
  78. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  79. {
  80. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  81. selectPermanentEffect.SetUp(
  82. selectPlayer: card.Owner,
  83. canTargetCondition: CanSelectPermanentCondition,
  84. canTargetCondition_ByPreSelecetedList: null,
  85. canEndSelectCondition: null,
  86. maxCount: 1,
  87. canNoSelect: false,
  88. canEndNotMax: false,
  89. selectPermanentCoroutine: null,
  90. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  91. mode: SelectPermanentEffect.Mode.Custom,
  92. cardEffect: activateClass);
  93. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  94. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  95. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  96. {
  97. foreach (Permanent permanent in permanents)
  98. {
  99. deleteTargetPermanents.Add(permanent);
  100. }
  101. yield return null;
  102. }
  103. }
  104. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: deleteTargetPermanents, activateClass: activateClass, successProcess: null, failureProcess: FailureProcess));
  105. IEnumerator FailureProcess()
  106. {
  107. if (CardEffectCommons.IsExistOnBattleArea(card))
  108. {
  109. Permanent selectedPermanent = card.PermanentOfThisCard();
  110. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  111. }
  112. }
  113. }
  114. }
  115. #endregion
  116. #region On Deletion
  117. if (timing == EffectTiming.OnDestroyedAnyone)
  118. {
  119. ActivateClass activateClass = new ActivateClass();
  120. activateClass.SetUpICardEffect("Play Digimon or Tamer.", CanUseCondition, card);
  121. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  122. cardEffects.Add(activateClass);
  123. string EffectDiscription()
  124. {
  125. return "[On Deletion] You may play 1 [Loogamon] or [Eiji Nagasumi] from your trash without paying the cost";
  126. }
  127. bool CanSelectCardCondition(CardSource cardSource)
  128. {
  129. if (cardSource.CardNames.Contains("Loogamon") || cardSource.CardNames.Contains("Eiji Nagasumi") || cardSource.CardNames.Contains("EijiNagasumi"))
  130. {
  131. return true;
  132. }
  133. return false;
  134. }
  135. bool CanUseCondition(Hashtable hashtable)
  136. {
  137. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  138. }
  139. bool CanActivateCondition(Hashtable hashtable)
  140. {
  141. return CardEffectCommons.CanActivateOnDeletion(card, activateClass);
  142. }
  143. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  144. {
  145. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  146. {
  147. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  148. List<CardSource> selectedCards = new List<CardSource>();
  149. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  150. selectCardEffect.SetUp(
  151. canTargetCondition: CanSelectCardCondition,
  152. canTargetCondition_ByPreSelecetedList: null,
  153. canEndSelectCondition: null,
  154. canNoSelect: () => true,
  155. selectCardCoroutine: SelectCardCoroutine,
  156. afterSelectCardCoroutine: null,
  157. message: "Select 1 card to play.",
  158. maxCount: maxCount,
  159. canEndNotMax: false,
  160. isShowOpponent: true,
  161. mode: SelectCardEffect.Mode.Custom,
  162. root: SelectCardEffect.Root.Trash,
  163. customRootCardList: null,
  164. canLookReverseCard: true,
  165. selectPlayer: card.Owner,
  166. cardEffect: activateClass);
  167. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  168. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  169. yield return StartCoroutine(selectCardEffect.Activate());
  170. IEnumerator SelectCardCoroutine(CardSource cardSource)
  171. {
  172. selectedCards.Add(cardSource);
  173. yield return null;
  174. }
  175. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  176. cardSources: selectedCards,
  177. activateClass: activateClass,
  178. payCost: false,
  179. isTapped: false,
  180. root: SelectCardEffect.Root.Trash,
  181. activateETB: true));
  182. }
  183. }
  184. }
  185. #endregion
  186. return cardEffects;
  187. }
  188. }
  189. }