BT8_019.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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 BT8_019 : 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("Delete Digimon 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] Your opponent chooses 1 of their Digimon. Delete all Digimon other than this Digimon and your opponent's chosen Digimon. For each Digimon deleted by this effect, gain 1 memory.";
  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. return true;
  36. }
  37. return false;
  38. }
  39. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  40. {
  41. Permanent selectedPermanent = null;
  42. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  43. {
  44. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  45. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  46. selectPermanentEffect.SetUp(
  47. selectPlayer: card.Owner.Enemy,
  48. canTargetCondition: CanSelectPermanentCondition,
  49. canTargetCondition_ByPreSelecetedList: null,
  50. canEndSelectCondition: null,
  51. maxCount: maxCount,
  52. canNoSelect: false,
  53. canEndNotMax: false,
  54. selectPermanentCoroutine: SelectPermanentCoroutine,
  55. afterSelectPermanentCoroutine: null,
  56. mode: SelectPermanentEffect.Mode.Custom,
  57. cardEffect: activateClass);
  58. selectPermanentEffect.SetUpCustomMessage("Select your 1 Digimon.", "The opponent is selecting 1 Digimon.");
  59. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  60. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  61. {
  62. selectedPermanent = permanent;
  63. yield return null;
  64. }
  65. }
  66. bool PermanentCondition(Permanent permanent)
  67. {
  68. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  69. {
  70. if (permanent.IsDigimon)
  71. {
  72. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  73. {
  74. if (permanent.CanBeDestroyedBySkill(activateClass))
  75. {
  76. if (permanent != selectedPermanent && permanent != card.PermanentOfThisCard())
  77. {
  78. return true;
  79. }
  80. }
  81. }
  82. }
  83. }
  84. return false;
  85. }
  86. List<Permanent> destroyedPermanetns =
  87. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  88. .Map(player => player.GetBattleAreaPermanents())
  89. .Flat()
  90. .Filter(PermanentCondition);
  91. DestroyPermanentsClass destroyPermanentsClass = new DestroyPermanentsClass(destroyedPermanetns, CardEffectCommons.CardEffectHashtable(activateClass));
  92. yield return ContinuousController.instance.StartCoroutine(destroyPermanentsClass.Destroy());
  93. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(destroyPermanentsClass.DestroyedPermanents.Count, activateClass));
  94. }
  95. }
  96. if (timing == EffectTiming.OnDestroyedAnyone)
  97. {
  98. ActivateClass activateClass = new ActivateClass();
  99. activateClass.SetUpICardEffect("This Digimon gains Security Attack +", CanUseCondition, card);
  100. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  101. cardEffects.Add(activateClass);
  102. string EffectDiscription()
  103. {
  104. return "[Your Turn] When an opponent's Digimon is deleted, this Digimon gains <Security Attack +1> for the turn for each of your opponent's Digimon deleted.";
  105. }
  106. bool PermanentCondition(Permanent permanent)
  107. {
  108. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  109. }
  110. bool CanUseCondition(Hashtable hashtable)
  111. {
  112. if (CardEffectCommons.IsExistOnBattleArea(card))
  113. {
  114. if (CardEffectCommons.IsOwnerTurn(card))
  115. {
  116. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass))
  117. {
  118. return true;
  119. }
  120. }
  121. }
  122. return false;
  123. }
  124. bool CanActivateCondition(Hashtable hashtable)
  125. {
  126. if (CardEffectCommons.IsExistOnBattleArea(card))
  127. {
  128. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  129. if (hashtables != null)
  130. {
  131. if (hashtables.Count >= 1)
  132. {
  133. return true;
  134. }
  135. }
  136. }
  137. return false;
  138. }
  139. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  140. {
  141. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(_hashtable);
  142. if (hashtables != null)
  143. {
  144. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(
  145. targetPermanent: card.PermanentOfThisCard(),
  146. changeValue: hashtables.Count,
  147. effectDuration: EffectDuration.UntilEachTurnEnd,
  148. activateClass: activateClass));
  149. }
  150. }
  151. }
  152. return cardEffects;
  153. }
  154. }