AD1_007.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. // Siriusmon
  7. namespace DCGO.CardEffects.AD1
  8. {
  9. public class AD1_007 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Alternative Digivolution Condition
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.HasText("Gammamon");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. level: 5,
  23. permanentCondition: PermanentCondition,
  24. digivolutionCost: 3,
  25. ignoreDigivolutionRequirement: false,
  26. card: card,
  27. condition: null)
  28. );
  29. }
  30. #endregion
  31. #region Raid
  32. if (timing == EffectTiming.OnAllyAttack)
  33. {
  34. cardEffects.Add(CardEffectFactory.RaidSelfEffect(isInheritedEffect: false, card: card, condition: null));
  35. }
  36. #endregion
  37. #region Security A. +1
  38. if (timing == EffectTiming.None)
  39. {
  40. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: false, card: card, condition: null));
  41. }
  42. #endregion
  43. #region Blocker
  44. if (timing == EffectTiming.None)
  45. {
  46. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  47. }
  48. #endregion
  49. #region Shared WD/WA
  50. string SharedHashString = "AD1_007_WD_WA";
  51. string SharedEffectName = "By placing 3 digivolution sources under this Digimon, delete 1 opponent's Digimon with equal or less DP";
  52. string SharedEffectDescription(string tag) => $"[{tag}] [Once Per Turn] By placing 3 Digimon cards with [Gammamon] in their texts from your hand or trash as this Digimon's top or bottom digivolution cards, delete 1 of your opponent's Digimon with as much or less DP as this Digimon.";
  53. bool SharedCanActivateCondition(Hashtable hashtable)
  54. {
  55. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  56. && (CardEffectCommons.MatchConditionOwnersCardCountInHand(card, GammamonInText) + CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, GammamonInText) >= 3);
  57. }
  58. bool GammamonInText(CardSource cardSource)
  59. {
  60. return cardSource.IsDigimon
  61. && cardSource.HasText("Gammamon");
  62. }
  63. bool ValidOpponentDigimon(Permanent permanent)
  64. {
  65. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  66. && permanent.HasDP
  67. && permanent.DP <= card.PermanentOfThisCard().DP;
  68. }
  69. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  70. {
  71. Permanent thisPermanent = card.PermanentOfThisCard();
  72. List<CardSource> selectedCards = new List<CardSource>();
  73. IEnumerator SelectCardCoroutine(CardSource cardSource)
  74. {
  75. selectedCards.Add(cardSource);
  76. yield return null;
  77. }
  78. while (selectedCards.Count < 3)
  79. {
  80. List<CardSource> validHandCards = card.Owner.HandCards.Filter(GammamonInText).Except(selectedCards).ToList();
  81. List<CardSource> validTrashCards = card.Owner.TrashCards.Filter(GammamonInText).Except(selectedCards).ToList();
  82. int validHandCardCount = validHandCards.Count;
  83. int validTrashCardCount = validTrashCards.Count;
  84. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  85. if (validHandCardCount > 0)
  86. {
  87. selectionElements.Add(new(message: $"from Hand", value: 1, spriteIndex: 0));
  88. }
  89. if (validTrashCardCount > 0)
  90. {
  91. selectionElements.Add(new(message: $"from Trash", value: 2, spriteIndex: 0));
  92. }
  93. string selectPlayerMessage = "From which area will you select a card to place under as digivolution cards?";
  94. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card to place under as digivolution cards.";
  95. Debug.Log("Selection Elements Count: " + selectionElements.Count);
  96. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  97. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  98. switch (GManager.instance.userSelectionManager.SelectedIntValue)
  99. {
  100. case 1: // From Hand
  101. {
  102. int maxCount = Math.Min(3 - selectedCards.Count, validHandCardCount);
  103. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  104. selectHandEffect.SetUp(
  105. selectPlayer: card.Owner,
  106. canTargetCondition: cardSource => validHandCards.Contains(cardSource),
  107. canTargetCondition_ByPreSelecetedList: null,
  108. canEndSelectCondition: null,
  109. maxCount: maxCount,
  110. canNoSelect: true,
  111. canEndNotMax: true,
  112. isShowOpponent: true,
  113. selectCardCoroutine: SelectCardCoroutine,
  114. afterSelectCardCoroutine: null,
  115. mode: SelectHandEffect.Mode.Custom,
  116. cardEffect: activateClass);
  117. selectHandEffect.SetUpCustomMessage($"Select up to {maxCount} cards to place under as digivolution cards.", "The opponent is selecting cards to place under as digivolution cards.");
  118. yield return StartCoroutine(selectHandEffect.Activate());
  119. break;
  120. }
  121. case 2: // From Trash
  122. {
  123. int maxCount = Math.Min(3 - selectedCards.Count, validTrashCardCount);
  124. SelectCardEffect selectCardEffect1 = GManager.instance.GetComponent<SelectCardEffect>();
  125. selectCardEffect1.SetUp(
  126. canTargetCondition: cardSource => validTrashCards.Contains(cardSource),
  127. canTargetCondition_ByPreSelecetedList: null,
  128. canEndSelectCondition: null,
  129. canNoSelect: () => true,
  130. selectCardCoroutine: SelectCardCoroutine,
  131. afterSelectCardCoroutine: null,
  132. message: "Select cards",
  133. maxCount: maxCount,
  134. canEndNotMax: true,
  135. isShowOpponent: true,
  136. mode: SelectCardEffect.Mode.Custom,
  137. root: SelectCardEffect.Root.Trash,
  138. customRootCardList: null,
  139. canLookReverseCard: true,
  140. selectPlayer: card.Owner,
  141. cardEffect: activateClass);
  142. selectCardEffect1.SetUpCustomMessage($"Select up to {maxCount} cards to place under as digivolution cards.", "The opponent is selecting cards to place under as digivolution cards.");
  143. yield return ContinuousController.instance.StartCoroutine(selectCardEffect1.Activate());
  144. break;
  145. }
  146. }
  147. }
  148. List<SelectionElement<bool>> selectionElements1 = new List<SelectionElement<bool>>()
  149. {
  150. new SelectionElement<bool>(message: $"To Top", value : true, spriteIndex: 0),
  151. new SelectionElement<bool>(message: $"To Bottom", value : false, spriteIndex: 1),
  152. };
  153. string selectPlayerMessage1 = "From which area do you select a card?";
  154. string notSelectPlayerMessage1 = "The opponent is choosing from which area to select a card.";
  155. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements1, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage1, notSelectPlayerMessage: notSelectPlayerMessage1);
  156. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  157. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  158. List<CardSource> fixedCards = new List<CardSource>();
  159. bool ToTop = GManager.instance.userSelectionManager.SelectedBoolValue;
  160. selectCardEffect.SetUp(
  161. canTargetCondition: _ => true,
  162. canTargetCondition_ByPreSelecetedList: null,
  163. canEndSelectCondition: null,
  164. canNoSelect: () => false,
  165. selectCardCoroutine: null,
  166. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  167. message: "Specify the order to place the cards in the digivolution cards\n(cards will be placed so that cards with lower numbers are on top).",
  168. maxCount: selectedCards.Count,
  169. canEndNotMax: false,
  170. isShowOpponent: false,
  171. mode: SelectCardEffect.Mode.Custom,
  172. root: SelectCardEffect.Root.Custom,
  173. customRootCardList: selectedCards,
  174. canLookReverseCard: true,
  175. selectPlayer: card.Owner,
  176. cardEffect: activateClass);
  177. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Cards");
  178. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  179. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  180. {
  181. fixedCards = cardSources.Clone();
  182. fixedCards.Reverse();
  183. if (ToTop)
  184. {
  185. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsTop(fixedCards, activateClass));
  186. }
  187. else
  188. {
  189. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(fixedCards, activateClass));
  190. }
  191. yield return null;
  192. }
  193. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, ValidOpponentDigimon))
  194. {
  195. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  196. selectPermanentEffect.SetUp(
  197. selectPlayer: card.Owner,
  198. canTargetCondition: ValidOpponentDigimon,
  199. canTargetCondition_ByPreSelecetedList: null,
  200. canEndSelectCondition: null,
  201. maxCount: 1,
  202. canNoSelect: true,
  203. canEndNotMax: false,
  204. selectPermanentCoroutine: null,
  205. afterSelectPermanentCoroutine: null,
  206. mode: SelectPermanentEffect.Mode.Destroy,
  207. cardEffect: activateClass);
  208. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  209. }
  210. }
  211. #endregion
  212. #region When Digivolving
  213. if (timing == EffectTiming.OnEnterFieldAnyone)
  214. {
  215. ActivateClass activateClass = new ActivateClass();
  216. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  217. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("When Digivolving"));
  218. activateClass.SetHashString(SharedHashString);
  219. cardEffects.Add(activateClass);
  220. bool CanUseCondition(Hashtable hashtable)
  221. {
  222. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  223. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  224. }
  225. }
  226. #endregion
  227. #region When Attacking
  228. if (timing == EffectTiming.OnAllyAttack)
  229. {
  230. ActivateClass activateClass = new ActivateClass();
  231. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  232. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("When Attacking"));
  233. activateClass.SetHashString(SharedHashString);
  234. cardEffects.Add(activateClass);
  235. bool CanUseCondition(Hashtable hashtable)
  236. {
  237. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  238. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  239. }
  240. }
  241. #endregion
  242. #region End of Your Turn
  243. if (timing == EffectTiming.OnEndTurn)
  244. {
  245. ActivateClass activateClass = new ActivateClass();
  246. activateClass.SetUpICardEffect("Attack with this Digimon without suspending", CanUseCondition, card);
  247. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  248. activateClass.SetHashString("AD1_007_EoYT");
  249. cardEffects.Add(activateClass);
  250. string EffectDescription()
  251. {
  252. return "[End of Your Turn] [Once Per Turn] This Digimon with 5 or more digivolution cards may attack without suspending.";
  253. }
  254. bool CanUseCondition(Hashtable hashtable)
  255. {
  256. return CardEffectCommons.IsExistOnBattleArea(card)
  257. && CardEffectCommons.IsOwnerTurn(card);
  258. }
  259. bool CanActivateCondition(Hashtable hashtable)
  260. {
  261. return CardEffectCommons.IsExistOnBattleArea(card)
  262. && card.PermanentOfThisCard().DigivolutionCards.Count >= 5
  263. && card.PermanentOfThisCard().CanAttack(activateClass, withoutTap: true);
  264. }
  265. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  266. {
  267. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  268. selectAttackEffect.SetUp(
  269. attacker: card.PermanentOfThisCard(),
  270. canAttackPlayerCondition: () => true,
  271. defenderCondition: (permanent) => true,
  272. cardEffect: activateClass);
  273. selectAttackEffect.SetWithoutTap();
  274. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  275. }
  276. }
  277. #endregion
  278. return cardEffects;
  279. }
  280. }
  281. }