BT23_069.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Necromon
  5. namespace DCGO.CardEffects.BT23
  6. {
  7. public class BT23_069 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Execute
  13. if (timing == EffectTiming.OnEndTurn)
  14. {
  15. cardEffects.Add(CardEffectFactory.ExecuteSelfEffect(isInheritedEffect: false, card: card, condition: null));
  16. }
  17. #endregion
  18. #region OP/OD Shared
  19. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  20. {
  21. bool HasCorrectTrait(CardSource cardSource)
  22. {
  23. return cardSource.IsDigimon && cardSource.EqualsTraits("Ghost") &&
  24. cardSource.HasLevel && cardSource.Level <= 5 &&
  25. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  26. }
  27. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, HasCorrectTrait))
  28. {
  29. CardSource selectedCard = null;
  30. #region Select Digimon
  31. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  32. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, HasCorrectTrait));
  33. selectCardEffect.SetUp(
  34. canTargetCondition: HasCorrectTrait,
  35. canTargetCondition_ByPreSelecetedList: null,
  36. canEndSelectCondition: null,
  37. canNoSelect: () => true,
  38. selectCardCoroutine: SelectCardCoroutine,
  39. afterSelectCardCoroutine: null,
  40. message: "Select 1 Digimon card to play.",
  41. maxCount: maxCount,
  42. canEndNotMax: false,
  43. isShowOpponent: true,
  44. mode: SelectCardEffect.Mode.Custom,
  45. root: SelectCardEffect.Root.Trash,
  46. customRootCardList: null,
  47. canLookReverseCard: true,
  48. selectPlayer: card.Owner,
  49. cardEffect: activateClass);
  50. IEnumerator SelectCardCoroutine(CardSource cardSource)
  51. {
  52. selectedCard = cardSource;
  53. yield return null;
  54. }
  55. selectCardEffect.SetUpCustomMessage("Select 1 Digimon card to play.", "The opponent is selecting 1 Digimon card to play.");
  56. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  57. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  58. #endregion
  59. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  60. cardSources: new List<CardSource>() { selectedCard },
  61. activateClass: activateClass,
  62. payCost: false,
  63. isTapped: false,
  64. root: SelectCardEffect.Root.Trash,
  65. activateETB: true)
  66. );
  67. }
  68. }
  69. #endregion
  70. #region On Play
  71. if (timing == EffectTiming.OnEnterFieldAnyone)
  72. {
  73. ActivateClass activateClass = new ActivateClass();
  74. activateClass.SetUpICardEffect("You may play 1 level 5 or lower Digimon", CanUseCondition, card);
  75. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, EffectDescriptionShared());
  76. cardEffects.Add(activateClass);
  77. string EffectDescriptionShared()
  78. {
  79. return "[On Play] You may play 1 level 5 or lower Digimon card with the [Ghost] trait from your trash without paying the cost.";
  80. }
  81. bool CanUseCondition(Hashtable hashtable)
  82. {
  83. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  84. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  85. }
  86. bool CanActivateCondition(Hashtable hashtable)
  87. {
  88. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  89. }
  90. }
  91. #endregion
  92. #region On Deletion
  93. if (timing == EffectTiming.OnDestroyedAnyone)
  94. {
  95. ActivateClass activateClass = new ActivateClass();
  96. activateClass.SetUpICardEffect("You may play 1 level 5 or lower Digimon", CanUseCondition, card);
  97. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, EffectDescriptionShared());
  98. cardEffects.Add(activateClass);
  99. string EffectDescriptionShared()
  100. {
  101. return "[On Deletion] You may play 1 level 5 or lower Digimon card with the [Ghost] trait from your trash without paying the cost.";
  102. }
  103. bool CanUseCondition(Hashtable hashtable)
  104. {
  105. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  106. }
  107. bool CanActivateCondition(Hashtable hashtable)
  108. {
  109. return CardEffectCommons.CanActivateOnDeletion(card);
  110. }
  111. }
  112. #endregion
  113. #region All Turns
  114. if (timing == EffectTiming.OnAllyAttack)
  115. {
  116. Permanent attackingPermament = null;
  117. ActivateClass activateClass = new ActivateClass();
  118. activateClass.SetUpICardEffect("By deleting this digimon, delete 1 level 6 or lower digimon. if you didnt delete, you may end the attack", CanUseCondition, card);
  119. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  120. cardEffects.Add(activateClass);
  121. string EffectDiscription()
  122. {
  123. return "[All Turns] When another Digimon attacks, by deleting this Digimon, delete 1 of your opponent's level 6 or lower Digimon. If this effect didn't delete your opponent's Digimon, you may end that attack.";
  124. }
  125. bool CanUseCondition(Hashtable hashtable)
  126. {
  127. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  128. && CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, AttackingPermament);
  129. }
  130. bool CanActivateCondition(Hashtable hashtable)
  131. {
  132. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  133. }
  134. bool AttackingPermament(Permanent permanent)
  135. {
  136. attackingPermament = permanent;
  137. return CardEffectCommons.IsPermanentExistsOnBattleArea(permanent);
  138. }
  139. bool CanSelectPermanentCondition(Permanent permanent)
  140. {
  141. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  142. && permanent.TopCard.HasLevel && permanent.TopCard.Level <= 6;
  143. }
  144. IEnumerator ActivateCoroutine(Hashtable hashtable)
  145. {
  146. if (attackingPermament == null)
  147. {
  148. Permanent thisPermament = card.PermanentOfThisCard();
  149. #region Setup User Selection
  150. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  151. {
  152. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  153. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  154. };
  155. string selectPlayerMessage = "Will you delete Necromon?";
  156. string notSelectPlayerMessage = "The opponent is choosing to delete Necromon.";
  157. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  158. #endregion
  159. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  160. bool isDeleting = GManager.instance.userSelectionManager.SelectedBoolValue;
  161. if (isDeleting) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  162. targetPermanents: new List<Permanent>() { thisPermament },
  163. activateClass: activateClass,
  164. successProcess: DeleteNecromonSuccessProcess,
  165. failureProcess: null));
  166. IEnumerator DeleteNecromonSuccessProcess(List<Permanent> permanents)
  167. {
  168. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  169. {
  170. Permanent selectedPermament = null;
  171. #region Select Opponent Permament
  172. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  173. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  174. selectPermanentEffect.SetUp(
  175. selectPlayer: card.Owner,
  176. canTargetCondition: CanSelectPermanentCondition,
  177. canTargetCondition_ByPreSelecetedList: null,
  178. canEndSelectCondition: null,
  179. maxCount: maxCount,
  180. canNoSelect: false,
  181. canEndNotMax: false,
  182. selectPermanentCoroutine: SelectPermanentCoroutine,
  183. afterSelectPermanentCoroutine: null,
  184. mode: SelectPermanentEffect.Mode.Custom,
  185. cardEffect: activateClass);
  186. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  187. {
  188. selectedPermament = permanent;
  189. yield return null;
  190. }
  191. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to delete", "Your opponent is selecting 1 digimon to delete");
  192. #endregion
  193. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  194. if (selectPermanentEffect != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  195. new List<Permanent>() { selectedPermament },
  196. activateClass: activateClass,
  197. successProcess: null,
  198. failureProcess: OpponentLevel6FailureProcess));
  199. IEnumerator OpponentLevel6FailureProcess()
  200. {
  201. #region Setup User Selection
  202. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  203. {
  204. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  205. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  206. };
  207. string selectPlayerMessage = "Will you end the attack?";
  208. string notSelectPlayerMessage = "The opponent is choosing to end the attack.";
  209. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  210. #endregion
  211. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  212. bool endAttack = GManager.instance.userSelectionManager.SelectedBoolValue;
  213. if (endAttack)
  214. {
  215. GManager.instance.attackProcess.IsEndAttack = true;
  216. yield return null;
  217. }
  218. yield return null;
  219. }
  220. }
  221. yield return null;
  222. }
  223. }
  224. }
  225. }
  226. #endregion
  227. return cardEffects;
  228. }
  229. }
  230. }