BT22_060.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Datamon
  6. namespace DCGO.CardEffects.BT22
  7. {
  8. public class BT22_060 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.IsLevel4 && targetPermanent.TopCard.HasDMTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 3,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null)
  26. );
  27. }
  28. #endregion
  29. #region Blocker
  30. if (timing == EffectTiming.None)
  31. {
  32. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  33. }
  34. #endregion
  35. #region On Play
  36. if (timing == EffectTiming.OnEnterFieldAnyone)
  37. {
  38. ActivateClass activateClass = new ActivateClass();
  39. activateClass.SetUpICardEffect("Gain immunity to De-Digivolve & gain 1k DP for each FD source card", CanUseCondition, card);
  40. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  41. cardEffects.Add(activateClass);
  42. string EffectDiscription()
  43. {
  44. return "[On Play] Until your opponent's turn ends, their <De-Digivolve> effects don't affect this Digimon, and it gets +1000 DP for each of its face-down digivolution cards.";
  45. }
  46. bool CanUseCondition(Hashtable hashtable)
  47. {
  48. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  49. }
  50. bool CanActivateCondition(Hashtable hashtable)
  51. {
  52. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  53. }
  54. void ActivateDeDigivolveProtection()
  55. {
  56. Permanent thisPermanent = card.PermanentOfThisCard();
  57. bool CanUseImmunityCondition(Hashtable hashtable1)
  58. {
  59. return thisPermanent.TopCard != null;
  60. }
  61. bool PermanentImmunityCondition(Permanent permanent)
  62. {
  63. return permanent == thisPermanent;
  64. }
  65. ImmuneFromDeDigivolveClass immuneFromDeDigivolveClass = new ImmuneFromDeDigivolveClass();
  66. immuneFromDeDigivolveClass.SetUpICardEffect("Isn't affected by <De-Digivolve>", CanUseImmunityCondition, thisPermanent.TopCard);
  67. immuneFromDeDigivolveClass.SetUpImmuneFromDeDigivolveClass(PermanentCondition: PermanentImmunityCondition);
  68. thisPermanent.UntilOpponentTurnEndEffects.Add(_ => immuneFromDeDigivolveClass);
  69. }
  70. IEnumerator ActivateCoroutine(Hashtable hashtable)
  71. {
  72. var flippedCards = card.PermanentOfThisCard().DigivolutionCards.Count(x => x.IsFlipped);
  73. var dpBonus = flippedCards * 1000;
  74. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: card.PermanentOfThisCard(), changeValue: dpBonus, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  75. ActivateDeDigivolveProtection();
  76. }
  77. }
  78. #endregion
  79. #region When Digivolving
  80. if (timing == EffectTiming.OnEnterFieldAnyone)
  81. {
  82. ActivateClass activateClass = new ActivateClass();
  83. activateClass.SetUpICardEffect("Gain immunity to De-Digivolve & gain 1k DP for each FD source card", CanUseCondition, card);
  84. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  85. cardEffects.Add(activateClass);
  86. string EffectDiscription()
  87. {
  88. return "[When Digivolving] Until your opponent's turn ends, their <De-Digivolve> effects don't affect this Digimon, and it gets +1000 DP for each of its face-down digivolution cards.";
  89. }
  90. bool CanUseCondition(Hashtable hashtable)
  91. {
  92. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  93. }
  94. bool CanActivateCondition(Hashtable hashtable)
  95. {
  96. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  97. }
  98. void ActivateDeDigivolveProtection()
  99. {
  100. Permanent thisPermanent = card.PermanentOfThisCard();
  101. bool CanUseImmunityCondition(Hashtable hashtable1)
  102. {
  103. return thisPermanent.TopCard != null;
  104. }
  105. bool PermanentImmunityCondition(Permanent permanent)
  106. {
  107. return permanent == thisPermanent;
  108. }
  109. ImmuneFromDeDigivolveClass immuneFromDeDigivolveClass = new ImmuneFromDeDigivolveClass();
  110. immuneFromDeDigivolveClass.SetUpICardEffect("Isn't affected by <De-Digivolve>", CanUseImmunityCondition, thisPermanent.TopCard);
  111. immuneFromDeDigivolveClass.SetUpImmuneFromDeDigivolveClass(PermanentCondition: PermanentImmunityCondition);
  112. thisPermanent.UntilOpponentTurnEndEffects.Add(_ => immuneFromDeDigivolveClass);
  113. }
  114. IEnumerator ActivateCoroutine(Hashtable hashtable)
  115. {
  116. var flippedCards = card.PermanentOfThisCard().DigivolutionCards.Count(x => x.IsFlipped);
  117. var dpBonus = flippedCards * 1000;
  118. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: card.PermanentOfThisCard(), changeValue: dpBonus, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  119. ActivateDeDigivolveProtection();
  120. }
  121. }
  122. #endregion
  123. #region ESS
  124. if (timing == EffectTiming.OnEndTurn)
  125. {
  126. ActivateClass activateClass = new ActivateClass();
  127. activateClass.SetUpICardEffect("1 of your opponent's digimon attacks", CanUseCondition, card);
  128. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  129. activateClass.SetHashString("BT22_060_EndOfOpponentTurn");
  130. activateClass.SetIsInheritedEffect(true);
  131. cardEffects.Add(activateClass);
  132. string EffectDiscription()
  133. {
  134. return "[End of Opponent's Turn] [Once Per Turn] You may choose 1 of your opponent's Digimon. Your opponent attacks with the chosen Digimon.";
  135. }
  136. bool CanUseCondition(Hashtable hashtable)
  137. {
  138. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  139. && CardEffectCommons.IsOpponentTurn(card);
  140. }
  141. bool CanActivateCondition(Hashtable hashtable)
  142. {
  143. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  144. && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, OpponentDigimon);
  145. }
  146. bool OpponentDigimon(Permanent permanent)
  147. {
  148. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  149. && permanent.CanAttack(activateClass);
  150. }
  151. IEnumerator ActivateCoroutine(Hashtable hashtable)
  152. {
  153. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, OpponentDigimon))
  154. {
  155. Permanent selectedPermanent = null;
  156. #region Select Permanent
  157. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, OpponentDigimon));
  158. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  159. selectPermanentEffect.SetUp(
  160. selectPlayer: card.Owner,
  161. canTargetCondition: OpponentDigimon,
  162. canTargetCondition_ByPreSelecetedList: null,
  163. canEndSelectCondition: null,
  164. maxCount: maxCount,
  165. canNoSelect: true,
  166. canEndNotMax: false,
  167. selectPermanentCoroutine: SelectPermanentCoroutine,
  168. afterSelectPermanentCoroutine: null,
  169. mode: SelectPermanentEffect.Mode.Custom,
  170. cardEffect: activateClass);
  171. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  172. {
  173. selectedPermanent = permanent;
  174. yield return null;
  175. }
  176. selectPermanentEffect.SetUpCustomMessage("Select 1 opponent's Digimon that will attack", "The opponent is selecting 1 Digimon that will attack");
  177. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  178. #endregion
  179. if (selectedPermanent != null)
  180. {
  181. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  182. selectAttackEffect.SetUp(
  183. attacker: selectedPermanent,
  184. canAttackPlayerCondition: () => true,
  185. defenderCondition: (permanent) => true,
  186. cardEffect: activateClass);
  187. selectAttackEffect.SetCanNotSelectNotAttack();
  188. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  189. }
  190. }
  191. }
  192. }
  193. #endregion
  194. return cardEffects;
  195. }
  196. }
  197. }