EX11_016.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // PolarBearmon
  6. namespace DCGO.CardEffects.EX11
  7. {
  8. public class EX11_016 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution Requirement
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsTraits("Ice-Snow")
  19. && targetPermanent.TopCard.IsLevel4;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Iceclad
  25. if (timing == EffectTiming.None)
  26. {
  27. cardEffects.Add(CardEffectFactory.IcecladSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  28. }
  29. #endregion
  30. #region Shared OP / WD
  31. string SharedEffectName()
  32. {
  33. return "Trash any 2 digivolution cards from your opponents Digimon, may send opponents sourceless digimon to top or bottom security.";
  34. }
  35. string SharedEffectDescription(string tag)
  36. {
  37. return $"[{tag}] Trash any 2 digivolution cards from your opponent's Digimon. Then, you may place 1 of their Digimon with no digivolution cards as the top or bottom security card.";
  38. }
  39. bool SharedCanActivateCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.IsExistOnBattleArea(card);
  42. }
  43. bool OpponentsDigimon(Permanent permanent)
  44. {
  45. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  46. }
  47. bool OpponentsDigimonWithoutSources(Permanent permanent)
  48. {
  49. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  50. permanent.DigivolutionCards.Count == 0;
  51. }
  52. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  53. {
  54. if (card.Owner.Enemy.GetBattleAreaDigimons().Count() > 0)
  55. {
  56. #region Strip 2 sources
  57. bool CanSelectCardCondition(CardSource cardSource)
  58. {
  59. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  60. }
  61. if (CardEffectCommons.HasMatchConditionPermanent(OpponentsDigimon)) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  62. permanentCondition: OpponentsDigimon,
  63. cardCondition: CanSelectCardCondition,
  64. maxCount: 2,
  65. canNoTrash: false,
  66. isFromOnly1Permanent: false,
  67. activateClass: activateClass
  68. ));
  69. #endregion
  70. #region Send to Security
  71. if (CardEffectCommons.HasMatchConditionPermanent(OpponentsDigimonWithoutSources)
  72. && card.Owner.CanAddSecurity(activateClass))
  73. {
  74. Permanent selectedPermanent = null;
  75. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  76. selectPermanentEffect1.SetUp(
  77. selectPlayer: card.Owner,
  78. canTargetCondition: OpponentsDigimonWithoutSources,
  79. canTargetCondition_ByPreSelecetedList: null,
  80. canEndSelectCondition: null,
  81. maxCount: 1,
  82. canNoSelect: true,
  83. canEndNotMax: false,
  84. selectPermanentCoroutine: SelectPermanentCoroutine1,
  85. afterSelectPermanentCoroutine: null,
  86. mode: SelectPermanentEffect.Mode.Custom,
  87. cardEffect: activateClass);
  88. selectPermanentEffect1.SetUpCustomMessage("Select 1 Digimon to place in security", "The opponent is selecting 1 Digimon place in security.");
  89. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  90. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  91. {
  92. selectedPermanent = permanent;
  93. yield return null;
  94. }
  95. if (selectedPermanent != null)
  96. {
  97. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  98. {
  99. new SelectionElement<bool>(message: $"Security Top", value : true, spriteIndex: 0),
  100. new SelectionElement<bool>(message: $"Security Bottom", value : false, spriteIndex: 1),
  101. };
  102. string selectPlayerMessage = "Choose security position?";
  103. string notSelectPlayerMessage = "The opponent is choosing security position";
  104. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  105. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  106. bool position = GManager.instance.userSelectionManager.SelectedBoolValue;
  107. yield return ContinuousController.instance.StartCoroutine(new IPutSecurityPermanent(selectedPermanent, CardEffectCommons.CardEffectHashtable(activateClass), toTop: position).PutSecurity());
  108. }
  109. }
  110. #endregion
  111. }
  112. }
  113. #endregion
  114. #region On Play
  115. if (timing == EffectTiming.OnEnterFieldAnyone)
  116. {
  117. ActivateClass activateClass = new ActivateClass();
  118. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  119. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hash) => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  120. cardEffects.Add(activateClass);
  121. bool CanUseCondition(Hashtable hashtable)
  122. {
  123. return CardEffectCommons.CanTriggerOnPlay(hashtable, card)
  124. && CardEffectCommons.IsExistOnBattleArea(card);
  125. }
  126. }
  127. #endregion
  128. #region When Digivolving
  129. if (timing == EffectTiming.OnEnterFieldAnyone)
  130. {
  131. ActivateClass activateClass = new ActivateClass();
  132. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  133. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hash) => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  134. cardEffects.Add(activateClass);
  135. bool CanUseCondition(Hashtable hashtable)
  136. {
  137. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card)
  138. && CardEffectCommons.IsExistOnBattleArea(card);
  139. }
  140. }
  141. #endregion
  142. #region Inherited Effect - Your Turn
  143. if (timing == EffectTiming.None)
  144. {
  145. bool Condition()
  146. {
  147. return CardEffectCommons.IsExistOnBattleArea(card)
  148. && CardEffectCommons.IsOwnerTurn(card)
  149. && card.PermanentOfThisCard().TopCard.EqualsTraits("Ice-Snow")
  150. && !CardEffectCommons.HasMatchConditionOpponentsPermanent(card, (permanent) =>
  151. permanent.IsDigimon && !permanent.HasNoDigivolutionCards);
  152. }
  153. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(1, true, card, Condition));
  154. }
  155. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  156. {
  157. bool Condition()
  158. {
  159. return CardEffectCommons.IsExistOnBattleArea(card)
  160. && CardEffectCommons.IsOwnerTurn(card)
  161. && card.PermanentOfThisCard().TopCard.EqualsTraits("Ice-Snow")
  162. && !CardEffectCommons.HasMatchConditionOpponentsPermanent(card, (permanent) =>
  163. permanent.IsDigimon && !permanent.HasNoDigivolutionCards);
  164. }
  165. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: true, card: card, condition: Condition));
  166. }
  167. #endregion
  168. return cardEffects;
  169. }
  170. }
  171. }