AD1_024.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. // Imperialdramon: Fighter Mode
  6. namespace DCGO.CardEffects.AD1
  7. {
  8. public class AD1_024 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolve Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsTraits("Hero");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 5, permanentCondition: PermanentCondition, digivolutionCost: 5, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. if (timing == EffectTiming.None)
  23. {
  24. static bool PermanentCondition(Permanent targetPermanent)
  25. {
  26. return targetPermanent.TopCard.EqualsCardName("Imperialdramon: Dragon Mode") || targetPermanent.TopCard.EqualsCardName("Imperialdramon Dragon Mode");
  27. }
  28. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false, card: card, condition: null));
  29. }
  30. #endregion
  31. #region Security +1
  32. if (timing == EffectTiming.None)
  33. {
  34. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: false, card: card, condition: null));
  35. }
  36. #endregion
  37. #region Blocker
  38. if (timing == EffectTiming.None)
  39. {
  40. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  41. }
  42. #endregion
  43. #region Shared WD / WA
  44. string SharedHashString = "AD1_024_WD_WA";
  45. string SharedEffectName = "Bottom deck 1 Opponent's lowest DP Digimon";
  46. string SharedEffectDescription(string tag) => $"[{tag}] [Once Per Turn] Return 1 of your opponent's lowest DP Digimon to the bottom of the deck.";
  47. bool IsLowestDPEnemy(Permanent permanent) => CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  48. bool SharedCanActivateCondition(Hashtable hashtable)
  49. {
  50. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  51. }
  52. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  53. {
  54. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsLowestDPEnemy))
  55. {
  56. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  57. selectPermanentEffect.SetUp(
  58. selectPlayer: card.Owner,
  59. canTargetCondition: IsLowestDPEnemy,
  60. canTargetCondition_ByPreSelecetedList: null,
  61. canEndSelectCondition: null,
  62. maxCount: 1,
  63. canNoSelect: false,
  64. canEndNotMax: false,
  65. selectPermanentCoroutine: null,
  66. afterSelectPermanentCoroutine: null,
  67. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  68. cardEffect: activateClass);
  69. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  70. }
  71. }
  72. #endregion
  73. #region When Digivolving
  74. if (timing == EffectTiming.OnEnterFieldAnyone)
  75. {
  76. ActivateClass activateClass = new ActivateClass();
  77. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  78. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("When Digivolving"));
  79. activateClass.SetHashString(SharedHashString);
  80. cardEffects.Add(activateClass);
  81. bool CanUseCondition(Hashtable hashtable)
  82. {
  83. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  84. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  85. }
  86. }
  87. #endregion
  88. #region When Attacking
  89. if (timing == EffectTiming.OnAllyAttack)
  90. {
  91. ActivateClass activateClass = new ActivateClass();
  92. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  93. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("When Attacking"));
  94. activateClass.SetHashString(SharedHashString);
  95. cardEffects.Add(activateClass);
  96. bool CanUseCondition(Hashtable hashtable)
  97. {
  98. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  99. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  100. }
  101. }
  102. #endregion
  103. #region All Turns
  104. if (timing == EffectTiming.OnEnterFieldAnyone)
  105. {
  106. ActivateClass activateClass = new ActivateClass();
  107. activateClass.SetUpICardEffect("May suspend 1 enemy Digimon and unsuspend. May bottom deck suspended enemy Digimon", CanUseCondition, card);
  108. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  109. activateClass.SetIsSkippable(true);
  110. activateClass.SetHashString("AD1_024_AT");
  111. cardEffects.Add(activateClass);
  112. string EffectDescription()
  113. => "[All Turns] [Once Per Turn] When Digimon are played or digivolve, you may suspend 1 of your opponent's Digimon and unsuspend this Digimon. Then, if played or digivolved by effects, you may return 1 of your opponent's suspended Digimon to the bottom of the deck.";
  114. bool CanUseCondition(Hashtable hashtable)
  115. {
  116. return CardEffectCommons.IsExistOnBattleArea(card)
  117. && (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, IsDigimonCondition)
  118. || CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, IsDigimonCondition));
  119. }
  120. bool IsDigimonCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent);
  121. bool IsOpponentsDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  122. bool IsOpponentsSuspendedDigimon(Permanent permanent) => IsOpponentsDigimon(permanent) && permanent.IsSuspended;
  123. bool CanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleArea(card);
  124. IEnumerator ActivateCoroutine(Hashtable hashtable)
  125. {
  126. bool isByEffect = CardEffectCommons.IsByEffect(hashtable, null);
  127. bool executed = false;
  128. string _Message;
  129. if (isByEffect)
  130. {
  131. _Message = $"Card entered by effect, will you use \"{activateClass.EffectName}\"?";
  132. }
  133. else
  134. {
  135. _Message = "Card did not enter by effect, Will you use \"May suspend 1 enemy Digimon and unsuspend.\"?";
  136. }
  137. List<SelectionElement<bool>> selectionElements1 = new List<SelectionElement<bool>>()
  138. {
  139. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  140. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  141. };
  142. string selectPlayerMessage1 = _Message;
  143. string notSelectPlayerMessage1 = "Opponent is selecting an effect";
  144. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements1, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage1, notSelectPlayerMessage: notSelectPlayerMessage1);
  145. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  146. var activate = GManager.instance.userSelectionManager.SelectedBoolValue;
  147. if (activate)
  148. {
  149. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsOpponentsDigimon))//first may includes both actions, so if suspend is possible
  150. {
  151. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  152. selectPermanentEffect.SetUp(
  153. selectPlayer: card.Owner,
  154. canTargetCondition: IsOpponentsDigimon,
  155. canTargetCondition_ByPreSelecetedList: null,
  156. canEndSelectCondition: null,
  157. maxCount: 1,
  158. canNoSelect: true,
  159. canEndNotMax: false,
  160. selectPermanentCoroutine: null,
  161. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  162. mode: SelectPermanentEffect.Mode.Tap,
  163. cardEffect: activateClass);
  164. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  165. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  166. {
  167. if (permanents.Count > 0)
  168. {
  169. yield return ContinuousController.instance.StartCoroutine(
  170. new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  171. executed = true;
  172. }
  173. }
  174. }
  175. else //if nothing to suspend, may still choose to take the action to unsuspend
  176. {
  177. string selectPlayerMessage = "Will you unsuspend this card?";
  178. string notSelectPlayerMessage = "The opponent is choosing if they will unsuspend.";
  179. List<SelectionElement<bool>> command_SelectCommands = new List<SelectionElement<bool>>()
  180. {
  181. new SelectionElement<bool>(message: $"Yes", value: true, spriteIndex: 0),
  182. new SelectionElement<bool>(message: $"No", value: false, spriteIndex: 1),
  183. };
  184. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: command_SelectCommands, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  185. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  186. bool unsuspend = GManager.instance.userSelectionManager.SelectedBoolValue;
  187. if (unsuspend)
  188. {
  189. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(
  190. new List<Permanent>() { card.PermanentOfThisCard() },
  191. activateClass).Unsuspend());
  192. executed = true;
  193. }
  194. }
  195. if (isByEffect && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsOpponentsSuspendedDigimon))
  196. {
  197. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  198. selectPermanentEffect.SetUp(
  199. selectPlayer: card.Owner,
  200. canTargetCondition: IsOpponentsSuspendedDigimon,
  201. canTargetCondition_ByPreSelecetedList: null,
  202. canEndSelectCondition: null,
  203. maxCount: 1,
  204. canNoSelect: true,
  205. canEndNotMax: false,
  206. selectPermanentCoroutine: null,
  207. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  208. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  209. cardEffect: activateClass);
  210. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  211. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  212. {
  213. if (permanents.Count > 0)
  214. executed = true;
  215. yield return null;
  216. }
  217. }
  218. }
  219. if (!executed) activateClass.RemoveUse();
  220. }
  221. }
  222. #endregion
  223. return cardEffects;
  224. }
  225. }
  226. }