P_147.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using static Cinemachine.DocumentationSortingAttribute;
  4. using System.Data;
  5. using System.Runtime.ConstrainedExecution;
  6. using UnityEngine.XR;
  7. using System.Linq;
  8. namespace DCGO.CardEffects.P
  9. {
  10. public class P_147 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region Rule: Name is also Pulsemon
  16. if (timing == EffectTiming.None)
  17. {
  18. ChangeCardNamesClass changeCardNamesClass = new ChangeCardNamesClass();
  19. changeCardNamesClass.SetUpICardEffect("Also treated as [Pulsemon]", CanUseCondition, card);
  20. changeCardNamesClass.SetUpChangeCardNamesClass(changeCardNames: changeCardNames);
  21. cardEffects.Add(changeCardNamesClass);
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. return true;
  25. }
  26. List<string> changeCardNames(CardSource cardSource, List<string> CardNames)
  27. {
  28. if (cardSource == card)
  29. {
  30. CardNames.Add("Pulsemon");
  31. }
  32. return CardNames;
  33. }
  34. }
  35. #endregion
  36. #region Alternate Digivolution Requirement
  37. if (timing == EffectTiming.None)
  38. {
  39. bool PermanentCondition(Permanent targetPermanent)
  40. {
  41. if (targetPermanent.TopCard.CardNames.Contains("Bibimon"))
  42. {
  43. return true;
  44. }
  45. return false;
  46. }
  47. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  48. permanentCondition: PermanentCondition,
  49. digivolutionCost: 0,
  50. ignoreDigivolutionRequirement: false,
  51. card: card,
  52. condition: null));
  53. }
  54. #endregion
  55. #region When Attacking
  56. if (timing == EffectTiming.OnAllyAttack)
  57. {
  58. ActivateClass activateClass = new ActivateClass();
  59. activateClass.SetUpICardEffect("Place 1 level 4 with [Pulsemon] in its text as bottom digivolution source, activate one of that card's [When Digivolving] effects", CanUseCondition, card);
  60. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  61. cardEffects.Add(activateClass);
  62. string EffectDiscription()
  63. {
  64. return "[When Attacking] [Once Per Turn] By placing 1 level 4 card with [Pulsemon] in its text from your hand as this Digimon’s bottom digivolution card, activate one of that card's [When Digivolving] effects as an effect of this Digimon.";
  65. }
  66. bool CanSelectCardCondition(CardSource cardSource)
  67. {
  68. if (cardSource.HasLevel && cardSource.Level == 4)
  69. {
  70. if (cardSource.HasPulsemonText)
  71. {
  72. return true;
  73. }
  74. }
  75. return false;
  76. }
  77. bool CanUseCondition(Hashtable hashtable)
  78. {
  79. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  80. }
  81. bool CanActivateCondition(Hashtable hashtable)
  82. {
  83. if (CardEffectCommons.IsExistOnBattleArea(card))
  84. {
  85. if(card.Owner.HandCards.Count >= 1)
  86. {
  87. return true;
  88. }
  89. }
  90. return false;
  91. }
  92. IEnumerator ActivateCoroutine(Hashtable hashtable)
  93. {
  94. List<CardSource> selectedCards = new List<CardSource>();
  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: 1,
  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(
  110. "Select 1 card to place on bottom of digivolution cards.",
  111. "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  112. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  113. yield return StartCoroutine(selectHandEffect.Activate());
  114. IEnumerator SelectCardCoroutine(CardSource cardSource)
  115. {
  116. selectedCards.Add(cardSource);
  117. yield return null;
  118. }
  119. CardSource selectedCard = null;
  120. if (selectedCards.Count >= 1)
  121. {
  122. if (CardEffectCommons.IsExistOnBattleArea(card))
  123. {
  124. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(
  125. selectedCards,
  126. activateClass));
  127. selectedCard = selectedCards[0];
  128. }
  129. }
  130. if (selectedCard != null)
  131. {
  132. List<ICardEffect> candidateEffects = selectedCard.EffectList_ForCard(EffectTiming.OnEnterFieldAnyone, card)
  133. .Clone()
  134. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsWhenDigivolving);
  135. if (candidateEffects.Count >= 1)
  136. {
  137. ICardEffect selectedEffect = null;
  138. if (candidateEffects.Count == 1)
  139. {
  140. selectedEffect = candidateEffects[0];
  141. }
  142. else
  143. {
  144. List<SkillInfo> skillInfos = candidateEffects
  145. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  146. List<CardSource> cardSources = candidateEffects
  147. .Map(cardEffect => cardEffect.EffectSourceCard);
  148. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  149. selectCardEffect.SetUp(
  150. canTargetCondition: (cardSource) => true,
  151. canTargetCondition_ByPreSelecetedList: null,
  152. canEndSelectCondition: null,
  153. canNoSelect: () => false,
  154. selectCardCoroutine: null,
  155. afterSelectCardCoroutine: null,
  156. message: "Select 1 effect to activate.",
  157. maxCount: 1,
  158. canEndNotMax: false,
  159. isShowOpponent: false,
  160. mode: SelectCardEffect.Mode.Custom,
  161. root: SelectCardEffect.Root.Custom,
  162. customRootCardList: cardSources,
  163. canLookReverseCard: true,
  164. selectPlayer: card.Owner,
  165. cardEffect: activateClass);
  166. selectCardEffect.SetNotShowCard();
  167. selectCardEffect.SetUpSkillInfos(skillInfos);
  168. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  169. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  170. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  171. {
  172. if (selectedIndexes.Count == 1)
  173. {
  174. selectedEffect = candidateEffects[selectedIndexes[0]];
  175. yield return null;
  176. }
  177. }
  178. }
  179. if (selectedEffect != null)
  180. {
  181. Hashtable effectHashtable = CardEffectCommons.WhenDigivolvingCheckHashtableOfCard(card);
  182. if (selectedEffect.CanUse(effectHashtable))
  183. {
  184. yield return ContinuousController.instance.StartCoroutine(
  185. ((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(effectHashtable));
  186. }
  187. }
  188. }
  189. }
  190. }
  191. }
  192. #endregion
  193. #region Your Turn - DP Boost
  194. if (timing == EffectTiming.None)
  195. {
  196. bool HasTamer(Permanent permanent)
  197. {
  198. return permanent.IsTamer;
  199. }
  200. bool Condition()
  201. {
  202. if (CardEffectCommons.IsOwnerTurn(card))
  203. {
  204. return CardEffectCommons.HasMatchConditionOwnersPermanent(card, HasTamer);
  205. }
  206. return false;
  207. }
  208. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect(
  209. changeValue: 3000,
  210. isInheritedEffect: false,
  211. card: card,
  212. condition: Condition));
  213. }
  214. #endregion
  215. return cardEffects;
  216. }
  217. }
  218. }