BT5_045.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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 BT5_045 : 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("Play 1 Digimon from hand", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Attacking] You may play a yellow level 3 Digimon card or a yellow Digimon card with [Warrior] in its type from your hand without paying its memory cost.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource.IsDigimon)
  26. {
  27. if (cardSource.HasCardColor(CardColor.Yellow))
  28. {
  29. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  30. {
  31. if (cardSource.Level == 3)
  32. {
  33. if (cardSource.HasLevel)
  34. {
  35. return true;
  36. }
  37. }
  38. if (cardSource.CardTraits.Contains("Warrior"))
  39. {
  40. return true;
  41. }
  42. }
  43. }
  44. }
  45. return false;
  46. }
  47. bool CanUseCondition(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  50. }
  51. bool CanActivateCondition(Hashtable hashtable)
  52. {
  53. if (CardEffectCommons.IsExistOnBattleArea(card))
  54. {
  55. if (card.Owner.HandCards.Count >= 1)
  56. {
  57. return true;
  58. }
  59. }
  60. return false;
  61. }
  62. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  63. {
  64. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  65. {
  66. List<CardSource> selectedCards = new List<CardSource>();
  67. int maxCount = 1;
  68. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  69. selectHandEffect.SetUp(
  70. selectPlayer: card.Owner,
  71. canTargetCondition: CanSelectCardCondition,
  72. canTargetCondition_ByPreSelecetedList: null,
  73. canEndSelectCondition: null,
  74. maxCount: maxCount,
  75. canNoSelect: true,
  76. canEndNotMax: false,
  77. isShowOpponent: true,
  78. selectCardCoroutine: SelectCardCoroutine,
  79. afterSelectCardCoroutine: null,
  80. mode: SelectHandEffect.Mode.Custom,
  81. cardEffect: activateClass);
  82. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  83. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  84. yield return StartCoroutine(selectHandEffect.Activate());
  85. IEnumerator SelectCardCoroutine(CardSource cardSource)
  86. {
  87. selectedCards.Add(cardSource);
  88. yield return null;
  89. }
  90. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  91. }
  92. }
  93. }
  94. if (timing == EffectTiming.None)
  95. {
  96. int count()
  97. {
  98. return card.Owner.GetBattleAreaDigimons().Count((permanent) => permanent != card.PermanentOfThisCard());
  99. }
  100. bool Condition()
  101. {
  102. if (CardEffectCommons.IsExistOnBattleArea(card))
  103. {
  104. if (count() >= 1)
  105. {
  106. return true;
  107. }
  108. }
  109. return false;
  110. }
  111. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect<Func<int>>(
  112. changeValue: () => 1000 * count(),
  113. isInheritedEffect: false,
  114. card: card,
  115. condition: Condition));
  116. }
  117. return cardEffects;
  118. }
  119. }