BT20_032.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT20
  4. {
  5. public class BT20_032 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Alt Digivovle Cost
  11. if (timing == EffectTiming.None)
  12. {
  13. bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return targetPermanent.TopCard.EqualsCardName("Pulsemon") ||
  16. (targetPermanent.TopCard.IsLevel3 && targetPermanent.TopCard.HasSeekersTraits);
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  19. permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false,
  20. card: card, condition: null));
  21. }
  22. #endregion
  23. #region On Play
  24. if (timing == EffectTiming.OnEnterFieldAnyone)
  25. {
  26. ActivateClass activateClass = new ActivateClass();
  27. activateClass.SetUpICardEffect("Add top security to hand, Recovery +1", CanUseCondition, card);
  28. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  29. cardEffects.Add(activateClass);
  30. string EffectDiscription()
  31. {
  32. return "[On Play] If you have 3 or more security cards, you may add your top security card to the hand. Then, if you have 2 or fewer security cards, <Recovery +1(Deck)>.";
  33. }
  34. bool CanUseCondition(Hashtable hashtable)
  35. {
  36. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  37. }
  38. bool CanActivateCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable hashtable)
  43. {
  44. if(card.Owner.SecurityCards.Count >= 3)
  45. {
  46. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  47. {
  48. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  49. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  50. };
  51. string selectPlayerMessage = "Will you add your top security card to hand?";
  52. string notSelectPlayerMessage = "The opponent is choosing whether or not to add their top security card to hand.";
  53. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  54. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  55. bool willAdd = GManager.instance.userSelectionManager.SelectedBoolValue;
  56. if (willAdd)
  57. {
  58. CardSource topCard = card.Owner.SecurityCards[0];
  59. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(new List<CardSource>() { topCard }, false, activateClass));
  60. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  61. player: card.Owner,
  62. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  63. activateClass).ReduceSecurity());
  64. }
  65. }
  66. if(card.Owner.SecurityCards.Count <= 2)
  67. {
  68. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  69. }
  70. }
  71. }
  72. #endregion
  73. #region When Digivolving
  74. if (timing == EffectTiming.OnEnterFieldAnyone)
  75. {
  76. ActivateClass activateClass = new ActivateClass();
  77. activateClass.SetUpICardEffect("Add top security to hand, Recovery +1", CanUseCondition, card);
  78. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  79. cardEffects.Add(activateClass);
  80. string EffectDiscription()
  81. {
  82. return "[When Digivolving] If you have 3 or more security cards, you may add your top security card to the hand. Then, if you have 2 or fewer security cards, <Recovery +1(Deck)>.";
  83. }
  84. bool CanUseCondition(Hashtable hashtable)
  85. {
  86. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  87. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  88. }
  89. bool CanActivateCondition(Hashtable hashtable)
  90. {
  91. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  92. }
  93. IEnumerator ActivateCoroutine(Hashtable hashtable)
  94. {
  95. if (card.Owner.SecurityCards.Count >= 3)
  96. {
  97. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  98. {
  99. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  100. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  101. };
  102. string selectPlayerMessage = "Will you add your top security card to hand?";
  103. string notSelectPlayerMessage = "The opponent is choosing whether or not to add their top security card to hand.";
  104. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  105. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  106. bool willAdd = GManager.instance.userSelectionManager.SelectedBoolValue;
  107. if (willAdd)
  108. {
  109. CardSource topCard = card.Owner.SecurityCards[0];
  110. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(new List<CardSource>() { topCard }, false, activateClass));
  111. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  112. player: card.Owner,
  113. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  114. activateClass).ReduceSecurity());
  115. }
  116. }
  117. if (card.Owner.SecurityCards.Count <= 2)
  118. {
  119. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  120. }
  121. }
  122. }
  123. #endregion
  124. #region ESS
  125. if (timing == EffectTiming.OnEndBattle)
  126. {
  127. ActivateClass activateClass = new ActivateClass();
  128. activateClass.SetUpICardEffect("Gain 1 memory", CanUseCondition, card);
  129. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  130. activateClass.SetHashString("Gain1_BT20-032");
  131. activateClass.SetIsInheritedEffect(true);
  132. cardEffects.Add(activateClass);
  133. string EffectDiscription()
  134. {
  135. return "[All Turns] [Once Per Turn] When this Digimon deletes your opponent's Digimon in battle, gain 1 memory.";
  136. }
  137. bool WinnerCondition(Permanent permanent) => permanent.cardSources.Contains(card);
  138. bool LoserCondition(Permanent permanent) => CardEffectCommons.IsOpponentPermanent(permanent, card);
  139. bool CanUseCondition(Hashtable hashtable)
  140. {
  141. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  142. CardEffectCommons.CanTriggerWhenDeleteOpponentDigimonByBattle(hashtable: hashtable,
  143. winnerCondition: WinnerCondition, loserCondition: LoserCondition, isOnlyWinnerSurvive: false);
  144. }
  145. bool CanActivateCondition(Hashtable hashtable)
  146. {
  147. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  148. {
  149. return true;
  150. }
  151. return false;
  152. }
  153. IEnumerator ActivateCoroutine(Hashtable hashtable)
  154. {
  155. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  156. }
  157. }
  158. #endregion
  159. return cardEffects;
  160. }
  161. }
  162. }