BT7_017.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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 BT7_017 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.None)
  14. {
  15. bool Condition()
  16. {
  17. return card.Owner.HandCards.Contains(card);
  18. }
  19. bool PermanentCondition(Permanent targetPermanent)
  20. {
  21. if (CardEffectCommons.IsPermanentExistsOnBattleArea(targetPermanent))
  22. {
  23. if (targetPermanent.TopCard.CardNames.Contains("Machinedramon"))
  24. {
  25. return true;
  26. }
  27. }
  28. return false;
  29. }
  30. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: true, card: card, condition: Condition));
  31. }
  32. if (timing == EffectTiming.OnEnterFieldAnyone)
  33. {
  34. ActivateClass activateClass = new ActivateClass();
  35. activateClass.SetUpICardEffect("Place a card in digivolution cards to delete Digimon", CanUseCondition, card);
  36. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  37. cardEffects.Add(activateClass);
  38. string EffectDiscription()
  39. {
  40. return "[When Digivolving] You may place 1 red or black level 5 card with [Cyborg] in its traits from your hand or trash on top of this card's digivolution cards to delete 1 of your opponent's Digimon with 6000 DP or less for each level 5 card with [Cyborg] in its traits in this Digimon's digivolution cards.";
  41. }
  42. bool CanSelectCardCondition(CardSource cardSource)
  43. {
  44. if (cardSource != null)
  45. {
  46. if (cardSource.IsDigimon)
  47. {
  48. if (cardSource.Owner == card.Owner)
  49. {
  50. if (cardSource.Level == 5 && cardSource.HasLevel)
  51. {
  52. if (cardSource.CardTraits.Contains("Cyborg"))
  53. {
  54. if (cardSource.HasCardColor(CardColor.Red))
  55. {
  56. return true;
  57. }
  58. if (cardSource.HasCardColor(CardColor.Black))
  59. {
  60. return true;
  61. }
  62. }
  63. }
  64. }
  65. }
  66. }
  67. return false;
  68. }
  69. bool CanSelectPermanentCondition(Permanent permanent)
  70. {
  71. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  72. {
  73. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(6000, activateClass))
  74. {
  75. return true;
  76. }
  77. }
  78. return false;
  79. }
  80. bool CanUseCondition(Hashtable hashtable)
  81. {
  82. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  83. }
  84. bool CanActivateCondition(Hashtable hashtable)
  85. {
  86. if (isExistOnField(card))
  87. {
  88. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  89. {
  90. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  91. {
  92. return true;
  93. }
  94. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  95. {
  96. return true;
  97. }
  98. }
  99. }
  100. return false;
  101. }
  102. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  103. {
  104. if (isExistOnField(card))
  105. {
  106. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  107. {
  108. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1 && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  109. {
  110. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  111. {
  112. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  113. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  114. };
  115. string selectPlayerMessage = "From which area do you place a card in digivolution cards?";
  116. string notSelectPlayerMessage = "The opponent is choosing from which area to place a card in digivolution cards.";
  117. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  118. }
  119. else if (card.Owner.HandCards.Count(CanSelectCardCondition) == 0 && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  120. {
  121. GManager.instance.userSelectionManager.SetBool(false);
  122. }
  123. else if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1 && card.Owner.TrashCards.Count(CanSelectCardCondition) == 0)
  124. {
  125. GManager.instance.userSelectionManager.SetBool(true);
  126. }
  127. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  128. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  129. List<CardSource> selectedCards = new List<CardSource>();
  130. IEnumerator SelectCardCoroutine(CardSource cardSource)
  131. {
  132. selectedCards.Add(cardSource);
  133. yield return null;
  134. }
  135. if (fromHand)
  136. {
  137. int maxCount = 1;
  138. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  139. selectHandEffect.SetUp(
  140. selectPlayer: card.Owner,
  141. canTargetCondition: CanSelectCardCondition,
  142. canTargetCondition_ByPreSelecetedList: null,
  143. canEndSelectCondition: null,
  144. maxCount: maxCount,
  145. canNoSelect: true,
  146. canEndNotMax: false,
  147. isShowOpponent: true,
  148. selectCardCoroutine: SelectCardCoroutine,
  149. afterSelectCardCoroutine: null,
  150. mode: SelectHandEffect.Mode.Custom,
  151. cardEffect: activateClass);
  152. selectHandEffect.SetUpCustomMessage("Select 1 card to place in digivolution cards.", "The opponent is selecting 1 card to place in digivolution cards.");
  153. yield return StartCoroutine(selectHandEffect.Activate());
  154. }
  155. else
  156. {
  157. int maxCount = 1;
  158. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  159. selectCardEffect.SetUp(
  160. canTargetCondition: CanSelectCardCondition,
  161. canTargetCondition_ByPreSelecetedList: null,
  162. canEndSelectCondition: null,
  163. canNoSelect: () => true,
  164. selectCardCoroutine: SelectCardCoroutine,
  165. afterSelectCardCoroutine: null,
  166. message: "Select 1 card to play.",
  167. maxCount: maxCount,
  168. canEndNotMax: false,
  169. isShowOpponent: true,
  170. mode: SelectCardEffect.Mode.Custom,
  171. root: SelectCardEffect.Root.Trash,
  172. customRootCardList: null,
  173. canLookReverseCard: true,
  174. selectPlayer: card.Owner,
  175. cardEffect: activateClass);
  176. selectCardEffect.SetUpCustomMessage("Select 1 card to place in digivolution cards.", "The opponent is selecting 1 card to place in digivolution cards.");
  177. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  178. }
  179. if (selectedCards.Count >= 1)
  180. {
  181. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsTop(selectedCards, activateClass));
  182. int count = card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardTraits.Contains("Cyborg") && cardSource.Level == 5 && cardSource.HasLevel);
  183. if (count >= 1)
  184. {
  185. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  186. {
  187. int maxCount = Math.Min(count, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  188. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  189. selectPermanentEffect.SetUp(
  190. selectPlayer: card.Owner,
  191. canTargetCondition: CanSelectPermanentCondition,
  192. canTargetCondition_ByPreSelecetedList: null,
  193. canEndSelectCondition: CanEndSelectCondition,
  194. maxCount: maxCount,
  195. canNoSelect: false,
  196. canEndNotMax: true,
  197. selectPermanentCoroutine: null,
  198. afterSelectPermanentCoroutine: null,
  199. mode: SelectPermanentEffect.Mode.Destroy,
  200. cardEffect: activateClass);
  201. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  202. bool CanEndSelectCondition(List<Permanent> permanents)
  203. {
  204. if (permanents.Count <= 0)
  205. {
  206. return false;
  207. }
  208. return true;
  209. }
  210. }
  211. }
  212. }
  213. }
  214. }
  215. }
  216. }
  217. return cardEffects;
  218. }
  219. }