P_221.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. using UnityEngine;
  6. //Chaosmon
  7. namespace DCGO.CardEffects.P
  8. {
  9. public class P_221 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region DNA
  15. if (timing == EffectTiming.None)
  16. {
  17. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  18. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  19. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  20. addJogressConditionClass.SetNotShowUI(true);
  21. cardEffects.Add(addJogressConditionClass);
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. return true;
  25. }
  26. JogressCondition GetJogress(CardSource cardSource)
  27. {
  28. if (cardSource == card)
  29. {
  30. bool PermanentCondition1(Permanent permanent) => permanent.TopCard.CardColors.Contains(CardColor.Yellow) && permanent.Levels_ForJogress(card).Contains(6);
  31. bool PermanentCondition2(Permanent permanent) => (permanent.TopCard.CardColors.Contains(CardColor.Purple) || permanent.TopCard.CardColors.Contains(CardColor.Black)) && permanent.Levels_ForJogress(card).Contains(6);
  32. JogressConditionElement[] elements = new JogressConditionElement[]
  33. {
  34. new JogressConditionElement(PermanentCondition1, "a level 6 yellow Digimon"),
  35. new JogressConditionElement(PermanentCondition2, "a level 6 purple/black Digimon"),
  36. };
  37. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  38. return jogressCondition;
  39. }
  40. return null;
  41. }
  42. }
  43. #endregion
  44. #region Partition
  45. if (timing == EffectTiming.WhenRemoveField)
  46. {
  47. List<PartitionCondition> partitionConditions = new List<PartitionCondition>();
  48. partitionConditions.Add(new PartitionCondition(6, CardColor.Yellow));
  49. partitionConditions.Add(new PartitionCondition(6, CardColor.Purple, CardColor.Black));
  50. cardEffects.Add(CardEffectFactory.PartitionSelfEffect(
  51. isInheritedEffect: false,
  52. card: card,
  53. condition: null,
  54. cardSourceConditions: partitionConditions));
  55. }
  56. #endregion
  57. #region Security Attack +1
  58. if (timing == EffectTiming.None)
  59. {
  60. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: false, card: card, condition: null));
  61. }
  62. #endregion
  63. #region When Digivolving 1
  64. if (timing == EffectTiming.OnEnterFieldAnyone)
  65. {
  66. ActivateClass activateClass = new ActivateClass();
  67. activateClass.SetUpICardEffect("Become immune.", CanUseCondition, card);
  68. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  69. cardEffects.Add(activateClass);
  70. string EffectDiscription()
  71. {
  72. return "[When Digivolving] If DNA digivolving, until your opponent's turn ends, their effects don't affect this Digimon";
  73. }
  74. bool CanUseCondition(Hashtable hashtable)
  75. {
  76. return CardEffectCommons.IsExistOnBattleArea(card)
  77. && CardEffectCommons.IsJogress(hashtable)
  78. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  79. }
  80. bool CanActivateCondition(Hashtable hashtable)
  81. {
  82. return CardEffectCommons.IsExistOnBattleArea(card);
  83. }
  84. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  85. {
  86. Permanent selectedPermanent = card.PermanentOfThisCard();
  87. if (selectedPermanent != null)
  88. {
  89. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  90. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's effects", CanUseCondition1, card);
  91. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  92. selectedPermanent.UntilOpponentTurnEndEffects.Add((_timing) => canNotAffectedClass);
  93. bool CanUseCondition1(Hashtable hashtable)
  94. {
  95. return CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent);
  96. }
  97. bool CardCondition(CardSource cardSource)
  98. {
  99. return CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent)
  100. && cardSource == selectedPermanent.TopCard;
  101. }
  102. bool SkillCondition(ICardEffect cardEffect)
  103. {
  104. return cardEffect != null
  105. && cardEffect.EffectSourceCard != null
  106. && cardEffect.EffectSourceCard.Owner == card.Owner.Enemy;
  107. }
  108. }
  109. yield return null;
  110. }
  111. }
  112. #endregion
  113. #region OP/WD Shared
  114. string EffectNameShared()
  115. => "Give 1 opponent's Digimon -10000 DP";
  116. string EffectDescriptionShared(string tag)
  117. {
  118. return $"[{tag}] 1 of your opponent's Digimon gets -10000 DP until their turn ends";
  119. }
  120. bool CanSelectPermanentCondition(Permanent permanent)
  121. {
  122. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  123. }
  124. bool CanActivateConditionShared(Hashtable hashtable)
  125. {
  126. return CardEffectCommons.IsExistOnBattleArea(card);
  127. }
  128. IEnumerator ActivateCoroutineShared(Hashtable hashtable, ActivateClass activateClass)
  129. {
  130. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  131. {
  132. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  133. selectPermanentEffect.SetUp(
  134. selectPlayer: card.Owner,
  135. canTargetCondition: CanSelectPermanentCondition,
  136. canTargetCondition_ByPreSelecetedList: null,
  137. canEndSelectCondition: null,
  138. maxCount: 1,
  139. canNoSelect: false,
  140. canEndNotMax: false,
  141. selectPermanentCoroutine: SelectPermanentCoroutine,
  142. afterSelectPermanentCoroutine: null,
  143. mode: SelectPermanentEffect.Mode.Custom,
  144. cardEffect: activateClass);
  145. selectPermanentEffect.SetUpCustomMessage(customMessageArray: CardEffectCommons.customPermanentMessageArray_ChangeDP(changeValue: -10000, maxCount: 1));
  146. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  147. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  148. {
  149. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  150. targetPermanent: permanent,
  151. changeValue: -10000,
  152. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  153. activateClass: activateClass));
  154. }
  155. }
  156. }
  157. #endregion
  158. #region When Digivolving 2
  159. if (timing == EffectTiming.OnEnterFieldAnyone)
  160. {
  161. ActivateClass activateClass = new ActivateClass();
  162. activateClass.SetUpICardEffect(EffectNameShared(), CanUseCondition, card);
  163. activateClass.SetUpActivateClass(CanActivateConditionShared, hash => ActivateCoroutineShared(hash, activateClass), -1, false, EffectDescriptionShared("When Digivolving"));
  164. cardEffects.Add(activateClass);
  165. bool CanUseCondition(Hashtable hashtable)
  166. {
  167. return CardEffectCommons.IsExistOnBattleArea(card)
  168. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  169. }
  170. }
  171. #endregion
  172. #region When Attacking
  173. if (timing == EffectTiming.OnAllyAttack)
  174. {
  175. ActivateClass activateClass = new ActivateClass();
  176. activateClass.SetUpICardEffect(EffectNameShared(), CanUseCondition, card);
  177. activateClass.SetUpActivateClass(CanActivateConditionShared, hash => ActivateCoroutineShared(hash, activateClass), -1, false, EffectDescriptionShared("When Attacking"));
  178. cardEffects.Add(activateClass);
  179. bool CanUseCondition(Hashtable hashtable)
  180. {
  181. return CardEffectCommons.IsExistOnBattleArea(card)
  182. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  183. }
  184. }
  185. #endregion
  186. return cardEffects;
  187. }
  188. }
  189. }