BT12_044.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT12
  6. {
  7. public class BT12_044 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region When Digivolving
  13. if (timing == EffectTiming.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Security Attack -2", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] Until the end of your opponent's turn, 1 of your opponent's Digimon gains <Security Attack -2>. (This Digimon checks 2 fewer security cards.)";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  26. }
  27. bool CanUseCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  30. }
  31. bool CanActivateCondition(Hashtable hashtable)
  32. {
  33. if (CardEffectCommons.IsExistOnBattleArea(card))
  34. {
  35. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  36. {
  37. return true;
  38. }
  39. }
  40. return false;
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  43. {
  44. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  45. {
  46. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  47. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  48. selectPermanentEffect.SetUp(
  49. selectPlayer: card.Owner,
  50. canTargetCondition: CanSelectPermanentCondition,
  51. canTargetCondition_ByPreSelecetedList: null,
  52. canEndSelectCondition: null,
  53. maxCount: maxCount,
  54. canNoSelect: false,
  55. canEndNotMax: false,
  56. selectPermanentCoroutine: SelectPermanentCoroutine,
  57. afterSelectPermanentCoroutine: null,
  58. mode: SelectPermanentEffect.Mode.Custom,
  59. cardEffect: activateClass);
  60. selectPermanentEffect.SetUpCustomMessage(
  61. "Select 1 Digimon that will get Security Attack -2.",
  62. "The opponent is selecting 1 Digimon that will get Security Attack -2.");
  63. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  64. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  65. {
  66. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(
  67. targetPermanent: permanent,
  68. changeValue: -2,
  69. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  70. activateClass: activateClass));
  71. }
  72. }
  73. //Initial check for your turn effect
  74. int count()
  75. {
  76. return card.Owner.Enemy.GetBattleAreaDigimons().Count((permanent) => permanent.HasSecurityAttackChanges);
  77. }
  78. List<ICardEffect> SecFromLamp = card.PermanentOfThisCard().EffectList(EffectTiming.None).Where(x => x.HashString == "SecAttackFromLampEffect").ToList();
  79. if (count() > SecFromLamp.Count())
  80. {
  81. int timesToRunLoop = count() - SecFromLamp.Count();
  82. for (int i = 0; i < timesToRunLoop; i++)
  83. {
  84. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(
  85. targetPermanent: card.PermanentOfThisCard(),
  86. changeValue: 1,
  87. effectDuration: EffectDuration.UntilEachTurnEnd,
  88. activateClass: activateClass,
  89. activateAnimation: false,
  90. hashstring: "SecAttackFromLampEffect"));
  91. }
  92. }
  93. }
  94. }
  95. #endregion
  96. #region Your Turn
  97. if (timing == EffectTiming.AfterEffectsActivate || timing == EffectTiming.OnStartTurn || timing == EffectTiming.OnEnterFieldAnyone || timing == EffectTiming.OnUseOption || timing == EffectTiming.OptionSkill || timing == EffectTiming.SecuritySkill || timing == EffectTiming.WhenRemoveField)
  98. {
  99. ActivateClass activateClass = new ActivateClass();
  100. activateClass.SetUpICardEffect("Gain Security Attack", CanUseCondition, card);
  101. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  102. activateClass.SetIsBackgroundProcess(true);
  103. cardEffects.Add(activateClass);
  104. int count()
  105. {
  106. return card.Owner.Enemy.GetBattleAreaDigimons().Count((permanent) => permanent.HasSecurityAttackChanges);
  107. }
  108. string EffectDiscription()
  109. {
  110. return "[Your Turn] This Digimon gains [Security A+1] for each of your opponent's Digimon with [Security Attack].";
  111. }
  112. bool CanUseCondition(Hashtable hashtable)
  113. {
  114. return true;
  115. }
  116. bool OpponentHasDigimonWithSecChanges(Permanent permanent)
  117. {
  118. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  119. {
  120. if (permanent.IsDigimon)
  121. {
  122. if (permanent.HasSecurityAttackChanges)
  123. {
  124. return true;
  125. }
  126. }
  127. }
  128. return false;
  129. }
  130. bool CanActivateCondition(Hashtable hashtable)
  131. {
  132. if (CardEffectCommons.IsExistOnBattleArea(card))
  133. {
  134. if (CardEffectCommons.IsOwnerTurn(card))
  135. {
  136. if (CardEffectCommons.HasMatchConditionPermanent(OpponentHasDigimonWithSecChanges))
  137. {
  138. return true;
  139. }
  140. }
  141. }
  142. return false;
  143. }
  144. IEnumerator ActivateCoroutine(Hashtable hashtable)
  145. {
  146. List<ICardEffect> SecFromLamp = card.PermanentOfThisCard().EffectList(EffectTiming.None).Where(x => x.HashString == "SecAttackFromLampEffect").ToList();
  147. if (count() > SecFromLamp.Count())
  148. {
  149. int timesToRunLoop = count() - SecFromLamp.Count();
  150. for (int i = 0; i < timesToRunLoop; i++)
  151. {
  152. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(
  153. targetPermanent: card.PermanentOfThisCard(),
  154. changeValue: 1,
  155. effectDuration: EffectDuration.UntilEachTurnEnd,
  156. activateClass: activateClass,
  157. activateAnimation: false,
  158. hashstring: "SecAttackFromLampEffect"));
  159. }
  160. }
  161. }
  162. }
  163. #endregion
  164. return cardEffects;
  165. }
  166. }
  167. }