AD1_020.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Tommy, Takuya, & Zoe
  6. namespace DCGO.CardEffects.AD1
  7. {
  8. public class AD1_020 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Name Rule
  14. if (timing == EffectTiming.None)
  15. {
  16. ChangeCardNamesClass changeCardNamesClass = new ChangeCardNamesClass();
  17. changeCardNamesClass.SetUpICardEffect("[Rule] Name: Also treated as [Tommy Himi]/[Takuya Kanbara]/[Zoe Orimoto].", _ => true, card);
  18. changeCardNamesClass.SetUpChangeCardNamesClass(changeCardNames: ChangeCardNames);
  19. cardEffects.Add(changeCardNamesClass);
  20. List<string> ChangeCardNames(CardSource cardSource, List<string> cardNames)
  21. {
  22. if (cardSource == card)
  23. {
  24. cardNames.Add("Tommy Himi");
  25. cardNames.Add("Takuya Kanbara");
  26. cardNames.Add("Zoe Orimoto");
  27. }
  28. return cardNames;
  29. }
  30. }
  31. #endregion
  32. #region Shared OP/SOMP
  33. string SharedEffectName = "Place up to 2 [Hybrid] cards with different colors under, if so <Draw 1> and if 4 or more under gain 2 memory";
  34. string SharedEffectDescription(string tag) =>
  35. $"[{tag}] You may place up to 2 [Hybrid] trait cards with different colors from your hand or trash under this Tamer. If this effect placed, <Draw 1>. Then, if there are 4 or more [Hybrid] trait cards under this Tamer, gain 2 memory.";
  36. bool IsHybridCard(CardSource cardSource)
  37. {
  38. return cardSource.ContainsTraits("Hybrid")
  39. && cardSource.Owner == card.Owner;
  40. }
  41. bool SharedCanActivateCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.IsExistOnBattleArea(card);
  44. }
  45. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  46. {
  47. List<CardSource> selectedCards = new List<CardSource>();
  48. HashSet<CardColor> selectedColors = new HashSet<CardColor>();
  49. IEnumerator SelectCardCoroutine(CardSource cardSource)
  50. {
  51. selectedCards.Add(cardSource);
  52. foreach (CardColor color in cardSource.CardColors)
  53. {
  54. selectedColors.Add(color);
  55. }
  56. yield return null;
  57. }
  58. bool CanSelectCardCondition(CardSource cardSource)
  59. {
  60. if (!IsHybridCard(cardSource)) return false;
  61. if (selectedCards.Contains(cardSource)) return false;
  62. if (selectedCards.Count > 0)
  63. {
  64. return cardSource.CardColors.Any(color1 => selectedCards[0].CardColors.Any(color2 => color2 != color1));
  65. }
  66. return true;
  67. }
  68. while (selectedCards.Count < 2)
  69. {
  70. List<CardSource> validHandCards = card.Owner.HandCards.Filter(CanSelectCardCondition).ToList();
  71. List<CardSource> validTrashCards = card.Owner.TrashCards.Filter(CanSelectCardCondition).ToList();
  72. if (validHandCards.Count == 0 && validTrashCards.Count == 0)
  73. {
  74. goto END_LOOP;
  75. }
  76. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  77. if (validHandCards.Count > 0)
  78. {
  79. selectionElements.Add(new(message: "from Hand", value: 1, spriteIndex: 0));
  80. }
  81. if (validTrashCards.Count > 0)
  82. {
  83. selectionElements.Add(new(message: "from Trash", value: 2, spriteIndex: 0));
  84. }
  85. selectionElements.Add(new(message: "Do not place", value: 3, spriteIndex: 1));
  86. GManager.instance.userSelectionManager.SetIntSelection(
  87. selectionElements: selectionElements,
  88. selectPlayer: card.Owner,
  89. selectPlayerMessage: "From which area will you select a [Hybrid] card to place under this Tamer?",
  90. notSelectPlayerMessage: "The opponent is choosing from which area to select a [Hybrid] card.");
  91. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  92. int prevCount = selectedCards.Count;
  93. switch (GManager.instance.userSelectionManager.SelectedIntValue)
  94. {
  95. case 1:
  96. {
  97. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  98. selectHandEffect.SetUp(
  99. selectPlayer: card.Owner,
  100. canTargetCondition: cardSource => validHandCards.Contains(cardSource),
  101. canTargetCondition_ByPreSelecetedList: null,
  102. canEndSelectCondition: null,
  103. maxCount: 1,
  104. canNoSelect: true,
  105. canEndNotMax: false,
  106. isShowOpponent: true,
  107. selectCardCoroutine: SelectCardCoroutine,
  108. afterSelectCardCoroutine: null,
  109. mode: SelectHandEffect.Mode.Custom,
  110. cardEffect: activateClass);
  111. selectHandEffect.SetUpCustomMessage(
  112. "Select 1 [Hybrid] card to place under this Tamer.",
  113. "The opponent is selecting a [Hybrid] card to place under this Tamer.");
  114. yield return StartCoroutine(selectHandEffect.Activate());
  115. break;
  116. }
  117. case 2:
  118. {
  119. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  120. selectCardEffect.SetUp(
  121. canTargetCondition: cardSource => validTrashCards.Contains(cardSource),
  122. canTargetCondition_ByPreSelecetedList: null,
  123. canEndSelectCondition: null,
  124. canNoSelect: () => true,
  125. selectCardCoroutine: SelectCardCoroutine,
  126. afterSelectCardCoroutine: null,
  127. message: "Select 1 [Hybrid] card",
  128. maxCount: 1,
  129. canEndNotMax: false,
  130. isShowOpponent: true,
  131. mode: SelectCardEffect.Mode.Custom,
  132. root: SelectCardEffect.Root.Trash,
  133. customRootCardList: null,
  134. canLookReverseCard: true,
  135. selectPlayer: card.Owner,
  136. cardEffect: activateClass);
  137. selectCardEffect.SetUpCustomMessage(
  138. "Select 1 [Hybrid] card to place under this Tamer.",
  139. "The opponent is selecting a [Hybrid] card to place under this Tamer.");
  140. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  141. break;
  142. }
  143. default:
  144. goto END_LOOP;
  145. }
  146. }
  147. END_LOOP:;
  148. if (selectedCards.Count > 0)
  149. {
  150. yield return ContinuousController.instance.StartCoroutine(
  151. card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  152. yield return ContinuousController.instance.StartCoroutine(new DrawClass(
  153. card.Owner,
  154. 1,
  155. activateClass).Draw());
  156. }
  157. int hybridCountUnderTamer = card.PermanentOfThisCard().DigivolutionCards.Count(IsHybridCard);
  158. if (hybridCountUnderTamer >= 4)
  159. {
  160. if (card.Owner.CanAddMemory(activateClass))
  161. {
  162. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(2, activateClass));
  163. }
  164. }
  165. }
  166. #endregion
  167. #region On Play
  168. if (timing == EffectTiming.OnEnterFieldAnyone)
  169. {
  170. ActivateClass activateClass = new ActivateClass();
  171. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  172. activateClass.SetUpActivateClass(SharedCanActivateCondition,
  173. hash => SharedActivateCoroutine(hash, activateClass), -1, false,
  174. SharedEffectDescription("On Play"));
  175. cardEffects.Add(activateClass);
  176. bool CanUseCondition(Hashtable hashtable)
  177. {
  178. return CardEffectCommons.IsExistOnBattleArea(card)
  179. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  180. }
  181. }
  182. #endregion
  183. #region Start of Your Main Phase
  184. if (timing == EffectTiming.OnStartMainPhase)
  185. {
  186. ActivateClass activateClass = new ActivateClass();
  187. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  188. activateClass.SetUpActivateClass(SharedCanActivateCondition,
  189. hash => SharedActivateCoroutine(hash, activateClass), -1, false,
  190. SharedEffectDescription("Start of Your Main Phase"));
  191. cardEffects.Add(activateClass);
  192. bool CanUseCondition(Hashtable hashtable)
  193. {
  194. return CardEffectCommons.IsExistOnBattleArea(card)
  195. && CardEffectCommons.IsOwnerTurn(card);
  196. }
  197. }
  198. #endregion
  199. #region End of Your Turn
  200. if (timing == EffectTiming.OnEndTurn)
  201. {
  202. ActivateClass activateClass = new ActivateClass();
  203. activateClass.SetUpICardEffect("Attack with this Digimon with Security A. +1",
  204. CanUseCondition, card);
  205. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true,
  206. EffectDescription());
  207. activateClass.SetIsInheritedEffect(true);
  208. activateClass.SetHashString("AD1_020_EoYT");
  209. cardEffects.Add(activateClass);
  210. string EffectDescription()
  211. {
  212. return "[End of Your Turn] [Once Per Turn] By attacking with this Digimon with the [Hybrid] or [Ten Warriors] trait, it gains <Security A. +1> (This Digimon checks 1 additional security card.) for the attack.";
  213. }
  214. bool HasHybridOrTenWarriors(Permanent permanent)
  215. {
  216. return permanent.TopCard.ContainsTraits("Hybrid")
  217. || permanent.TopCard.ContainsTraits("Ten Warriors")
  218. || permanent.TopCard.ContainsTraits("TenWarriors");
  219. }
  220. bool CanUseCondition(Hashtable hashtable)
  221. {
  222. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  223. && CardEffectCommons.IsOwnerTurn(card);
  224. }
  225. bool CanActivateCondition(Hashtable hashtable)
  226. {
  227. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  228. && HasHybridOrTenWarriors(card.PermanentOfThisCard())
  229. && card.PermanentOfThisCard().CanAttack(activateClass);
  230. }
  231. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  232. {
  233. Permanent thisPermanent = card.PermanentOfThisCard();
  234. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  235. selectAttackEffect.SetUp(
  236. attacker: thisPermanent,
  237. canAttackPlayerCondition: () => true,
  238. defenderCondition: (permanent) => true,
  239. cardEffect: activateClass);
  240. selectAttackEffect.SetCanNotSelectNotAttack();
  241. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  242. yield return ContinuousController.instance.StartCoroutine(
  243. CardEffectCommons.ChangeDigimonSAttack(
  244. targetPermanent: thisPermanent,
  245. changeValue: 1,
  246. effectDuration: EffectDuration.UntilEndAttack,
  247. activateClass: activateClass));
  248. }
  249. }
  250. #endregion
  251. #region Security Effect
  252. if (timing == EffectTiming.SecuritySkill)
  253. {
  254. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  255. }
  256. #endregion
  257. return cardEffects;
  258. }
  259. }
  260. }