BT9_041.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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 BT9_041 : 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.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.CardNames.Contains("RizeGreymon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. if (timing == EffectTiming.OnEnterFieldAnyone)
  22. {
  23. ActivateClass activateClass = new ActivateClass();
  24. activateClass.SetUpICardEffect("Play 1 Tamer from hand and opponent's Digimon reduces DP", CanUseCondition, card);
  25. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  26. cardEffects.Add(activateClass);
  27. string EffectDiscription()
  28. {
  29. return "[When Digivolving] You may play 1 yellow or red Tamer card from your hand without paying its memory cost. Then, if [RizeGreymon] or [X Antibody] is in this Digimon's digivolution cards, 1 of your opponent's Digimon gets -2000 DP for the turn for each yellow or red Tamer you have in play.";
  30. }
  31. bool CanSelectCardCondition(CardSource cardSource)
  32. {
  33. if (cardSource.IsTamer)
  34. {
  35. if (cardSource.HasCardColor(CardColor.Yellow) || cardSource.HasCardColor(CardColor.Red))
  36. {
  37. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  38. {
  39. return true;
  40. }
  41. }
  42. }
  43. return false;
  44. }
  45. bool CanSelectPermanentCondition(Permanent permanent)
  46. {
  47. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  48. }
  49. bool CanUseCondition(Hashtable hashtable)
  50. {
  51. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  52. }
  53. bool CanActivateCondition(Hashtable hashtable)
  54. {
  55. if (CardEffectCommons.IsExistOnBattleArea(card))
  56. {
  57. return true;
  58. }
  59. return false;
  60. }
  61. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  62. {
  63. if (isExistOnField(card))
  64. {
  65. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  66. {
  67. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  68. {
  69. List<CardSource> selectedCards = new List<CardSource>();
  70. int maxCount = 1;
  71. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  72. selectHandEffect.SetUp(
  73. selectPlayer: card.Owner,
  74. canTargetCondition: CanSelectCardCondition,
  75. canTargetCondition_ByPreSelecetedList: null,
  76. canEndSelectCondition: null,
  77. maxCount: maxCount,
  78. canNoSelect: true,
  79. canEndNotMax: false,
  80. isShowOpponent: true,
  81. selectCardCoroutine: SelectCardCoroutine,
  82. afterSelectCardCoroutine: null,
  83. mode: SelectHandEffect.Mode.Custom,
  84. cardEffect: activateClass);
  85. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  86. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  87. yield return StartCoroutine(selectHandEffect.Activate());
  88. IEnumerator SelectCardCoroutine(CardSource cardSource)
  89. {
  90. selectedCards.Add(cardSource);
  91. yield return null;
  92. }
  93. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  94. }
  95. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardNames.Contains("RizeGreymon") || cardSource.CardNames.Contains("X Antibody") || cardSource.CardNames.Contains("XAntibody")) >= 1)
  96. {
  97. int minusDP = 2000 * card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.IsTamer && (permanent.TopCard.CardColors.Contains(CardColor.Red) || permanent.TopCard.CardColors.Contains(CardColor.Yellow)));
  98. if (minusDP > 0)
  99. {
  100. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  101. {
  102. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  103. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  104. selectPermanentEffect.SetUp(
  105. selectPlayer: card.Owner,
  106. canTargetCondition: CanSelectPermanentCondition,
  107. canTargetCondition_ByPreSelecetedList: null,
  108. canEndSelectCondition: null,
  109. maxCount: maxCount,
  110. canNoSelect: false,
  111. canEndNotMax: false,
  112. selectPermanentCoroutine: SelectPermanentCoroutine,
  113. afterSelectPermanentCoroutine: null,
  114. mode: SelectPermanentEffect.Mode.Custom,
  115. cardEffect: activateClass);
  116. selectPermanentEffect.SetUpCustomMessage($"Select 1 Digimon that will get DP -{minusDP}.", $"The opponent is selecting 1 Digimon that will get DP -{minusDP}.");
  117. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  118. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  119. {
  120. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -minusDP, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  121. }
  122. }
  123. }
  124. }
  125. }
  126. }
  127. }
  128. }
  129. if (timing == EffectTiming.None)
  130. {
  131. int count()
  132. {
  133. return card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.IsTamer);
  134. }
  135. bool Condition()
  136. {
  137. if (CardEffectCommons.IsExistOnBattleArea(card))
  138. {
  139. if (CardEffectCommons.IsOwnerTurn(card))
  140. {
  141. if (count() >= 1)
  142. {
  143. return true;
  144. }
  145. }
  146. }
  147. return false;
  148. }
  149. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect<Func<int>>(changeValue: () => 1000 * count(), isInheritedEffect: false, card: card, condition: Condition));
  150. }
  151. return cardEffects;
  152. }
  153. }