BT4_011.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. public class BT4_011 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. List<Func<EffectTiming, ICardEffect>> getCardEffects = new List<Func<EffectTiming, ICardEffect>>();
  14. if (timing == EffectTiming.None)
  15. {
  16. bool Condition()
  17. {
  18. return card.Owner.HandCards.Contains(card);
  19. }
  20. bool PermanentCondition(Permanent targetPermanent)
  21. {
  22. return targetPermanent.TopCard.CardColors.Contains(CardColor.Red) && targetPermanent.IsTamer;
  23. }
  24. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: Condition));
  25. }
  26. if(timing == EffectTiming.BeforePayCost)
  27. {
  28. ActivateClass activateClass = new ActivateClass();
  29. activateClass.SetUpICardEffect("Trash your Security to reduce digivolution cost", CanUseCondition, card);
  30. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, "");
  31. activateClass.SetIsBackgroundProcess(true);
  32. cardEffects.Add(activateClass);
  33. bool CanUseCondition(Hashtable hashtable)
  34. {
  35. if (CardEffectCommons.IsExistOnHand(card))
  36. {
  37. bool PermanentCondition(Permanent targetPermanent)
  38. {
  39. return targetPermanent.TopCard.CardColors.Contains(CardColor.Red) && targetPermanent.IsTamer;
  40. }
  41. bool CardCondition(CardSource cardSource)
  42. {
  43. return cardSource == card;
  44. }
  45. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, CardCondition))
  46. {
  47. return true;
  48. }
  49. }
  50. return false;
  51. }
  52. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  53. {
  54. Permanent selectedPermanent = CardEffectCommons.GetPermanentsFromHashtable(_hashtable)[0];
  55. bool CanUseChangeCondition(Hashtable ccHashtable)
  56. {
  57. if (selectedPermanent.TopCard != null)
  58. {
  59. if (card.Owner.GetBattleAreaPermanents().Contains(selectedPermanent))
  60. {
  61. if (card == selectedPermanent.TopCard)
  62. {
  63. return true;
  64. }
  65. }
  66. }
  67. return false;
  68. }
  69. ChangePermanentLevelClass changePermanentLevelClass = new ChangePermanentLevelClass();
  70. changePermanentLevelClass.SetUpICardEffect($"Treated as level 3", CanUseChangeCondition, card);
  71. changePermanentLevelClass.SetUpChangePermanentLevelClass(GetLevel: GetLevel);
  72. changePermanentLevelClass.SetNotShowUI(true);
  73. int GetLevel(Permanent permanent, int level)
  74. {
  75. if (selectedPermanent.TopCard != null)
  76. {
  77. if (permanent == selectedPermanent)
  78. {
  79. level = 3;
  80. }
  81. }
  82. return level;
  83. }
  84. TreatAsDigimonClass treatAsDigimonClass = new TreatAsDigimonClass();
  85. treatAsDigimonClass.SetUpICardEffect($"Treated as Digimon", CanUseChangeCondition, card);
  86. treatAsDigimonClass.SetUpTreatAsDigimonClass(
  87. permanentCondition: PermanentCondition);
  88. treatAsDigimonClass.SetNotShowUI(true);
  89. bool PermanentCondition(Permanent permanent)
  90. {
  91. if (selectedPermanent.TopCard != null)
  92. {
  93. if (permanent == selectedPermanent)
  94. {
  95. return true;
  96. }
  97. }
  98. return false;
  99. }
  100. DontHaveDPClass dontHaveDPClass = new DontHaveDPClass();
  101. dontHaveDPClass.SetUpICardEffect("Don't have DP", CanUseChangeCondition, card);
  102. dontHaveDPClass.SetUpDontHaveDPClass(PermanentCondition: PermanentCondition);
  103. dontHaveDPClass.SetNotShowUI(true);
  104. getCardEffects =
  105. new List<Func<EffectTiming, ICardEffect>>()
  106. {
  107. _ => changePermanentLevelClass,
  108. _ => treatAsDigimonClass,
  109. _ => dontHaveDPClass,
  110. };
  111. foreach (Func<EffectTiming, ICardEffect> getCardEffect in getCardEffects)
  112. {
  113. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  114. }
  115. yield return null;
  116. }
  117. }
  118. return cardEffects;
  119. }
  120. }