P_195.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnityEngine;
  5. //Inori Misono
  6. namespace DCGO.CardEffects.P
  7. {
  8. public class P_195 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Start of Main Phase
  14. if (timing == EffectTiming.OnStartMainPhase)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "[Start of Your Main Phase] If your opponent has a Digimon, gain 1 memory.";
  23. }
  24. bool CanUseCondition(Hashtable hashtable)
  25. {
  26. if (CardEffectCommons.IsExistOnBattleArea(card))
  27. {
  28. if (CardEffectCommons.IsOwnerTurn(card))
  29. {
  30. return true;
  31. }
  32. }
  33. return false;
  34. }
  35. bool CanActivateCondition(Hashtable hashtable)
  36. {
  37. if (CardEffectCommons.IsExistOnBattleArea(card))
  38. {
  39. if (card.Owner.Enemy.GetBattleAreaDigimons().Count >= 1)
  40. {
  41. if (card.Owner.CanAddMemory(activateClass))
  42. {
  43. return true;
  44. }
  45. }
  46. }
  47. return false;
  48. }
  49. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  50. {
  51. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  52. }
  53. }
  54. #endregion
  55. #region On Play
  56. if (timing == EffectTiming.OnEnterFieldAnyone)
  57. {
  58. ActivateClass activateClass = new ActivateClass();
  59. activateClass.SetUpICardEffect("Play 1 [Elecmon] or digivolve into [Aegiomon]", CanUseCondition, card);
  60. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  61. cardEffects.Add(activateClass);
  62. string EffectDiscription()
  63. {
  64. return "[On Play] Activate 1 of the effects below:\r\n・You may play 1 [Elecmon] from your hand without paying the cost.\r\n・1 of your Digimon may digivolve into [Aegiomon] in the hand without paying the cost.";
  65. }
  66. bool CanUseCondition(Hashtable hashtable)
  67. {
  68. return CardEffectCommons.IsExistOnBattleArea(card) &&
  69. CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  70. }
  71. bool CanActivateCondition(Hashtable hashtable)
  72. {
  73. return CardEffectCommons.IsExistOnBattleArea(card);
  74. }
  75. bool IsElecmon(CardSource source)
  76. {
  77. return source.EqualsCardName("Elecmon") &&
  78. CardEffectCommons.CanPlayAsNewPermanent(source, false, activateClass);
  79. }
  80. bool IsAegiomon(CardSource source)
  81. {
  82. return source.IsDigimon &&
  83. source.EqualsCardName("Aegiomon");
  84. }
  85. bool CanSelectPermanentCondition(Permanent permanent)
  86. {
  87. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  88. {
  89. foreach (CardSource cardSource in card.Owner.HandCards)
  90. {
  91. if (IsAegiomon(cardSource))
  92. {
  93. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  94. {
  95. return true;
  96. }
  97. }
  98. }
  99. }
  100. return false;
  101. }
  102. IEnumerator ActivateCoroutine(Hashtable hashtable)
  103. {
  104. bool CanPlayElecmon = CardEffectCommons.HasMatchConditionOwnersHand(card, IsElecmon);
  105. bool CanEvoAegiomon = CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  106. #region Option Selection
  107. if (CanPlayElecmon || CanEvoAegiomon)
  108. {
  109. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  110. {
  111. new(message: "You may play 1 [Elecmon] from your hand without paying the cost.", value: 0, spriteIndex: 0),
  112. new(message: "1 of your Digimon may digivolve into [Aegiomon] in the hand without paying the cost.", value: 1, spriteIndex: 0),
  113. };
  114. string selectPlayerMessage = "Which effect will you activate?";
  115. string notSelectPlayerMessage = "The opponent is choosing which effect to activate.";
  116. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements,
  117. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  118. notSelectPlayerMessage: notSelectPlayerMessage);
  119. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  120. int actionID = GManager.instance.userSelectionManager.SelectedIntValue;
  121. #region Play Elecmon
  122. if (actionID == 0 && CanPlayElecmon)
  123. {
  124. List<CardSource> selectedCards = new List<CardSource>();
  125. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  126. selectHandEffect.SetUp(
  127. selectPlayer: card.Owner,
  128. canTargetCondition: IsElecmon,
  129. canTargetCondition_ByPreSelecetedList: null,
  130. canEndSelectCondition: null,
  131. maxCount: 1,
  132. canNoSelect: true,
  133. canEndNotMax: false,
  134. isShowOpponent: true,
  135. selectCardCoroutine: SelectCardCoroutine,
  136. afterSelectCardCoroutine: null,
  137. mode: SelectHandEffect.Mode.Custom,
  138. cardEffect: activateClass);
  139. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  140. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  141. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  142. IEnumerator SelectCardCoroutine(CardSource cardSource)
  143. {
  144. selectedCards.Add(cardSource);
  145. yield return null;
  146. }
  147. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  148. }
  149. #endregion
  150. #region Digivolve
  151. if (actionID == 1 && CanEvoAegiomon)
  152. {
  153. Permanent target = null;
  154. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  155. selectPermanentEffect.SetUp(
  156. selectPlayer: card.Owner,
  157. canTargetCondition: CanSelectPermanentCondition,
  158. canTargetCondition_ByPreSelecetedList: null,
  159. canEndSelectCondition: null,
  160. maxCount: 1,
  161. canNoSelect: true,
  162. canEndNotMax: false,
  163. selectPermanentCoroutine: SelectPermanentCoroutine,
  164. afterSelectPermanentCoroutine: null,
  165. mode: SelectPermanentEffect.Mode.Custom,
  166. cardEffect: activateClass);
  167. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to digivolve.", "The opponent is selecting 1 digimon to digivolve.");
  168. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  169. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  170. {
  171. target = permanent;
  172. yield return null;
  173. }
  174. if (target != null)
  175. {
  176. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  177. targetPermanent: target,
  178. cardCondition: IsAegiomon,
  179. payCost: false,
  180. reduceCostTuple: null,
  181. fixedCostTuple: null,
  182. ignoreDigivolutionRequirementFixedCost: -1,
  183. isHand: true,
  184. activateClass: activateClass,
  185. successProcess: null,
  186. ignoreRequirements: CardEffectCommons.IgnoreRequirement.All));
  187. }
  188. }
  189. #endregion
  190. }
  191. #endregion
  192. }
  193. }
  194. #endregion
  195. #region Security
  196. if (timing == EffectTiming.SecuritySkill)
  197. {
  198. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  199. }
  200. #endregion
  201. return cardEffects;
  202. }
  203. }
  204. }