EX4_011.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.EX4
  5. {
  6. public class EX4_011 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.None)
  12. {
  13. bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return targetPermanent.TopCard.ContainsCardName("WarGrowlmon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5;
  16. }
  17. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  18. }
  19. if (timing == EffectTiming.OnEndTurn)
  20. {
  21. ActivateClass activateClass = new ActivateClass();
  22. activateClass.SetUpICardEffect("Play this card", CanUseCondition, card);
  23. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  24. cardEffects.Add(activateClass);
  25. string EffectDiscription()
  26. {
  27. return "[Trash][End of Your Turn] By deleting 1 of your Digimon with digivolution cards and [Gallantmon] in its name, you may play this card without paying the cost.";
  28. }
  29. bool CanSelectPermanentCondition(Permanent permanent)
  30. {
  31. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  32. {
  33. if (permanent.DigivolutionCards.Count >= 1)
  34. {
  35. if (permanent.TopCard.ContainsCardName("Gallantmon"))
  36. {
  37. return true;
  38. }
  39. }
  40. }
  41. return false;
  42. }
  43. bool CanUseCondition(Hashtable hashtable)
  44. {
  45. if (CardEffectCommons.IsExistOnTrash(card))
  46. {
  47. if (CardEffectCommons.IsOwnerTurn(card))
  48. {
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54. bool CanActivateCondition(Hashtable hashtable)
  55. {
  56. if (CardEffectCommons.IsExistOnTrash(card))
  57. {
  58. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  59. {
  60. return true;
  61. }
  62. }
  63. return false;
  64. }
  65. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  66. {
  67. if (CardEffectCommons.IsExistOnTrash(card))
  68. {
  69. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  70. {
  71. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  72. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  73. selectPermanentEffect.SetUp(
  74. selectPlayer: card.Owner,
  75. canTargetCondition: CanSelectPermanentCondition,
  76. canTargetCondition_ByPreSelecetedList: null,
  77. canEndSelectCondition: null,
  78. maxCount: maxCount,
  79. canNoSelect: true,
  80. canEndNotMax: false,
  81. selectPermanentCoroutine: SelectPermanentCoroutine,
  82. afterSelectPermanentCoroutine: null,
  83. mode: SelectPermanentEffect.Mode.Custom,
  84. cardEffect: activateClass);
  85. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  86. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  87. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  88. {
  89. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  90. IEnumerator SuccessProcess()
  91. {
  92. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: card, payCost: false, cardEffect: activateClass, root: SelectCardEffect.Root.Trash))
  93. {
  94. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  95. {
  96. new SelectionElement<bool>(message: $"Play the card", value : true, spriteIndex: 0),
  97. new SelectionElement<bool>(message: $"Not play", value : false, spriteIndex: 1),
  98. };
  99. string selectPlayerMessage = "Will you play the card?";
  100. string notSelectPlayerMessage = "The opponent is choosing which to play the card.";
  101. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  102. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  103. bool playCard = GManager.instance.userSelectionManager.SelectedBoolValue;
  104. if (playCard)
  105. {
  106. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  107. cardSources: new List<CardSource>() { card },
  108. activateClass: activateClass,
  109. payCost: false,
  110. isTapped: false,
  111. root: SelectCardEffect.Root.Trash,
  112. activateETB: true));
  113. }
  114. }
  115. }
  116. }
  117. }
  118. }
  119. }
  120. }
  121. if (timing == EffectTiming.OnEnterFieldAnyone)
  122. {
  123. ActivateClass activateClass = new ActivateClass();
  124. activateClass.SetUpICardEffect($"Delete 1 Digimon", CanUseCondition, card);
  125. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  126. cardEffects.Add(activateClass);
  127. string EffectDiscription()
  128. {
  129. return "[On Play] Delete 1 of your opponent's Digimon with 7000 DP or less. For every 10 total cards in both players' trashes, add 2000 to the maximum this DP-based deletion effect can delete.";
  130. }
  131. int maxDP()
  132. {
  133. int maxDP = 7000;
  134. int trashSum = 0;
  135. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  136. {
  137. trashSum += player.TrashCards.Count;
  138. }
  139. maxDP += 2000 * (trashSum / 10);
  140. return maxDP;
  141. }
  142. bool CanSelectPermanentCondition(Permanent permanent)
  143. {
  144. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  145. {
  146. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(maxDP(), activateClass))
  147. {
  148. return true;
  149. }
  150. }
  151. return false;
  152. }
  153. bool CanUseCondition(Hashtable hashtable)
  154. {
  155. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  156. }
  157. bool CanActivateCondition(Hashtable hashtable)
  158. {
  159. if (CardEffectCommons.IsExistOnBattleArea(card))
  160. {
  161. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  162. {
  163. activateClass.SetEffectName($"Delete 1 Digimon with {maxDP()} DP or less");
  164. return true;
  165. }
  166. }
  167. return false;
  168. }
  169. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  170. {
  171. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  172. {
  173. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  174. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  175. selectPermanentEffect.SetUp(
  176. selectPlayer: card.Owner,
  177. canTargetCondition: CanSelectPermanentCondition,
  178. canTargetCondition_ByPreSelecetedList: null,
  179. canEndSelectCondition: null,
  180. maxCount: maxCount,
  181. canNoSelect: false,
  182. canEndNotMax: false,
  183. selectPermanentCoroutine: null,
  184. afterSelectPermanentCoroutine: null,
  185. mode: SelectPermanentEffect.Mode.Destroy,
  186. cardEffect: activateClass);
  187. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  188. }
  189. }
  190. }
  191. return cardEffects;
  192. }
  193. }
  194. }