AD1_024.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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.IsLevel5
  19. && targetPermanent.TopCard.EqualsTraits("Hero");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 5, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. if (timing == EffectTiming.None)
  24. {
  25. static bool PermanentCondition(Permanent targetPermanent)
  26. {
  27. return targetPermanent.TopCard.EqualsCardName("Imperialdramon: Dragon Mode") || targetPermanent.TopCard.EqualsCardName("Imperialdramon Dragon Mode");
  28. }
  29. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false, card: card, condition: null));
  30. }
  31. #endregion
  32. #region Security +1
  33. if (timing == EffectTiming.None)
  34. {
  35. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: false, card: card, condition: null));
  36. }
  37. #endregion
  38. #region Blocker
  39. if (timing == EffectTiming.None)
  40. {
  41. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  42. }
  43. #endregion
  44. #region Shared WD / WA
  45. string SharedHashString = "AD1_024_WD_WA";
  46. string SharedEffectName = "Bottom deck 1 Opponent's lowest DP Digimon";
  47. string SharedEffectDescription(string tag) => $"[{tag}] [Once Per Turn] Return 1 of your opponent's lowest DP Digimon to the bottom of the deck.";
  48. bool IsLowestDPEnemy(Permanent permanent) => CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  49. bool SharedCanActivateCondition(Hashtable hashtable)
  50. {
  51. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  52. }
  53. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  54. {
  55. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsLowestDPEnemy))
  56. {
  57. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  58. selectPermanentEffect.SetUp(
  59. selectPlayer: card.Owner,
  60. canTargetCondition: IsLowestDPEnemy,
  61. canTargetCondition_ByPreSelecetedList: null,
  62. canEndSelectCondition: null,
  63. maxCount: 1,
  64. canNoSelect: false,
  65. canEndNotMax: false,
  66. selectPermanentCoroutine: null,
  67. afterSelectPermanentCoroutine: null,
  68. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  69. cardEffect: activateClass);
  70. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  71. }
  72. }
  73. #endregion
  74. #region When Digivolving
  75. if (timing == EffectTiming.OnEnterFieldAnyone)
  76. {
  77. ActivateClass activateClass = new ActivateClass();
  78. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  79. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("When Digivolving"));
  80. activateClass.SetHashString(SharedHashString);
  81. cardEffects.Add(activateClass);
  82. bool CanUseCondition(Hashtable hashtable)
  83. {
  84. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  85. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  86. }
  87. }
  88. #endregion
  89. #region When Attacking
  90. if (timing == EffectTiming.OnAllyAttack)
  91. {
  92. ActivateClass activateClass = new ActivateClass();
  93. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  94. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("When Attacking"));
  95. activateClass.SetHashString(SharedHashString);
  96. cardEffects.Add(activateClass);
  97. bool CanUseCondition(Hashtable hashtable)
  98. {
  99. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  100. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  101. }
  102. }
  103. #endregion
  104. #region All Turns
  105. if (timing == EffectTiming.OnEnterFieldAnyone)
  106. {
  107. ActivateClass activateClass = new ActivateClass();
  108. activateClass.SetUpICardEffect("May suspend 1 enemy Digimon and unsuspend. May bottom deck suspended enemy Digimon", CanUseCondition, card);
  109. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  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) => permanent.IsDigimon;
  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. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsOpponentsDigimon))//first may includes both actions, so if suspend is possible
  127. {
  128. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  129. selectPermanentEffect.SetUp(
  130. selectPlayer: card.Owner,
  131. canTargetCondition: IsOpponentsDigimon,
  132. canTargetCondition_ByPreSelecetedList: null,
  133. canEndSelectCondition: null,
  134. maxCount: 1,
  135. canNoSelect: true,
  136. canEndNotMax: false,
  137. selectPermanentCoroutine: null,
  138. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  139. mode: SelectPermanentEffect.Mode.Tap,
  140. cardEffect: activateClass);
  141. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  142. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  143. {
  144. if (permanents.Count > 0) yield return ContinuousController.instance.StartCoroutine(
  145. new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  146. yield return null;
  147. }
  148. }
  149. else //if nothing to suspend, may still choose to take the action to unsuspend
  150. {
  151. string selectPlayerMessage = "Will you unsuspend this card?";
  152. string notSelectPlayerMessage = "The opponent is choosing if they will unsuspend.";
  153. List<SelectionElement<bool>> command_SelectCommands = new List<SelectionElement<bool>>()
  154. {
  155. new SelectionElement<bool>(message: $"Yes", value: true, spriteIndex: 0),
  156. new SelectionElement<bool>(message: $"No", value: false, spriteIndex: 1),
  157. };
  158. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: command_SelectCommands, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  159. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  160. bool unsuspend = GManager.instance.userSelectionManager.SelectedBoolValue;
  161. if (unsuspend)
  162. {
  163. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(
  164. new List<Permanent>() { card.PermanentOfThisCard() },
  165. activateClass).Unsuspend());
  166. }
  167. }
  168. ICardEffect cardEffect = CardEffectCommons.GetCardEffectFromHashtable(hashtable);
  169. if (cardEffect != null && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsOpponentsSuspendedDigimon))
  170. {
  171. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  172. selectPermanentEffect.SetUp(
  173. selectPlayer: card.Owner,
  174. canTargetCondition: IsOpponentsSuspendedDigimon,
  175. canTargetCondition_ByPreSelecetedList: null,
  176. canEndSelectCondition: null,
  177. maxCount: 1,
  178. canNoSelect: true,
  179. canEndNotMax: false,
  180. selectPermanentCoroutine: null,
  181. afterSelectPermanentCoroutine: null,
  182. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  183. cardEffect: activateClass);
  184. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  185. }
  186. }
  187. }
  188. #endregion
  189. return cardEffects;
  190. }
  191. }
  192. }