BT4_060.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 BT4_060 : 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 the played Digimon", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[All Turns] When you or your opponent play a level 4 or lower Digimon, suspend it.";
  22. }
  23. bool PermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  26. {
  27. if (permanent.IsDigimon)
  28. {
  29. if (permanent.Level <= 4)
  30. {
  31. if (permanent.TopCard.HasLevel)
  32. {
  33. return true;
  34. }
  35. }
  36. }
  37. }
  38. return false;
  39. }
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. if (CardEffectCommons.IsExistOnBattleArea(card))
  43. {
  44. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  45. {
  46. return true;
  47. }
  48. }
  49. return false;
  50. }
  51. bool CanActivateCondition(Hashtable hashtable)
  52. {
  53. if (CardEffectCommons.IsExistOnBattleArea(card))
  54. {
  55. List<Permanent> permanents = CardEffectCommons.GetPlayedPermanentsFromEnterFieldHashtable(
  56. hashtable: hashtable,
  57. rootCondition: null);
  58. if (permanents != null)
  59. {
  60. if (permanents.Count(permanent => CardEffectCommons.IsPermanentExistsOnBattleArea(permanent)
  61. && !permanent.TopCard.CanNotBeAffected(activateClass)
  62. && !permanent.IsSuspended && permanent.CanSuspend) >= 1)
  63. {
  64. return true;
  65. }
  66. }
  67. }
  68. return false;
  69. }
  70. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  71. {
  72. List<Permanent> permanents = CardEffectCommons.GetPlayedPermanentsFromEnterFieldHashtable(
  73. hashtable: _hashtable,
  74. rootCondition: null);
  75. if (permanents != null)
  76. {
  77. List<Permanent> suspendTargetPermanents = permanents
  78. .Filter(permanent => CardEffectCommons.IsPermanentExistsOnBattleArea(permanent)
  79. && !permanent.TopCard.CanNotBeAffected(activateClass)
  80. && !permanent.IsSuspended && permanent.CanSuspend);
  81. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(suspendTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  82. }
  83. }
  84. }
  85. return cardEffects;
  86. }
  87. }