EX4_069.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX4
  6. {
  7. public class EX4_069 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.OptionSkill)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  16. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[Main] Choose 1 of each player's Digimon with the highest play cost. Delete all other Digimon.";
  21. }
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  25. }
  26. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  27. {
  28. List<Permanent> selectedPermanents = new List<Permanent>();
  29. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  30. {
  31. bool CanSelectPermanentCondition(Permanent permanent)
  32. {
  33. return CardEffectCommons.IsMaxCost(permanent, player, true);
  34. }
  35. if (player.GetBattleAreaDigimons().Count(CanSelectPermanentCondition) >= 1)
  36. {
  37. int maxCount = Math.Min(1, player.GetBattleAreaDigimons().Count(CanSelectPermanentCondition));
  38. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  39. selectPermanentEffect.SetUp(
  40. selectPlayer: card.Owner,
  41. canTargetCondition: CanSelectPermanentCondition,
  42. canTargetCondition_ByPreSelecetedList: null,
  43. canEndSelectCondition: null,
  44. maxCount: maxCount,
  45. canNoSelect: false,
  46. canEndNotMax: false,
  47. selectPermanentCoroutine: SelectPermanentCoroutine,
  48. afterSelectPermanentCoroutine: null,
  49. mode: SelectPermanentEffect.Mode.Custom,
  50. cardEffect: activateClass);
  51. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon.", "The opponent is selecting 1 Digimon.");
  52. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  53. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  54. {
  55. selectedPermanents.Add(permanent);
  56. yield return null;
  57. }
  58. }
  59. }
  60. List<Permanent> destroyTargetPermanents = GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  61. .Map(player => player.GetBattleAreaDigimons())
  62. .Flat()
  63. .Filter(permanent => !selectedPermanents.Contains(permanent)
  64. && !permanent.TopCard.CanNotBeAffected(activateClass)
  65. && !permanent.IsTamer
  66. && permanent.CanBeDestroyedBySkill(activateClass));
  67. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  68. }
  69. }
  70. if (timing == EffectTiming.SecuritySkill)
  71. {
  72. CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects, effectName: $"Select Digimon and delete the others");
  73. }
  74. return cardEffects;
  75. }
  76. }
  77. }