P_129.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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_129 : 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.OnStartMainPhase)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Start of Your Main Phase] If you have more security cards than your opponent, gain 1 memory.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. if (CardEffectCommons.IsExistOnBattleArea(card))
  26. {
  27. if (CardEffectCommons.IsOwnerTurn(card))
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. bool CanActivateCondition(Hashtable hashtable)
  35. {
  36. if (CardEffectCommons.IsExistOnBattleArea(card))
  37. {
  38. if (card.Owner.SecurityCards.Count > card.Owner.Enemy.SecurityCards.Count)
  39. {
  40. if (card.Owner.CanAddMemory(activateClass))
  41. {
  42. return true;
  43. }
  44. }
  45. }
  46. return false;
  47. }
  48. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  49. {
  50. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  51. }
  52. }
  53. if (timing == EffectTiming.OnEnterFieldAnyone)
  54. {
  55. ActivateClass activateClass = new ActivateClass();
  56. activateClass.SetUpICardEffect("Play 1 [Patamon] or your 1 Digimon digivolves into [Angemon]", CanUseCondition, card);
  57. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  58. cardEffects.Add(activateClass);
  59. string EffectDiscription()
  60. {
  61. return "[On Play] Activate 1 of the effects below: - You may play 1 [Patamon] from your hand without paying the cost. - 1 of your Digimon may digivolve into [Angemon] in the hand without paying the cost.";
  62. }
  63. bool CanSelectCardCondition(CardSource cardSource)
  64. {
  65. if (cardSource.CardNames.Contains("Patamon"))
  66. {
  67. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  68. {
  69. return true;
  70. }
  71. }
  72. return false;
  73. }
  74. bool CanSelectPermanentCondition(Permanent permanent)
  75. {
  76. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  77. {
  78. foreach (CardSource cardSource in card.Owner.HandCards)
  79. {
  80. if (CanSelectCardCondition1(cardSource))
  81. {
  82. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  83. {
  84. return true;
  85. }
  86. }
  87. }
  88. }
  89. return false;
  90. }
  91. bool CanSelectCardCondition1(CardSource cardSource)
  92. {
  93. return cardSource.CardNames.Contains("Angemon");
  94. }
  95. bool CanUseCondition(Hashtable hashtable)
  96. {
  97. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  98. }
  99. bool CanActivateCondition(Hashtable hashtable)
  100. {
  101. if (CardEffectCommons.IsExistOnBattleArea(card))
  102. {
  103. if (card.Owner.HandCards.Count >= 1)
  104. {
  105. return true;
  106. }
  107. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition))
  108. {
  109. return true;
  110. }
  111. }
  112. return false;
  113. }
  114. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  115. {
  116. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  117. {
  118. new SelectionElement<bool>(message: $"Play [Patamon]", value : true, spriteIndex: 0),
  119. new SelectionElement<bool>(message: $"Digivolve into [Angemon]", value : false, spriteIndex: 1),
  120. };
  121. string selectPlayerMessage = "Which effect do you choose?";
  122. string notSelectPlayerMessage = "The opponent is choosing the effect.";
  123. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  124. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  125. bool isPlayPatamon = GManager.instance.userSelectionManager.SelectedBoolValue;
  126. if (isPlayPatamon)
  127. {
  128. List<CardSource> selectedCards = new List<CardSource>();
  129. int maxCount = 1;
  130. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  131. selectHandEffect.SetUp(
  132. selectPlayer: card.Owner,
  133. canTargetCondition: CanSelectCardCondition,
  134. canTargetCondition_ByPreSelecetedList: null,
  135. canEndSelectCondition: null,
  136. maxCount: maxCount,
  137. canNoSelect: true,
  138. canEndNotMax: false,
  139. isShowOpponent: true,
  140. selectCardCoroutine: SelectCardCoroutine,
  141. afterSelectCardCoroutine: null,
  142. mode: SelectHandEffect.Mode.Custom,
  143. cardEffect: activateClass);
  144. selectHandEffect.SetUpCustomMessage("Select 1 [Patamon] to play.", "The opponent is selecting 1 [Patamon] to play.");
  145. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  146. yield return StartCoroutine(selectHandEffect.Activate());
  147. IEnumerator SelectCardCoroutine(CardSource cardSource)
  148. {
  149. selectedCards.Add(cardSource);
  150. yield return null;
  151. }
  152. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  153. }
  154. else
  155. {
  156. Permanent selectedPermanent = null;
  157. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  158. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  159. selectPermanentEffect.SetUp(
  160. selectPlayer: card.Owner,
  161. canTargetCondition: CanSelectPermanentCondition,
  162. canTargetCondition_ByPreSelecetedList: null,
  163. canEndSelectCondition: null,
  164. maxCount: maxCount,
  165. canNoSelect: true,
  166. canEndNotMax: false,
  167. selectPermanentCoroutine: SelectPermanentCoroutine,
  168. afterSelectPermanentCoroutine: null,
  169. mode: SelectPermanentEffect.Mode.Custom,
  170. cardEffect: activateClass);
  171. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve into [Angemon].", "The opponent is selecting 1 Digimon to digivolve into [Angemon].");
  172. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  173. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  174. {
  175. selectedPermanent = permanent;
  176. yield return null;
  177. }
  178. if (selectedPermanent != null)
  179. {
  180. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  181. targetPermanent: selectedPermanent,
  182. cardCondition: CanSelectCardCondition1,
  183. payCost: false,
  184. reduceCostTuple: null,
  185. fixedCostTuple: null,
  186. ignoreDigivolutionRequirementFixedCost: -1,
  187. isHand: true,
  188. activateClass: activateClass,
  189. successProcess: null));
  190. }
  191. }
  192. }
  193. }
  194. if (timing == EffectTiming.SecuritySkill)
  195. {
  196. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  197. }
  198. return cardEffects;
  199. }
  200. }