JustimonBlitzArm_EX2_038.cs 11 KB

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