BT10_072.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. namespace DCGO.CardEffects.BT10
  9. {
  10. public class BT10_072 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. if (timing == EffectTiming.OnAllyAttack)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect("Place 1 card from hand under 1 Tamer to draw 1", CanUseCondition, card);
  19. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "[When Attacking] By placing 1 purple Digimon card from your hand under one of your Tamers, <Draw 1>. (Draw 1 card from your deck.)";
  24. }
  25. bool CanSelectCardCondition(CardSource cardSource)
  26. {
  27. if (cardSource.IsDigimon)
  28. {
  29. if (cardSource.HasCardColor(CardColor.Purple))
  30. {
  31. return true;
  32. }
  33. }
  34. return false;
  35. }
  36. bool CanSelectPermanentCondition(Permanent permanent)
  37. {
  38. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  39. {
  40. if (permanent.IsTamer)
  41. {
  42. if (!permanent.IsToken)
  43. {
  44. return true;
  45. }
  46. }
  47. }
  48. return false;
  49. }
  50. bool CanUseCondition(Hashtable hashtable)
  51. {
  52. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  53. }
  54. bool CanActivateCondition(Hashtable hashtable)
  55. {
  56. if (CardEffectCommons.IsExistOnBattleArea(card))
  57. {
  58. if (card.Owner.HandCards.Count >= 1)
  59. {
  60. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  61. {
  62. return true;
  63. }
  64. }
  65. }
  66. return false;
  67. }
  68. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  69. {
  70. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  71. {
  72. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  73. {
  74. bool placed = false;
  75. int maxCount = 1;
  76. List<CardSource> selectedCards = new List<CardSource>();
  77. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  78. selectHandEffect.SetUp(
  79. selectPlayer: card.Owner,
  80. canTargetCondition: CanSelectCardCondition,
  81. canTargetCondition_ByPreSelecetedList: null,
  82. canEndSelectCondition: null,
  83. maxCount: maxCount,
  84. canNoSelect: true,
  85. canEndNotMax: false,
  86. isShowOpponent: true,
  87. selectCardCoroutine: SelectCardCoroutine,
  88. afterSelectCardCoroutine: null,
  89. mode: SelectHandEffect.Mode.Custom,
  90. cardEffect: activateClass);
  91. yield return StartCoroutine(selectHandEffect.Activate());
  92. IEnumerator SelectCardCoroutine(CardSource cardSource)
  93. {
  94. selectedCards.Add(cardSource);
  95. yield return null;
  96. }
  97. if (selectedCards.Count >= 1)
  98. {
  99. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  100. {
  101. maxCount = Math.Min(1, card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition));
  102. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  103. selectPermanentEffect.SetUp(
  104. selectPlayer: card.Owner,
  105. canTargetCondition: CanSelectPermanentCondition,
  106. canTargetCondition_ByPreSelecetedList: null,
  107. canEndSelectCondition: null,
  108. maxCount: maxCount,
  109. canNoSelect: true,
  110. canEndNotMax: false,
  111. selectPermanentCoroutine: SelectPermanentCoroutine,
  112. afterSelectPermanentCoroutine: null,
  113. mode: SelectPermanentEffect.Mode.Custom,
  114. cardEffect: activateClass);
  115. selectPermanentEffect.SetUpCustomMessage("Select a Tamer that will get a digivolution card.", "The opponent is selecting a Tamer that will get a digivolution card.");
  116. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  117. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  118. {
  119. Permanent selectedPermanent = permanent;
  120. if (selectedPermanent != null)
  121. {
  122. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  123. placed = true;
  124. }
  125. }
  126. }
  127. }
  128. if (placed)
  129. {
  130. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  131. }
  132. }
  133. }
  134. }
  135. }
  136. if (timing == EffectTiming.OnDestroyedAnyone)
  137. {
  138. cardEffects.Add(CardEffectFactory.SaveEffect(card: card));
  139. }
  140. if (timing == EffectTiming.OnDigivolutionCardDiscarded)
  141. {
  142. ActivateClass activateClass = new ActivateClass();
  143. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  144. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  145. activateClass.SetIsInheritedEffect(true);
  146. cardEffects.Add(activateClass);
  147. string EffectDiscription()
  148. {
  149. return "[Opponent's Turn] When an effect trashes this digivolution card, gain 1 memory.";
  150. }
  151. bool CanUseCondition(Hashtable hashtable)
  152. {
  153. if (CardEffectCommons.IsExistOnBattleArea(card))
  154. {
  155. if (CardEffectCommons.IsOpponentTurn(card))
  156. {
  157. if (CardEffectCommons.CanTriggerOnTrashSelfDigivolutionCard(hashtable, cardEffect => cardEffect != null, card))
  158. {
  159. return true;
  160. }
  161. }
  162. }
  163. return false;
  164. }
  165. bool CanActivateCondition(Hashtable hashtable)
  166. {
  167. if (CardEffectCommons.IsExistOnTrash(card))
  168. {
  169. if (card.Owner.CanAddMemory(activateClass))
  170. {
  171. return true;
  172. }
  173. }
  174. return false;
  175. }
  176. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  177. {
  178. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  179. }
  180. }
  181. return cardEffects;
  182. }
  183. }
  184. }