BT15_078.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT15
  6. {
  7. public class BT15_078 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region All Turns - Effect plays opponents digimon
  13. if (timing == EffectTiming.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("All Opponents digimon, gain Memory -1", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  18. activateClass.SetHashString("LoseMemory_BT15_078");
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "[All Turns] [Once Per Turn] When an effect plays an opponent's Digimon, until the end of their turn, all of your opponent's Digimon gain \"[On Deletion] Lose 1 memory.\"";
  23. }
  24. bool PermanentCondition(Permanent permanent)
  25. {
  26. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  27. }
  28. bool CanUseCondition(Hashtable hashtable)
  29. {
  30. if (CardEffectCommons.IsExistOnBattleArea(card))
  31. {
  32. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  33. {
  34. if (CardEffectCommons.IsByEffect(hashtable, null))
  35. {
  36. return true;
  37. }
  38. }
  39. }
  40. return false;
  41. }
  42. bool CanActivateCondition(Hashtable hashtable)
  43. {
  44. if (CardEffectCommons.IsExistOnBattleArea(card))
  45. {
  46. return true;
  47. }
  48. return false;
  49. }
  50. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  51. {
  52. bool PermanentCondition(Permanent permanent)
  53. {
  54. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  55. {
  56. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  57. {
  58. return true;
  59. }
  60. }
  61. return false;
  62. }
  63. foreach (Permanent permanent in card.Owner.Enemy.GetBattleAreaPermanents())
  64. {
  65. if (PermanentCondition(permanent))
  66. {
  67. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(permanent));
  68. }
  69. }
  70. AddSkillClass addSkillClass = new AddSkillClass();
  71. addSkillClass.SetUpICardEffect("Memory -1", CanUseCondition1, card);
  72. addSkillClass.SetUpAddSkillClass(cardSourceCondition: CardSourceCondition, getEffects: GetEffects);
  73. card.Owner.UntilOpponentTurnEndEffects.Add((_timing) => addSkillClass);
  74. card.Owner.UntilOpponentTurnEndEffects.Add(GetDetailEffect);
  75. bool CanUseCondition1(Hashtable hashtable)
  76. {
  77. return true;
  78. }
  79. bool CardSourceCondition(CardSource cardSource)
  80. {
  81. if (PermanentCondition(cardSource.PermanentOfThisCard()))
  82. {
  83. if (cardSource == cardSource.PermanentOfThisCard().TopCard)
  84. {
  85. return true;
  86. }
  87. }
  88. return false;
  89. }
  90. ICardEffect GetDetailEffect(EffectTiming timing)
  91. {
  92. if (timing == EffectTiming.None)
  93. {
  94. return CardEffectFactory.AddDetailClass(CanUseCondition1, PermanentCondition, "[On Deletion] Lose 1 memory.", true, card);
  95. }
  96. return null;
  97. }
  98. List<ICardEffect> GetEffects(CardSource cardSource, List<ICardEffect> cardEffects, EffectTiming _timing)
  99. {
  100. if (_timing == EffectTiming.OnDestroyedAnyone)
  101. {
  102. ActivateClass activateClass1 = new ActivateClass();
  103. activateClass1.SetUpICardEffect("Memory -1", CanUseCondition2, cardSource);
  104. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  105. cardEffects.Add(activateClass1);
  106. if (cardSource.PermanentOfThisCard() != null)
  107. {
  108. activateClass1.SetEffectSourcePermanent(cardSource.PermanentOfThisCard());
  109. }
  110. string EffectDiscription1()
  111. {
  112. return "[On Deletion] Lose 1 memory.";
  113. }
  114. bool CanUseCondition2(Hashtable hashtable)
  115. {
  116. if (CardSourceCondition(cardSource))
  117. {
  118. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, permanent => permanent == cardSource.PermanentOfThisCard(), activateClass1))
  119. {
  120. return true;
  121. }
  122. }
  123. return false;
  124. }
  125. bool CanActivateCondition1(Hashtable hashtable)
  126. {
  127. if (CardEffectCommons.CanActivateOnDeletion(cardSource, activateClass1))
  128. {
  129. return true;
  130. }
  131. return false;
  132. }
  133. IEnumerator ActivateCoroutine1(Hashtable _hashtable)
  134. {
  135. yield return ContinuousController.instance.StartCoroutine(cardSource.Owner.AddMemory(-1, activateClass1));
  136. }
  137. }
  138. return cardEffects;
  139. }
  140. }
  141. }
  142. #endregion
  143. #region When Attacking - opponent plays a digimon
  144. if (timing == EffectTiming.OnAllyAttack)
  145. {
  146. ActivateClass activateClass = new ActivateClass();
  147. activateClass.SetUpICardEffect("Opponent plays 1 Digimon from trash", CanUseCondition, card);
  148. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  149. cardEffects.Add(activateClass);
  150. string EffectDiscription()
  151. {
  152. return "[When Attacking] Your opponent plays 1 level 4 or lower Digimon card from their trash suspended without paying the cost. [On Play] effects on Digimon played by this effect don't activate. Then, you may switch the target of attack to that Digimon.";
  153. }
  154. bool CanSelectCardCondition(CardSource cardSource)
  155. {
  156. if (cardSource.IsDigimon)
  157. {
  158. if (cardSource.Level <= 4)
  159. {
  160. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  161. {
  162. if (cardSource.HasLevel)
  163. {
  164. return true;
  165. }
  166. }
  167. }
  168. }
  169. return false;
  170. }
  171. bool CanUseCondition(Hashtable hashtable)
  172. {
  173. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  174. }
  175. bool CanActivateCondition(Hashtable hashtable)
  176. {
  177. if (CardEffectCommons.IsExistOnBattleArea(card))
  178. {
  179. if (CardEffectCommons.HasMatchConditionOpponentsCardInTrash(card, CanSelectCardCondition))
  180. {
  181. return true;
  182. }
  183. }
  184. return false;
  185. }
  186. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  187. {
  188. if (CardEffectCommons.HasMatchConditionOpponentsCardInTrash(card, CanSelectCardCondition))
  189. {
  190. List<CardSource> selectedCards = new List<CardSource>();
  191. int maxCount = Math.Min(1, card.Owner.Enemy.TrashCards.Count(CanSelectCardCondition));
  192. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  193. selectCardEffect.SetUp(
  194. canTargetCondition: CanSelectCardCondition,
  195. canTargetCondition_ByPreSelecetedList: null,
  196. canEndSelectCondition: null,
  197. canNoSelect: () => false,
  198. selectCardCoroutine: SelectCardCoroutine,
  199. afterSelectCardCoroutine: null,
  200. message: "Select 1 card to play.",
  201. maxCount: maxCount,
  202. canEndNotMax: false,
  203. isShowOpponent: true,
  204. mode: SelectCardEffect.Mode.Custom,
  205. root: SelectCardEffect.Root.Trash,
  206. customRootCardList: null,
  207. canLookReverseCard: true,
  208. selectPlayer: card.Owner.Enemy,
  209. cardEffect: activateClass);
  210. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  211. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  212. yield return StartCoroutine(selectCardEffect.Activate());
  213. IEnumerator SelectCardCoroutine(CardSource cardSource)
  214. {
  215. selectedCards.Add(cardSource);
  216. yield return null;
  217. }
  218. if (selectedCards.Count > 0)
  219. {
  220. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  221. cardSources: selectedCards,
  222. activateClass: activateClass,
  223. payCost: false,
  224. isTapped: true,
  225. root: SelectCardEffect.Root.Trash,
  226. activateETB: false));
  227. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  228. {
  229. new SelectionElement<bool>(message: $"Redirect Attack", value : true, spriteIndex: 0),
  230. new SelectionElement<bool>(message: $"Continue Attack", value : false, spriteIndex: 1),
  231. };
  232. string selectPlayerMessage = "Would you like to redirect the attack?";
  233. string notSelectPlayerMessage = "The opponent is selecting whether to redirect the attack.";
  234. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  235. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  236. if (GManager.instance.userSelectionManager.SelectedBoolValue)
  237. {
  238. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  239. activateClass,
  240. false,
  241. selectedCards[0].PermanentOfThisCard()));
  242. }
  243. }
  244. }
  245. }
  246. }
  247. #endregion
  248. //Inherited Effect
  249. if (timing == EffectTiming.OnDestroyedAnyone)
  250. {
  251. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: true, card: card, condition: null));
  252. }
  253. return cardEffects;
  254. }
  255. }
  256. }