EX2_038.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX2
  6. {
  7. public class EX2_038 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Choose 1 effect", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[When Digivolving] Activate 1 of the effects below. - This Digimon gets +2000 DP for the turn. - Unsuspend this Digimon. - Delete 1 of your opponent's Digimon with a play cost of 5 or less.";
  21. }
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  25. }
  26. bool CanActivateCondition(Hashtable hashtable)
  27. {
  28. if (CardEffectCommons.IsExistOnBattleArea(card))
  29. {
  30. return true;
  31. }
  32. return false;
  33. }
  34. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  35. {
  36. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  37. {
  38. new SelectionElement<int>(message: $"DP+2000", value : 0, spriteIndex: 0),
  39. new SelectionElement<int>(message: $"Unsuspend", value : 1, spriteIndex: 0),
  40. new SelectionElement<int>(message: $"Delete 1 Digimon", value : 2, spriteIndex: 0),
  41. };
  42. string selectPlayerMessage = "Which effect will you activate?";
  43. string notSelectPlayerMessage = "The opponent is choosing which effect to activate.";
  44. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  45. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  46. int actionID = GManager.instance.userSelectionManager.SelectedIntValue;
  47. switch (actionID)
  48. {
  49. case 0:
  50. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: card.PermanentOfThisCard(), changeValue: 2000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  51. break;
  52. case 1:
  53. Permanent selectedPermanent = card.PermanentOfThisCard();
  54. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  55. break;
  56. case 2:
  57. bool CanSelectPermanentCondition(Permanent permanent)
  58. {
  59. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  60. {
  61. if (permanent.TopCard.GetCostItself <= 5)
  62. {
  63. if (permanent.TopCard.HasPlayCost)
  64. {
  65. return true;
  66. }
  67. }
  68. }
  69. return false;
  70. }
  71. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  72. {
  73. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  74. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  75. selectPermanentEffect.SetUp(
  76. selectPlayer: card.Owner,
  77. canTargetCondition: CanSelectPermanentCondition,
  78. canTargetCondition_ByPreSelecetedList: null,
  79. canEndSelectCondition: null,
  80. maxCount: maxCount,
  81. canNoSelect: false,
  82. canEndNotMax: false,
  83. selectPermanentCoroutine: null,
  84. afterSelectPermanentCoroutine: null,
  85. mode: SelectPermanentEffect.Mode.Destroy,
  86. cardEffect: activateClass);
  87. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  88. }
  89. break;
  90. }
  91. }
  92. }
  93. if (timing == EffectTiming.OnAllyAttack)
  94. {
  95. ActivateClass activateClass = new ActivateClass();
  96. activateClass.SetUpICardEffect("Activate [When Digivolving] effect", CanUseCondition, card);
  97. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  98. activateClass.SetHashString("ActivateWhenDigivolving_EX2_038");
  99. cardEffects.Add(activateClass);
  100. string EffectDiscription()
  101. {
  102. return "[When Attacking][Once Per Turn] For each Tamer you have in play, activate this Digimon's [When Digivolving] effect.";
  103. }
  104. bool CanUseCondition(Hashtable hashtable)
  105. {
  106. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  107. }
  108. bool CanActivateCondition(Hashtable hashtable)
  109. {
  110. if (CardEffectCommons.IsExistOnBattleArea(card))
  111. {
  112. return true;
  113. }
  114. return false;
  115. }
  116. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  117. {
  118. int tamerCount = card.Owner.GetBattleAreaPermanents().Count(permanent => permanent.IsTamer);
  119. for (int i = 0; i < tamerCount; i++)
  120. {
  121. if (CardEffectCommons.IsExistOnBattleArea(card))
  122. {
  123. List<ICardEffect> candidateEffects = card.PermanentOfThisCard().EffectList(EffectTiming.OnEnterFieldAnyone)
  124. .Clone()
  125. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsWhenDigivolving);
  126. if (candidateEffects.Count >= 1)
  127. {
  128. ICardEffect selectedEffect = null;
  129. if (candidateEffects.Count == 1)
  130. {
  131. selectedEffect = candidateEffects[0];
  132. }
  133. else
  134. {
  135. List<SkillInfo> skillInfos = candidateEffects
  136. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  137. List<CardSource> cardSources = candidateEffects
  138. .Map(cardEffect => cardEffect.EffectSourceCard);
  139. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  140. selectCardEffect.SetUp(
  141. canTargetCondition: (cardSource) => true,
  142. canTargetCondition_ByPreSelecetedList: null,
  143. canEndSelectCondition: null,
  144. canNoSelect: () => false,
  145. selectCardCoroutine: null,
  146. afterSelectCardCoroutine: null,
  147. message: "Select 1 effect to activate.",
  148. maxCount: 1,
  149. canEndNotMax: false,
  150. isShowOpponent: false,
  151. mode: SelectCardEffect.Mode.Custom,
  152. root: SelectCardEffect.Root.Custom,
  153. customRootCardList: cardSources,
  154. canLookReverseCard: true,
  155. selectPlayer: card.Owner,
  156. cardEffect: activateClass);
  157. selectCardEffect.SetNotShowCard();
  158. selectCardEffect.SetUpSkillInfos(skillInfos);
  159. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  160. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  161. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  162. {
  163. if (selectedIndexes.Count == 1)
  164. {
  165. selectedEffect = candidateEffects[selectedIndexes[0]];
  166. yield return null;
  167. }
  168. }
  169. }
  170. if (selectedEffect != null)
  171. {
  172. if (selectedEffect.EffectSourceCard != null)
  173. {
  174. if (selectedEffect.EffectSourceCard.PermanentOfThisCard() != null)
  175. {
  176. Hashtable effectHashtable = CardEffectCommons.WhenDigivolvingCheckHashtableOfCard(selectedEffect.EffectSourceCard);
  177. if (selectedEffect.CanUse(effectHashtable))
  178. {
  179. yield return ContinuousController.instance.StartCoroutine(((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(effectHashtable));
  180. }
  181. }
  182. }
  183. }
  184. }
  185. }
  186. }
  187. }
  188. }
  189. return cardEffects;
  190. }
  191. }
  192. }