P_225.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // DigiLab
  5. namespace DCGO.CardEffects.P
  6. {
  7. public class P_225 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Ignore Color Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  16. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  17. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  18. cardEffects.Add(ignoreColorConditionClass);
  19. bool HasCSTrait(Permanent permanent)
  20. {
  21. if (CardEffectCommons.IsOwnerPermanent(permanent, card))
  22. {
  23. if (permanent.TopCard.HasCSTraits)
  24. {
  25. if (permanent.IsDigimon || permanent.IsTamer)
  26. {
  27. return true;
  28. }
  29. }
  30. }
  31. return false;
  32. }
  33. bool CanUseCondition(Hashtable hashtable)
  34. {
  35. return CardEffectCommons.HasMatchConditionPermanent(HasCSTrait, true);
  36. }
  37. bool CardCondition(CardSource cardSource)
  38. {
  39. return cardSource == card;
  40. }
  41. }
  42. #endregion
  43. #region Main
  44. if (timing == EffectTiming.OptionSkill)
  45. {
  46. ActivateClass activateClass = new ActivateClass();
  47. activateClass.SetUpICardEffect("Draw 1, then place in battle area", CanUseCondition, card);
  48. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  49. cardEffects.Add(activateClass);
  50. string EffectDiscription()
  51. {
  52. return "[Main] <Draw 1>. Then, place this card in the battle area.";
  53. }
  54. bool CanUseCondition(Hashtable hashtable)
  55. {
  56. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  57. }
  58. IEnumerator ActivateCoroutine(Hashtable hashtable)
  59. {
  60. yield return ContinuousController.instance.StartCoroutine(new DrawClass(
  61. player: card.Owner,
  62. drawCount: 1,
  63. cardEffect: activateClass).Draw()
  64. );
  65. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(
  66. card: card,
  67. cardEffect: activateClass)
  68. );
  69. }
  70. }
  71. #endregion
  72. #region Main [Delay]
  73. if (timing == EffectTiming.OnDeclaration)
  74. {
  75. ActivateClass activateClass = new ActivateClass();
  76. activateClass.SetUpICardEffect("By placing the top stacked card of any of your level 4 or higher [CS] Trait Digimon as its bottom digivolution card, gain 2 memory.", CanUseCondition, card);
  77. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  78. cardEffects.Add(activateClass);
  79. string EffectDiscription()
  80. {
  81. return "[Main] <Delay>, By placing the top stacked card of any of your level 4 or higher [CS] Trait Digimon as its bottom digivolution card, gain 2 memory.";
  82. }
  83. bool CanUseCondition(Hashtable hashtable)
  84. {
  85. return CardEffectCommons.IsExistOnBattleArea(card)
  86. && CardEffectCommons.CanDeclareOptionDelayEffect(card);
  87. }
  88. bool CanActivateCondition(Hashtable hashtable)
  89. {
  90. return CardEffectCommons.IsExistOnBattleArea(card);
  91. }
  92. bool CanSelectCard(Permanent permanent)
  93. {
  94. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  95. && permanent.TopCard.HasCSTraits
  96. && permanent.TopCard.HasLevel
  97. && permanent.TopCard.Level >= 4
  98. && permanent.DigivolutionCards.Count >= 1;
  99. }
  100. IEnumerator ActivateCoroutine(Hashtable hashtable)
  101. {
  102. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  103. targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() },
  104. activateClass: activateClass,
  105. successProcess: SuccessProcess,
  106. failureProcess: null));
  107. IEnumerator SuccessProcess(List<Permanent> permanents)
  108. {
  109. Permanent selectedPermanent = null;
  110. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectCard))
  111. {
  112. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  113. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectCard));
  114. selectPermanentEffect.SetUp(
  115. selectPlayer: card.Owner,
  116. canTargetCondition: CanSelectCard,
  117. canTargetCondition_ByPreSelecetedList: null,
  118. canEndSelectCondition: null,
  119. maxCount: maxCount,
  120. canNoSelect: true,
  121. canEndNotMax: false,
  122. selectPermanentCoroutine: SelectPermanentCoroutine,
  123. afterSelectPermanentCoroutine: null,
  124. mode: SelectPermanentEffect.Mode.Custom,
  125. cardEffect: activateClass);
  126. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon.", "The opponent is selecting a Digimon.");
  127. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  128. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  129. {
  130. selectedPermanent = permanent;
  131. yield return null;
  132. }
  133. if(selectedPermanent != null)
  134. {
  135. if (CardEffectCommons.IsExistOnBattleArea(selectedPermanent.TopCard) && selectedPermanent.DigivolutionCards.Count >= 1)
  136. {
  137. CardSource topCard = selectedPermanent.TopCard;
  138. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { topCard }, activateClass));
  139. if (selectedPermanent.DigivolutionCards.Contains(topCard))
  140. {
  141. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(2, activateClass));
  142. }
  143. }
  144. }
  145. }
  146. }
  147. }
  148. }
  149. #endregion
  150. #region Security
  151. if (timing == EffectTiming.SecuritySkill)
  152. {
  153. cardEffects.Add(CardEffectFactory.PlaceSelfDelayOptionSecurityEffect(card));
  154. }
  155. #endregion
  156. return cardEffects;
  157. }
  158. }
  159. }