P_115.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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. public class P_115 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.OnDestroyedAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Play 1 [Nene Amano] or [Yuu Amano] from hand or trash, and save", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[On Deletion] You may play 1 tamer card with [Nene Amano]/[Yuu Amano] in its name from your hand or trash without paying the cost. Then, <Save> (You may place this card under one of your Tamers).";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource != null)
  26. {
  27. if (cardSource.Owner == card.Owner)
  28. {
  29. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  30. {
  31. if (cardSource.ContainsCardName("Nene Amano"))
  32. {
  33. return true;
  34. }
  35. if (cardSource.ContainsCardName("Yuu Amano"))
  36. {
  37. return true;
  38. }
  39. }
  40. }
  41. }
  42. return false;
  43. }
  44. bool CanSelectPermanentCondition(Permanent permanent)
  45. {
  46. if (permanent != null)
  47. {
  48. if (permanent.TopCard != null)
  49. {
  50. if (permanent.IsTamer)
  51. {
  52. if (permanent.TopCard.Owner == card.Owner)
  53. {
  54. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  55. {
  56. if (!permanent.IsToken)
  57. {
  58. return true;
  59. }
  60. }
  61. }
  62. }
  63. }
  64. }
  65. return false;
  66. }
  67. bool CanUseCondition(Hashtable hashtable)
  68. {
  69. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  70. }
  71. bool CanActivateCondition(Hashtable hashtable)
  72. {
  73. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  74. {
  75. if (card.Owner.HandCards.Count >= 1)
  76. {
  77. return true;
  78. }
  79. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  80. {
  81. return true;
  82. }
  83. }
  84. if (CardEffectCommons.CanActivateSave(hashtable, CanSelectPermanentCondition))
  85. {
  86. return true;
  87. }
  88. return false;
  89. }
  90. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  91. {
  92. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1 || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  93. {
  94. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1 && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  95. {
  96. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  97. {
  98. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  99. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  100. };
  101. string selectPlayerMessage = "From which area do you play a card?";
  102. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  103. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  104. }
  105. else if (card.Owner.HandCards.Count(CanSelectCardCondition) == 0 && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  106. {
  107. GManager.instance.userSelectionManager.SetBool(false);
  108. }
  109. else if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1 && card.Owner.TrashCards.Count(CanSelectCardCondition) == 0)
  110. {
  111. GManager.instance.userSelectionManager.SetBool(true);
  112. }
  113. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  114. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  115. List<CardSource> selectedCards = new List<CardSource>();
  116. IEnumerator SelectCardCoroutine(CardSource cardSource)
  117. {
  118. selectedCards.Add(cardSource);
  119. yield return null;
  120. }
  121. if (fromHand)
  122. {
  123. int maxCount = 1;
  124. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  125. selectHandEffect.SetUp(
  126. selectPlayer: card.Owner,
  127. canTargetCondition: CanSelectCardCondition,
  128. canTargetCondition_ByPreSelecetedList: null,
  129. canEndSelectCondition: null,
  130. maxCount: maxCount,
  131. canNoSelect: true,
  132. canEndNotMax: false,
  133. isShowOpponent: true,
  134. selectCardCoroutine: SelectCardCoroutine,
  135. afterSelectCardCoroutine: null,
  136. mode: SelectHandEffect.Mode.Custom,
  137. cardEffect: activateClass);
  138. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  139. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  140. yield return StartCoroutine(selectHandEffect.Activate());
  141. }
  142. else
  143. {
  144. int maxCount = 1;
  145. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  146. selectCardEffect.SetUp(
  147. canTargetCondition: CanSelectCardCondition,
  148. canTargetCondition_ByPreSelecetedList: null,
  149. canEndSelectCondition: null,
  150. canNoSelect: () => true,
  151. selectCardCoroutine: SelectCardCoroutine,
  152. afterSelectCardCoroutine: null,
  153. message: "Select 1 card to play.",
  154. maxCount: maxCount,
  155. canEndNotMax: false,
  156. isShowOpponent: true,
  157. mode: SelectCardEffect.Mode.Custom,
  158. root: SelectCardEffect.Root.Trash,
  159. customRootCardList: null,
  160. canLookReverseCard: true,
  161. selectPlayer: card.Owner,
  162. cardEffect: activateClass);
  163. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  164. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  165. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  166. }
  167. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  168. if (!fromHand)
  169. {
  170. root = SelectCardEffect.Root.Trash;
  171. }
  172. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  173. cardSources: selectedCards,
  174. activateClass: activateClass,
  175. payCost: false,
  176. isTapped: false,
  177. root: root,
  178. activateETB: true));
  179. }
  180. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SaveProcess(_hashtable, activateClass, card, CanSelectPermanentCondition));
  181. }
  182. }
  183. if (timing == EffectTiming.None)
  184. {
  185. bool Condition()
  186. {
  187. if (CardEffectCommons.IsExistOnBattleArea(card))
  188. {
  189. if (CardEffectCommons.IsOwnerTurn(card))
  190. {
  191. if (card.PermanentOfThisCard().Level >= 5)
  192. {
  193. if (card.PermanentOfThisCard().TopCard.HasLevel)
  194. {
  195. if (card.PermanentOfThisCard().TopCard.CardTraits.Contains("Bagra Army"))
  196. {
  197. return true;
  198. }
  199. if (card.PermanentOfThisCard().TopCard.CardTraits.Contains("BagraArmy"))
  200. {
  201. return true;
  202. }
  203. if (card.PermanentOfThisCard().TopCard.CardTraits.Contains("Twilight"))
  204. {
  205. return true;
  206. }
  207. }
  208. }
  209. }
  210. }
  211. return false;
  212. }
  213. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: true, card: card, condition: Condition));
  214. }
  215. return cardEffects;
  216. }
  217. }