ST12_12.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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 ST12_12 : 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("Trash 1 card from hand to Draw 2", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[On Play] By trashing 1 card in your hand, <Draw 2>. (Draw 2 cards from your deck.)";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. return true;
  26. }
  27. bool CanUseCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  30. }
  31. bool CanActivateCondition(Hashtable hashtable)
  32. {
  33. if (CardEffectCommons.IsExistOnBattleArea(card))
  34. {
  35. if (card.Owner.HandCards.Count >= 1)
  36. {
  37. return true;
  38. }
  39. }
  40. return false;
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  43. {
  44. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  45. {
  46. bool discarded = false;
  47. int discardCount = 1;
  48. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  49. selectHandEffect.SetUp(
  50. selectPlayer: card.Owner,
  51. canTargetCondition: CanSelectCardCondition,
  52. canTargetCondition_ByPreSelecetedList: null,
  53. canEndSelectCondition: null,
  54. maxCount: discardCount,
  55. canNoSelect: true,
  56. canEndNotMax: false,
  57. isShowOpponent: true,
  58. selectCardCoroutine: null,
  59. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  60. mode: SelectHandEffect.Mode.Discard,
  61. cardEffect: activateClass);
  62. yield return StartCoroutine(selectHandEffect.Activate());
  63. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  64. {
  65. if (cardSources.Count >= 1)
  66. {
  67. discarded = true;
  68. yield return null;
  69. }
  70. }
  71. if (discarded)
  72. {
  73. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  74. }
  75. }
  76. }
  77. }
  78. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  79. {
  80. bool CanSelectPermanentCondition(Permanent permanent)
  81. {
  82. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  83. {
  84. if (permanent != card.PermanentOfThisCard())
  85. {
  86. if (permanent.TopCard.CardColors.Contains(CardColor.Red) || permanent.TopCard.CardColors.Contains(CardColor.Black))
  87. {
  88. if (permanent.willBeRemoveField)
  89. {
  90. return true;
  91. }
  92. }
  93. }
  94. }
  95. return false;
  96. }
  97. string EffectDiscription()
  98. {
  99. return "<Decoy (Red/Black)>.(When one of your other red or black Digimon would be deleted by an opponent's effect, you may delete this Digimon to prevent that deletion.)";
  100. }
  101. bool Condition()
  102. {
  103. if (CardEffectCommons.IsExistOnBattleArea(card))
  104. {
  105. if (card.Owner.GetBattleAreaDigimons().Count(permanent => permanent.TopCard.ContainsCardName("Huckmon") || permanent.TopCard.HasRoyalKnightTraits) >= 1)
  106. {
  107. return true;
  108. }
  109. }
  110. return false;
  111. }
  112. cardEffects.Add(CardEffectFactory.DecoySelfEffect(isInheritedEffect: false, card: card, condition: Condition, permanentCondition: CanSelectPermanentCondition, effectName: "Decoy (Red/Black)", effectDiscription: EffectDiscription()));
  113. }
  114. return cardEffects;
  115. }
  116. }