P_179.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Justimon: Critical Arm
  5. namespace DCGO.CardEffects.P
  6. {
  7. public class P_179 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. if (targetPermanent.TopCard.EqualsCardName("Justimon: Blitz Arm") || targetPermanent.TopCard.EqualsCardName("Justimon: Accel Arm"))
  18. {
  19. return true;
  20. }
  21. return false;
  22. }
  23. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false, card: card, condition: null));
  24. }
  25. #endregion
  26. #region Reduce Digivolution Cost
  27. if (timing == EffectTiming.None)
  28. {
  29. bool PermanentCondition(Permanent targetPermanent)
  30. => (targetPermanent.TopCard.EqualsCardName("Justimon: Blitz Arm") || targetPermanent.TopCard.EqualsCardName("Justimon: Accel Arm"));
  31. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 1, false, card, null));
  32. }
  33. #endregion
  34. #region When Digivolving
  35. if (timing == EffectTiming.OnEnterFieldAnyone)
  36. {
  37. ActivateClass activateClass = new ActivateClass();
  38. activateClass.SetUpICardEffect("Place [Device] option from hand or trash", CanUseCondition, card);
  39. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  40. cardEffects.Add(activateClass);
  41. string EffectDiscription()
  42. => "[When Digivolving] By placing 1 Option card with the [Device] trait from your hand or trash into the battle area, this Digimon gets +3000 DP until your opponent's turn ends.";
  43. bool CanSelectOption(CardSource cardSource)
  44. => cardSource.IsOption && cardSource.HasDeviceTraits;
  45. bool CanUseCondition(Hashtable hashtable)
  46. {
  47. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  48. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  49. }
  50. bool CanActivateCondition(Hashtable hashtable)
  51. {
  52. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  53. (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectOption) || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectOption));
  54. }
  55. IEnumerator ActivateCoroutine(Hashtable hashtable)
  56. {
  57. CardSource selectedDevice = null;
  58. bool optionInHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectOption);
  59. bool optionInTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectOption);
  60. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  61. if (optionInHand && optionInTrash)
  62. {
  63. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  64. {
  65. new(message: "From hand", value: true, spriteIndex: 0),
  66. new(message: "From trash", value: false, spriteIndex: 1)
  67. };
  68. string selectPlayerMessage = "Choose option location";
  69. string notSelectPlayerMessage = "The opponent is choosing the option location.";
  70. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner,
  71. selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  72. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  73. root = GManager.instance.userSelectionManager.SelectedBoolValue ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash;
  74. }
  75. else
  76. {
  77. root = optionInHand ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash;
  78. }
  79. if(root == SelectCardEffect.Root.Hand)
  80. {
  81. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  82. selectHandEffect.SetUp(
  83. selectPlayer: card.Owner,
  84. canTargetCondition: CanSelectOption,
  85. canTargetCondition_ByPreSelecetedList: null,
  86. canEndSelectCondition: null,
  87. maxCount: 1,
  88. canNoSelect: false,
  89. canEndNotMax: false,
  90. isShowOpponent: true,
  91. selectCardCoroutine: SelectCardCoroutine,
  92. afterSelectCardCoroutine: null,
  93. mode: SelectHandEffect.Mode.Custom,
  94. cardEffect: activateClass);
  95. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  96. }
  97. else
  98. {
  99. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  100. selectCardEffect.SetUp(
  101. canTargetCondition: CanSelectOption,
  102. canTargetCondition_ByPreSelecetedList: null,
  103. canEndSelectCondition: null,
  104. canNoSelect: () => false,
  105. selectCardCoroutine: SelectCardCoroutine,
  106. afterSelectCardCoroutine: null,
  107. message: "Select Device to play",
  108. maxCount: 1,
  109. canEndNotMax: false,
  110. isShowOpponent: true,
  111. mode: SelectCardEffect.Mode.Custom,
  112. root: SelectCardEffect.Root.Trash,
  113. customRootCardList: null,
  114. canLookReverseCard: true,
  115. selectPlayer: card.Owner,
  116. cardEffect: activateClass);
  117. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  118. }
  119. IEnumerator SelectCardCoroutine(CardSource cardSource)
  120. {
  121. selectedDevice = cardSource;
  122. yield return null;
  123. }
  124. if (selectedDevice != null)
  125. {
  126. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: selectedDevice, cardEffect: activateClass));
  127. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  128. targetPermanent: card.PermanentOfThisCard(),
  129. changeValue: 3000,
  130. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  131. activateClass: activateClass));
  132. }
  133. }
  134. }
  135. #endregion
  136. #region When Digivolving/Attacking OPT Shared
  137. bool CanSelectPermanentOptionCondition(Permanent permanent)
  138. => CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  139. && permanent.IsOption;
  140. bool CanSelectPermanentDigimonCondition(Permanent permanent)
  141. => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  142. && permanent.TopCard.HasPlayCost
  143. && permanent.TopCard.GetCostItself <= 9;
  144. IEnumerator SharedActivateCoroutine(Hashtable _hashtable, ActivateClass activateClass)
  145. {
  146. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentOptionCondition))
  147. {
  148. bool deviceTrashed = false;
  149. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentOptionCondition));
  150. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  151. selectPermanentEffect.SetUp(
  152. selectPlayer: card.Owner,
  153. canTargetCondition: CanSelectPermanentOptionCondition,
  154. canTargetCondition_ByPreSelecetedList: null,
  155. canEndSelectCondition: null,
  156. maxCount: maxCount,
  157. canNoSelect: false,
  158. canEndNotMax: false,
  159. selectPermanentCoroutine: SelectPermanentCoroutine,
  160. afterSelectPermanentCoroutine: null,
  161. mode: SelectPermanentEffect.Mode.Destroy,
  162. cardEffect: activateClass);
  163. selectPermanentEffect.SetUpCustomMessage("Select 1 option to trash", "The opponent is selecting 1 option to trash");
  164. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  165. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  166. {
  167. deviceTrashed = true;
  168. yield return null;
  169. }
  170. if (deviceTrashed && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentDigimonCondition))
  171. {
  172. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentDigimonCondition));
  173. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  174. selectPermanentEffect1.SetUp(
  175. selectPlayer: card.Owner,
  176. canTargetCondition: CanSelectPermanentDigimonCondition,
  177. canTargetCondition_ByPreSelecetedList: null,
  178. canEndSelectCondition: null,
  179. maxCount: maxCount1,
  180. canNoSelect: false,
  181. canEndNotMax: false,
  182. selectPermanentCoroutine: SelectPermanentCoroutine,
  183. afterSelectPermanentCoroutine: null,
  184. mode: SelectPermanentEffect.Mode.Destroy,
  185. cardEffect: activateClass);
  186. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to delete", "The opponent is selecting 1 digimon to delete");
  187. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  188. }
  189. }
  190. }
  191. #endregion
  192. #region When Digivolving OPT
  193. if (timing == EffectTiming.OnEnterFieldAnyone)
  194. {
  195. ActivateClass activateClass = new ActivateClass();
  196. activateClass.SetUpICardEffect("Trash 1 [Device] Option on field", CanUseCondition, card);
  197. activateClass.SetUpActivateClass(CanActivateCondition, (hashtable) => SharedActivateCoroutine(hashtable, activateClass), 1, true, SharedEffectDiscription());
  198. activateClass.SetHashString("P_179_Trash&Delete");
  199. cardEffects.Add(activateClass);
  200. string SharedEffectDiscription()
  201. => "[When Digivolving] By trashing 1 [Device] Option on the field, you can select 1 of your opponent's Digimon with a level of 9 or less to delete.";
  202. bool CanUseCondition(Hashtable hashtable)
  203. => CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  204. bool CanActivateCondition(Hashtable hashtable)
  205. => CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  206. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  207. }
  208. #endregion
  209. #region When Attacking OPT
  210. if (timing == EffectTiming.OnAllyAttack)
  211. {
  212. ActivateClass activateClass = new ActivateClass();
  213. activateClass.SetUpICardEffect("Trash 1 [Device] Option on field", CanUseCondition, card);
  214. activateClass.SetUpActivateClass(CanActivateCondition, (hashtable) => SharedActivateCoroutine(hashtable, activateClass), 1, true, SharedEffectDiscription());
  215. activateClass.SetHashString("P_179_Trash&Delete");
  216. cardEffects.Add(activateClass);
  217. string SharedEffectDiscription()
  218. => "[When Attacking] By trashing 1 [Device] Option on the field, you can select 1 of your opponent's Digimon with a level of 9 or less to delete.";
  219. bool CanUseCondition(Hashtable hashtable)
  220. => CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  221. bool CanActivateCondition(Hashtable hashtable)
  222. => CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  223. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  224. }
  225. #endregion
  226. return cardEffects;
  227. }
  228. }
  229. }