EX4_061.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.EX4
  5. {
  6. public class EX4_061 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.OnEnterFieldAnyone)
  12. {
  13. ActivateClass activateClass = new ActivateClass();
  14. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  15. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  16. cardEffects.Add(activateClass);
  17. string EffectDiscription()
  18. {
  19. return "[Your Turn] When you play [Gabumon] or [Agumon], by suspending this Tamer, gain 1 memory.";
  20. }
  21. bool PermanentCondition(Permanent permanent)
  22. {
  23. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  24. {
  25. if (permanent.TopCard.CardNames.Contains("Agumon"))
  26. {
  27. return true;
  28. }
  29. if (permanent.TopCard.CardNames.Contains("Gabumon"))
  30. {
  31. return true;
  32. }
  33. }
  34. return false;
  35. }
  36. bool CanUseCondition(Hashtable hashtable)
  37. {
  38. if (CardEffectCommons.IsExistOnBattleArea(card))
  39. {
  40. if (CardEffectCommons.IsOwnerTurn(card))
  41. {
  42. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  43. {
  44. return true;
  45. }
  46. }
  47. }
  48. return false;
  49. }
  50. bool CanActivateCondition(Hashtable hashtable)
  51. {
  52. if (CardEffectCommons.IsExistOnBattleArea(card))
  53. {
  54. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  55. {
  56. return true;
  57. }
  58. }
  59. return false;
  60. }
  61. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  62. {
  63. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  64. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  65. }
  66. }
  67. if (timing == EffectTiming.OnEnterFieldAnyone)
  68. {
  69. ActivateClass activateClass = new ActivateClass();
  70. activateClass.SetUpICardEffect("Play 1 [Gabumon] or [Agumon] from hand or trash", CanUseCondition, card);
  71. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  72. activateClass.SetHashString("Play_EX4_061");
  73. cardEffects.Add(activateClass);
  74. string EffectDiscription()
  75. {
  76. return "[Your Turn][Once Per Turn] When one of your Digimon digivolves, if you have 1 or fewer Digimon, you may play 1 [Gabumon] if that Digimon has [Greymon] in its name or 1 [Agumon] if it has [Garurumon] in its name from your hand or trash without paying the cost.";
  77. }
  78. bool CanSelectCardCondition(CardSource cardSource)
  79. {
  80. if (cardSource.IsDigimon)
  81. {
  82. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  83. {
  84. if (card.Owner.GetBattleAreaDigimons().Count == 1)
  85. {
  86. Permanent permanent = card.Owner.GetBattleAreaDigimons()[0];
  87. if (permanent.TopCard.HasGreymonName)
  88. {
  89. if (cardSource.CardNames.Contains("Gabumon"))
  90. {
  91. return true;
  92. }
  93. }
  94. if (permanent.TopCard.HasGarurumonName)
  95. {
  96. if (cardSource.CardNames.Contains("Agumon"))
  97. {
  98. return true;
  99. }
  100. }
  101. }
  102. }
  103. }
  104. return false;
  105. }
  106. bool PermanentCondition(Permanent permanent)
  107. {
  108. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  109. }
  110. bool CanUseCondition(Hashtable hashtable)
  111. {
  112. if (CardEffectCommons.IsExistOnBattleArea(card))
  113. {
  114. if (CardEffectCommons.IsOwnerTurn(card))
  115. {
  116. if (CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, PermanentCondition))
  117. {
  118. return true;
  119. }
  120. }
  121. }
  122. return false;
  123. }
  124. bool CanActivateCondition(Hashtable hashtable)
  125. {
  126. if (CardEffectCommons.IsExistOnBattleArea(card))
  127. {
  128. if (card.Owner.GetBattleAreaDigimons().Count == 1)
  129. {
  130. Permanent permanent = card.Owner.GetBattleAreaDigimons()[0];
  131. if (permanent.TopCard.HasGreymonName || permanent.TopCard.HasGarurumonName)
  132. {
  133. if (card.Owner.HandCards.Count >= 1)
  134. {
  135. return true;
  136. }
  137. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  138. {
  139. return true;
  140. }
  141. }
  142. }
  143. }
  144. return false;
  145. }
  146. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  147. {
  148. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  149. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  150. if (canSelectHand || canSelectTrash)
  151. {
  152. if (canSelectHand && canSelectTrash)
  153. {
  154. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  155. {
  156. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  157. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  158. };
  159. string selectPlayerMessage = "From which area do you play a card?";
  160. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  161. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  162. }
  163. else
  164. {
  165. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  166. }
  167. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  168. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  169. List<CardSource> selectedCards = new List<CardSource>();
  170. IEnumerator SelectCardCoroutine(CardSource cardSource)
  171. {
  172. selectedCards.Add(cardSource);
  173. yield return null;
  174. }
  175. if (fromHand)
  176. {
  177. int maxCount = 1;
  178. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  179. selectHandEffect.SetUp(
  180. selectPlayer: card.Owner,
  181. canTargetCondition: CanSelectCardCondition,
  182. canTargetCondition_ByPreSelecetedList: null,
  183. canEndSelectCondition: null,
  184. maxCount: maxCount,
  185. canNoSelect: true,
  186. canEndNotMax: false,
  187. isShowOpponent: true,
  188. selectCardCoroutine: SelectCardCoroutine,
  189. afterSelectCardCoroutine: null,
  190. mode: SelectHandEffect.Mode.Custom,
  191. cardEffect: activateClass);
  192. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  193. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  194. yield return StartCoroutine(selectHandEffect.Activate());
  195. }
  196. else
  197. {
  198. int maxCount = 1;
  199. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  200. selectCardEffect.SetUp(
  201. canTargetCondition: CanSelectCardCondition,
  202. canTargetCondition_ByPreSelecetedList: null,
  203. canEndSelectCondition: null,
  204. canNoSelect: () => true,
  205. selectCardCoroutine: SelectCardCoroutine,
  206. afterSelectCardCoroutine: null,
  207. message: "Select 1 card to play.",
  208. maxCount: maxCount,
  209. canEndNotMax: false,
  210. isShowOpponent: true,
  211. mode: SelectCardEffect.Mode.Custom,
  212. root: SelectCardEffect.Root.Trash,
  213. customRootCardList: null,
  214. canLookReverseCard: true,
  215. selectPlayer: card.Owner,
  216. cardEffect: activateClass);
  217. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  218. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  219. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  220. }
  221. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  222. if (!fromHand)
  223. {
  224. root = SelectCardEffect.Root.Trash;
  225. }
  226. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: root, activateETB: true));
  227. }
  228. }
  229. }
  230. if (timing == EffectTiming.SecuritySkill)
  231. {
  232. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  233. }
  234. return cardEffects;
  235. }
  236. }
  237. }