BT20_065.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT20
  5. {
  6. public class WormmonBT20_065 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region On Play
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Give effects to your opponent's Digimon", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[On Play] By trashing 1 card in your hand, give 1 of your opponent's Digimon '[On Deletion] Lose 1 memory.' until the end of their turn.";
  21. }
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  25. }
  26. bool CanActivateCondition(Hashtable hashtable)
  27. {
  28. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  29. }
  30. bool CanSelectPermanentCondition(Permanent permanent)
  31. {
  32. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  33. }
  34. IEnumerator ActivateCoroutine(Hashtable hashtable)
  35. {
  36. if (card.Owner.HandCards.Count >= 1){
  37. bool discarded = false;
  38. int discardCount = 1;
  39. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  40. selectHandEffect.SetUp(
  41. selectPlayer: card.Owner,
  42. canTargetCondition: cardSource => true,
  43. canTargetCondition_ByPreSelecetedList: null,
  44. canEndSelectCondition: null,
  45. maxCount: discardCount,
  46. canNoSelect: true,
  47. canEndNotMax: false,
  48. isShowOpponent: true,
  49. selectCardCoroutine: null,
  50. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  51. mode: SelectHandEffect.Mode.Discard,
  52. cardEffect: activateClass);
  53. yield return StartCoroutine(selectHandEffect.Activate());
  54. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  55. {
  56. if (cardSources.Count == 1)
  57. {
  58. discarded = true;
  59. yield return null;
  60. }
  61. }
  62. if (discarded)
  63. {
  64. Permanent selectedPermanent = null;
  65. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  66. {
  67. int maxCount = Math.Min(1,
  68. CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  69. SelectPermanentEffect selectPermanentEffect =
  70. GManager.instance.GetComponent<SelectPermanentEffect>();
  71. selectPermanentEffect.SetUp(
  72. selectPlayer: card.Owner,
  73. canTargetCondition: CanSelectPermanentCondition,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: null,
  76. maxCount: maxCount,
  77. canNoSelect: false,
  78. canEndNotMax: false,
  79. selectPermanentCoroutine: SelectPermanentCoroutine,
  80. afterSelectPermanentCoroutine: null,
  81. mode: SelectPermanentEffect.Mode.Custom,
  82. cardEffect: activateClass);
  83. selectPermanentEffect.SetUpCustomMessage(
  84. "Select 1 Digimon that will gain effect.",
  85. "The opponent is selecting 1 Digimon that will gain effect.");
  86. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  87. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  88. {
  89. selectedPermanent = permanent;
  90. yield return null;
  91. }
  92. if(selectedPermanent != null)
  93. {
  94. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  95. bool PermanentCondition(Permanent permanent)
  96. {
  97. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  98. }
  99. AddSkillClass addSkillClass = new AddSkillClass();
  100. addSkillClass.SetUpICardEffect("Memory -1", CanUseCondition1, card);
  101. addSkillClass.SetUpAddSkillClass(cardSourceCondition: CardSourceCondition, getEffects: GetEffects);
  102. selectedPermanent.UntilOpponentTurnEndEffects.Add((_timing) => addSkillClass);
  103. bool CanUseCondition1(Hashtable hashtable)
  104. {
  105. return true;
  106. }
  107. bool CardSourceCondition(CardSource cardSource)
  108. {
  109. if (PermanentCondition(cardSource.PermanentOfThisCard()))
  110. {
  111. if (cardSource == cardSource.PermanentOfThisCard().TopCard)
  112. {
  113. return true;
  114. }
  115. }
  116. return false;
  117. }
  118. List<ICardEffect> GetEffects(CardSource cardSource, List<ICardEffect> cardEffects, EffectTiming _timing)
  119. {
  120. if (_timing == EffectTiming.OnDestroyedAnyone)
  121. {
  122. ActivateClass activateClass1 = new ActivateClass();
  123. activateClass1.SetUpICardEffect("Memory -1", CanUseCondition2, cardSource);
  124. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  125. cardEffects.Add(activateClass1);
  126. if (cardSource.PermanentOfThisCard() != null)
  127. {
  128. activateClass1.SetEffectSourcePermanent(cardSource.PermanentOfThisCard());
  129. }
  130. string EffectDiscription1()
  131. {
  132. return "[On Deletion] Lose 1 memory.";
  133. }
  134. bool CanUseCondition2(Hashtable hashtable)
  135. {
  136. if (CardSourceCondition(cardSource))
  137. {
  138. if (CardEffectCommons.CanTriggerOnDeletion(hashtable, cardSource))
  139. {
  140. return true;
  141. }
  142. }
  143. return false;
  144. }
  145. bool CanActivateCondition1(Hashtable hashtable)
  146. {
  147. if (CardEffectCommons.CanActivateOnDeletion(cardSource))
  148. {
  149. return true;
  150. }
  151. return false;
  152. }
  153. IEnumerator ActivateCoroutine1(Hashtable _hashtable)
  154. {
  155. yield return ContinuousController.instance.StartCoroutine(cardSource.Owner.AddMemory(-1, activateClass1));
  156. }
  157. }
  158. return cardEffects;
  159. }
  160. }
  161. }
  162. }
  163. }
  164. }
  165. }
  166. #endregion
  167. if (timing == EffectTiming.OnDestroyedAnyone)
  168. {
  169. cardEffects.Add(CardEffectFactory.RetaliationSelfEffect(isInheritedEffect: true, card: card, condition: null));
  170. }
  171. return cardEffects;
  172. }
  173. }
  174. }