BT20_065.cs 8.7 KB

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