BT16_071.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT16
  5. {
  6. public class BT16_071 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Digivolution Condition
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. if (targetPermanent.TopCard.CardNames.Contains("Liollmon"))
  17. {
  18. return true;
  19. }
  20. if (targetPermanent.TopCard.CardNames.Contains("Elecmon"))
  21. {
  22. return true;
  23. }
  24. return false;
  25. }
  26. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  27. }
  28. #endregion
  29. #region When Attacking
  30. if (timing == EffectTiming.OnAllyAttack)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect("Digivolve into a [Leomon] in name Digimon from hand or trash.", CanUseCondition, card);
  34. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  35. cardEffects.Add(activateClass);
  36. string EffectDiscription()
  37. {
  38. return "[When Attacking] This Digimon may digivolve into a Digimon card with [Leomon] in it's name from your hand or trash.";
  39. }
  40. bool CanSelectCardCondition(CardSource cardSource)
  41. {
  42. if (cardSource.IsDigimon)
  43. {
  44. if (cardSource.ContainsCardName("Leomon"))
  45. {
  46. if (cardSource.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame, true, activateClass))
  47. {
  48. return true;
  49. }
  50. }
  51. }
  52. return false;
  53. }
  54. bool CanUseCondition(Hashtable hashtable)
  55. {
  56. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  57. }
  58. bool CanActivateCondition(Hashtable hashtable)
  59. {
  60. if (CardEffectCommons.IsExistOnBattleArea(card))
  61. {
  62. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  63. {
  64. return true;
  65. }
  66. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  67. {
  68. return true;
  69. }
  70. }
  71. return false;
  72. }
  73. IEnumerator ActivateCoroutine(Hashtable hashtable)
  74. {
  75. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  76. bool canSelectTrash = card.Owner.TrashCards.Count(CanSelectCardCondition) >= 1;
  77. if (canSelectHand || canSelectTrash)
  78. {
  79. if (canSelectHand && canSelectTrash)
  80. {
  81. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  82. {
  83. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  84. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  85. };
  86. string selectPlayerMessage = "From which area do you want to digivolve from?";
  87. string notSelectPlayerMessage = "The opponent is choosing where to digivolve from.";
  88. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  89. }
  90. else
  91. {
  92. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  93. }
  94. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  95. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  96. if (fromHand)
  97. {
  98. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  99. targetPermanent: card.PermanentOfThisCard(),
  100. cardCondition: CanSelectCardCondition,
  101. payCost: true,
  102. reduceCostTuple: null,
  103. fixedCostTuple: null,
  104. ignoreDigivolutionRequirementFixedCost: -1,
  105. isHand: true,
  106. activateClass: activateClass,
  107. successProcess: null));
  108. }
  109. else
  110. {
  111. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  112. targetPermanent: card.PermanentOfThisCard(),
  113. cardCondition: CanSelectCardCondition,
  114. payCost: true,
  115. reduceCostTuple: null,
  116. fixedCostTuple: null,
  117. ignoreDigivolutionRequirementFixedCost: -1,
  118. isHand: false,
  119. activateClass: activateClass,
  120. successProcess: null));
  121. }
  122. }
  123. }
  124. }
  125. #endregion
  126. #region Inherit
  127. if (timing == EffectTiming.OnEndAttack)
  128. {
  129. ActivateClass activateClass = new ActivateClass();
  130. activateClass.SetUpICardEffect("Delete this Digimon to play a level 4 or lower Digimon from your trash.", CanUseCondition, card);
  131. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  132. activateClass.SetIsInheritedEffect(true);
  133. activateClass.SetHashString("DeleteAndPlay_BT16_071");
  134. cardEffects.Add(activateClass);
  135. string EffectDiscription()
  136. {
  137. return "[End of Attack] By deleting this Digimon, you may play 1 level 4 or lower Digimon card from your trash without paying the cost.";
  138. }
  139. bool CanUseCondition(Hashtable hashtable)
  140. {
  141. return CardEffectCommons.CanTriggerOnEndAttack(hashtable, card);
  142. }
  143. bool CanSelectCardCondition(CardSource cardSource)
  144. {
  145. if (card.Owner.TrashCards.Count >= 1)
  146. {
  147. if (cardSource.HasLevel && cardSource.Level <= 4 && cardSource.IsDigimon)
  148. {
  149. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  150. {
  151. return true;
  152. }
  153. }
  154. }
  155. return false;
  156. }
  157. bool CanActivateCondition(Hashtable hashtable)
  158. {
  159. if (CardEffectCommons.IsExistOnBattleArea(card))
  160. {
  161. if (card.PermanentOfThisCard().CanBeDestroyedBySkill(activateClass))
  162. {
  163. return true;
  164. }
  165. }
  166. return false;
  167. }
  168. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  169. {
  170. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  171. new List<Permanent>() { card.PermanentOfThisCard() },
  172. CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  173. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  174. {
  175. List<CardSource> selectedCards = new List<CardSource>();
  176. int maxCount = 1;
  177. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  178. selectCardEffect.SetUp(
  179. canTargetCondition: CanSelectCardCondition,
  180. canTargetCondition_ByPreSelecetedList: null,
  181. canEndSelectCondition: null,
  182. canNoSelect: () => true,
  183. selectCardCoroutine: SelectCardCoroutine,
  184. afterSelectCardCoroutine: null,
  185. message: "Select 1 card to play.",
  186. maxCount: maxCount,
  187. canEndNotMax: false,
  188. isShowOpponent: true,
  189. mode: SelectCardEffect.Mode.Custom,
  190. root: SelectCardEffect.Root.Custom,
  191. customRootCardList: card.Owner.TrashCards,
  192. canLookReverseCard: true,
  193. selectPlayer: card.Owner,
  194. cardEffect: activateClass);
  195. selectCardEffect.SetUpCustomMessage("Select 1 trash card to play.", "The opponent is selecting 1 trash card to play.");
  196. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  197. yield return StartCoroutine(selectCardEffect.Activate());
  198. IEnumerator SelectCardCoroutine(CardSource cardSource)
  199. {
  200. selectedCards.Add(cardSource);
  201. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  202. }
  203. }
  204. }
  205. }
  206. #endregion
  207. return cardEffects;
  208. }
  209. }
  210. }