EX5_059.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. public class EX5_059 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. if (timing == EffectTiming.None)
  11. {
  12. bool PermanentCondition(Permanent targetPermanent)
  13. {
  14. return targetPermanent.TopCard.CardNames.Contains("Dobermon");
  15. }
  16. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  17. }
  18. if (timing == EffectTiming.OnEnterFieldAnyone)
  19. {
  20. ActivateClass activateClass = new ActivateClass();
  21. activateClass.SetUpICardEffect("Your 1 Digimon gains Retaliation", CanUseCondition, card);
  22. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  23. cardEffects.Add(activateClass);
  24. string EffectDiscription()
  25. {
  26. return "[On Play] 1 of your Digimon gains <Retaliation> (When this Digimon is deleted after losing a battle, delete the Digimon it was battling), until the end of your opponent's turn.";
  27. }
  28. bool CanSelectPermanentCondition(Permanent permanent)
  29. {
  30. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  31. }
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  35. }
  36. bool CanActivateCondition(Hashtable hashtable)
  37. {
  38. if (CardEffectCommons.IsExistOnBattleArea(card))
  39. {
  40. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  41. {
  42. return true;
  43. }
  44. }
  45. return false;
  46. }
  47. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  48. {
  49. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  50. {
  51. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  52. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  53. selectPermanentEffect.SetUp(
  54. selectPlayer: card.Owner,
  55. canTargetCondition: CanSelectPermanentCondition,
  56. canTargetCondition_ByPreSelecetedList: null,
  57. canEndSelectCondition: null,
  58. maxCount: maxCount,
  59. canNoSelect: false,
  60. canEndNotMax: false,
  61. selectPermanentCoroutine: SelectPermanentCoroutine,
  62. afterSelectPermanentCoroutine: null,
  63. mode: SelectPermanentEffect.Mode.Custom,
  64. cardEffect: activateClass);
  65. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get Retaliation.",
  66. "The opponent is selecting 1 Digimon that will get Retaliation.");
  67. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  68. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  69. {
  70. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainRetaliation(
  71. targetPermanent: permanent,
  72. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  73. activateClass: activateClass));
  74. }
  75. }
  76. }
  77. }
  78. if (timing == EffectTiming.OnEnterFieldAnyone)
  79. {
  80. ActivateClass activateClass = new ActivateClass();
  81. activateClass.SetUpICardEffect("Draw 1, trash 1 card from hand and activate [On Play] effect", CanUseCondition, card);
  82. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  83. cardEffects.Add(activateClass);
  84. string EffectDiscription()
  85. {
  86. return "[When Digivolving] <Draw 1> (Draw 1 card from your deck). Then, trash 1 card in your hand. If [Dobermon] in its name or [X Antibody] is in this Digimon's digivolution cards, activate this Digimon's [On Play] effects.";
  87. }
  88. bool CanUseCondition(Hashtable hashtable)
  89. {
  90. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  91. }
  92. bool CanActivateCondition(Hashtable hashtable)
  93. {
  94. if (CardEffectCommons.IsExistOnBattleArea(card))
  95. {
  96. if (card.Owner.LibraryCards.Count >= 1)
  97. {
  98. return true;
  99. }
  100. if (card.Owner.HandCards.Count >= 1)
  101. {
  102. return true;
  103. }
  104. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) =>
  105. (cardSource.IsDigimon && cardSource.ContainsCardName("Dobermon"))
  106. || cardSource.CardNames.Contains("X Antibody") || cardSource.CardNames.Contains("XAntibody")) >= 1)
  107. {
  108. return true;
  109. }
  110. }
  111. return false;
  112. }
  113. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  114. {
  115. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  116. if (card.Owner.HandCards.Count >= 1)
  117. {
  118. int discardCount = Math.Min(1, card.Owner.HandCards.Count);
  119. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  120. selectHandEffect.SetUp(
  121. selectPlayer: card.Owner,
  122. canTargetCondition: (cardSource) => true,
  123. canTargetCondition_ByPreSelecetedList: null,
  124. canEndSelectCondition: null,
  125. maxCount: discardCount,
  126. canNoSelect: false,
  127. canEndNotMax: false,
  128. isShowOpponent: true,
  129. selectCardCoroutine: null,
  130. afterSelectCardCoroutine: null,
  131. mode: SelectHandEffect.Mode.Discard,
  132. cardEffect: activateClass);
  133. yield return StartCoroutine(selectHandEffect.Activate());
  134. }
  135. if (CardEffectCommons.IsExistOnBattleArea(card))
  136. {
  137. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) =>
  138. (cardSource.IsDigimon && cardSource.ContainsCardName("Dobermon"))
  139. || cardSource.CardNames.Contains("X Antibody") || cardSource.CardNames.Contains("XAntibody")) >= 1)
  140. {
  141. Permanent selectedPermanent = card.PermanentOfThisCard();
  142. if (selectedPermanent != null)
  143. {
  144. List<ICardEffect> candidateEffects = selectedPermanent.EffectList(EffectTiming.OnEnterFieldAnyone)
  145. .Clone()
  146. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsOnPlay);
  147. if (candidateEffects.Count >= 1)
  148. {
  149. ICardEffect selectedEffect = null;
  150. if (candidateEffects.Count == 1)
  151. {
  152. selectedEffect = candidateEffects[0];
  153. }
  154. else
  155. {
  156. List<SkillInfo> skillInfos = candidateEffects
  157. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  158. List<CardSource> cardSources = candidateEffects
  159. .Map(cardEffect => cardEffect.EffectSourceCard);
  160. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  161. selectCardEffect.SetUp(
  162. canTargetCondition: (cardSource) => true,
  163. canTargetCondition_ByPreSelecetedList: null,
  164. canEndSelectCondition: null,
  165. canNoSelect: () => false,
  166. selectCardCoroutine: null,
  167. afterSelectCardCoroutine: null,
  168. message: "Select 1 effect to activate.",
  169. maxCount: 1,
  170. canEndNotMax: false,
  171. isShowOpponent: false,
  172. mode: SelectCardEffect.Mode.Custom,
  173. root: SelectCardEffect.Root.Custom,
  174. customRootCardList: cardSources,
  175. canLookReverseCard: true,
  176. selectPlayer: card.Owner,
  177. cardEffect: activateClass);
  178. selectCardEffect.SetNotShowCard();
  179. selectCardEffect.SetUpSkillInfos(skillInfos);
  180. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  181. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  182. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  183. {
  184. if (selectedIndexes.Count == 1)
  185. {
  186. selectedEffect = candidateEffects[selectedIndexes[0]];
  187. yield return null;
  188. }
  189. }
  190. }
  191. if (selectedEffect != null)
  192. {
  193. if (selectedEffect.EffectSourceCard != null)
  194. {
  195. if (selectedEffect.EffectSourceCard.PermanentOfThisCard() != null)
  196. {
  197. Hashtable effectHashtable = CardEffectCommons.OnPlayCheckHashtableOfCard(selectedEffect.EffectSourceCard);
  198. if (selectedEffect.CanUse(effectHashtable))
  199. {
  200. yield return ContinuousController.instance.StartCoroutine(((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(effectHashtable));
  201. }
  202. }
  203. }
  204. }
  205. }
  206. }
  207. }
  208. }
  209. }
  210. }
  211. if (timing == EffectTiming.OnEnterFieldAnyone)
  212. {
  213. ActivateClass activateClass = new ActivateClass();
  214. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  215. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  216. activateClass.SetHashString("Memory1_EX5_059");
  217. activateClass.SetIsInheritedEffect(true);
  218. cardEffects.Add(activateClass);
  219. string EffectDiscription()
  220. {
  221. return "[Your Turn] [Once Per Turn] When an effect plays one of your Digimon, gain 1 memory.";
  222. }
  223. bool PermanentCondition(Permanent permanent)
  224. {
  225. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  226. }
  227. bool CanUseCondition(Hashtable hashtable)
  228. {
  229. if (CardEffectCommons.IsExistOnBattleArea(card))
  230. {
  231. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  232. {
  233. if (CardEffectCommons.IsByEffect(hashtable, null))
  234. {
  235. if (CardEffectCommons.IsOwnerTurn(card))
  236. {
  237. return true;
  238. }
  239. }
  240. }
  241. }
  242. return false;
  243. }
  244. bool CanActivateCondition(Hashtable hashtable)
  245. {
  246. if (CardEffectCommons.IsExistOnBattleArea(card))
  247. {
  248. return true;
  249. }
  250. return false;
  251. }
  252. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  253. {
  254. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  255. }
  256. }
  257. return cardEffects;
  258. }
  259. }