BT10_082.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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. using Unity.Mathematics;
  9. namespace DCGO.CardEffects.BT10
  10. {
  11. public class BT10_082 : CEntity_Effect
  12. {
  13. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  14. {
  15. List<ICardEffect> cardEffects = new List<ICardEffect>();
  16. if (timing == EffectTiming.None)
  17. {
  18. bool PermanentCondition(Permanent targetPermanent)
  19. {
  20. return (targetPermanent.TopCard.CardTraits.Contains("Xros Heart") || targetPermanent.TopCard.CardTraits.Contains("XrosHeart")) && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5;
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  23. }
  24. if (timing == EffectTiming.OnEnterFieldAnyone)
  25. {
  26. ActivateClass activateClass = new ActivateClass();
  27. activateClass.SetUpICardEffect("Trash 3 cards from deck top and delete level 4 or lower Digimon", CanUseCondition, card);
  28. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  29. cardEffects.Add(activateClass);
  30. string EffectDiscription()
  31. {
  32. return "[On Play] You may trash the top 3 cards of your deck. Then, for every 10 cards in your trash, delete 1 of your opponent's level 4 or lower Digimon.";
  33. }
  34. bool CanSelectPermanentCondition(Permanent permanent)
  35. {
  36. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  37. {
  38. if (permanent.Level <= 4)
  39. {
  40. if (permanent.TopCard.HasLevel)
  41. {
  42. if (permanent.CanSelectBySkill(activateClass))
  43. {
  44. return true;
  45. }
  46. }
  47. }
  48. }
  49. return false;
  50. }
  51. bool CanUseCondition(Hashtable hashtable)
  52. {
  53. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  54. }
  55. bool CanActivateCondition(Hashtable hashtable)
  56. {
  57. if (CardEffectCommons.IsExistOnBattleArea(card))
  58. {
  59. return true;
  60. }
  61. return false;
  62. }
  63. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  64. {
  65. if (card.Owner.LibraryCards.Count >= 1)
  66. {
  67. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  68. {
  69. new SelectionElement<bool>(message: $"Trash", value : true, spriteIndex: 0),
  70. new SelectionElement<bool>(message: $"Not trash", value : false, spriteIndex: 1),
  71. };
  72. string selectPlayerMessage = "Will you trash top 3 cards of deck?";
  73. string notSelectPlayerMessage = "The opponent is choosing whether to trash deck cards.";
  74. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  75. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  76. bool doTrash = GManager.instance.userSelectionManager.SelectedBoolValue;
  77. if (doTrash)
  78. {
  79. yield return ContinuousController.instance.StartCoroutine(new IAddTrashCardsFromLibraryTop(3, card.Owner, activateClass).AddTrashCardsFromLibraryTop());
  80. }
  81. }
  82. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  83. {
  84. int maxCount = card.Owner.TrashCards.Count / 10;
  85. if (maxCount >= 1)
  86. {
  87. maxCount = Math.Min(maxCount, card.Owner.Enemy.GetBattleAreaDigimons().Count(CanSelectPermanentCondition));
  88. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  89. selectPermanentEffect.SetUp(
  90. selectPlayer: card.Owner,
  91. canTargetCondition: CanSelectPermanentCondition,
  92. canTargetCondition_ByPreSelecetedList: null,
  93. canEndSelectCondition: null,
  94. maxCount: maxCount,
  95. canNoSelect: false,
  96. canEndNotMax: false,
  97. selectPermanentCoroutine: null,
  98. afterSelectPermanentCoroutine: null,
  99. mode: SelectPermanentEffect.Mode.Destroy,
  100. cardEffect: activateClass);
  101. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  102. }
  103. }
  104. }
  105. }
  106. if (timing == EffectTiming.OnEnterFieldAnyone)
  107. {
  108. ActivateClass activateClass = new ActivateClass();
  109. activateClass.SetUpICardEffect("Trash 3 cards from deck top and delete level 4 or lower Digimon", CanUseCondition, card);
  110. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  111. cardEffects.Add(activateClass);
  112. string EffectDiscription()
  113. {
  114. return "[When Digivolving] You may trash the top 3 cards of your deck. Then, for every 10 cards in your trash, delete 1 of your opponent's level 4 or lower Digimon.";
  115. }
  116. bool CanSelectPermanentCondition(Permanent permanent)
  117. {
  118. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  119. {
  120. if (permanent.Level <= 4)
  121. {
  122. if (permanent.TopCard.HasLevel)
  123. {
  124. if (permanent.CanSelectBySkill(activateClass))
  125. {
  126. return true;
  127. }
  128. }
  129. }
  130. }
  131. return false;
  132. }
  133. bool CanUseCondition(Hashtable hashtable)
  134. {
  135. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  136. }
  137. bool CanActivateCondition(Hashtable hashtable)
  138. {
  139. if (CardEffectCommons.IsExistOnBattleArea(card))
  140. {
  141. return true;
  142. }
  143. return false;
  144. }
  145. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  146. {
  147. if (card.Owner.LibraryCards.Count >= 1)
  148. {
  149. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  150. {
  151. new SelectionElement<bool>(message: $"Trash", value : true, spriteIndex: 0),
  152. new SelectionElement<bool>(message: $"Not trash", value : false, spriteIndex: 1),
  153. };
  154. string selectPlayerMessage = "Will you trash top 3 cards of deck?";
  155. string notSelectPlayerMessage = "The opponent is choosing whether to trash deck cards.";
  156. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  157. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  158. bool doTrash = GManager.instance.userSelectionManager.SelectedBoolValue;
  159. if (doTrash)
  160. {
  161. yield return ContinuousController.instance.StartCoroutine(new IAddTrashCardsFromLibraryTop(3, card.Owner, activateClass).AddTrashCardsFromLibraryTop());
  162. }
  163. }
  164. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  165. {
  166. int maxCount = card.Owner.TrashCards.Count / 10;
  167. if (maxCount >= 1)
  168. {
  169. maxCount = Math.Min(maxCount, card.Owner.Enemy.GetBattleAreaDigimons().Count(CanSelectPermanentCondition));
  170. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  171. selectPermanentEffect.SetUp(
  172. selectPlayer: card.Owner,
  173. canTargetCondition: CanSelectPermanentCondition,
  174. canTargetCondition_ByPreSelecetedList: null,
  175. canEndSelectCondition: null,
  176. maxCount: maxCount,
  177. canNoSelect: false,
  178. canEndNotMax: false,
  179. selectPermanentCoroutine: null,
  180. afterSelectPermanentCoroutine: null,
  181. mode: SelectPermanentEffect.Mode.Destroy,
  182. cardEffect: activateClass);
  183. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  184. }
  185. }
  186. }
  187. }
  188. if (timing == EffectTiming.OnEndAttack)
  189. {
  190. int count()
  191. {
  192. return card.Owner.TrashCards.Count / 10;
  193. }
  194. ActivateClass activateClass = new ActivateClass();
  195. activateClass.SetUpICardEffect("Gain Memory", CanUseCondition, card);
  196. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  197. activateClass.SetIsInheritedEffect(true);
  198. activateClass.SetHashString("Memory+_BT10_082");
  199. cardEffects.Add(activateClass);
  200. string EffectDiscription()
  201. {
  202. return "[End of Attack][Once Per Turn] For every 10 cards in your trash, gain 1 memory.";
  203. }
  204. bool CanUseCondition(Hashtable hashtable)
  205. {
  206. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  207. }
  208. bool CanActivateCondition(Hashtable hashtable)
  209. {
  210. if (CardEffectCommons.IsExistOnBattleArea(card))
  211. {
  212. return true;
  213. }
  214. return false;
  215. }
  216. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  217. {
  218. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(count(), activateClass));
  219. }
  220. }
  221. return cardEffects;
  222. }
  223. }
  224. }