EX12_066.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Hiro Amanokawa
  6. namespace DCGO.CardEffects.EX12
  7. {
  8. public class EX12_066 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Start of Your Turn
  14. if (timing == EffectTiming.OnStartTurn)
  15. {
  16. cardEffects.Add(CardEffectFactory.SetMemoryTo3TamerEffect(card));
  17. }
  18. #endregion
  19. #region Your Turn
  20. if (timing == EffectTiming.OnAllyAttack)
  21. {
  22. ActivateClass activateClass = new ActivateClass();
  23. activateClass.SetUpICardEffect("Suspend to digivolve or use an option", CanUseCondition, card);
  24. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  25. activateClass.SetIsSkippable(true);
  26. cardEffects.Add(activateClass);
  27. string EffectDescription()
  28. {
  29. return "[Your Turn] When one of your Digimon with [Gammamon] in its text or the [VB] trait attacks, by suspending this Tamer, activate 1 of the effects below:\r\n- It my digivolve into a level 6 or lower card with [Gammamon] in its text or the [VB] trait in the hand with the cost reduced by 1.\r\n- You may use 1 Option card with [Gammamon] in its text or the [VB] trait from your hand with the cost reduced by 2.";
  30. }
  31. bool CanUseCondition(Hashtable hashtable)
  32. {
  33. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  34. && CardEffectCommons.IsOwnerTurn(card)
  35. && CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition);
  36. }
  37. bool CanActivateCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass)
  40. && CardEffectCommons.CanActivateSuspendCostEffect(card);
  41. }
  42. bool PermanentCondition(Permanent permanent)
  43. {
  44. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  45. && (permanent.TopCard.HasText("Gammamon")
  46. || permanent.TopCard.EqualsTraits("VB"));
  47. }
  48. bool CanSelectDigivolveCondition(CardSource cardSource)
  49. {
  50. return cardSource.HasLevel
  51. && cardSource.Level <= 6
  52. && (cardSource.HasText("Gammamon")
  53. || cardSource.EqualsTraits("VB"));
  54. }
  55. bool CanSelectOptionCondition(CardSource cardSource)
  56. {
  57. return cardSource.IsOption
  58. && (cardSource.HasText("Gammamon")
  59. || cardSource.EqualsTraits("VB"));
  60. }
  61. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  62. {
  63. bool HasDigivolveCondition(CardSource cardSource)
  64. {
  65. List<int> costList = cardSource.CostList(GManager.instance.attackProcess.AttackingPermanent, false, false);
  66. return cardSource.HasLevel
  67. && cardSource.Level <= 6
  68. && (cardSource.HasText("Gammamon")
  69. || cardSource.EqualsTraits("VB"))
  70. && costList.Count > 0 && card.Owner.MaxMemoryCost >= costList.Min() - 1;
  71. }
  72. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  73. if (CardEffectCommons.HasMatchConditionOwnersHand(card, HasDigivolveCondition))
  74. {
  75. selectionElements.Add(new(message: "Attacking Digimon Digivolves", value: 1, spriteIndex: 0));
  76. }
  77. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectOptionCondition))
  78. {
  79. selectionElements.Add(new(message: "Use an Option", value: 2, spriteIndex: 0));
  80. }
  81. selectionElements.Add(new(message: "Suspend only", value: 3, spriteIndex: 1));
  82. selectionElements.Add(new(message: "Do not use", value: 4, spriteIndex: 1));
  83. string selectPlayerMessage = "Which effect will you activate?";
  84. string notSelectPlayerMessage = "The opponent is choosing which effect to activate.";
  85. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  86. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  87. if (GManager.instance.userSelectionManager.SelectedIntValue != 4)
  88. {
  89. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  90. if (GManager.instance.userSelectionManager.SelectedIntValue != 3)
  91. {
  92. if (GManager.instance.userSelectionManager.SelectedIntValue == 1)
  93. {
  94. yield return ContinuousController.instance.StartCoroutine(
  95. CardEffectCommons.DigivolveIntoHandOrTrashCard(
  96. targetPermanent: GManager.instance.attackProcess.AttackingPermanent,
  97. cardCondition: CanSelectDigivolveCondition,
  98. payCost: true,
  99. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  100. fixedCostTuple: null,
  101. ignoreDigivolutionRequirementFixedCost: -1,
  102. isHand: true,
  103. activateClass: activateClass,
  104. successProcess: null));
  105. }
  106. else
  107. {
  108. CardSource selectedCard = null;
  109. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  110. selectHandEffect.SetUp(
  111. selectPlayer: card.Owner,
  112. canTargetCondition: CanSelectOptionCondition,
  113. canTargetCondition_ByPreSelecetedList: null,
  114. canEndSelectCondition: null,
  115. maxCount: 1,
  116. canNoSelect: true,
  117. canEndNotMax: false,
  118. isShowOpponent: true,
  119. selectCardCoroutine: SelectCardCoroutine,
  120. afterSelectCardCoroutine: null,
  121. mode: SelectHandEffect.Mode.Custom,
  122. cardEffect: activateClass);
  123. selectHandEffect.SetUpCustomMessage("Select 1 card to use.", "The opponent is selecting 1 card to use.");
  124. selectHandEffect.SetUpCustomMessage_ShowCard("Used Card");
  125. IEnumerator SelectCardCoroutine(CardSource cardSource)
  126. {
  127. selectedCard = cardSource;
  128. yield return null;
  129. }
  130. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  131. if (selectedCard != null)
  132. {
  133. #region reduce use cost
  134. ChangeCostClass changeCostClass = new ChangeCostClass();
  135. changeCostClass.SetUpICardEffect($"Use Cost -2", CanUseCondition1, card);
  136. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: PlayOrUseCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  137. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  138. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  139. ICardEffect GetCardEffect(EffectTiming _timing)
  140. {
  141. if (_timing == EffectTiming.None)
  142. {
  143. return changeCostClass;
  144. }
  145. return null;
  146. }
  147. bool CanUseCondition1(Hashtable hashtable)
  148. {
  149. return true;
  150. }
  151. bool PlayOrUseCondition(CardSource cardSource)
  152. {
  153. return true;
  154. }
  155. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  156. {
  157. if (PlayOrUseCondition(cardSource)
  158. && RootCondition(root)
  159. && PermanentsCondition(targetPermanents))
  160. {
  161. Cost -= 2;
  162. }
  163. return Cost;
  164. }
  165. bool PermanentsCondition(List<Permanent> targetPermanents)
  166. {
  167. return targetPermanents == null
  168. || targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0;
  169. }
  170. bool RootCondition(SelectCardEffect.Root root)
  171. {
  172. return true;
  173. }
  174. bool isUpDown()
  175. {
  176. return true;
  177. }
  178. #endregion
  179. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayOptionCards(
  180. cardSources: new List<CardSource> { selectedCard },
  181. activateClass: activateClass,
  182. payCost: true,
  183. root: SelectCardEffect.Root.Hand));
  184. #region release effect
  185. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  186. #endregion
  187. }
  188. }
  189. }
  190. }
  191. }
  192. }
  193. #endregion
  194. #region Security
  195. if (timing == EffectTiming.SecuritySkill)
  196. {
  197. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  198. }
  199. #endregion
  200. return cardEffects;
  201. }
  202. }
  203. }