BT17_059.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT17
  5. {
  6. public class BT17_059 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region When Digivolving
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("By placing [Doomsday Clock] in sources, Play 2 Diaboromon tokens", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[When Digivolving] By placing 1 [Doomsday Clock] from your hand or trash as this Digimon's bottom digivolution card, you may play 2 [Diaboromon] (Digimon | 14 Cost | Level 6 | White | Mega | Unknown | Unidentified | DP3000) Tokens without paying its cost.";
  21. }
  22. bool HasDoomsdayClock(CardSource source)
  23. {
  24. return source.EqualsCardName("Doomsday Clock");
  25. }
  26. bool CanUseCondition(Hashtable hashtable)
  27. {
  28. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  29. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  30. return false;
  31. }
  32. bool CanActivateCondition(Hashtable hashtable)
  33. {
  34. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  35. {
  36. if (CardEffectCommons.HasMatchConditionOwnersHand(card, HasDoomsdayClock) || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, HasDoomsdayClock))
  37. {
  38. return true;
  39. }
  40. }
  41. return false;
  42. }
  43. IEnumerator ActivateCoroutine(Hashtable hashtable)
  44. {
  45. bool validCardInTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, HasDoomsdayClock);
  46. bool validCardInHand = CardEffectCommons.HasMatchConditionOwnersHand(card, HasDoomsdayClock);
  47. bool useTrash = false;
  48. bool cardAdded = false;
  49. if (validCardInTrash || validCardInHand)
  50. {
  51. #region Selecting Hand or Trash
  52. if (validCardInTrash && validCardInHand)
  53. {
  54. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  55. {
  56. new SelectionElement<int>(message: $"Trash", value : 0, spriteIndex: 0),
  57. new SelectionElement<int>(message: $"Hand", value : 1, spriteIndex: 0),
  58. new SelectionElement<int>(message: $"No Selection", value : 2, spriteIndex: 1),
  59. };
  60. string selectPlayerMessage = "Will you use a card from hand or trash?";
  61. string notSelectPlayerMessage = "The opponent is choosing whether use a card from hand or trash.";
  62. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  63. }
  64. else if (validCardInTrash && !validCardInHand)
  65. {
  66. GManager.instance.userSelectionManager.SetInt(0);
  67. }
  68. else if (!validCardInTrash && validCardInHand)
  69. {
  70. GManager.instance.userSelectionManager.SetInt(1);
  71. }
  72. else
  73. {
  74. GManager.instance.userSelectionManager.SetInt(2);
  75. }
  76. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  77. useTrash = (GManager.instance.userSelectionManager.SelectedIntValue == 0);
  78. #endregion
  79. if (GManager.instance.userSelectionManager.SelectedIntValue != 2)
  80. {
  81. #region Card Selection
  82. IEnumerator SelectCardCoroutine(CardSource cardSource)
  83. {
  84. if(cardSource != null)
  85. {
  86. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(
  87. new List<CardSource>() { cardSource },
  88. activateClass));
  89. cardAdded = true;
  90. }
  91. }
  92. if (!useTrash)
  93. {
  94. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  95. selectHandEffect.SetUp(
  96. selectPlayer: card.Owner,
  97. canTargetCondition: HasDoomsdayClock,
  98. canTargetCondition_ByPreSelecetedList: null,
  99. canEndSelectCondition: null,
  100. maxCount: 1,
  101. canNoSelect: true,
  102. canEndNotMax: false,
  103. isShowOpponent: true,
  104. selectCardCoroutine: SelectCardCoroutine,
  105. afterSelectCardCoroutine: null,
  106. mode: SelectHandEffect.Mode.Custom,
  107. cardEffect: activateClass);
  108. selectHandEffect.SetUpCustomMessage(
  109. "Select 1 card to place at the bottom of digivolution cards.",
  110. "The opponent is selecting 1 card to place at the bottom of digivolution cards.");
  111. selectHandEffect.SetUpCustomMessage_ShowCard("Place bottom digivolution card");
  112. yield return StartCoroutine(selectHandEffect.Activate());
  113. }
  114. else
  115. {
  116. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  117. selectCardEffect.SetUp(
  118. canTargetCondition: HasDoomsdayClock,
  119. canTargetCondition_ByPreSelecetedList: null,
  120. canEndSelectCondition: null,
  121. canNoSelect: () => true,
  122. selectCardCoroutine: SelectCardCoroutine,
  123. afterSelectCardCoroutine: null,
  124. message: "Select 1 card to play.",
  125. maxCount: 1,
  126. canEndNotMax: false,
  127. isShowOpponent: true,
  128. mode: SelectCardEffect.Mode.Custom,
  129. root: SelectCardEffect.Root.Trash,
  130. customRootCardList: null,
  131. canLookReverseCard: true,
  132. selectPlayer: card.Owner,
  133. cardEffect: activateClass);
  134. selectCardEffect.SetUpCustomMessage(
  135. "Select 1 card to place at the bottom of digivolution cards.",
  136. "The opponent is selecting 1 card to place at the bottom of digivolution cards.");
  137. selectCardEffect.SetUpCustomMessage_ShowCard("Place bottom digivolution card");
  138. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  139. }
  140. #endregion
  141. }
  142. }
  143. if (cardAdded)
  144. {
  145. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayDiaboromonToken(activateClass, 2));
  146. }
  147. }
  148. }
  149. #endregion
  150. #region Opponents Turn
  151. if (timing == EffectTiming.OnAllyAttack)
  152. {
  153. ActivateClass activateClass = new ActivateClass();
  154. activateClass.SetUpICardEffect("Switch attack target to a [Diaboromon]", CanUseCondition, card);
  155. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  156. activateClass.SetHashString("AttackSwitch_BT17_059");
  157. cardEffects.Add(activateClass);
  158. string EffectDiscription()
  159. {
  160. return "[Opponent's Turn] [Once Per Turn] When one of your opponent's Digimon attacks, you may switch the attack target to 1 of your Digimon with [Diaboromon] in its name.";
  161. }
  162. bool AttackingPermanent(Permanent permanent)
  163. {
  164. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  165. }
  166. bool DefendingPermanent(Permanent permanent)
  167. {
  168. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  169. return permanent.TopCard.ContainsCardName("Diaboromon");
  170. return false;
  171. }
  172. bool CanUseCondition(Hashtable hashtable)
  173. {
  174. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  175. {
  176. if(CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, AttackingPermanent))
  177. {
  178. return true;
  179. }
  180. }
  181. return false;
  182. }
  183. bool CanActivateCondition(Hashtable hashtable)
  184. {
  185. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  186. {
  187. if (GManager.instance.attackProcess.AttackingPermanent != null)
  188. {
  189. if (GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget)
  190. {
  191. if (CardEffectCommons.HasMatchConditionPermanent(DefendingPermanent))
  192. {
  193. return true;
  194. }
  195. }
  196. }
  197. }
  198. return false;
  199. }
  200. IEnumerator ActivateCoroutine(Hashtable hashtable)
  201. {
  202. if (CardEffectCommons.HasMatchConditionPermanent(DefendingPermanent))
  203. {
  204. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(DefendingPermanent));
  205. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  206. selectPermanentEffect.SetUp(
  207. selectPlayer: card.Owner,
  208. canTargetCondition: DefendingPermanent,
  209. canTargetCondition_ByPreSelecetedList: null,
  210. canEndSelectCondition: null,
  211. maxCount: maxCount,
  212. canNoSelect: false,
  213. canEndNotMax: false,
  214. selectPermanentCoroutine: SelectPermanentCoroutine,
  215. afterSelectPermanentCoroutine: null,
  216. mode: SelectPermanentEffect.Mode.Custom,
  217. cardEffect: activateClass);
  218. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that opponent's Digimon attacks to.", "The opponent is selecting 1 Digimon that opponent's Digimon attacks to.");
  219. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  220. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  221. {
  222. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  223. activateClass,
  224. false,
  225. permanent));
  226. }
  227. }
  228. }
  229. }
  230. #endregion
  231. return cardEffects;
  232. }
  233. }
  234. }