P_146.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.P
  6. {
  7. public class P_146 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Ignore Color Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  16. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  17. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  18. cardEffects.Add(ignoreColorConditionClass);
  19. bool HasTamer(Permanent permanent)
  20. {
  21. return permanent.IsTamer;
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.HasMatchConditionOwnersPermanent(card, HasTamer);
  26. }
  27. bool CardCondition(CardSource cardSource)
  28. {
  29. return cardSource == card;
  30. }
  31. }
  32. #endregion
  33. #region Security Skill
  34. if (timing == EffectTiming.SecuritySkill)
  35. {
  36. ActivateClass activateClass = new ActivateClass();
  37. activateClass.SetUpICardEffect("1 opponent's digimon gains <Security A. -1> for the turn", CanUseCondition, card);
  38. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  39. activateClass.SetIsSecurityEffect(true);
  40. cardEffects.Add(activateClass);
  41. string EffectDiscription()
  42. {
  43. return "[Security] 1 of your opponent's Digimon gains <Security A. -1> for the turn.";
  44. }
  45. bool CanSelectPermanentCondition(Permanent permanent)
  46. {
  47. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  48. }
  49. bool CanUseCondition(Hashtable hashtable)
  50. {
  51. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  52. }
  53. IEnumerator ActivateCoroutine(Hashtable hashtable)
  54. {
  55. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  56. {
  57. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  58. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  59. selectPermanentEffect.SetUp(
  60. selectPlayer: card.Owner,
  61. canTargetCondition: CanSelectPermanentCondition,
  62. canTargetCondition_ByPreSelecetedList: null,
  63. canEndSelectCondition: null,
  64. maxCount: maxCount,
  65. canNoSelect: false,
  66. canEndNotMax: false,
  67. selectPermanentCoroutine: SelectPermanentCoroutine,
  68. afterSelectPermanentCoroutine: null,
  69. mode: SelectPermanentEffect.Mode.Custom,
  70. cardEffect: activateClass);
  71. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get <security A. -1>.", "The opponent is selecting 1 Digimon that will get <security A. -1>.");
  72. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  73. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  74. {
  75. Permanent selectedPermanent = permanent;
  76. if (selectedPermanent != null)
  77. {
  78. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(
  79. targetPermanent: permanent,
  80. changeValue: -1,
  81. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  82. activateClass: activateClass));
  83. }
  84. }
  85. }
  86. }
  87. }
  88. #endregion
  89. #region Main
  90. if (timing == EffectTiming.OptionSkill)
  91. {
  92. ActivateClass activateClass = new ActivateClass();
  93. activateClass.SetUpICardEffect("Place as bottom Digivolution source", CanUseCondition, card);
  94. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  95. cardEffects.Add(activateClass);
  96. string EffectDiscription()
  97. {
  98. return "[Main] Place this card as 1 of your non-white Digimon's bottom digivolution card.";
  99. }
  100. bool IsNonWhiteDigimon(Permanent targetPermanent)
  101. {
  102. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(targetPermanent, card))
  103. {
  104. if (!targetPermanent.TopCard.CardColors.Contains(CardColor.White))
  105. return true;
  106. }
  107. return false;
  108. }
  109. bool CanUseCondition(Hashtable hashtable)
  110. {
  111. if (CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card))
  112. {
  113. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsNonWhiteDigimon))
  114. {
  115. return true;
  116. }
  117. }
  118. return false;
  119. }
  120. IEnumerator ActivateCoroutine(Hashtable hashtable)
  121. {
  122. Permanent selectedPermanent = null;
  123. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsNonWhiteDigimon));
  124. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  125. selectPermanentEffect.SetUp(
  126. selectPlayer: card.Owner,
  127. canTargetCondition: IsNonWhiteDigimon,
  128. canTargetCondition_ByPreSelecetedList: null,
  129. canEndSelectCondition: null,
  130. maxCount: maxCount,
  131. canNoSelect: true,
  132. canEndNotMax: false,
  133. selectPermanentCoroutine: SelectPermanentCoroutine,
  134. afterSelectPermanentCoroutine: null,
  135. mode: SelectPermanentEffect.Mode.Custom,
  136. cardEffect: activateClass);
  137. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to add bottom digivolution source.", "The opponent is selecting 1 Digimon to add bottom digivolution source.");
  138. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  139. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  140. {
  141. selectedPermanent = permanent;
  142. yield return null;
  143. }
  144. if (selectedPermanent != null)
  145. {
  146. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(
  147. new List<CardSource>() { card },
  148. activateClass));
  149. }
  150. }
  151. }
  152. #endregion
  153. #region All Turns- When would be destoryed - ESS
  154. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  155. {
  156. ActivateClass activateClass = new ActivateClass();
  157. activateClass.SetUpICardEffect("Place card from digivolution sources to security, to prevent deletion by battle", CanUseCondition, card);
  158. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  159. activateClass.SetIsInheritedEffect(true);
  160. cardEffects.Add(activateClass);
  161. string EffectDiscription()
  162. {
  163. return "[All Turns] When this Digimon would be deleted by battle, by placing 1 [Reload Plug-In Q] from this Digimon's digivolution cards at the bottom of your security stack, prevent that deletion.";
  164. }
  165. bool CanSelectCardCondition(CardSource cardSource)
  166. {
  167. if (card.PermanentOfThisCard().cardSources.Contains(cardSource))
  168. {
  169. return cardSource.CardNames.Contains(card.BaseENGCardNameFromEntity);
  170. }
  171. return false;
  172. }
  173. bool CanUseCondition(Hashtable hashtable)
  174. {
  175. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  176. {
  177. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  178. {
  179. if(CardEffectCommons.IsByBattle(hashtable))
  180. return true;
  181. }
  182. }
  183. return false;
  184. }
  185. bool CanActivateCondition(Hashtable hashtable)
  186. {
  187. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  188. {
  189. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  190. {
  191. return true;
  192. }
  193. }
  194. return false;
  195. }
  196. IEnumerator ActivateCoroutine(Hashtable hashtable)
  197. {
  198. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  199. selectCardEffect.SetUp(
  200. selectPlayer: card.Owner,
  201. canTargetCondition: CanSelectCardCondition,
  202. canTargetCondition_ByPreSelecetedList: null,
  203. canEndSelectCondition: null,
  204. maxCount: 1,
  205. canNoSelect: () => true,
  206. canEndNotMax: false,
  207. selectCardCoroutine: SelectCardCoroutine,
  208. afterSelectCardCoroutine: null,
  209. message: "Select 1 card to put in security.",
  210. isShowOpponent: true,
  211. mode: SelectCardEffect.Mode.Custom,
  212. root: SelectCardEffect.Root.DigivolutionCards,
  213. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  214. canLookReverseCard: false,
  215. cardEffect: activateClass);
  216. selectCardEffect.SetUpCustomMessage("Select 1 card to put in security.", "The opponent is selecting 1 card to put in security.");
  217. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  218. IEnumerator SelectCardCoroutine(CardSource cardSource)
  219. {
  220. Permanent thisCardPermanent = card.PermanentOfThisCard();
  221. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(cardSource, toTop: false));
  222. thisCardPermanent.willBeRemoveField = false;
  223. thisCardPermanent.HideDeleteEffect();
  224. }
  225. }
  226. }
  227. #endregion
  228. return cardEffects;
  229. }
  230. }
  231. }