AD1_005.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Gaiamon
  6. namespace DCGO.CardEffects.AD1
  7. {
  8. public class AD1_005 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Static Effects
  14. #region Alternative Digivolution Condition - Ult.
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.EqualsTraits("Ult.");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region App Fusion (Globemon & Charismon)
  25. if (timing == EffectTiming.None) cardEffects.Add(CardEffectFactory.AddAppfuseMethodByName(new List<string>() { "Globemon", "Charismon" }, card));
  26. #endregion
  27. #region Blast Digivolve
  28. if (timing == EffectTiming.OnCounterTiming) cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  29. #endregion
  30. #region Security A. +1
  31. if (timing == EffectTiming.None) cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: false, card: card, condition: null));
  32. #endregion
  33. #region Blocker
  34. if (timing == EffectTiming.None) cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  35. #endregion
  36. #region Link +1
  37. if (timing == EffectTiming.None) cardEffects.Add(CardEffectFactory.ChangeSelfLinkMaxStaticEffect(1, false, card, null));
  38. #endregion
  39. #endregion
  40. #region Shared OP / WD / WA
  41. string SharedHashString = "AD1_005_OP_WD_WA";
  42. string SharedEffectName = "You may link up to 2 cards from hand or digivolution cards. Then you may delete 1 Digimon with equal or less DP than this Digimon.";
  43. string SharedEffectDescription(string tag)
  44. => $"[{tag}] [Once Per Turn] You may link up to 2 [Social], [Navi] or [Tool] trait cards from your hand or this Digimon’s digivolution cards to this Digimon without paying the cost. Then, you may delete 1 of your opponent’s Digimon with as much or less DP as this Digimon.";
  45. bool SharedCanActivateCondition(Hashtable hashtable)
  46. {
  47. return CardEffectCommons.IsExistOnBattleArea(card)
  48. && (CardEffectCommons.HasMatchConditionOwnersHand(card, IsProperTraitCard)
  49. || card.PermanentOfThisCard().DigivolutionCards.Any(IsProperTraitCard)
  50. || CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsWeakerOpponentsDigimon));
  51. }
  52. bool IsProperTraitCard(CardSource cardSource)
  53. {
  54. return (cardSource.EqualsTraits("Social")
  55. || cardSource.EqualsTraits("Navi")
  56. || cardSource.EqualsTraits("Tool"))
  57. && cardSource.CanLinkToTargetPermanent(card.PermanentOfThisCard(), false);
  58. }
  59. bool IsWeakerOpponentsDigimon(Permanent permanent)
  60. {
  61. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  62. && permanent.HasDP
  63. && permanent.DP <= card.PermanentOfThisCard().DP;
  64. }
  65. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  66. {
  67. #region Link 2 cards
  68. Permanent thisPermanent = card.PermanentOfThisCard();
  69. List<CardSource> selectedCards = new List<CardSource>();
  70. IEnumerator SelectCardCoroutine(CardSource cardSource)
  71. {
  72. selectedCards.Add(cardSource);
  73. yield return null;
  74. }
  75. while (selectedCards.Count < 2)
  76. {
  77. List<CardSource> validHandCards = card.Owner.HandCards.Filter(IsProperTraitCard).Except(selectedCards).ToList();
  78. List<CardSource> validDigivolutionCards = thisPermanent.DigivolutionCards.Filter(IsProperTraitCard).Except(selectedCards).ToList();
  79. int validHandCardCount = validHandCards.Count;
  80. int validDigivolutionCardCount = validDigivolutionCards.Count;
  81. if (validHandCardCount + validDigivolutionCardCount <= 0)//No cards left to pick
  82. {
  83. goto END_LOOP;
  84. }
  85. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  86. if (validHandCardCount > 0)
  87. {
  88. selectionElements.Add(new (message: $"Link from Hand", value : 1, spriteIndex: 0));
  89. }
  90. if (validDigivolutionCardCount > 0)
  91. {
  92. selectionElements.Add(new (message: $"Link from Digivolution Cards", value : 2, spriteIndex: 0));
  93. }
  94. selectionElements.Add( new (message: (selectedCards.Count == 0 ? $"Don't link" : $"Finish Linking"), value: 3, spriteIndex: 1));
  95. string selectPlayerMessage = "From which area will you link a card?";
  96. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  97. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  98. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  99. switch (GManager.instance.userSelectionManager.SelectedIntValue)
  100. {
  101. case 1: // From Hand
  102. {
  103. int maxCount = Math.Min(2-selectedCards.Count, validHandCardCount);
  104. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  105. selectHandEffect.SetUp(
  106. selectPlayer: card.Owner,
  107. canTargetCondition: cardSource => validHandCards.Contains(cardSource),
  108. canTargetCondition_ByPreSelecetedList: null,
  109. canEndSelectCondition: null,
  110. maxCount: maxCount,
  111. canNoSelect: true,
  112. canEndNotMax: true,
  113. isShowOpponent: true,
  114. selectCardCoroutine: SelectCardCoroutine,
  115. afterSelectCardCoroutine: null,
  116. mode: SelectHandEffect.Mode.Custom,
  117. cardEffect: activateClass);
  118. selectHandEffect.SetUpCustomMessage($"Select up to {maxCount} cards to link.", "The opponent is selecting cards to link.");
  119. yield return StartCoroutine(selectHandEffect.Activate());
  120. break;
  121. }
  122. case 2: // From Digivolution Cards
  123. {
  124. int maxCount = Math.Min(2-selectedCards.Count, validDigivolutionCardCount);
  125. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  126. selectCardEffect.SetUp(
  127. canTargetCondition: cardSource => validDigivolutionCards.Contains(cardSource),
  128. canTargetCondition_ByPreSelecetedList: null,
  129. canEndSelectCondition: null,
  130. canNoSelect: () => true,
  131. selectCardCoroutine: SelectCardCoroutine,
  132. afterSelectCardCoroutine: null,
  133. message: "Select cards to link.",
  134. maxCount: maxCount,
  135. canEndNotMax: true,
  136. isShowOpponent: true,
  137. mode: SelectCardEffect.Mode.Custom,
  138. root: SelectCardEffect.Root.DigivolutionCards,
  139. customRootCardList: thisPermanent.DigivolutionCards,
  140. canLookReverseCard: false,
  141. selectPlayer: card.Owner,
  142. cardEffect: activateClass);
  143. selectCardEffect.SetUpCustomMessage($"Select up to {maxCount} cards to link.", "The opponent is selecting cards to link.");
  144. yield return StartCoroutine(selectCardEffect.Activate());
  145. break;
  146. }
  147. default:
  148. goto END_LOOP;
  149. }
  150. }
  151. END_LOOP:;
  152. foreach(CardSource linkCard in selectedCards)
  153. {
  154. yield return ContinuousController.instance.StartCoroutine(thisPermanent.AddLinkCard(linkCard, activateClass));
  155. }
  156. #endregion
  157. #region Delete 1 Digimon
  158. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsWeakerOpponentsDigimon))
  159. {
  160. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  161. selectPermanentEffect.SetUp(
  162. selectPlayer: card.Owner,
  163. canTargetCondition: IsWeakerOpponentsDigimon,
  164. canTargetCondition_ByPreSelecetedList: null,
  165. canEndSelectCondition: null,
  166. maxCount: 1,
  167. canNoSelect: true,
  168. canEndNotMax: false,
  169. selectPermanentCoroutine: null,
  170. afterSelectPermanentCoroutine: null,
  171. mode: SelectPermanentEffect.Mode.Destroy,
  172. cardEffect: activateClass);
  173. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  174. }
  175. #endregion
  176. }
  177. #endregion
  178. #region On Play
  179. if (timing == EffectTiming.OnEnterFieldAnyone)
  180. {
  181. ActivateClass activateClass = new ActivateClass();
  182. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  183. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("On Play"));
  184. activateClass.SetHashString(SharedHashString);
  185. cardEffects.Add(activateClass);
  186. bool CanUseCondition(Hashtable hashtable)
  187. {
  188. return CardEffectCommons.IsExistOnBattleArea(card)
  189. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  190. }
  191. }
  192. #endregion
  193. #region When Digivolving
  194. if (timing == EffectTiming.OnEnterFieldAnyone)
  195. {
  196. ActivateClass activateClass = new ActivateClass();
  197. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  198. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("When Digivolving"));
  199. activateClass.SetHashString(SharedHashString);
  200. cardEffects.Add(activateClass);
  201. bool CanUseCondition(Hashtable hashtable)
  202. {
  203. return CardEffectCommons.IsExistOnBattleArea(card)
  204. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  205. }
  206. }
  207. #endregion
  208. #region When Attacking
  209. if (timing == EffectTiming.OnAllyAttack)
  210. {
  211. ActivateClass activateClass = new ActivateClass();
  212. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  213. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("When Attacking"));
  214. activateClass.SetHashString(SharedHashString);
  215. cardEffects.Add(activateClass);
  216. bool CanUseCondition(Hashtable hashtable)
  217. {
  218. return CardEffectCommons.IsExistOnBattleArea(card)
  219. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  220. }
  221. }
  222. #endregion
  223. return cardEffects;
  224. }
  225. }
  226. }