BT12_017.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT12
  6. {
  7. public class BT12_017 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.None)
  13. {
  14. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: false, card: card, condition: null));
  15. }
  16. if (timing == EffectTiming.OnEnterFieldAnyone)
  17. {
  18. ActivateClass activateClass = new ActivateClass();
  19. activateClass.SetUpICardEffect("Delete 1 Digimon", CanUseCondition, card);
  20. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  21. cardEffects.Add(activateClass);
  22. string EffectDiscription()
  23. {
  24. return "[When Digivolving] Delete 1 of your opponent's Digimon with 6000 DP or less. If this Digimon has a red Tamer in its digivolution cards, delete 1 of your opponent�'s Digimon with DP less than or equal to this Digimon� instead.";
  25. }
  26. bool CanSelectPermanentCondition(Permanent permanent)
  27. {
  28. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  29. {
  30. if (CardEffectCommons.IsExistOnBattleArea(card)
  31. && card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) =>
  32. cardSource.IsTamer && cardSource.CardColors.Contains(CardColor.Red)) >= 1)
  33. {
  34. if (permanent.DP <= card.PermanentOfThisCard().DP)
  35. {
  36. return true;
  37. }
  38. }
  39. else
  40. {
  41. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(6000, activateClass))
  42. {
  43. return true;
  44. }
  45. }
  46. }
  47. return false;
  48. }
  49. bool CanUseCondition(Hashtable hashtable)
  50. {
  51. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  52. }
  53. bool CanActivateCondition(Hashtable hashtable)
  54. {
  55. if (CardEffectCommons.IsExistOnBattleArea(card))
  56. {
  57. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  58. {
  59. return true;
  60. }
  61. }
  62. return false;
  63. }
  64. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  65. {
  66. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  67. {
  68. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  69. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  70. selectPermanentEffect.SetUp(
  71. selectPlayer: card.Owner,
  72. canTargetCondition: CanSelectPermanentCondition,
  73. canTargetCondition_ByPreSelecetedList: null,
  74. canEndSelectCondition: null,
  75. maxCount: maxCount,
  76. canNoSelect: false,
  77. canEndNotMax: false,
  78. selectPermanentCoroutine: null,
  79. afterSelectPermanentCoroutine: null,
  80. mode: SelectPermanentEffect.Mode.Destroy,
  81. cardEffect: activateClass);
  82. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  83. }
  84. }
  85. }
  86. if (timing == EffectTiming.OnDestroyedAnyone)
  87. {
  88. ActivateClass activateClass = new ActivateClass();
  89. activateClass.SetUpICardEffect("Play 1 [Takuya Kanbara] from hand or trash", CanUseCondition, card);
  90. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  91. cardEffects.Add(activateClass);
  92. string EffectDiscription()
  93. {
  94. return "[On Deletion] You may play 1 [Takuya Kanbara] from your hand or trash without paying its cost.";
  95. }
  96. bool CanSelectCardCondition(CardSource cardSource)
  97. {
  98. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  99. {
  100. if (cardSource.CardNames.Contains("Takuya Kanbara"))
  101. {
  102. return true;
  103. }
  104. if (cardSource.CardNames.Contains("TakuyaKanbara"))
  105. {
  106. return true;
  107. }
  108. }
  109. return false;
  110. }
  111. bool CanUseCondition(Hashtable hashtable)
  112. {
  113. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  114. }
  115. bool CanActivateCondition(Hashtable hashtable)
  116. {
  117. if (CardEffectCommons.IsExistOnTrash(card))
  118. {
  119. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  120. {
  121. return true;
  122. }
  123. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  124. {
  125. return true;
  126. }
  127. }
  128. return false;
  129. }
  130. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  131. {
  132. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  133. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  134. if (canSelectHand || canSelectTrash)
  135. {
  136. if (canSelectHand && canSelectTrash)
  137. {
  138. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  139. {
  140. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  141. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  142. };
  143. string selectPlayerMessage = "From which area do you play a card?";
  144. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  145. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  146. }
  147. else
  148. {
  149. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  150. }
  151. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  152. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  153. List<CardSource> selectedCards = new List<CardSource>();
  154. IEnumerator SelectCardCoroutine(CardSource cardSource)
  155. {
  156. selectedCards.Add(cardSource);
  157. yield return null;
  158. }
  159. if (fromHand)
  160. {
  161. int maxCount = 1;
  162. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  163. selectHandEffect.SetUp(
  164. selectPlayer: card.Owner,
  165. canTargetCondition: CanSelectCardCondition,
  166. canTargetCondition_ByPreSelecetedList: null,
  167. canEndSelectCondition: null,
  168. maxCount: maxCount,
  169. canNoSelect: true,
  170. canEndNotMax: false,
  171. isShowOpponent: true,
  172. selectCardCoroutine: SelectCardCoroutine,
  173. afterSelectCardCoroutine: null,
  174. mode: SelectHandEffect.Mode.Custom,
  175. cardEffect: activateClass);
  176. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  177. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  178. yield return StartCoroutine(selectHandEffect.Activate());
  179. }
  180. else
  181. {
  182. int maxCount = 1;
  183. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  184. selectCardEffect.SetUp(
  185. canTargetCondition: CanSelectCardCondition,
  186. canTargetCondition_ByPreSelecetedList: null,
  187. canEndSelectCondition: null,
  188. canNoSelect: () => true,
  189. selectCardCoroutine: SelectCardCoroutine,
  190. afterSelectCardCoroutine: null,
  191. message: "Select 1 card to play.",
  192. maxCount: maxCount,
  193. canEndNotMax: false,
  194. isShowOpponent: true,
  195. mode: SelectCardEffect.Mode.Custom,
  196. root: SelectCardEffect.Root.Trash,
  197. customRootCardList: null,
  198. canLookReverseCard: true,
  199. selectPlayer: card.Owner,
  200. cardEffect: activateClass);
  201. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  202. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  203. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  204. }
  205. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  206. if (!fromHand)
  207. {
  208. root = SelectCardEffect.Root.Trash;
  209. }
  210. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  211. cardSources: selectedCards,
  212. activateClass: activateClass,
  213. payCost: false,
  214. isTapped: false,
  215. root: root,
  216. activateETB: true));
  217. }
  218. }
  219. }
  220. return cardEffects;
  221. }
  222. }
  223. }