BT23_086.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. //Yuugo
  6. namespace DCGO.CardEffects.BT23
  7. {
  8. public class BT23_086 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Start Of Your Turn
  14. if (timing == EffectTiming.OnStartTurn)
  15. {
  16. cardEffects.Add(CardEffectFactory.SetMemoryTo3TamerEffect(card));
  17. }
  18. #endregion
  19. #region On Play
  20. if (timing == EffectTiming.OnEnterFieldAnyone)
  21. {
  22. ActivateClass activateClass = new ActivateClass();
  23. activateClass.SetUpICardEffect("By adding your top security, you may place 1 digimon face up in security", CanUseCondition, card);
  24. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  25. cardEffects.Add(activateClass);
  26. string EffectDescription()
  27. {
  28. return "[On Play] By adding your top security card to the hand, you may place 1 Digimon card with the [Zaxon] trait from your hand or trash face up as the bottom security card.";
  29. }
  30. bool CanSelectCardSource(CardSource source)
  31. {
  32. return source.IsDigimon &&
  33. source.EqualsTraits("Zaxon");
  34. }
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  38. }
  39. bool CanActivateCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.IsExistOnBattleArea(card) &&
  42. card.Owner.SecurityCards.Count > 0;
  43. }
  44. IEnumerator ActivateCoroutine(Hashtable hashtable)
  45. {
  46. CardSource topCard = card.Owner.SecurityCards[0];
  47. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(new List<CardSource>() { topCard }, false, activateClass));
  48. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  49. player: card.Owner,
  50. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  51. activateClass).ReduceSecurity());
  52. bool handSelected = true;
  53. bool canAddHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardSource);
  54. bool canAddTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardSource);
  55. if(card.Owner.CanAddSecurity(activateClass) && (canAddHand || canAddTrash))
  56. {
  57. if(canAddHand && canAddTrash)
  58. {
  59. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  60. {
  61. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  62. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  63. };
  64. string selectPlayerMessage = "From which area do you select a card?";
  65. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  66. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  67. }
  68. else
  69. {
  70. GManager.instance.userSelectionManager.SetBool(canAddHand);
  71. }
  72. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  73. handSelected = GManager.instance.userSelectionManager.SelectedBoolValue;
  74. CardSource selectedCard = null;
  75. if (handSelected)
  76. {
  77. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  78. selectHandEffect.SetUp(
  79. selectPlayer: card.Owner,
  80. canTargetCondition: CanSelectCardSource,
  81. canTargetCondition_ByPreSelecetedList: null,
  82. canEndSelectCondition: null,
  83. maxCount: 1,
  84. canNoSelect: true,
  85. canEndNotMax: false,
  86. isShowOpponent: true,
  87. selectCardCoroutine: SelectCardCoroutine,
  88. afterSelectCardCoroutine: null,
  89. mode: SelectHandEffect.Mode.Custom,
  90. cardEffect: activateClass);
  91. selectHandEffect.SetUpCustomMessage("Select 1 card to add face up in security.", "The opponent is selecting 1 card to add face up in security.");
  92. yield return StartCoroutine(selectHandEffect.Activate());
  93. }
  94. else
  95. {
  96. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  97. selectCardEffect.SetUp(
  98. canTargetCondition: CanSelectCardSource,
  99. canTargetCondition_ByPreSelecetedList: null,
  100. canEndSelectCondition: null,
  101. canNoSelect: () => true,
  102. selectCardCoroutine: SelectCardCoroutine,
  103. afterSelectCardCoroutine: null,
  104. message: "Select 1 card to add face up in security.",
  105. maxCount: 1,
  106. canEndNotMax: false,
  107. isShowOpponent: true,
  108. mode: SelectCardEffect.Mode.Custom,
  109. root: SelectCardEffect.Root.Trash,
  110. customRootCardList: null,
  111. canLookReverseCard: true,
  112. selectPlayer: card.Owner,
  113. cardEffect: activateClass);
  114. selectCardEffect.SetUpCustomMessage("Select 1 card to add face up in security.", "The opponent is selecting 1 card to add face up in security.");
  115. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  116. }
  117. IEnumerator SelectCardCoroutine(CardSource cardSource)
  118. {
  119. selectedCard = cardSource;
  120. yield return null;
  121. }
  122. if(selectedCard != null)
  123. {
  124. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(
  125. selectedCard, toTop: false, faceUp: true));
  126. }
  127. }
  128. }
  129. }
  130. #endregion
  131. #region End of Your Turn
  132. if (timing == EffectTiming.OnEndTurn)
  133. {
  134. ActivateClass activateClass = new ActivateClass();
  135. activateClass.SetUpICardEffect("By suspending, 1 of your digimon may attack", CanUseCondition, card);
  136. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  137. cardEffects.Add(activateClass);
  138. string EffectDiscription()
  139. {
  140. return "[End of Your Turn] By suspending this Tamer, 1 of your level 6 Digimon with the [Machine] or [Zaxon] trait may attack a player.";
  141. }
  142. bool CanUseCondition(Hashtable hashtable)
  143. {
  144. return CardEffectCommons.IsExistOnBattleArea(card)
  145. && CardEffectCommons.IsOwnerTurn(card);
  146. }
  147. bool CanActivateCondition(Hashtable hashtable)
  148. {
  149. return CardEffectCommons.IsExistOnBattleArea(card)
  150. && CardEffectCommons.CanActivateSuspendCostEffect(card);
  151. }
  152. bool PermanentCondition(Permanent permanent)
  153. {
  154. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  155. permanent.TopCard.HasLevel && permanent.TopCard.IsLevel6 &&
  156. (permanent.TopCard.EqualsTraits("Machine") || permanent.TopCard.EqualsTraits("Zaxon"));
  157. }
  158. IEnumerator ActivateCoroutine(Hashtable hashtable)
  159. {
  160. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(
  161. permanents: new List<Permanent>() { card.PermanentOfThisCard() },
  162. hashtable: hashtable).Tap()
  163. );
  164. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  165. {
  166. Permanent selectedPermanent = null;
  167. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  168. selectPermanentEffect.SetUp(
  169. selectPlayer: card.Owner,
  170. canTargetCondition: PermanentCondition,
  171. canTargetCondition_ByPreSelecetedList: null,
  172. canEndSelectCondition: null,
  173. maxCount: 1,
  174. canNoSelect: false,
  175. canEndNotMax: false,
  176. selectPermanentCoroutine: SelectPermanentCoroutine,
  177. afterSelectPermanentCoroutine: null,
  178. mode: SelectPermanentEffect.Mode.Custom,
  179. cardEffect: activateClass);
  180. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that may attack.", "The opponent is selecting 1 Digimon that may attack.");
  181. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  182. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  183. {
  184. selectedPermanent = permanent;
  185. yield return null;
  186. }
  187. if (selectedPermanent != null)
  188. {
  189. if (selectedPermanent.CanAttack(activateClass))
  190. {
  191. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  192. selectAttackEffect.SetUp(
  193. attacker: selectedPermanent,
  194. canAttackPlayerCondition: () => true,
  195. defenderCondition: (permanent) => false,
  196. cardEffect: activateClass);
  197. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  198. }
  199. }
  200. }
  201. }
  202. }
  203. #endregion
  204. #region Security
  205. if (timing == EffectTiming.SecuritySkill)
  206. {
  207. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  208. }
  209. #endregion
  210. return cardEffects;
  211. }
  212. }
  213. }