BT23_076.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //Sistermon Blanc
  5. namespace DCGO.CardEffects.BT23
  6. {
  7. public class BT23_076 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region On Play
  13. if (timing == EffectTiming.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Add your top security, <Recovery +1 (Deck)>", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  18. cardEffects.Add(activateClass);
  19. string EffectDescription()
  20. {
  21. return "[On Play] Add your top security card to the hand. Then, <Recovery +1 (Deck)>";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  26. }
  27. bool CanActivateCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.IsExistOnBattleArea(card);
  30. }
  31. IEnumerator ActivateCoroutine(Hashtable hashtable)
  32. {
  33. if(card.Owner.SecurityCards.Count > 0)
  34. {
  35. CardSource topCard = card.Owner.SecurityCards[0];
  36. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(new List<CardSource>() { topCard }, false, activateClass));
  37. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  38. player: card.Owner,
  39. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  40. activateClass).ReduceSecurity());
  41. }
  42. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  43. }
  44. }
  45. #endregion
  46. #region Your Turns
  47. if (timing == EffectTiming.OnTappedAnyone)
  48. {
  49. ActivateClass activateClass = new ActivateClass();
  50. activateClass.SetUpICardEffect("1 of your other Digimon digivolves without paying the cost", CanUseCondition, card);
  51. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  52. cardEffects.Add(activateClass);
  53. string EffectDescription()
  54. {
  55. return "[Your Turn] When this Digimon suspends, 1 of your other Digimon may digivolve into a Digimon card with [Huckmon] in its name or the [Royal Knight] or [CS] trait in the hand or trash with the digivolution cost reduced by 1.";
  56. }
  57. bool DigivolveFromPermanentCondition(Permanent permanent)
  58. {
  59. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  60. permanent.IsDigimon &&
  61. permanent != card.PermanentOfThisCard() &&
  62. (card.Owner.HandCards.Where(DigivolveToCardCondition).Any(cardSource =>
  63. cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass)) ||
  64. card.Owner.TrashCards.Where(DigivolveToCardCondition).Any(cardSource =>
  65. cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass)));
  66. }
  67. bool DigivolveToCardCondition(CardSource cardSource)
  68. {
  69. return cardSource.IsDigimon &&
  70. (cardSource.HasRoyalKnightTraits || cardSource.HasCSTraits || cardSource.ContainsCardName("Huckmon"));
  71. }
  72. bool CanUseCondition(Hashtable hashtable)
  73. {
  74. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  75. CardEffectCommons.IsOwnerTurn(card) &&
  76. CardEffectCommons.CanTriggerWhenSelfPermanentSuspends(hashtable, card);
  77. }
  78. bool CanActivateCondition(Hashtable hashtable)
  79. {
  80. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  81. CardEffectCommons.HasMatchConditionPermanent(DigivolveFromPermanentCondition);
  82. }
  83. IEnumerator ActivateCoroutine(Hashtable hashtable)
  84. {
  85. Permanent selectedPermanent = null;
  86. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  87. selectPermanentEffect.SetUp(
  88. selectPlayer: card.Owner,
  89. canTargetCondition: DigivolveFromPermanentCondition,
  90. canTargetCondition_ByPreSelecetedList: null,
  91. canEndSelectCondition: null,
  92. maxCount: 1,
  93. canNoSelect: true,
  94. canEndNotMax: false,
  95. selectPermanentCoroutine: SelectPermanentCoroutine,
  96. afterSelectPermanentCoroutine: null,
  97. mode: SelectPermanentEffect.Mode.Custom,
  98. cardEffect: activateClass);
  99. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.",
  100. "The opponent is selecting 1 Digimon that will digivolve.");
  101. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  102. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  103. {
  104. selectedPermanent = permanent;
  105. yield return null;
  106. }
  107. if (selectedPermanent != null)
  108. {
  109. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, DigivolveToCardCondition);
  110. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, DigivolveToCardCondition);
  111. if (canSelectHand || canSelectTrash)
  112. {
  113. if (canSelectHand && canSelectTrash)
  114. {
  115. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  116. {
  117. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  118. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  119. };
  120. string selectPlayerMessage = "From which area do you want to digivolve from?";
  121. string notSelectPlayerMessage = "The opponent is choosing where to digivolve from.";
  122. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  123. }
  124. else
  125. {
  126. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  127. }
  128. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  129. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  130. if (fromHand)
  131. {
  132. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  133. targetPermanent: selectedPermanent,
  134. cardCondition: DigivolveToCardCondition,
  135. payCost: true,
  136. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  137. fixedCostTuple: null,
  138. ignoreDigivolutionRequirementFixedCost: -1,
  139. isHand: true,
  140. activateClass: activateClass,
  141. successProcess: null));
  142. }
  143. else
  144. {
  145. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  146. targetPermanent: selectedPermanent,
  147. cardCondition: DigivolveToCardCondition,
  148. payCost: true,
  149. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  150. fixedCostTuple: null,
  151. ignoreDigivolutionRequirementFixedCost: -1,
  152. isHand: false,
  153. activateClass: activateClass,
  154. successProcess: null));
  155. }
  156. }
  157. }
  158. }
  159. }
  160. #endregion
  161. return cardEffects;
  162. }
  163. }
  164. }