Helloogarmon_BT16_010.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. namespace DCGO.CardEffects.BT16
  9. {
  10. public class Helloogarmon_BT16_010 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. # region Alternate Digivolution Requirement
  16. if (timing == EffectTiming.None)
  17. {
  18. bool PermanentCondition(Permanent targetPermanent)
  19. {
  20. if (targetPermanent.TopCard.ContainsTraits("SoC"))
  21. {
  22. return true;
  23. }
  24. return false;
  25. }
  26. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  27. permanentCondition: PermanentCondition,
  28. digivolutionCost: 3,
  29. ignoreDigivolutionRequirement: false,
  30. card: card,
  31. condition: null));
  32. }
  33. #endregion
  34. #region End of Opponent's Turn
  35. if (timing == EffectTiming.OnEndTurn)
  36. {
  37. ActivateClass activateClass = new ActivateClass();
  38. activateClass.SetUpICardEffect("Delete 1 Digimon", CanUseCondition, card);
  39. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  40. cardEffects.Add(activateClass);
  41. string EffectDiscription()
  42. {
  43. return "[End of Opponent's Turn] By deleting this Digimon, delete one of your opponent's Digimon with the lowest DP.";
  44. }
  45. bool CanUseCondition(Hashtable hashtable)
  46. {
  47. if (CardEffectCommons.IsOpponentTurn(card))
  48. {
  49. return true;
  50. }
  51. return false;
  52. }
  53. bool CanSelectPermanentCondition(Permanent permanent)
  54. {
  55. if(CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy))
  56. {
  57. if(permanent.IsDigimon)
  58. {
  59. return true;
  60. }
  61. }
  62. return false;
  63. }
  64. bool CanActivateCondition(Hashtable hashtable)
  65. {
  66. return CardEffectCommons.IsExistOnBattleArea(card);
  67. }
  68. IEnumerator ActivateCoroutine(Hashtable hashtable)
  69. {
  70. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  71. new List<Permanent>() { card.PermanentOfThisCard() },
  72. CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  73. List<Permanent> deleteTargetPermanents = new List<Permanent>();
  74. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  75. {
  76. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  77. selectPermanentEffect.SetUp(
  78. selectPlayer: card.Owner,
  79. canTargetCondition: CanSelectPermanentCondition,
  80. canTargetCondition_ByPreSelecetedList: null,
  81. canEndSelectCondition: null,
  82. maxCount: 1,
  83. canNoSelect: false,
  84. canEndNotMax: false,
  85. selectPermanentCoroutine: null,
  86. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  87. mode: SelectPermanentEffect.Mode.Custom,
  88. cardEffect: activateClass);
  89. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  90. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  91. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  92. {
  93. foreach (Permanent permanent in permanents)
  94. {
  95. deleteTargetPermanents.Add(permanent);
  96. }
  97. yield return null;
  98. }
  99. }
  100. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: deleteTargetPermanents, activateClass: activateClass, successProcess: null, failureProcess: FailureProcess));
  101. IEnumerator FailureProcess()
  102. {
  103. if (CardEffectCommons.IsExistOnBattleArea(card))
  104. {
  105. Permanent selectedPermanent = card.PermanentOfThisCard();
  106. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  107. }
  108. }
  109. }
  110. }
  111. #endregion
  112. #region On Deletion
  113. if (timing == EffectTiming.OnDestroyedAnyone)
  114. {
  115. ActivateClass activateClass = new ActivateClass();
  116. activateClass.SetUpICardEffect("Play Digimon or Tamer.", CanUseCondition, card);
  117. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  118. cardEffects.Add(activateClass);
  119. string EffectDiscription()
  120. {
  121. return "[On Deletion] You may play 1 [Loogamon] or [Eiji Nagasumi] from your trash without paying the cost";
  122. }
  123. bool CanSelectCardCondition(CardSource cardSource)
  124. {
  125. if (cardSource.CardNames.Contains("Loogamon") || cardSource.CardNames.Contains("Eiji Nagasumi"))
  126. {
  127. return true;
  128. }
  129. return false;
  130. }
  131. bool CanUseCondition(Hashtable hashtable)
  132. {
  133. if (CardEffectCommons.IsExistOnBattleArea(card))
  134. {
  135. return true;
  136. }
  137. return false;
  138. }
  139. bool CanActivateCondition(Hashtable hashtable)
  140. {
  141. return CardEffectCommons.IsExistOnBattleArea(card);
  142. }
  143. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  144. {
  145. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  146. {
  147. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  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. }