P_189.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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.HasPlayCost && cardSource.GetCostItself <= 4;
  37. }
  38. IEnumerator ActivateCoroutine(Hashtable hashtable)
  39. {
  40. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  41. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  42. if (canSelectHand || canSelectTrash)
  43. {
  44. if (canSelectHand && canSelectTrash)
  45. {
  46. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  47. {
  48. new(message: $"From hand", value: true, spriteIndex: 0),
  49. new(message: $"From trash", value: false, spriteIndex: 1),
  50. };
  51. string selectPlayerMessage = "From which area do you play a card?";
  52. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  53. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  54. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  55. notSelectPlayerMessage: notSelectPlayerMessage);
  56. }
  57. else
  58. {
  59. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  60. }
  61. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  62. .WaitForEndSelect());
  63. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  64. List<CardSource> selectedCards = new List<CardSource>();
  65. IEnumerator SelectCardCoroutine(CardSource cardSource)
  66. {
  67. selectedCards.Add(cardSource);
  68. yield return null;
  69. }
  70. if (fromHand)
  71. {
  72. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  73. selectHandEffect.SetUp(
  74. selectPlayer: card.Owner,
  75. canTargetCondition: CanSelectCardCondition,
  76. canTargetCondition_ByPreSelecetedList: null,
  77. canEndSelectCondition: null,
  78. maxCount: 1,
  79. canNoSelect: true,
  80. canEndNotMax: false,
  81. isShowOpponent: true,
  82. selectCardCoroutine: SelectCardCoroutine,
  83. afterSelectCardCoroutine: null,
  84. mode: SelectHandEffect.Mode.Custom,
  85. cardEffect: activateClass);
  86. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  87. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  88. yield return StartCoroutine(selectHandEffect.Activate());
  89. }
  90. else
  91. {
  92. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  93. selectCardEffect.SetUp(
  94. canTargetCondition: CanSelectCardCondition,
  95. canTargetCondition_ByPreSelecetedList: null,
  96. canEndSelectCondition: null,
  97. canNoSelect: () => true,
  98. selectCardCoroutine: SelectCardCoroutine,
  99. afterSelectCardCoroutine: null,
  100. message: "Select 1 card to play.",
  101. maxCount: 1,
  102. canEndNotMax: false,
  103. isShowOpponent: true,
  104. mode: SelectCardEffect.Mode.Custom,
  105. root: SelectCardEffect.Root.Custom,
  106. customRootCardList: card.Owner.TrashCards,
  107. canLookReverseCard: true,
  108. selectPlayer: card.Owner,
  109. cardEffect: activateClass);
  110. selectCardEffect.SetUpCustomMessage("Select 1 trash card to play.",
  111. "The opponent is selecting 1 trash card to play.");
  112. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  113. yield return StartCoroutine(selectCardEffect.Activate());
  114. }
  115. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  116. cardSources: selectedCards,
  117. activateClass: activateClass,
  118. payCost: false,
  119. isTapped: false,
  120. root: fromHand ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash,
  121. activateETB: true));
  122. }
  123. }
  124. }
  125. #endregion
  126. #region Progress
  127. if (timing == EffectTiming.None)
  128. {
  129. cardEffects.Add(CardEffectFactory.ProgressSelfStaticEffect(false, card, null));
  130. }
  131. #endregion
  132. #region Your Turn inherit
  133. if (timing == EffectTiming.OnLoseSecurity)
  134. {
  135. ActivateClass activateClass = new ActivateClass();
  136. activateClass.SetUpICardEffect("Gain 1 memory", CanUseCondition, card);
  137. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  138. activateClass.SetIsInheritedEffect(true);
  139. activateClass.SetHashString("GainMemory_P_189");
  140. cardEffects.Add(activateClass);
  141. string EffectDiscription()
  142. => "[Your Turn] [Once Per Turn] When your opponent's security stack is removed from, gain 1 memory.";
  143. bool CanUseCondition(Hashtable hashtable)
  144. {
  145. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  146. {
  147. if (CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, PlayerCondition))
  148. {
  149. if (CardEffectCommons.IsOwnerTurn(card))
  150. {
  151. return true;
  152. }
  153. }
  154. }
  155. return false;
  156. }
  157. bool CanActivateCondition(Hashtable hashtable)
  158. {
  159. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  160. {
  161. return true;
  162. }
  163. return false;
  164. }
  165. bool PlayerCondition(Player player)
  166. {
  167. if (player == card.Owner.Enemy)
  168. {
  169. return true;
  170. }
  171. return false;
  172. }
  173. IEnumerator ActivateCoroutine(Hashtable hashtable)
  174. {
  175. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  176. }
  177. }
  178. #endregion
  179. return cardEffects;
  180. }
  181. }
  182. }