BT11_092.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. namespace DCGO.CardEffects.BT11
  6. {
  7. public class BT11_092 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.OnStartMainPhase)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Trash 1 card from hand to gain Memory +1 and Draw 1", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[Start of Your Main Phase] By trashing 1 level 5 card with [Cyborg] in its traits in your hand, gain 1 memory and <Draw 1>.";
  21. }
  22. bool CanSelectCardCondition(CardSource cardSource)
  23. {
  24. if (cardSource.CardTraits.Contains("Cyborg"))
  25. {
  26. if (cardSource.Level == 5)
  27. {
  28. if (cardSource.HasLevel)
  29. {
  30. return true;
  31. }
  32. }
  33. }
  34. return false;
  35. }
  36. bool CanUseCondition(Hashtable hashtable)
  37. {
  38. if (CardEffectCommons.IsExistOnBattleArea(card))
  39. {
  40. if (CardEffectCommons.IsOwnerTurn(card))
  41. {
  42. return true;
  43. }
  44. }
  45. return false;
  46. }
  47. bool CanActivateCondition(Hashtable hashtable)
  48. {
  49. if (CardEffectCommons.IsExistOnBattleArea(card))
  50. {
  51. if (card.Owner.HandCards.Count >= 1)
  52. {
  53. return true;
  54. }
  55. }
  56. return false;
  57. }
  58. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  59. {
  60. if (card.Owner.HandCards.Some(CanSelectCardCondition))
  61. {
  62. bool discarded = false;
  63. int discardCount = 1;
  64. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  65. selectHandEffect.SetUp(
  66. selectPlayer: card.Owner,
  67. canTargetCondition: CanSelectCardCondition,
  68. canTargetCondition_ByPreSelecetedList: null,
  69. canEndSelectCondition: null,
  70. maxCount: discardCount,
  71. canNoSelect: true,
  72. canEndNotMax: false,
  73. isShowOpponent: true,
  74. selectCardCoroutine: null,
  75. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  76. mode: SelectHandEffect.Mode.Discard,
  77. cardEffect: activateClass);
  78. yield return StartCoroutine(selectHandEffect.Activate());
  79. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  80. {
  81. if (cardSources.Count >= 1)
  82. {
  83. discarded = true;
  84. yield return null;
  85. }
  86. }
  87. if (discarded)
  88. {
  89. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  90. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  91. }
  92. }
  93. }
  94. }
  95. if (timing == EffectTiming.OnAllyAttack)
  96. {
  97. ActivateClass activateClass = new ActivateClass();
  98. activateClass.SetUpICardEffect("Switch Attack Target to your Digimon", CanUseCondition, card);
  99. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  100. cardEffects.Add(activateClass);
  101. string EffectDiscription()
  102. {
  103. return "[Opponent's Turn] When an opponent's Digimon attacks a player, by suspending this Tamer, switch the target of attack to 1 of your level 6 Digimon with [Machine] in its traits.";
  104. }
  105. bool CanSelectPermanentCondition(Permanent permanent)
  106. {
  107. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  108. {
  109. if (permanent.TopCard.CardTraits.Contains("Machine"))
  110. {
  111. if (permanent.TopCard.HasLevel && permanent.TopCard.Level == 6)
  112. {
  113. return true;
  114. }
  115. }
  116. }
  117. return false;
  118. }
  119. bool PermanentCondition(Permanent permanent)
  120. {
  121. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  122. }
  123. bool CanUseCondition(Hashtable hashtable)
  124. {
  125. if (CardEffectCommons.IsExistOnBattleArea(card))
  126. {
  127. if (CardEffectCommons.IsOpponentTurn(card))
  128. {
  129. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition))
  130. {
  131. if (GManager.instance.attackProcess.DefendingPermanent == null)
  132. {
  133. return true;
  134. }
  135. }
  136. }
  137. }
  138. return false;
  139. }
  140. bool CanActivateCondition(Hashtable hashtable)
  141. {
  142. if (CardEffectCommons.IsExistOnBattleArea(card))
  143. {
  144. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  145. {
  146. return true;
  147. }
  148. }
  149. return false;
  150. }
  151. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  152. {
  153. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(
  154. new List<Permanent>() { card.PermanentOfThisCard() },
  155. CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  156. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  157. {
  158. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  159. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  160. selectPermanentEffect.SetUp(
  161. selectPlayer: card.Owner,
  162. canTargetCondition: CanSelectPermanentCondition,
  163. canTargetCondition_ByPreSelecetedList: null,
  164. canEndSelectCondition: null,
  165. maxCount: maxCount,
  166. canNoSelect: false,
  167. canEndNotMax: false,
  168. selectPermanentCoroutine: SelectPermanentCoroutine,
  169. afterSelectPermanentCoroutine: null,
  170. mode: SelectPermanentEffect.Mode.Custom,
  171. cardEffect: activateClass);
  172. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that opponent's Digimon attacks to.", "The opponent is selecting 1 Digimon that your Digimon attacks to.");
  173. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  174. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  175. {
  176. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  177. activateClass,
  178. false,
  179. permanent));
  180. }
  181. }
  182. }
  183. }
  184. if (timing == EffectTiming.SecuritySkill)
  185. {
  186. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  187. }
  188. return cardEffects;
  189. }
  190. }
  191. }