BT10_016.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. namespace DCGO.CardEffects.BT10
  9. {
  10. public class BT10_016 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.CardNames.Contains("Jesmon");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  24. {
  25. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  26. }
  27. if (timing == EffectTiming.OnEnterFieldAnyone)
  28. {
  29. ActivateClass activateClass = new ActivateClass();
  30. activateClass.SetUpICardEffect("Play 1 Digimon from hand or trash and your Digimon get effects", CanUseCondition, card);
  31. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  32. cardEffects.Add(activateClass);
  33. string EffectDiscription()
  34. {
  35. return "[When Digivolving] You may play 1 Digimon card with [Sistermon] in its name from your hand or trash without paying its memory cost. Then, if [Jesmon] is in this Digimon's digivolution cards or you have a Digimon with [Sistermon] in its name in play, until the end of your opponent's turn, all of your Digimon may also attack unsuspended Digimon and get +2000 DP.";
  36. }
  37. bool CanSelectCardCondition(CardSource cardSource)
  38. {
  39. if (cardSource.IsDigimon)
  40. {
  41. if (cardSource.ContainsCardName("Sistermon"))
  42. {
  43. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  44. {
  45. return true;
  46. }
  47. }
  48. }
  49. return false;
  50. }
  51. bool CanUseCondition(Hashtable hashtable)
  52. {
  53. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  54. }
  55. bool CanActivateCondition(Hashtable hashtable)
  56. {
  57. if (CardEffectCommons.IsExistOnBattleArea(card))
  58. {
  59. return true;
  60. }
  61. return false;
  62. }
  63. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  64. {
  65. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  66. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  67. if (canSelectHand || canSelectTrash)
  68. {
  69. if (canSelectHand && canSelectTrash)
  70. {
  71. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  72. {
  73. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  74. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  75. };
  76. string selectPlayerMessage = "From which area do you play a card?";
  77. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  78. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  79. }
  80. else
  81. {
  82. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  83. }
  84. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  85. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  86. List<CardSource> selectedCards = new List<CardSource>();
  87. IEnumerator SelectCardCoroutine(CardSource cardSource)
  88. {
  89. selectedCards.Add(cardSource);
  90. yield return null;
  91. }
  92. if (fromHand)
  93. {
  94. int maxCount = 1;
  95. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  96. selectHandEffect.SetUp(
  97. selectPlayer: card.Owner,
  98. canTargetCondition: CanSelectCardCondition,
  99. canTargetCondition_ByPreSelecetedList: null,
  100. canEndSelectCondition: null,
  101. maxCount: maxCount,
  102. canNoSelect: true,
  103. canEndNotMax: false,
  104. isShowOpponent: true,
  105. selectCardCoroutine: SelectCardCoroutine,
  106. afterSelectCardCoroutine: null,
  107. mode: SelectHandEffect.Mode.Custom,
  108. cardEffect: activateClass);
  109. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  110. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  111. yield return StartCoroutine(selectHandEffect.Activate());
  112. }
  113. else
  114. {
  115. int maxCount = 1;
  116. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  117. selectCardEffect.SetUp(
  118. canTargetCondition: CanSelectCardCondition,
  119. canTargetCondition_ByPreSelecetedList: null,
  120. canEndSelectCondition: null,
  121. canNoSelect: () => true,
  122. selectCardCoroutine: SelectCardCoroutine,
  123. afterSelectCardCoroutine: null,
  124. message: "Select 1 card to play.",
  125. maxCount: maxCount,
  126. canEndNotMax: false,
  127. isShowOpponent: true,
  128. mode: SelectCardEffect.Mode.Custom,
  129. root: SelectCardEffect.Root.Trash,
  130. customRootCardList: null,
  131. canLookReverseCard: true,
  132. selectPlayer: card.Owner,
  133. cardEffect: activateClass);
  134. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  135. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  136. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  137. }
  138. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  139. if (!fromHand)
  140. {
  141. root = SelectCardEffect.Root.Trash;
  142. }
  143. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: root, activateETB: true));
  144. }
  145. if ((CardEffectCommons.IsExistOnBattleArea(card) && card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardNames.Contains("Jesmon")) >= 1) || CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent.TopCard.ContainsCardName("Sistermon")))
  146. {
  147. bool PermanentCondition(Permanent permanent)
  148. {
  149. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  150. }
  151. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDPPlayerEffect(
  152. permanentCondition: PermanentCondition,
  153. changeValue: 2000,
  154. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  155. activateClass: activateClass));
  156. CanAttackTargetDefendingPermanentClass canAttackTargetDefendingPermanentClass = new CanAttackTargetDefendingPermanentClass();
  157. canAttackTargetDefendingPermanentClass.SetUpICardEffect($"Can attack to unsuspended Digimon", CanUseCondition1, card);
  158. canAttackTargetDefendingPermanentClass.SetUpCanAttackTargetDefendingPermanentClass(attackerCondition: PermanentCondition, defenderCondition: DefenderCondition, cardEffectCondition: CardEffectCondition);
  159. card.Owner.UntilOpponentTurnEndEffects.Add((_timing) => canAttackTargetDefendingPermanentClass);
  160. bool CanUseCondition1(Hashtable hashtable)
  161. {
  162. return true;
  163. }
  164. bool DefenderCondition(Permanent permanent)
  165. {
  166. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  167. {
  168. if (!permanent.IsSuspended)
  169. {
  170. return true;
  171. }
  172. }
  173. return false;
  174. }
  175. bool CardEffectCondition(ICardEffect cardEffect)
  176. {
  177. return true;
  178. }
  179. }
  180. }
  181. }
  182. return cardEffects;
  183. }
  184. }
  185. }