AD1_015.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Beowolfmon
  5. namespace DCGO.CardEffects.AD1
  6. {
  7. public class AD1_015 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.EqualsCardName("Koji Minamoto")
  18. && targetPermanent.DigivolutionCards.Count(cardSource => cardSource.EqualsTraits("Hybrid")) >= 2;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 3,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null)
  26. );
  27. }
  28. #endregion
  29. #region Jamming
  30. if (timing == EffectTiming.None)
  31. {
  32. cardEffects.Add(CardEffectFactory.JammingSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  33. }
  34. #endregion
  35. #region DPReduction WD / WA / WA ESS
  36. string DPReductionEffectName = "Give 1 Opponent's digimon -4k DP";
  37. CardEffectFactory.ActivateClassesForSharedEffects
  38. (ref cardEffects, timing, card,
  39. DPReductionEffectName,
  40. DPReductionActivateCoroutine,
  41. DPReductionEffectDescription,
  42. optional: false,
  43. whenDigivolving: true,
  44. whenAttacking: true);
  45. string DPReductionEffectDescription(string tag) => $"[{tag}] 1 of your opponent's Digimon gets -4000 DP for the turn.";
  46. bool IsEnemyDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  47. IEnumerator DPReductionActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  48. {
  49. if (CardEffectCommons.HasMatchConditionPermanent(IsEnemyDigimon))
  50. {
  51. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  52. selectPermanentEffect.SetUp(
  53. selectPlayer: card.Owner,
  54. canTargetCondition: IsEnemyDigimon,
  55. canTargetCondition_ByPreSelecetedList: null,
  56. canEndSelectCondition: null,
  57. maxCount: 1,
  58. canNoSelect: false,
  59. canEndNotMax: false,
  60. selectPermanentCoroutine: SelectPermanentCoroutine,
  61. afterSelectPermanentCoroutine: null,
  62. mode: SelectPermanentEffect.Mode.Custom,
  63. cardEffect: activateClass);
  64. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -4000.", "The opponent is selecting 1 Digimon that will get DP -4000.");
  65. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  66. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  67. {
  68. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -4000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  69. }
  70. }
  71. }
  72. #endregion
  73. #region When Attacking - ESS
  74. if (timing == EffectTiming.OnAllyAttack)
  75. {
  76. ActivateClass activateClass = new ActivateClass();
  77. activateClass.SetUpICardEffect(DPReductionEffectName, CanUseCondition, card);
  78. activateClass.SetUpActivateClass(CanActivateCondition, hash => DPReductionActivateCoroutine(hash, activateClass), -1, false, DPReductionEffectDescription("When Attacking"));
  79. activateClass.SetIsInheritedEffect(true);
  80. cardEffects.Add(activateClass);
  81. bool CanUseCondition(Hashtable hashtable)
  82. {
  83. return CardEffectCommons.IsExistOnBattleArea(card)
  84. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  85. }
  86. bool CanActivateCondition(Hashtable hashtable)
  87. {
  88. return CardEffectCommons.IsExistOnBattleArea(card);
  89. }
  90. }
  91. #endregion
  92. #region PlayTamer EoA / OD
  93. string PlayTamerEffectName = "You may play 1 Yellow / Black / Purple Tamer with inherited effects, then by placing a hybrid card under a tamer: draw 2";
  94. CardEffectFactory.ActivateClassesForSharedEffects
  95. (ref cardEffects, timing, card,
  96. PlayTamerEffectName,
  97. PlayTamerActivateCoroutine,
  98. PlayTamerEffectDescription,
  99. additionalActivateCondition: PlayTamerCanActivateCondition,
  100. optional: false,
  101. endOfAttack: true,
  102. onDeletion: true);
  103. string PlayTamerEffectDescription(string tag) => $"[{tag}] You may play 1 yellow, black or purple Tamer card with inherited effects from your hand or trash without paying the cost. Then, by placing 1 [Hybrid] or [Ten Warriors] trait card from your hand under this Digimon or your Tamers, <Draw 2>.";
  104. bool CanPlayTamerCondition(CardSource cardSource)
  105. {
  106. return cardSource.IsTamer
  107. && (cardSource.HasCardColor(CardColor.Yellow)
  108. || cardSource.HasCardColor(CardColor.Black)
  109. || cardSource.HasCardColor(CardColor.Purple))
  110. && cardSource.HasInheritedEffect;
  111. }
  112. bool CanPlaceCardCondition(CardSource cardSource) => cardSource.HasHybridTenWarriorsTraits;
  113. bool CanPlaceUnderTamerCondition(Permanent permanent)
  114. {
  115. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  116. && permanent.IsTamer;
  117. }
  118. bool PlayTamerCanActivateCondition(Hashtable hashtable, ActivateClass activateClass)
  119. {
  120. return CardEffectCommons.HasMatchConditionOwnersHand(card, CanPlayTamerCondition)
  121. || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanPlayTamerCondition)
  122. || CardEffectCommons.HasMatchConditionOwnersHand(card, CanPlaceCardCondition);
  123. }
  124. IEnumerator PlayTamerActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  125. {
  126. bool validHandCard = CardEffectCommons.HasMatchConditionOwnersHand(card, CanPlayTamerCondition);
  127. bool validTrashCard = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanPlayTamerCondition);
  128. if (validHandCard || validTrashCard)
  129. {
  130. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  131. if (validHandCard)
  132. {
  133. selectionElements.Add(new (message: $"Play Tamer from hand", value : 1, spriteIndex: 0));
  134. }
  135. if (validTrashCard)
  136. {
  137. selectionElements.Add(new (message: $"Play Tamer from trash", value : 2, spriteIndex: 0));
  138. };
  139. selectionElements.Add( new (message: $"Don't play", value: 3, spriteIndex: 1));
  140. string selectPlayerMessage = "From where will you play a Tamer?";
  141. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  142. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  143. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  144. bool doPlay = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  145. bool fromHand = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  146. if (doPlay)
  147. {
  148. List<CardSource> selectedCards = new List<CardSource>();
  149. if (fromHand)
  150. {
  151. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  152. selectHandEffect.SetUp(
  153. selectPlayer: card.Owner,
  154. canTargetCondition: CanPlayTamerCondition,
  155. canTargetCondition_ByPreSelecetedList: null,
  156. canEndSelectCondition: null,
  157. maxCount: 1,
  158. canNoSelect: true,
  159. canEndNotMax: false,
  160. isShowOpponent: true,
  161. selectCardCoroutine: null,
  162. afterSelectCardCoroutine: null,
  163. mode: SelectHandEffect.Mode.PlayForFree,
  164. cardEffect: activateClass);
  165. yield return StartCoroutine(selectHandEffect.Activate());
  166. }
  167. else
  168. {
  169. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  170. selectCardEffect.SetUp(
  171. canTargetCondition: CanPlayTamerCondition,
  172. canTargetCondition_ByPreSelecetedList: null,
  173. canEndSelectCondition: null,
  174. canNoSelect: () => true,
  175. selectCardCoroutine: null,
  176. afterSelectCardCoroutine: null,
  177. message: "Select 1 card to play.",
  178. maxCount: 1,
  179. canEndNotMax: false,
  180. isShowOpponent: true,
  181. mode: SelectCardEffect.Mode.PlayForFree,
  182. root: SelectCardEffect.Root.Trash,
  183. customRootCardList: null,
  184. canLookReverseCard: true,
  185. selectPlayer: card.Owner,
  186. cardEffect: activateClass);
  187. yield return StartCoroutine(selectCardEffect.Activate());
  188. }
  189. }
  190. }
  191. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanPlaceCardCondition))
  192. {
  193. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  194. selectionElements.Add(new (message: $"Place under this Digimon", value : 1, spriteIndex: 0));
  195. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanPlaceUnderTamerCondition))
  196. {
  197. selectionElements.Add(new (message: $"Place under a Tamer", value : 2, spriteIndex: 0));
  198. };
  199. selectionElements.Add( new (message: $"Don't place", value: 3, spriteIndex: 1));
  200. string selectPlayerMessage = "Will you place a card under this Digimon or a tamer?";
  201. string notSelectPlayerMessage = "The opponent is choosing to place a card.";
  202. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  203. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  204. bool doPlace = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  205. bool underThis = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  206. if (doPlace)
  207. {
  208. Permanent selectedPermanent = null;
  209. if (underThis)
  210. {
  211. selectedPermanent = card.PermanentOfThisCard();
  212. }
  213. else
  214. {
  215. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  216. selectPermanentEffect.SetUp(
  217. selectPlayer: card.Owner,
  218. canTargetCondition: CanPlaceUnderTamerCondition,
  219. canTargetCondition_ByPreSelecetedList: null,
  220. canEndSelectCondition: null,
  221. maxCount: 1,
  222. canNoSelect: true,
  223. canEndNotMax: false,
  224. selectPermanentCoroutine: SelectPermanentCoroutine,
  225. afterSelectPermanentCoroutine: null,
  226. mode: SelectPermanentEffect.Mode.Custom,
  227. cardEffect: activateClass);
  228. selectPermanentEffect.SetUpCustomMessage("Select 1 tamer to place a card under.", "The opponent is selecting 1 tamer to place a card under.");
  229. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  230. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  231. {
  232. selectedPermanent = permanent;
  233. yield return null;
  234. }
  235. }
  236. if (selectedPermanent != null)
  237. {
  238. List<CardSource> selectedCards1 = new List<CardSource>();
  239. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  240. selectHandEffect.SetUp(
  241. selectPlayer: card.Owner,
  242. canTargetCondition: CanPlaceCardCondition,
  243. canTargetCondition_ByPreSelecetedList: null,
  244. canEndSelectCondition: null,
  245. maxCount: 1,
  246. canNoSelect: true,
  247. canEndNotMax: false,
  248. isShowOpponent: true,
  249. selectCardCoroutine: SelectCardCoroutine,
  250. afterSelectCardCoroutine: null,
  251. mode: SelectHandEffect.Mode.Custom,
  252. cardEffect: activateClass);
  253. IEnumerator SelectCardCoroutine(CardSource cardSource)
  254. {
  255. selectedCards1.Add(cardSource);
  256. yield return null;
  257. }
  258. selectHandEffect.SetUpCustomMessage("Select 1 card to place.", "Opponent is selecting 1 card to place under.");
  259. yield return StartCoroutine(selectHandEffect.Activate());
  260. if (selectedCards1.Count > 0)
  261. {
  262. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(selectedCards1, activateClass));
  263. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  264. }
  265. }
  266. }
  267. }
  268. }
  269. #endregion
  270. return cardEffects;
  271. }
  272. }
  273. }