BT21_083.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Taiki Kudo
  5. namespace DCGO.CardEffects.BT21
  6. {
  7. public class BT21_083 : 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 Main Phase
  13. if (timing == EffectTiming.OnStartMainPhase)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Place digimon under tamer to draw 1 gain 1", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Start of Your Main Phase] By placing 1 Digimon card with the [Xros Heart]/[Blue Flare]/[Hero] trait from your hand under this Tamer, <Draw 1> (Draw 1 card from your deck) and gain 1 memory.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. if (CardEffectCommons.IsExistOnBattleArea(card))
  26. {
  27. if (CardEffectCommons.IsOwnerTurn(card))
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. bool CanActivateCondition(Hashtable hashtable)
  35. {
  36. if (CardEffectCommons.IsExistOnBattleArea(card))
  37. {
  38. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectDigimon))
  39. {
  40. return true;
  41. }
  42. }
  43. return false;
  44. }
  45. bool CanSelectDigimon(CardSource card)
  46. {
  47. if (card.IsDigimon)
  48. {
  49. if (card.EqualsTraits("Xros Heart") || card.EqualsTraits("Blue Flare") || card.EqualsTraits("Hero"))
  50. {
  51. return true;
  52. }
  53. }
  54. return false;
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable hashtable)
  57. {
  58. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectDigimon))
  59. {
  60. CardSource selectedCard = null;
  61. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, CanSelectDigimon));
  62. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  63. selectHandEffect.SetUp(
  64. selectPlayer: card.Owner,
  65. canTargetCondition: CanSelectDigimon,
  66. canTargetCondition_ByPreSelecetedList: null,
  67. canEndSelectCondition: null,
  68. maxCount: maxCount,
  69. canNoSelect: true,
  70. canEndNotMax: false,
  71. isShowOpponent: true,
  72. selectCardCoroutine: SelectCardCoroutine,
  73. afterSelectCardCoroutine: null,
  74. mode: SelectHandEffect.Mode.Custom,
  75. cardEffect: activateClass);
  76. selectHandEffect.SetUpCustomMessage("Select 1 digimon to place under tamer.", "The opponent is selecting 1 digimon to place under tamer.");
  77. selectHandEffect.SetUpCustomMessage_ShowCard("Selected digimon");
  78. yield return StartCoroutine(selectHandEffect.Activate());
  79. IEnumerator SelectCardCoroutine(CardSource cardSource)
  80. {
  81. selectedCard = cardSource;
  82. yield return null;
  83. }
  84. if (selectedCard != null)
  85. {
  86. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass));
  87. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  88. if (card.Owner.CanAddMemory(activateClass))
  89. {
  90. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  91. }
  92. }
  93. }
  94. }
  95. }
  96. #endregion
  97. #region Your Turn
  98. if (timing == EffectTiming.OnEnterFieldAnyone)
  99. {
  100. List<Permanent> playedPermanents = new List<Permanent>();
  101. ActivateClass activateClass = new ActivateClass();
  102. activateClass.SetUpICardEffect("Suspend this tamer, Attack with a [Xros Heart]/[Hero] Digimon", CanUseCondition, card);
  103. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  104. cardEffects.Add(activateClass);
  105. string EffectDiscription()
  106. {
  107. return "[Your Turn] When your Digimon are played or digivolve, if any of them have the [Xros Heart]/[Hero] trait, by suspending this Tamer, one of them may attack.";
  108. }
  109. bool CanUseCondition(Hashtable hashtable)
  110. {
  111. if (CardEffectCommons.IsExistOnBattleArea(card))
  112. {
  113. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition) || CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, PermanentCondition))
  114. {
  115. return true;
  116. }
  117. }
  118. return false;
  119. }
  120. bool CanActivateCondition(Hashtable hashtable)
  121. {
  122. if (CardEffectCommons.IsExistOnBattleArea(card))
  123. {
  124. if (CardEffectCommons.IsOwnerTurn(card))
  125. {
  126. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  127. {
  128. return true;
  129. }
  130. }
  131. }
  132. return false;
  133. }
  134. bool PermanentCondition(Permanent permanent)
  135. {
  136. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  137. (permanent.TopCard.EqualsTraits("Xros Heart") || permanent.TopCard.EqualsTraits("Hero"));
  138. }
  139. IEnumerator ActivateCoroutine(Hashtable hashtable)
  140. {
  141. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  142. foreach(Hashtable hash in CardEffectCommons.GetHashtablesFromHashtable(hashtable))
  143. {
  144. playedPermanents.Add(CardEffectCommons.GetPermanentFromHashtable(hash));
  145. }
  146. bool AttackingPermanentCondition(Permanent permanent)
  147. {
  148. if (playedPermanents.Contains(permanent))
  149. {
  150. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  151. {
  152. if (permanent.TopCard.EqualsTraits("Xros Heart") || permanent.TopCard.EqualsTraits("Hero"))
  153. {
  154. if (permanent.CanAttack(activateClass))
  155. {
  156. return true;
  157. }
  158. }
  159. }
  160. }
  161. return false;
  162. }
  163. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, AttackingPermanentCondition))
  164. {
  165. Permanent selectedPermanent = null;
  166. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, AttackingPermanentCondition));
  167. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  168. selectPermanentEffect.SetUp(
  169. selectPlayer: card.Owner,
  170. canTargetCondition: AttackingPermanentCondition,
  171. canTargetCondition_ByPreSelecetedList: null,
  172. canEndSelectCondition: null,
  173. maxCount: maxCount,
  174. canNoSelect: false,
  175. canEndNotMax: false,
  176. selectPermanentCoroutine: SelectPermanentCoroutine,
  177. afterSelectPermanentCoroutine: null,
  178. mode: SelectPermanentEffect.Mode.Custom,
  179. cardEffect: activateClass);
  180. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to attack", "The opponent is selecting 1 digimon to attack");
  181. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  182. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  183. {
  184. selectedPermanent = permanent;
  185. if(selectedPermanent.CanAttack(activateClass))
  186. {
  187. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  188. selectAttackEffect.SetUp(
  189. attacker: selectedPermanent,
  190. canAttackPlayerCondition: () => true,
  191. defenderCondition: (permanent) => true,
  192. cardEffect: activateClass);
  193. selectAttackEffect.SetCanNotSelectNotAttack();
  194. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  195. }
  196. }
  197. /*if (selectedPermanent != null)
  198. {
  199. if (selectedPermanent.CanAttack(activateClass))
  200. {
  201. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  202. selectAttackEffect.SetUp(
  203. attacker: selectedPermanent,
  204. canAttackPlayerCondition: () => true,
  205. defenderCondition: (permanent) => true,
  206. cardEffect: activateClass);
  207. selectAttackEffect.SetCanNotSelectNotAttack();
  208. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  209. }
  210. }*/
  211. }
  212. }
  213. }
  214. #endregion
  215. #region Security
  216. if (timing == EffectTiming.SecuritySkill)
  217. {
  218. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  219. }
  220. #endregion
  221. return cardEffects;
  222. }
  223. }
  224. }