AD1_023.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // J.P., Koji, & Koichi
  5. namespace DCGO.CardEffects.AD1
  6. {
  7. public class AD1_023 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Name Rule
  13. if (timing == EffectTiming.None)
  14. {
  15. ChangeCardNamesClass changeCardNamesClass = new ChangeCardNamesClass();
  16. changeCardNamesClass.SetUpICardEffect("[Rule] Name: Also treated as [J.P. Shibayama]/[Koji Minamoto]/[Koichi Kimura].", _ => true, card);
  17. changeCardNamesClass.SetUpChangeCardNamesClass(changeCardNames: ChangeCardNames);
  18. cardEffects.Add(changeCardNamesClass);
  19. List<string> ChangeCardNames(CardSource cardSource, List<string> cardNames)
  20. {
  21. if (cardSource == card)
  22. {
  23. cardNames.Add("J.P. Shibayama");
  24. cardNames.Add("Koji Minamoto");
  25. cardNames.Add("Koichi Kimura");
  26. }
  27. return cardNames;
  28. }
  29. }
  30. #endregion
  31. #region Shared OP/SOMP
  32. 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";
  33. string SharedEffectDescription(string tag) =>
  34. $"[{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.";
  35. bool IsHybridCard(CardSource cardSource)
  36. {
  37. return cardSource.ContainsTraits("Hybrid")
  38. && cardSource.Owner == card.Owner;
  39. }
  40. bool SharedCanActivateCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.IsExistOnBattleArea(card);
  43. }
  44. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  45. {
  46. List<CardSource> selectedCards = new List<CardSource>();
  47. HashSet<CardColor> selectedColors = new HashSet<CardColor>();
  48. IEnumerator SelectCardCoroutine(CardSource cardSource)
  49. {
  50. selectedCards.Add(cardSource);
  51. foreach (CardColor color in cardSource.CardColors)
  52. {
  53. selectedColors.Add(color);
  54. }
  55. yield return null;
  56. }
  57. bool CanSelectCardCondition(CardSource cardSource)
  58. {
  59. if (!IsHybridCard(cardSource)) return false;
  60. if (selectedCards.Contains(cardSource)) return false;
  61. if (selectedCards.Count > 0)
  62. {
  63. return cardSource.CardColors.Any(color1 => selectedCards[0].CardColors.Any(color2 => color2 != color1));
  64. }
  65. return true;
  66. }
  67. while (selectedCards.Count < 2)
  68. {
  69. List<CardSource> validHandCards = card.Owner.HandCards.Filter(CanSelectCardCondition).ToList();
  70. List<CardSource> validTrashCards = card.Owner.TrashCards.Filter(CanSelectCardCondition).ToList();
  71. if (validHandCards.Count == 0 && validTrashCards.Count == 0)
  72. {
  73. goto END_LOOP;
  74. }
  75. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  76. if (validHandCards.Count > 0)
  77. {
  78. selectionElements.Add(new(message: "from Hand", value: 1, spriteIndex: 0));
  79. }
  80. if (validTrashCards.Count > 0)
  81. {
  82. selectionElements.Add(new(message: "from Trash", value: 2, spriteIndex: 0));
  83. }
  84. selectionElements.Add(new(message: "Do not place", value: 3, spriteIndex: 1));
  85. GManager.instance.userSelectionManager.SetIntSelection(
  86. selectionElements: selectionElements,
  87. selectPlayer: card.Owner,
  88. selectPlayerMessage: "From which area will you select a [Hybrid] card to place under this Tamer?",
  89. notSelectPlayerMessage: "The opponent is choosing from which area to select a [Hybrid] card.");
  90. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  91. switch (GManager.instance.userSelectionManager.SelectedIntValue)
  92. {
  93. case 1:
  94. {
  95. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  96. selectHandEffect.SetUp(
  97. selectPlayer: card.Owner,
  98. canTargetCondition: cardSource => validHandCards.Contains(cardSource),
  99. canTargetCondition_ByPreSelecetedList: null,
  100. canEndSelectCondition: null,
  101. maxCount: 1,
  102. canNoSelect: true,
  103. canEndNotMax: false,
  104. isShowOpponent: true,
  105. selectCardCoroutine: SelectCardCoroutine,
  106. afterSelectCardCoroutine: null,
  107. mode: SelectHandEffect.Mode.Custom,
  108. cardEffect: activateClass);
  109. selectHandEffect.SetUpCustomMessage(
  110. "Select 1 [Hybrid] card to place under this Tamer.",
  111. "The opponent is selecting a [Hybrid] card to place under this Tamer.");
  112. yield return StartCoroutine(selectHandEffect.Activate());
  113. break;
  114. }
  115. case 2:
  116. {
  117. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  118. selectCardEffect.SetUp(
  119. canTargetCondition: cardSource => validTrashCards.Contains(cardSource),
  120. canTargetCondition_ByPreSelecetedList: null,
  121. canEndSelectCondition: null,
  122. canNoSelect: () => true,
  123. selectCardCoroutine: SelectCardCoroutine,
  124. afterSelectCardCoroutine: null,
  125. message: "Select 1 [Hybrid] card",
  126. maxCount: 1,
  127. canEndNotMax: false,
  128. isShowOpponent: true,
  129. mode: SelectCardEffect.Mode.Custom,
  130. root: SelectCardEffect.Root.Trash,
  131. customRootCardList: null,
  132. canLookReverseCard: true,
  133. selectPlayer: card.Owner,
  134. cardEffect: activateClass);
  135. selectCardEffect.SetUpCustomMessage(
  136. "Select 1 [Hybrid] card to place under this Tamer.",
  137. "The opponent is selecting a [Hybrid] card to place under this Tamer.");
  138. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  139. break;
  140. }
  141. default:
  142. goto END_LOOP;
  143. }
  144. }
  145. END_LOOP:;
  146. if (selectedCards.Count > 0)
  147. {
  148. yield return ContinuousController.instance.StartCoroutine(
  149. card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  150. yield return ContinuousController.instance.StartCoroutine(new DrawClass(
  151. card.Owner,
  152. 1,
  153. activateClass).Draw());
  154. }
  155. int hybridCountUnderTamer = card.PermanentOfThisCard().DigivolutionCards.Count(IsHybridCard);
  156. if (hybridCountUnderTamer >= 4)
  157. {
  158. if (card.Owner.CanAddMemory(activateClass))
  159. {
  160. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(2, activateClass));
  161. }
  162. }
  163. }
  164. #endregion
  165. #region On Play
  166. if (timing == EffectTiming.OnEnterFieldAnyone)
  167. {
  168. ActivateClass activateClass = new ActivateClass();
  169. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  170. activateClass.SetUpActivateClass(SharedCanActivateCondition,
  171. hash => SharedActivateCoroutine(hash, activateClass), -1, false,
  172. SharedEffectDescription("On Play"));
  173. cardEffects.Add(activateClass);
  174. bool CanUseCondition(Hashtable hashtable)
  175. {
  176. return CardEffectCommons.IsExistOnBattleArea(card)
  177. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  178. }
  179. }
  180. #endregion
  181. #region Start of Your Main Phase
  182. if (timing == EffectTiming.OnStartMainPhase)
  183. {
  184. ActivateClass activateClass = new ActivateClass();
  185. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  186. activateClass.SetUpActivateClass(SharedCanActivateCondition,
  187. hash => SharedActivateCoroutine(hash, activateClass), -1, false,
  188. SharedEffectDescription("Start of Your Main Phase"));
  189. cardEffects.Add(activateClass);
  190. bool CanUseCondition(Hashtable hashtable)
  191. {
  192. return CardEffectCommons.IsExistOnBattleArea(card)
  193. && CardEffectCommons.IsOwnerTurn(card);
  194. }
  195. }
  196. #endregion
  197. #region Inherited All Turns
  198. if (timing == EffectTiming.WhenRemoveField)
  199. {
  200. ActivateClass activateClass = new ActivateClass();
  201. activateClass.SetUpICardEffect("Add top security to hand to not leave", CanUseCondition, card);
  202. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  203. activateClass.SetHashString("AD1_023_ESS_AT");
  204. activateClass.SetIsInheritedEffect(true);
  205. cardEffects.Add(activateClass);
  206. string EffectDescription()
  207. {
  208. return "[All Turns] [Once Per Turn] When this Digimon with the [Hybrid] or [Ten Warriors] trait would leave the battle area, by adding your top security card to the hand, it doesn't leave.";
  209. }
  210. bool CanUseCondition(Hashtable hashtable)
  211. {
  212. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  213. && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card);
  214. }
  215. bool CanActivateCondition(Hashtable hashtable)
  216. {
  217. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  218. && card.Owner.SecurityCards.Count >= 1
  219. && card.PermanentOfThisCard().TopCard.HasHybridTenWarriorsTraits;
  220. }
  221. IEnumerator ActivateCoroutine(Hashtable hashtable)
  222. {
  223. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(new List<CardSource>() { card.Owner.SecurityCards[0] }, false, activateClass));
  224. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  225. player: card.Owner,
  226. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  227. activateClass).ReduceSecurity());
  228. card.PermanentOfThisCard().willBeRemoveField = false;
  229. card.PermanentOfThisCard().HideDeleteEffect();
  230. card.PermanentOfThisCard().HideHandBounceEffect();
  231. card.PermanentOfThisCard().HideDeckBounceEffect();
  232. card.PermanentOfThisCard().HideWillRemoveFieldEffect();
  233. }
  234. }
  235. #endregion
  236. #region Security Effect
  237. if (timing == EffectTiming.SecuritySkill)
  238. {
  239. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  240. }
  241. #endregion
  242. return cardEffects;
  243. }
  244. }
  245. }