BT20_017.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects
  6. {
  7. //Regular Jesmon
  8. public class BT20_017 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region OnPlay WhenDigivovling
  14. if (timing == EffectTiming.OnEnterFieldAnyone)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Play token", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "Play 1 [Atho, René & Por] Token. (Digimon/White/6000 DP/<Reboot> <Blocker> <Decoy Red/Black>)";
  23. }
  24. bool CanUseCondition(Hashtable hashtable)
  25. {
  26. return (CardEffectCommons.CanTriggerOnPlay(hashtable, card) || CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card));
  27. }
  28. bool CanActivateCondition(Hashtable hashtable)
  29. {
  30. if (CardEffectCommons.IsExistOnBattleArea(card))
  31. {
  32. if (card.Owner.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame()) >= 1)
  33. {
  34. return true;
  35. }
  36. }
  37. return false;
  38. }
  39. //#TODO Implement token effect script
  40. IEnumerator ActivateCoroutine(Hashtable hashtable)
  41. {
  42. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayAthoRenePorToken(activateClass));
  43. }
  44. }
  45. #endregion
  46. #region AllTurns
  47. if (timing == EffectTiming.OnEnterFieldAnyone)
  48. {
  49. ActivateClass activateClass = new ActivateClass();
  50. activateClass.SetUpICardEffect("Play token", CanUseCondition, card);
  51. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDiscription());
  52. cardEffects.Add(activateClass);
  53. string EffectDiscription ()
  54. {
  55. return "When this Digimon would digivolve or leave the battle area, delete"
  56. }
  57. bool CanUseCondition (Hashtable hashtable)
  58. {
  59. if (CardEffectCommons.IsExistOnBattleArea(card))
  60. {
  61. if (!CardEffectCommons.IsOpponentTurn(card))
  62. {
  63. return true;
  64. }
  65. }
  66. return false;
  67. }
  68. bool CanSelectDeletePermanentCondition (Permanent permanent)
  69. {
  70. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  71. {
  72. if (permanent.CanBeRemoved() && permanent.DP <= 8000)
  73. {
  74. return true;
  75. }
  76. }
  77. return false;
  78. }
  79. bool CanSelectAttackPermanentCondition (Permanent permanent)
  80. {
  81. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  82. {
  83. if (permanent.CanAttack(activateClass))
  84. {
  85. if (card.Owner.Enemy.GetBattleAreaDigimons().Count((enemyDigimon) => permanent.CanAttackTargetDigimon(enemyDigimon, activateClass)) >= 1)
  86. {
  87. return true;
  88. }
  89. }
  90. }
  91. return false;
  92. }
  93. IEnumerator ActivateCoroutine (Hashtable hashtable)
  94. {
  95. List<Permanent> selectedPermanents = new List<Permanent>();
  96. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectDeletePermanentCondition))
  97. {
  98. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectDeletePermanentCondition));
  99. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  100. selectPermanentEffect.SetUp(
  101. selectPlayer: card.Owner,
  102. canTargetCondition: CanSelectDeletePermanentCondition,
  103. canTargetCondition_ByPreSelecetedList: null,
  104. canEndSelectCondition: null,
  105. maxCount: maxCount,
  106. canNoSelect: true,
  107. canEndNotMax: false,
  108. selectPermanentCoroutine: null,
  109. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  110. mode: SelectPermanentEffect.Mode.Custom,
  111. cardEffect: activateClass);
  112. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "Opponent is selecting one Digimon to delete.");
  113. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  114. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  115. {
  116. selectedPermanents = permanents;
  117. yield return null;
  118. }
  119. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  120. selectedPermanents,
  121. CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  122. }
  123. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectAttackPermanentCondition))
  124. {
  125. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectAttackPermanentCondition));
  126. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  127. selectPermanentEffect.SetUp(
  128. selectPlayer: card.Owner,
  129. canTargetCondition: CanSelectAttackPermanentCondition,
  130. canTargetCondition_ByPreSelecetedList: null,
  131. canEndSelectCondition: null,
  132. maxCount: maxCount,
  133. canNoSelect: true,
  134. canEndNotMax: false,
  135. selectPermanentCoroutine: null,
  136. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  137. mode: SelectPermanentEffect.Mode.Custom,
  138. cardEffect: activateClass);
  139. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will attack.", "Opponent is selecting on Digimon that will attack.");
  140. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  141. IEnumerator AfterSelectPermanentCoroutine (List<Permanent> permanents)
  142. {
  143. selectedPermanents = permanents;
  144. yield return null;
  145. }
  146. foreach (Permanent permanent in selectedPermanents)
  147. {
  148. Permanent selectedPermanent = permanent;
  149. if (selectedPermanent != null)
  150. {
  151. if (selectedPermanent.CanAttack(activateClass))
  152. {
  153. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  154. selectAttackEffect.SetUp(
  155. attacker: selectedPermanent,
  156. canAttackPlayerCondition: () => false,
  157. defenderCondition: (permanent) => true,
  158. cardEffect: activateClass);
  159. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  160. }
  161. }
  162. }
  163. }
  164. }
  165. }
  166. #endregion
  167. return cardEffects;
  168. }
  169. }
  170. }