P_189.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. //Dimetromon
  4. namespace DCGO.CardEffects.P
  5. {
  6. public class P_189 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Security Effect
  12. if (timing == EffectTiming.SecuritySkill)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Play a card from your hand or trash.", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  17. activateClass.SetIsSecurityEffect(true);
  18. activateClass.SetIsDigimonEffect(true);
  19. cardEffects.Add(activateClass);
  20. string EffectDescription()
  21. {
  22. return
  23. "[Security] You may play 1 card with the [LIBERATOR] trait and a play cost of 4 or less from your hand or trash without paying the cost.";
  24. }
  25. bool CanUseCondition(Hashtable hashtable)
  26. {
  27. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  28. }
  29. bool CanActivateCondition(Hashtable hashtable)
  30. {
  31. return CardEffectCommons.IsExistOnExecutingArea(card);
  32. }
  33. bool CanSelectCardCondition(CardSource cardSource)
  34. {
  35. return (cardSource.ContainsTraits("Liberator") || cardSource.ContainsTraits("LIBERATOR")) &&
  36. !cardSource.IsDigiEgg &&
  37. cardSource.HasPlayCost && cardSource.GetCostItself <= 4;
  38. }
  39. IEnumerator ActivateCoroutine(Hashtable hashtable)
  40. {
  41. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  42. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  43. if (canSelectHand || canSelectTrash)
  44. {
  45. if (canSelectHand && canSelectTrash)
  46. {
  47. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  48. {
  49. new(message: $"From hand", value: true, spriteIndex: 0),
  50. new(message: $"From trash", value: false, spriteIndex: 1),
  51. };
  52. string selectPlayerMessage = "From which area do you play a card?";
  53. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  54. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  55. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  56. notSelectPlayerMessage: notSelectPlayerMessage);
  57. }
  58. else
  59. {
  60. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  61. }
  62. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  63. .WaitForEndSelect());
  64. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  65. List<CardSource> selectedCards = new List<CardSource>();
  66. IEnumerator SelectCardCoroutine(CardSource cardSource)
  67. {
  68. selectedCards.Add(cardSource);
  69. yield return null;
  70. }
  71. if (fromHand)
  72. {
  73. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  74. selectHandEffect.SetUp(
  75. selectPlayer: card.Owner,
  76. canTargetCondition: CanSelectCardCondition,
  77. canTargetCondition_ByPreSelecetedList: null,
  78. canEndSelectCondition: null,
  79. maxCount: 1,
  80. canNoSelect: true,
  81. canEndNotMax: false,
  82. isShowOpponent: true,
  83. selectCardCoroutine: SelectCardCoroutine,
  84. afterSelectCardCoroutine: null,
  85. mode: SelectHandEffect.Mode.Custom,
  86. cardEffect: activateClass);
  87. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  88. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  89. yield return StartCoroutine(selectHandEffect.Activate());
  90. }
  91. else
  92. {
  93. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  94. selectCardEffect.SetUp(
  95. canTargetCondition: CanSelectCardCondition,
  96. canTargetCondition_ByPreSelecetedList: null,
  97. canEndSelectCondition: null,
  98. canNoSelect: () => true,
  99. selectCardCoroutine: SelectCardCoroutine,
  100. afterSelectCardCoroutine: null,
  101. message: "Select 1 card to play.",
  102. maxCount: 1,
  103. canEndNotMax: false,
  104. isShowOpponent: true,
  105. mode: SelectCardEffect.Mode.Custom,
  106. root: SelectCardEffect.Root.Custom,
  107. customRootCardList: card.Owner.TrashCards,
  108. canLookReverseCard: true,
  109. selectPlayer: card.Owner,
  110. cardEffect: activateClass);
  111. selectCardEffect.SetUpCustomMessage("Select 1 trash card to play.",
  112. "The opponent is selecting 1 trash card to play.");
  113. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  114. yield return StartCoroutine(selectCardEffect.Activate());
  115. }
  116. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  117. cardSources: selectedCards,
  118. activateClass: activateClass,
  119. payCost: false,
  120. isTapped: false,
  121. root: fromHand ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash,
  122. activateETB: true));
  123. }
  124. }
  125. }
  126. #endregion
  127. #region Progress
  128. if (timing == EffectTiming.None)
  129. {
  130. cardEffects.Add(CardEffectFactory.ProgressSelfStaticEffect(false, card, null));
  131. }
  132. #endregion
  133. #region Your Turn inherit
  134. if (timing == EffectTiming.OnLoseSecurity)
  135. {
  136. ActivateClass activateClass = new ActivateClass();
  137. activateClass.SetUpICardEffect("Gain 1 memory", CanUseCondition, card);
  138. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  139. activateClass.SetIsInheritedEffect(true);
  140. activateClass.SetHashString("GainMemory_P_189");
  141. cardEffects.Add(activateClass);
  142. string EffectDiscription()
  143. => "[Your Turn] [Once Per Turn] When your opponent's security stack is removed from, gain 1 memory.";
  144. bool CanUseCondition(Hashtable hashtable)
  145. {
  146. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  147. {
  148. if (CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, PlayerCondition))
  149. {
  150. if (CardEffectCommons.IsOwnerTurn(card))
  151. {
  152. return true;
  153. }
  154. }
  155. }
  156. return false;
  157. }
  158. bool CanActivateCondition(Hashtable hashtable)
  159. {
  160. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  161. {
  162. return true;
  163. }
  164. return false;
  165. }
  166. bool PlayerCondition(Player player)
  167. {
  168. if (player == card.Owner.Enemy)
  169. {
  170. return true;
  171. }
  172. return false;
  173. }
  174. IEnumerator ActivateCoroutine(Hashtable hashtable)
  175. {
  176. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  177. }
  178. }
  179. #endregion
  180. return cardEffects;
  181. }
  182. }
  183. }