BT17_081.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. namespace DCGO.CardEffects.BT17
  5. {
  6. public class BT17_081 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region All Turns
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Gain Memory", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true,
  17. EffectDescription());
  18. cardEffects.Add(activateClass);
  19. string EffectDescription()
  20. {
  21. return
  22. "[All Turns] When one of your Digimon is played or digivolves, by suspending this Tamer, if you have a Digimon with [Greymon] in its name, gain 1 memory. If you have a Digimon with [Garurumon] in its name, gain 1 memory.";
  23. }
  24. bool PermanentCondition(Permanent permanent)
  25. {
  26. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  27. }
  28. bool IsGreymonPermanentCondition(Permanent permanent)
  29. {
  30. return permanent.IsDigimon && permanent.TopCard.HasGreymonName;
  31. }
  32. bool IsGarurumonPermanentCondition(Permanent permanent)
  33. {
  34. return permanent.IsDigimon && permanent.TopCard.HasGarurumonName;
  35. }
  36. bool CanUseCondition(Hashtable hashtable)
  37. {
  38. if (CardEffectCommons.IsExistOnBattleArea(card))
  39. {
  40. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition) ||
  41. CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, PermanentCondition))
  42. {
  43. return true;
  44. }
  45. }
  46. return false;
  47. }
  48. bool CanActivateCondition(Hashtable hashtable)
  49. {
  50. if (CardEffectCommons.IsExistOnBattleArea(card))
  51. {
  52. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  53. {
  54. return true;
  55. }
  56. }
  57. return false;
  58. }
  59. IEnumerator ActivateCoroutine(Hashtable hashtable)
  60. {
  61. yield return ContinuousController.instance.StartCoroutine(
  62. new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() },
  63. CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  64. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsGreymonPermanentCondition))
  65. {
  66. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  67. }
  68. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsGarurumonPermanentCondition))
  69. {
  70. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  71. }
  72. }
  73. }
  74. #endregion
  75. #region End of Your Turn
  76. if (timing == EffectTiming.OnEndTurn)
  77. {
  78. ActivateClass activateClass = new ActivateClass();
  79. activateClass.SetUpICardEffect("1 of your [Omnimon] can attack a player", CanUseCondition, card);
  80. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  81. activateClass.SetHashString("Attack_BT17_081");
  82. cardEffects.Add(activateClass);
  83. string EffectDescription()
  84. {
  85. return
  86. "[End of Your Turn] [Once Per Turn] 1 of your Digimon with [Omnimon] in its name may attack a player.";
  87. }
  88. bool IsOmnimonPermanentCondition(Permanent permanent)
  89. {
  90. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  91. {
  92. if (permanent.TopCard.ContainsCardName("Omnimon"))
  93. {
  94. return permanent.CanAttack(activateClass);
  95. }
  96. }
  97. return false;
  98. }
  99. bool CanUseCondition(Hashtable hashtable)
  100. {
  101. if (CardEffectCommons.IsExistOnBattleArea(card))
  102. {
  103. if (CardEffectCommons.IsOwnerTurn(card))
  104. {
  105. return true;
  106. }
  107. }
  108. return false;
  109. }
  110. bool CanActivateCondition(Hashtable hashtable)
  111. {
  112. if (CardEffectCommons.IsExistOnBattleArea(card))
  113. {
  114. if (CardEffectCommons.HasMatchConditionPermanent(IsOmnimonPermanentCondition))
  115. {
  116. return true;
  117. }
  118. }
  119. return false;
  120. }
  121. IEnumerator ActivateCoroutine(Hashtable hashtable)
  122. {
  123. if (CardEffectCommons.HasMatchConditionPermanent(IsOmnimonPermanentCondition))
  124. {
  125. Permanent selectedPermanent = null;
  126. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsOmnimonPermanentCondition));
  127. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  128. selectPermanentEffect.SetUp(
  129. selectPlayer: card.Owner,
  130. canTargetCondition: IsOmnimonPermanentCondition,
  131. canTargetCondition_ByPreSelecetedList: null,
  132. canEndSelectCondition: null,
  133. maxCount: maxCount,
  134. canNoSelect: false,
  135. canEndNotMax: false,
  136. selectPermanentCoroutine: SelectPermanentCoroutine,
  137. afterSelectPermanentCoroutine: null,
  138. mode: SelectPermanentEffect.Mode.Custom,
  139. cardEffect: activateClass);
  140. selectPermanentEffect.SetUpCustomMessage(
  141. "Select 1 Digimon that will attack.",
  142. "The opponent is selecting 1 Digimon that will attack.");
  143. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  144. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  145. {
  146. selectedPermanent = permanent;
  147. yield return null;
  148. }
  149. if (selectedPermanent != null)
  150. {
  151. if (selectedPermanent.CanAttack(activateClass))
  152. {
  153. if (selectedPermanent.CanAttackTargetDigimon(null, activateClass))
  154. {
  155. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  156. selectAttackEffect.SetUp(
  157. attacker: selectedPermanent,
  158. canAttackPlayerCondition: () => true,
  159. defenderCondition: _ => false,
  160. cardEffect: activateClass);
  161. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  162. }
  163. }
  164. }
  165. }
  166. }
  167. }
  168. #endregion
  169. #region Security Effect
  170. if (timing == EffectTiming.SecuritySkill)
  171. {
  172. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  173. }
  174. #endregion
  175. return cardEffects;
  176. }
  177. }
  178. }