BT9_069.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. public class BT9_069 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Suspend Digimon and Tamers and gain Memory", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] Unsuspend up to 2 Digimon and/or Tamers. Then, gain 1 memory for each of your opponent's unsuspended Digimon and Tamers.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  26. {
  27. if (permanent.IsDigimon)
  28. {
  29. return true;
  30. }
  31. if (permanent.IsTamer)
  32. {
  33. return true;
  34. }
  35. }
  36. return false;
  37. }
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  41. }
  42. bool CanActivateCondition(Hashtable hashtable)
  43. {
  44. if (CardEffectCommons.IsExistOnBattleArea(card))
  45. {
  46. return true;
  47. }
  48. return false;
  49. }
  50. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  51. {
  52. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) + card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  53. {
  54. int maxCount = Math.Min(2, card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) + card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition));
  55. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  56. selectPermanentEffect.SetUp(
  57. selectPlayer: card.Owner,
  58. canTargetCondition: CanSelectPermanentCondition,
  59. canTargetCondition_ByPreSelecetedList: null,
  60. canEndSelectCondition: CanEndSelectCondition,
  61. maxCount: maxCount,
  62. canNoSelect: false,
  63. canEndNotMax: true,
  64. selectPermanentCoroutine: null,
  65. afterSelectPermanentCoroutine: null,
  66. mode: SelectPermanentEffect.Mode.UnTap,
  67. cardEffect: activateClass);
  68. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  69. bool CanEndSelectCondition(List<Permanent> permanents)
  70. {
  71. if (CardEffectCommons.HasNoElement(permanents))
  72. {
  73. return false;
  74. }
  75. return true;
  76. }
  77. }
  78. int plusMemory = card.Owner.Enemy.GetBattleAreaPermanents().Count((permanent) => !permanent.IsSuspended && (permanent.IsDigimon || permanent.IsTamer));
  79. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(plusMemory, activateClass));
  80. }
  81. }
  82. if (timing == EffectTiming.OnEndTurn)
  83. {
  84. ActivateClass activateClass = new ActivateClass();
  85. activateClass.SetUpICardEffect("Trash opponent's security", CanUseCondition, card);
  86. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  87. activateClass.SetHashString("TrashSecurity_BT9_069");
  88. cardEffects.Add(activateClass);
  89. string EffectDiscription()
  90. {
  91. return "[End of Your Turn][Once Per Turn] For every 2 unsuspended Digimon and/or Tamers your opponent has in play, trash 1 card from the top of your opponent's security stack.";
  92. }
  93. bool CanUseCondition(Hashtable hashtable)
  94. {
  95. if (CardEffectCommons.IsExistOnBattleArea(card))
  96. {
  97. if (CardEffectCommons.IsOwnerTurn(card))
  98. {
  99. return true;
  100. }
  101. }
  102. return false;
  103. }
  104. bool CanActivateCondition(Hashtable hashtable)
  105. {
  106. if (CardEffectCommons.IsExistOnBattleArea(card))
  107. {
  108. return true;
  109. }
  110. return false;
  111. }
  112. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  113. {
  114. if (card.Owner.SecurityCards.Count >= 1)
  115. {
  116. int trashCount = card.Owner.Enemy.GetBattleAreaPermanents().Count((permanent) => !permanent.IsSuspended && (permanent.IsDigimon || permanent.IsTamer)) / 2;
  117. if (trashCount >= 1)
  118. {
  119. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  120. player: card.Owner.Enemy,
  121. destroySecurityCount: trashCount,
  122. cardEffect: activateClass,
  123. fromTop: true).DestroySecurity());
  124. }
  125. }
  126. }
  127. }
  128. return cardEffects;
  129. }
  130. }