BT22_040.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Cendrillmon
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_040 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Overclock
  13. if (timing == EffectTiming.OnEndTurn)
  14. {
  15. cardEffects.Add(CardEffectFactory.OverclockSelfEffect(trait: "Puppet", isInheritedEffect: false, card: card, condition: null));
  16. }
  17. #endregion
  18. #region On Play
  19. if (timing == EffectTiming.OnEnterFieldAnyone)
  20. {
  21. ActivateClass activateClass = new ActivateClass();
  22. activateClass.SetUpICardEffect("Play 1 [Familiar] Token", CanUseCondition, card);
  23. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  24. cardEffects.Add(activateClass);
  25. string EffectDiscription()
  26. {
  27. return "[On Play] You may play 1 [Familiar] Token. (Digimon/Yellow/3000 DP/[On Deletion] 1 of your opponent's Digimon gets -3000 DP for the turn.)";
  28. }
  29. bool CanUseCondition(Hashtable hashtable)
  30. {
  31. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  32. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  33. }
  34. bool CanActivateCondition(Hashtable hashtable)
  35. {
  36. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  37. && card.Owner.fieldCardFrames.Count(frame => frame.IsEmptyFrame()) >= 1;
  38. }
  39. IEnumerator ActivateCoroutine(Hashtable hashtable)
  40. {
  41. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayFamiliarToken(activateClass));
  42. }
  43. }
  44. #endregion
  45. #region When Digivolving
  46. if (timing == EffectTiming.OnEnterFieldAnyone)
  47. {
  48. ActivateClass activateClass = new ActivateClass();
  49. activateClass.SetUpICardEffect("Play 1 [Familiar] Token", CanUseCondition, card);
  50. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  51. cardEffects.Add(activateClass);
  52. string EffectDiscription()
  53. {
  54. return "[When Digivolving] You may play 1 [Familiar] Token. (Digimon/Yellow/3000 DP/[On Deletion] 1 of your opponent's Digimon gets -3000 DP for the turn.)";
  55. }
  56. bool CanUseCondition(Hashtable hashtable)
  57. {
  58. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  59. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  60. }
  61. bool CanActivateCondition(Hashtable hashtable)
  62. {
  63. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  64. && card.Owner.fieldCardFrames.Count(frame => frame.IsEmptyFrame()) >= 1;
  65. }
  66. IEnumerator ActivateCoroutine(Hashtable hashtable)
  67. {
  68. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayFamiliarToken(activateClass));
  69. }
  70. }
  71. #endregion
  72. #region All Turns - OPT
  73. if (timing == EffectTiming.OnDestroyedAnyone)
  74. {
  75. ActivateClass activateClass = new ActivateClass();
  76. activateClass.SetUpICardEffect("Activate a [When Digivolving] effect", CanUseCondition, card);
  77. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  78. activateClass.SetHashString("BT22_040_UseWD");
  79. cardEffects.Add(activateClass);
  80. string EffectDiscription()
  81. {
  82. return "[All Turns] [Once Per Turn] When any of your other Digimon are deleted, you may activate 1 of this Digimon's [When Digivolving] effects.";
  83. }
  84. bool CanUseCondition(Hashtable hashtable)
  85. {
  86. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  87. && CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, IsOwnerDigimon, activateClass);
  88. }
  89. bool CanActivateCondition(Hashtable hashtable)
  90. {
  91. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  92. }
  93. bool IsOwnerDigimon(Permanent permanent)
  94. {
  95. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  96. permanent != card.PermanentOfThisCard();
  97. }
  98. IEnumerator ActivateCoroutine(Hashtable hashtable)
  99. {
  100. List<ICardEffect> candidateEffects = card.PermanentOfThisCard().EffectList(EffectTiming.OnEnterFieldAnyone)
  101. .Clone()
  102. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsWhenDigivolving);
  103. if (candidateEffects.Count >= 1)
  104. {
  105. ICardEffect selectedEffect = null;
  106. if (candidateEffects.Count == 1)
  107. {
  108. selectedEffect = candidateEffects[0];
  109. }
  110. else
  111. {
  112. List<SkillInfo> skillInfos = candidateEffects
  113. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  114. List<CardSource> cardSources = candidateEffects
  115. .Map(cardEffect => cardEffect.EffectSourceCard);
  116. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  117. selectCardEffect.SetUp(
  118. canTargetCondition: (cardSource) => true,
  119. canTargetCondition_ByPreSelecetedList: null,
  120. canEndSelectCondition: null,
  121. canNoSelect: () => false,
  122. selectCardCoroutine: null,
  123. afterSelectCardCoroutine: null,
  124. message: "Select 1 effect to activate.",
  125. maxCount: 1,
  126. canEndNotMax: false,
  127. isShowOpponent: false,
  128. mode: SelectCardEffect.Mode.Custom,
  129. root: SelectCardEffect.Root.Custom,
  130. customRootCardList: cardSources,
  131. canLookReverseCard: true,
  132. selectPlayer: card.Owner,
  133. cardEffect: activateClass);
  134. selectCardEffect.SetNotShowCard();
  135. selectCardEffect.SetUpSkillInfos(skillInfos);
  136. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  137. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  138. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  139. {
  140. if (selectedIndexes.Count == 1)
  141. {
  142. selectedEffect = candidateEffects[selectedIndexes[0]];
  143. yield return null;
  144. }
  145. }
  146. }
  147. if (selectedEffect != null)
  148. {
  149. Hashtable effectHashtable = CardEffectCommons.WhenDigivolvingCheckHashtableOfCard(selectedEffect.EffectSourceCard);
  150. if (!selectedEffect.IsDisabled)
  151. {
  152. yield return ContinuousController.instance.StartCoroutine(
  153. ((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(effectHashtable));
  154. }
  155. }
  156. }
  157. }
  158. }
  159. #endregion
  160. return cardEffects;
  161. }
  162. }
  163. }