BT21_018.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // DoGatchmon
  4. namespace DCGO.CardEffects.BT21
  5. {
  6. public class BT21_018 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Static effects
  12. #region Alternative Digivolution Condition - Stnd.
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.EqualsTraits("Stnd.");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region Raid
  23. if (timing == EffectTiming.OnAllyAttack)
  24. {
  25. cardEffects.Add(CardEffectFactory.RaidSelfEffect(isInheritedEffect: false, card: card, condition: null));
  26. }
  27. #endregion
  28. #region Rush
  29. if (timing == EffectTiming.None)
  30. {
  31. cardEffects.Add(CardEffectFactory.RushSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  32. }
  33. #endregion
  34. #region Link Condition
  35. if (timing == EffectTiming.None)
  36. {
  37. static bool PermanentCondition(Permanent targetPermanent)
  38. {
  39. return targetPermanent.TopCard.HasAppmonTraits;
  40. }
  41. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 2, card: card));
  42. }
  43. #endregion
  44. #region App Fusion (Gatchmon, Navimon, Tweetmon)
  45. if (timing == EffectTiming.None)
  46. {
  47. cardEffects.Add(CardEffectFactory.AddAppfuseMethodByName(new List<string>() { "Gatchmon", "Navimon", "Tweetmon" }, card));
  48. }
  49. #endregion
  50. #region Link
  51. if (timing == EffectTiming.OnDeclaration)
  52. {
  53. /// <summary>
  54. /// Used to link a card
  55. /// </summary>
  56. /// <param name="card">Reference to this card</param>
  57. /// <param name="condition">OPTIONAL - Function to check for effect conditions</param>
  58. /// <author>Mike Bunch</author>
  59. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  60. }
  61. #endregion
  62. #endregion
  63. #region Your Turn
  64. if (timing == EffectTiming.WhenLinked)
  65. {
  66. ActivateClass activateClass = new ActivateClass();
  67. activateClass.SetUpICardEffect("This digimon may attack", CanUseCondition, card);
  68. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  69. activateClass.SetHashString("WhenLinked_BT21_018");
  70. cardEffects.Add(activateClass);
  71. string EffectDiscription()
  72. => "[Your Turn] [Once Per Turn] When this Digimon gets linked, it may attack.";
  73. bool CanUseCondition(Hashtable hashtable)
  74. {
  75. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  76. {
  77. if (CardEffectCommons.CanTriggerWhenLinked(hashtable, LinkPermanentCondition, null))
  78. {
  79. return true;
  80. }
  81. }
  82. return false;
  83. }
  84. bool CanActivateCondition(Hashtable hashtable)
  85. {
  86. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  87. {
  88. if (CardEffectCommons.IsOwnerTurn(card))
  89. {
  90. if (card.PermanentOfThisCard().CanAttack(activateClass))
  91. {
  92. return true;
  93. }
  94. }
  95. }
  96. return false;
  97. }
  98. bool LinkPermanentCondition(Permanent permanent)
  99. {
  100. return permanent == card.PermanentOfThisCard();
  101. }
  102. IEnumerator ActivateCoroutine(Hashtable hashtable)
  103. {
  104. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  105. selectAttackEffect.SetUp(
  106. attacker: card.PermanentOfThisCard(),
  107. canAttackPlayerCondition: () => true,
  108. defenderCondition: (permanent) => true,
  109. cardEffect: activateClass);
  110. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  111. }
  112. }
  113. #endregion
  114. #region When Linked
  115. if (timing == EffectTiming.WhenLinked)
  116. {
  117. ActivateClass activateClass = new ActivateClass();
  118. activateClass.SetUpICardEffect("This digimon may attack", CanUseCondition, card);
  119. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  120. activateClass.SetIsLinkedEffect(true);
  121. cardEffects.Add(activateClass);
  122. string EffectDiscription()
  123. => "[When Linking] this Digimon may attack.";
  124. bool CanUseCondition(Hashtable hashtable)
  125. {
  126. UnityEngine.Debug.Log($"CAN USE: {CardEffectCommons.IsExistOnBattleAreaDigimon(card)}, {CardEffectCommons.CanTriggerWhenLinking(hashtable, PermanentCondition, card)}");
  127. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  128. {
  129. if (CardEffectCommons.CanTriggerWhenLinking(hashtable, PermanentCondition, card))
  130. {
  131. return true;
  132. }
  133. }
  134. return false;
  135. }
  136. bool CanActivateCondition(Hashtable hashtable)
  137. {
  138. UnityEngine.Debug.Log($"CAN ACTIVATE: {CardEffectCommons.IsExistOnBattleAreaDigimon(card)}, {card.PermanentOfThisCard().CanAttack(activateClass)}");
  139. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  140. {
  141. if (card.PermanentOfThisCard().CanAttack(activateClass))
  142. {
  143. return true;
  144. }
  145. }
  146. return false;
  147. }
  148. bool PermanentCondition(Permanent permanent)
  149. {
  150. return permanent == card.PermanentOfThisCard();
  151. }
  152. IEnumerator ActivateCoroutine(Hashtable hashtable)
  153. {
  154. if (CardEffectCommons.IsExistOnBattleArea(card))
  155. {
  156. if (card.PermanentOfThisCard().TopCard.PermanentOfThisCard().CanAttack(activateClass))
  157. {
  158. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  159. selectAttackEffect.SetUp(
  160. attacker: card.PermanentOfThisCard().TopCard.PermanentOfThisCard(),
  161. canAttackPlayerCondition: () => true,
  162. defenderCondition: (permanent) => true,
  163. cardEffect: activateClass);
  164. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  165. }
  166. }
  167. }
  168. }
  169. #endregion
  170. return cardEffects;
  171. }
  172. }
  173. }