EX10_068.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnityEngine;
  5. namespace DCGO.CardEffects.EX10
  6. {
  7. public class EX10_068 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Name Change
  13. if (timing == EffectTiming.None)
  14. {
  15. ChangeCardNamesClass changeCardNamesClass = new ChangeCardNamesClass();
  16. changeCardNamesClass.SetUpICardEffect("Also treated as [Ken Ichijoji]", CanUseCondition, card);
  17. changeCardNamesClass.SetUpChangeCardNamesClass(changeCardNames: changeCardNames);
  18. cardEffects.Add(changeCardNamesClass);
  19. bool CanUseCondition(Hashtable hashtable)
  20. {
  21. return true;
  22. }
  23. List<string> changeCardNames(CardSource cardSource, List<string> CardNames)
  24. {
  25. if (cardSource == card)
  26. {
  27. CardNames.Add("Ken Ichijoji");
  28. }
  29. return CardNames;
  30. }
  31. }
  32. #endregion
  33. #region Start of Your Main Phase
  34. if (timing == EffectTiming.OnStartMainPhase)
  35. {
  36. ActivateClass activateClass = new ActivateClass();
  37. activateClass.SetUpICardEffect("Gain Memory", CanUseCondition, card);
  38. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  39. cardEffects.Add(activateClass);
  40. string EffectDiscription()
  41. {
  42. return "[Start of Your Main Phase] For every 2 colors your opponent's Digimon and Tamers have, gain 1 memory.";
  43. }
  44. bool CanUseCondition(Hashtable hashtable)
  45. {
  46. return CardEffectCommons.IsExistOnField(card) &&
  47. CardEffectCommons.IsOwnerTurn(card);
  48. }
  49. bool CanActivateCondition(Hashtable hashtable)
  50. {
  51. return CardEffectCommons.IsExistOnField(card) &&
  52. card.Owner.CanAddMemory(activateClass);
  53. }
  54. bool CanGetCardColour(Permanent permanent)
  55. {
  56. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  57. || CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaTamer(permanent, card);
  58. }
  59. IEnumerator ActivateCoroutine(Hashtable hashtable)
  60. {
  61. int memoryGain = Mathf.RoundToInt(CardEffectCommons.GetUniqueColourCountOnOpponentsBattleArea(card, CanGetCardColour) / 2);
  62. if (memoryGain > 0)
  63. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(memoryGain, activateClass));
  64. }
  65. }
  66. #endregion
  67. #region On Play
  68. if (timing == EffectTiming.OnEnterFieldAnyone)
  69. {
  70. ActivateClass activateClass = new ActivateClass();
  71. activateClass.SetUpICardEffect("Delete 1 Digimon, Return 1 Digimon, Play 1 Digimon", CanUseCondition, card);
  72. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  73. cardEffects.Add(activateClass);
  74. string EffectDiscription()
  75. {
  76. return "[On Play] Delete 1 of your opponent's play cost 5 or lower Digimon. Then, by returning 1 Digimon card from your opponent's trash to the bottom of the deck, from your hand or trash and without paying the cost, you may play 1 level 4 or lower Digimon card with the same color as the card this effect returned.";
  77. }
  78. bool CanUseCondition(Hashtable hashtable)
  79. {
  80. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  81. }
  82. bool CanActivateCondition(Hashtable hashtable)
  83. {
  84. return isExistOnField(card);
  85. }
  86. bool CanSelectPermanentCondition(Permanent permanent)
  87. {
  88. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  89. permanent.TopCard.HasPlayCost && permanent.TopCard.GetCostItself <= 5;
  90. }
  91. bool OpponentsTrashDigimon(CardSource card)
  92. {
  93. return card.IsDigimon;
  94. }
  95. IEnumerator ActivateCoroutine(Hashtable hashtable)
  96. {
  97. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  98. {
  99. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  100. selectPermanentEffect.SetUp(
  101. selectPlayer: card.Owner,
  102. canTargetCondition: CanSelectPermanentCondition,
  103. canTargetCondition_ByPreSelecetedList: null,
  104. canEndSelectCondition: null,
  105. maxCount: 1,
  106. canNoSelect: false,
  107. canEndNotMax: false,
  108. selectPermanentCoroutine: null,
  109. afterSelectPermanentCoroutine: null,
  110. mode: SelectPermanentEffect.Mode.Destroy,
  111. cardEffect: activateClass);
  112. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  113. }
  114. if (CardEffectCommons.HasMatchConditionOpponentsCardInTrash(card, OpponentsTrashDigimon))
  115. {
  116. List<CardSource> selectedCards = new List<CardSource>();
  117. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  118. selectCardEffect.SetUp(
  119. canTargetCondition: OpponentsTrashDigimon,
  120. canTargetCondition_ByPreSelecetedList: null,
  121. canEndSelectCondition: null,
  122. canNoSelect: () => true,
  123. selectCardCoroutine: null,
  124. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  125. message: "Select 1 card in opponent's trash to place at the bottom of the deck.",
  126. maxCount: 1,
  127. canEndNotMax: false,
  128. isShowOpponent: false,
  129. mode: SelectCardEffect.Mode.Custom,
  130. root: SelectCardEffect.Root.Custom,
  131. customRootCardList: card.Owner.Enemy.TrashCards,
  132. canLookReverseCard: true,
  133. selectPlayer: card.Owner,
  134. cardEffect: activateClass);
  135. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  136. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  137. {
  138. selectedCards = cardSources.Clone();
  139. yield return null;
  140. }
  141. if (selectedCards.Count > 0)
  142. {
  143. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(selectedCards));
  144. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(selectedCards, "Deck Bottom Card", true, true));
  145. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  146. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  147. bool CanSelectCardCondition(CardSource cardSource)
  148. {
  149. if (cardSource.IsDigimon)
  150. {
  151. if(cardSource.HasLevel && cardSource.Level <= 4)
  152. {
  153. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  154. {
  155. foreach (CardSource item in selectedCards)
  156. {
  157. if (cardSource.CardColors.Any(x => item.HasCardColor(x)))
  158. return true;
  159. }
  160. }
  161. }
  162. }
  163. return false;
  164. }
  165. if (canSelectHand || canSelectTrash)
  166. {
  167. if (canSelectHand && canSelectTrash)
  168. {
  169. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  170. {
  171. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  172. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  173. };
  174. string selectPlayerMessage = "From which area do you play a card?";
  175. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  176. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  177. }
  178. else
  179. {
  180. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  181. }
  182. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  183. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  184. List<CardSource> playingCards = new List<CardSource>();
  185. IEnumerator SelectCardCoroutine(CardSource cardSource)
  186. {
  187. playingCards.Add(cardSource);
  188. yield return null;
  189. }
  190. if (fromHand)
  191. {
  192. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  193. selectHandEffect.SetUp(
  194. selectPlayer: card.Owner,
  195. canTargetCondition: CanSelectCardCondition,
  196. canTargetCondition_ByPreSelecetedList: null,
  197. canEndSelectCondition: null,
  198. maxCount: 1,
  199. canNoSelect: true,
  200. canEndNotMax: false,
  201. isShowOpponent: true,
  202. selectCardCoroutine: SelectCardCoroutine,
  203. afterSelectCardCoroutine: null,
  204. mode: SelectHandEffect.Mode.Custom,
  205. cardEffect: activateClass);
  206. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  207. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  208. yield return StartCoroutine(selectHandEffect.Activate());
  209. }
  210. else
  211. {
  212. selectCardEffect.SetUp(
  213. canTargetCondition: CanSelectCardCondition,
  214. canTargetCondition_ByPreSelecetedList: null,
  215. canEndSelectCondition: null,
  216. canNoSelect: () => true,
  217. selectCardCoroutine: SelectCardCoroutine,
  218. afterSelectCardCoroutine: null,
  219. message: "Select 1 card to play.",
  220. maxCount: 1,
  221. canEndNotMax: false,
  222. isShowOpponent: true,
  223. mode: SelectCardEffect.Mode.Custom,
  224. root: SelectCardEffect.Root.Trash,
  225. customRootCardList: null,
  226. canLookReverseCard: true,
  227. selectPlayer: card.Owner,
  228. cardEffect: activateClass);
  229. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  230. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  231. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  232. }
  233. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  234. if (!fromHand)
  235. {
  236. root = SelectCardEffect.Root.Trash;
  237. }
  238. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  239. cardSources: playingCards,
  240. activateClass: activateClass,
  241. payCost: false,
  242. isTapped: false,
  243. root: root,
  244. activateETB: true));
  245. }
  246. }
  247. }
  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. }