PermanentEffectFactory.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. /// <summary>
  7. /// Class for given effects for Permanents, applying to the entire stack even if any specific card is removed from it
  8. /// </summary>
  9. public partial class PermanentEffectFactory
  10. {
  11. #region Effect of a Permanent to Delete Itself
  12. public static ActivateClass DeleteSelfEffect(Permanent permanent, bool deleteOnOwnturn = true, bool deleteOnOpponentsTurn = true)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Delete this Digimon", CanUseCondition, permanent.TopCard);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, "");
  17. activateClass.SetEffectSourcePermanent(permanent);
  18. return activateClass;
  19. bool CanUseCondition(Hashtable hashtable)
  20. {
  21. if (permanent.TopCard != null && CardEffectCommons.IsExistOnBattleArea(permanent.TopCard))
  22. {
  23. if (CardEffectCommons.IsOwnerTurn(permanent.TopCard))
  24. {
  25. return deleteOnOwnturn;
  26. }
  27. else
  28. {
  29. return deleteOnOpponentsTurn;
  30. }
  31. }
  32. return false;
  33. }
  34. bool CanActivateCondition(Hashtable hashtable)
  35. {
  36. return permanent.TopCard != null
  37. && CardEffectCommons.IsExistOnBattleArea(permanent.TopCard);
  38. }
  39. IEnumerator ActivateCoroutine(Hashtable hashtable)
  40. {
  41. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(new List<Permanent>() { permanent }, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  42. }
  43. }
  44. #endregion
  45. #region Digimon Effect Immunity
  46. public static CanNotAffectedClass DigimonEffectImmunity(Permanent permanent)
  47. {
  48. bool CanUseCondition1(Hashtable hashtable)
  49. {
  50. return CardEffectCommons.IsExistOnBattleAreaDigimon(permanent.TopCard);
  51. }
  52. bool CardCondition(CardSource cardSource)
  53. {
  54. return cardSource == permanent.TopCard
  55. && CardEffectCommons.IsExistOnBattleAreaDigimon(permanent.TopCard);
  56. }
  57. bool SkillCondition(ICardEffect cardEffect)
  58. {
  59. return CardEffectCommons.IsOpponentEffect(cardEffect, permanent.TopCard)
  60. && cardEffect.IsDigimonEffect;
  61. }
  62. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  63. canNotAffectedClass.SetUpICardEffect("Not affected by opponent's Digimon's effects", CanUseCondition1, permanent.TopCard);
  64. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  65. canNotAffectedClass.SetEffectSourcePermanent(permanent);
  66. return canNotAffectedClass;
  67. }
  68. #endregion
  69. }