ST17_09.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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.ST17
  9. {
  10. public class ST17_09 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region Digivolution Condition
  16. if (timing == EffectTiming.None)
  17. {
  18. bool PermanentCondition(Permanent targetPermanent)
  19. {
  20. if ((targetPermanent.TopCard.CardNames.Contains("Antylamon") && targetPermanent.Level == 5))
  21. {
  22. return true;
  23. }
  24. return false;
  25. }
  26. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  27. }
  28. #endregion
  29. #region Alliance
  30. if (timing == EffectTiming.OnAllyAttack)
  31. {
  32. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  33. }
  34. #endregion
  35. #region When Digivolving
  36. if (timing == EffectTiming.OnEnterFieldAnyone)
  37. {
  38. ActivateClass activateClass = new ActivateClass();
  39. activateClass.SetUpICardEffect("Delete 1 Digimon and/or play 1 Digimon.", CanUseCondition, card);
  40. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  41. cardEffects.Add(activateClass);
  42. string EffectDiscription()
  43. {
  44. return "[When Digivolving] You may delete 1 level 4 or lower Digimon. Then, you may play 1 green or purple Digimon from your hand or trash without paying the cost.";
  45. }
  46. bool CanSelectPermanentCondition(Permanent permanent)
  47. {
  48. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  49. {
  50. if (permanent.Level <= 4)
  51. {
  52. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  53. {
  54. if (permanent.CanBeDestroyedBySkill(activateClass))
  55. {
  56. return true;
  57. }
  58. }
  59. }
  60. }
  61. return false;
  62. }
  63. bool CanSelectCardCondition(CardSource cardSource)
  64. {
  65. if (CardEffectCommons.IsExistOnHand(cardSource))
  66. {
  67. if (cardSource.Level <= 4 && cardSource.HasCardColor(CardColor.Purple) && cardSource.IsDigimon)
  68. {
  69. return true;
  70. }
  71. if (cardSource.Level <= 4 && cardSource.HasCardColor(CardColor.Green) && cardSource.IsDigimon)
  72. {
  73. return true;
  74. }
  75. }
  76. return false;
  77. }
  78. bool CanSelectCardCondition1(CardSource cardSource)
  79. {
  80. if (CardEffectCommons.IsExistOnTrash(cardSource))
  81. {
  82. if (cardSource.Level <= 4 && cardSource.HasCardColor(CardColor.Purple) && cardSource.IsDigimon)
  83. {
  84. return true;
  85. }
  86. if (cardSource.Level <= 4 && cardSource.HasCardColor(CardColor.Green) && cardSource.IsDigimon)
  87. {
  88. return true;
  89. }
  90. }
  91. return false;
  92. }
  93. bool CanUseCondition(Hashtable hashtable)
  94. {
  95. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  96. }
  97. bool CanActivateCondition(Hashtable hashtable)
  98. {
  99. return CardEffectCommons.IsExistOnBattleArea(card);
  100. }
  101. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  102. {
  103. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  104. {
  105. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  106. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  107. selectPermanentEffect.SetUp(
  108. selectPlayer: card.Owner,
  109. canTargetCondition: CanSelectPermanentCondition,
  110. canTargetCondition_ByPreSelecetedList: null,
  111. canEndSelectCondition: null,
  112. maxCount: maxCount,
  113. canNoSelect: true,
  114. canEndNotMax: false,
  115. selectPermanentCoroutine: null,
  116. afterSelectPermanentCoroutine: null,
  117. mode: SelectPermanentEffect.Mode.Destroy,
  118. cardEffect: activateClass);
  119. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  120. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  121. }
  122. if (CardEffectCommons.IsExistOnBattleArea(card))
  123. {
  124. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  125. bool canSelectTrash = card.Owner.TrashCards.Count(CanSelectCardCondition1) >= 1;
  126. if (canSelectHand || canSelectTrash)
  127. {
  128. if (canSelectHand && canSelectTrash)
  129. {
  130. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  131. {
  132. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  133. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  134. };
  135. string selectPlayerMessage = "From which area do you play a card?";
  136. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  137. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  138. }
  139. else
  140. {
  141. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  142. }
  143. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  144. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  145. List<CardSource> selectedCards = new List<CardSource>();
  146. IEnumerator SelectCardCoroutine(CardSource cardSource)
  147. {
  148. selectedCards.Add(cardSource);
  149. yield return null;
  150. }
  151. if (fromHand)
  152. {
  153. int maxCount1 = 1;
  154. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  155. selectHandEffect.SetUp(
  156. selectPlayer: card.Owner,
  157. canTargetCondition: CanSelectCardCondition,
  158. canTargetCondition_ByPreSelecetedList: null,
  159. canEndSelectCondition: null,
  160. maxCount: maxCount1,
  161. canNoSelect: true,
  162. canEndNotMax: false,
  163. isShowOpponent: true,
  164. selectCardCoroutine: SelectCardCoroutine,
  165. afterSelectCardCoroutine: null,
  166. mode: SelectHandEffect.Mode.Custom,
  167. cardEffect: activateClass);
  168. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  169. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  170. yield return StartCoroutine(selectHandEffect.Activate());
  171. }
  172. else
  173. {
  174. int maxCount1 = 1;
  175. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  176. selectCardEffect.SetUp(
  177. canTargetCondition: CanSelectCardCondition1,
  178. canTargetCondition_ByPreSelecetedList: null,
  179. canEndSelectCondition: null,
  180. canNoSelect: () => true,
  181. selectCardCoroutine: SelectCardCoroutine,
  182. afterSelectCardCoroutine: null,
  183. message: "Select 1 card to play.",
  184. maxCount: maxCount1,
  185. canEndNotMax: false,
  186. isShowOpponent: true,
  187. mode: SelectCardEffect.Mode.Custom,
  188. root: SelectCardEffect.Root.Custom,
  189. customRootCardList: card.Owner.TrashCards,
  190. canLookReverseCard: true,
  191. selectPlayer: card.Owner,
  192. cardEffect: activateClass);
  193. selectCardEffect.SetUpCustomMessage("Select 1 trash card to play.", "The opponent is selecting 1 trash card to play.");
  194. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  195. yield return StartCoroutine(selectCardEffect.Activate());
  196. }
  197. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  198. if (!fromHand)
  199. {
  200. root = SelectCardEffect.Root.Trash;
  201. }
  202. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  203. cardSources: selectedCards,
  204. activateClass: activateClass,
  205. payCost: false,
  206. isTapped: false,
  207. root: root,
  208. activateETB: true));
  209. }
  210. }
  211. }
  212. }
  213. #endregion
  214. return cardEffects;
  215. }
  216. }
  217. }