AD1_015.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. SelectCardEffect.Root root = GManager.instance.userSelectionManager.SelectedIntValue == 1 ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash;
  146. if (doPlay)
  147. {
  148. #region Hand/Trash Card Selection & Play
  149. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayByEffect(
  150. canTargetCondition: CanPlayTamerCondition,
  151. root,
  152. activateClass,
  153. payCost: false
  154. ));
  155. #endregion
  156. }
  157. }
  158. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanPlaceCardCondition))
  159. {
  160. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  161. selectionElements.Add(new (message: $"Place under this Digimon", value : 1, spriteIndex: 0));
  162. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanPlaceUnderTamerCondition))
  163. {
  164. selectionElements.Add(new (message: $"Place under a Tamer", value : 2, spriteIndex: 0));
  165. };
  166. selectionElements.Add( new (message: $"Don't place", value: 3, spriteIndex: 1));
  167. string selectPlayerMessage = "Will you place a card under this Digimon or a tamer?";
  168. string notSelectPlayerMessage = "The opponent is choosing to place a card.";
  169. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  170. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  171. bool doPlace = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  172. bool underThis = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  173. if (doPlace)
  174. {
  175. Permanent selectedPermanent = null;
  176. if (underThis)
  177. {
  178. selectedPermanent = card.PermanentOfThisCard();
  179. }
  180. else
  181. {
  182. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  183. selectPermanentEffect.SetUp(
  184. selectPlayer: card.Owner,
  185. canTargetCondition: CanPlaceUnderTamerCondition,
  186. canTargetCondition_ByPreSelecetedList: null,
  187. canEndSelectCondition: null,
  188. maxCount: 1,
  189. canNoSelect: true,
  190. canEndNotMax: false,
  191. selectPermanentCoroutine: SelectPermanentCoroutine,
  192. afterSelectPermanentCoroutine: null,
  193. mode: SelectPermanentEffect.Mode.Custom,
  194. cardEffect: activateClass);
  195. selectPermanentEffect.SetUpCustomMessage("Select 1 tamer to place a card under.", "The opponent is selecting 1 tamer to place a card under.");
  196. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  197. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  198. {
  199. selectedPermanent = permanent;
  200. yield return null;
  201. }
  202. }
  203. if (selectedPermanent != null)
  204. {
  205. List<CardSource> selectedCards1 = new List<CardSource>();
  206. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  207. selectHandEffect.SetUp(
  208. selectPlayer: card.Owner,
  209. canTargetCondition: CanPlaceCardCondition,
  210. canTargetCondition_ByPreSelecetedList: null,
  211. canEndSelectCondition: null,
  212. maxCount: 1,
  213. canNoSelect: true,
  214. canEndNotMax: false,
  215. isShowOpponent: true,
  216. selectCardCoroutine: SelectCardCoroutine,
  217. afterSelectCardCoroutine: null,
  218. mode: SelectHandEffect.Mode.Custom,
  219. cardEffect: activateClass);
  220. IEnumerator SelectCardCoroutine(CardSource cardSource)
  221. {
  222. selectedCards1.Add(cardSource);
  223. yield return null;
  224. }
  225. selectHandEffect.SetUpCustomMessage("Select 1 card to place.", "Opponent is selecting 1 card to place under.");
  226. yield return StartCoroutine(selectHandEffect.Activate());
  227. if (selectedCards1.Count > 0)
  228. {
  229. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(selectedCards1, activateClass));
  230. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  231. }
  232. }
  233. }
  234. }
  235. }
  236. #endregion
  237. return cardEffects;
  238. }
  239. }
  240. }