BT23_040.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Wormmon
  5. namespace DCGO.CardEffects.BT23
  6. {
  7. public class BT23_040 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasCSTraits
  18. && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.IsLevel2;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 0,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null)
  26. );
  27. }
  28. #endregion
  29. #region Start Of Your Main Phase
  30. if (timing == EffectTiming.OnStartMainPhase)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect("By placing 1 [Erika Mishima] as bottom digivolution card, this digimon may digivolve into a [Hudie] digimon in hand/trash for 2 reduced cost", CanUseCondition, card);
  34. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  35. cardEffects.Add(activateClass);
  36. string EffectDiscription()
  37. {
  38. return "[Start of Your Main Phase] By placing 1 of your [Erika Mishima] as this Digimon's bottom digivolution card, this Digimon may digivolve into [Hudiemon] in the hand or trash with the digivolution cost reduced by 2.";
  39. }
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  43. }
  44. bool CanActivateCondition(Hashtable hashtable)
  45. {
  46. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  47. && CardEffectCommons.IsOwnerTurn(card)
  48. && CardEffectCommons.HasMatchConditionPermanent(IsErikaMishima);
  49. }
  50. bool IsErikaMishima(Permanent permanent)
  51. {
  52. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  53. && permanent.IsTamer
  54. && permanent.TopCard.EqualsCardName("Erika Mishima");
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable hashtable)
  57. {
  58. Permanent thisPermament = card.PermanentOfThisCard();
  59. if (CardEffectCommons.HasMatchConditionPermanent(IsErikaMishima))
  60. {
  61. Permanent selectedErikaMishima = null;
  62. #region Select Erika Mishima
  63. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  64. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsErikaMishima));
  65. selectPermanentEffect.SetUp(
  66. selectPlayer: card.Owner,
  67. canTargetCondition: IsErikaMishima,
  68. canTargetCondition_ByPreSelecetedList: null,
  69. canEndSelectCondition: null,
  70. maxCount: maxCount,
  71. canNoSelect: false,
  72. canEndNotMax: false,
  73. selectPermanentCoroutine: SelectPermanentCoroutine,
  74. afterSelectPermanentCoroutine: null,
  75. mode: SelectPermanentEffect.Mode.Custom,
  76. cardEffect: activateClass);
  77. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  78. {
  79. selectedErikaMishima = permanent;
  80. yield return null;
  81. }
  82. selectPermanentEffect.SetUpCustomMessage("Select 1 [Erika Mishima] to place as bottom digivolution source", "The opponent is selecting 1 [Erika Mishima] to place as bottom digivolution source.");
  83. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  84. #endregion
  85. if (selectedErikaMishima != null)
  86. {
  87. #region Place Erika Mishima
  88. var placeSources = new IPlacePermanentToDigivolutionCards(
  89. permanentArrays: new List<Permanent[]>() { new Permanent[] { selectedErikaMishima, thisPermament } },
  90. toTop: false,
  91. cardEffect: activateClass);
  92. yield return ContinuousController.instance.StartCoroutine(placeSources.PlacePermanentToDigivolutionCards());
  93. #endregion
  94. bool SelectSourceCard(CardSource cardSource)
  95. {
  96. return cardSource.IsDigimon
  97. && cardSource.EqualsCardName("Hudiemon")
  98. && cardSource.CanPlayCardTargetFrame(thisPermament.PermanentFrame, true, activateClass);
  99. }
  100. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, SelectSourceCard);
  101. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, SelectSourceCard);
  102. if (canSelectHand || canSelectTrash)
  103. {
  104. #region Setup Location Selection
  105. if (canSelectHand && canSelectTrash)
  106. {
  107. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  108. {
  109. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  110. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  111. };
  112. string selectPlayerMessage = "From which area do you select a card?";
  113. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  114. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  115. }
  116. else
  117. {
  118. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  119. }
  120. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  121. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  122. #endregion
  123. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  124. targetPermanent: thisPermament,
  125. cardCondition: SelectSourceCard,
  126. payCost: true,
  127. reduceCostTuple: (reduceCost: 2, reduceCostCardCondition: null),
  128. fixedCostTuple: null,
  129. ignoreDigivolutionRequirementFixedCost: -1,
  130. isHand: fromHand,
  131. activateClass: activateClass,
  132. successProcess: null));
  133. }
  134. }
  135. }
  136. }
  137. }
  138. #endregion
  139. #region All Turns
  140. if (timing == EffectTiming.None)
  141. {
  142. string EffectDiscription()
  143. {
  144. return "[All Turns] All of your Digimon with the [Hudie] trait get +1000 DP.";
  145. }
  146. bool Condition()
  147. {
  148. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  149. }
  150. bool PermanentCondition(Permanent permanent)
  151. {
  152. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  153. && permanent.TopCard.HasHudieTraits;
  154. }
  155. cardEffects.Add(CardEffectFactory.ChangeDPStaticEffect(
  156. permanentCondition: PermanentCondition,
  157. changeValue: 1000,
  158. isInheritedEffect: true,
  159. card: card,
  160. condition: Condition,
  161. effectName: EffectDiscription));
  162. }
  163. #endregion
  164. return cardEffects;
  165. }
  166. }
  167. }