BT8_044.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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_044 : 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.OnAllyAttack)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Trash a Security to get Memory +2", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Attacking] You may trash the top card of your security stack to gain 2 memory.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  26. }
  27. bool CanActivateCondition(Hashtable hashtable)
  28. {
  29. if (CardEffectCommons.IsExistOnBattleArea(card))
  30. {
  31. if (card.Owner.SecurityCards.Count >= 1)
  32. {
  33. return true;
  34. }
  35. }
  36. return false;
  37. }
  38. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  39. {
  40. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  41. player: card.Owner,
  42. destroySecurityCount: 1,
  43. cardEffect: activateClass,
  44. fromTop: true).DestroySecurity());
  45. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(2, activateClass));
  46. }
  47. }
  48. if (timing == EffectTiming.OnEnterFieldAnyone)
  49. {
  50. ActivateClass activateClass = new ActivateClass();
  51. activateClass.SetUpICardEffect("Unsuspend the digivolved Digimon", CanUseCondition, card);
  52. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  53. activateClass.SetHashString("Unsuspend_BT8_044");
  54. cardEffects.Add(activateClass);
  55. string EffectDiscription()
  56. {
  57. return "[Your Turn][Once Per Turn] When one of your other Digimon digivolves, you may unsuspend it.";
  58. }
  59. bool PermanentCondition(Permanent permanent)
  60. {
  61. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  62. {
  63. if (permanent != card.PermanentOfThisCard())
  64. {
  65. return true;
  66. }
  67. }
  68. return false;
  69. }
  70. bool CanUseCondition(Hashtable hashtable)
  71. {
  72. if (CardEffectCommons.IsExistOnBattleArea(card))
  73. {
  74. if (CardEffectCommons.IsOwnerTurn(card))
  75. {
  76. if (CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, PermanentCondition))
  77. {
  78. return true;
  79. }
  80. }
  81. }
  82. return false;
  83. }
  84. bool CanActivateCondition(Hashtable hashtable)
  85. {
  86. if (CardEffectCommons.IsExistOnBattleArea(card))
  87. {
  88. List<Permanent> permanents = CardEffectCommons.GetPlayedPermanentsFromEnterFieldHashtable(
  89. hashtable: hashtable,
  90. rootCondition: null);
  91. if (permanents != null)
  92. {
  93. if (permanents.Count(permanent => CardEffectCommons.IsPermanentExistsOnBattleArea(permanent) && permanent.IsSuspended && permanent.CanUnsuspend) >= 1)
  94. {
  95. return true;
  96. }
  97. }
  98. }
  99. return false;
  100. }
  101. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  102. {
  103. List<Permanent> permanents = CardEffectCommons.GetPlayedPermanentsFromEnterFieldHashtable(
  104. hashtable: _hashtable,
  105. rootCondition: null);
  106. if (permanents != null)
  107. {
  108. List<Permanent> unsuspendTargetPermanents = permanents.Filter(permanent =>
  109. CardEffectCommons.IsPermanentExistsOnBattleArea(permanent)
  110. && permanent.IsSuspended
  111. && permanent.CanUnsuspend);
  112. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(unsuspendTargetPermanents, activateClass).Unsuspend());
  113. }
  114. }
  115. }
  116. return cardEffects;
  117. }
  118. }