Magnadramon_BT15_042.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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. using System.Runtime.InteropServices.WindowsRuntime;
  9. public class Magnadramon_BT15_042 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region All Turns
  15. if (timing == EffectTiming.OnLoseSecurity)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect("Place 1 yellow card from your hand to the top or bottom of your security stack.", CanUseCondition, card);
  19. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "[All Turns][Once per turn] When a card is removed from your security stack, if you have 3 or less security cards, you may place 1 yellow card from your hand at the top or bottom of your security stack.";
  24. }
  25. bool CanActivateCondition(Hashtable hashtable)
  26. {
  27. if (CardEffectCommons.IsExistOnBattleArea(card))
  28. {
  29. return true;
  30. }
  31. return false;
  32. }
  33. bool CanUseCondition(Hashtable hashtable)
  34. {
  35. if (CardEffectCommons.IsExistOnBattleArea(card))
  36. {
  37. if (CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner))
  38. {
  39. return true;
  40. if (card.Owner.SecurityCards.Count() <= 3)
  41. {
  42. return true;
  43. }
  44. }
  45. }
  46. return false;
  47. }
  48. bool CanSelectCardCondition(CardSource cardSource)
  49. {
  50. if(cardSource.CardColors.Contains(CardColor.Yellow))
  51. {
  52. return true;
  53. }
  54. return false;
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  57. {
  58. if (card.Owner.SecurityCards.Count <= 3)
  59. {
  60. if (card.Owner.CanAddSecurity(activateClass))
  61. {
  62. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  63. {
  64. List<CardSource> selectedCard = new List<CardSource>();
  65. int maxCount = 1;
  66. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  67. selectHandEffect.SetUp(
  68. selectPlayer: card.Owner,
  69. canTargetCondition: CanSelectCardCondition,
  70. canTargetCondition_ByPreSelecetedList: null,
  71. canEndSelectCondition: null,
  72. maxCount: maxCount,
  73. canNoSelect: true,
  74. canEndNotMax: false,
  75. isShowOpponent: true,
  76. selectCardCoroutine: SelectCardCoroutine,
  77. afterSelectCardCoroutine: null,
  78. mode: SelectHandEffect.Mode.Custom,
  79. cardEffect: activateClass);
  80. selectHandEffect.SetUpCustomMessage(
  81. "Select 1 card to place at the top or bottom of security.",
  82. "The opponent is selecting 1 card to place at the bottom of security.");
  83. selectHandEffect.SetUpCustomMessage_ShowCard("Security Bottom Card");
  84. yield return StartCoroutine(selectHandEffect.Activate());
  85. IEnumerator SelectCardCoroutine(CardSource cardSource)
  86. {
  87. if (selectedCard != null)
  88. {
  89. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  90. {
  91. new SelectionElement<bool>(message: $"Security Top", value : true, spriteIndex: 0),
  92. new SelectionElement<bool>(message: $"Security Bottom", value : false, spriteIndex: 1),
  93. };
  94. string selectPlayerMessage = "Will you place the card on the top or bottom of the security?";
  95. string notSelectPlayerMessage = "The opponent is selecting whether to place the card on the top or bottom of security.";
  96. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  97. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  98. bool toTop = GManager.instance.userSelectionManager.SelectedBoolValue;
  99. if (toTop)
  100. {
  101. GManager.instance.commandText.OpenCommandText("\"Place to the top of security\" was selected.");
  102. GManager.instance.playLog.AddLogString($"\n{card.BaseENGCardNameFromEntity}({card.CardID}):Place the Digimon to the top of security\n");
  103. }
  104. else
  105. {
  106. GManager.instance.commandText.OpenCommandText("\"Place to the bottom of security\" was selected.");
  107. GManager.instance.playLog.AddLogString($"\n{card.BaseENGCardNameFromEntity}({card.CardID}):Place the Digimon to the bottom of security\n");
  108. }
  109. yield return new WaitForSeconds(0.4f);
  110. GManager.instance.commandText.CloseCommandText();
  111. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  112. selectedCard.Add(cardSource);
  113. yield return null;
  114. foreach (CardSource card in selectedCard)
  115. {
  116. if (toTop)
  117. {
  118. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(card, toTop: true));
  119. }
  120. if (!toTop)
  121. {
  122. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(card, toTop: false));
  123. }
  124. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateRecoveryEffect(card.Owner));
  125. yield return ContinuousController.instance.StartCoroutine(new IAddSecurity(card.Owner).AddSecurity());
  126. }
  127. }
  128. }
  129. }
  130. }
  131. }
  132. }
  133. }
  134. #endregion
  135. #region On Play
  136. if (timing == EffectTiming.OnEnterFieldAnyone)
  137. {
  138. ActivateClass activateClass = new ActivateClass();
  139. activateClass.SetUpICardEffect("Trash the top or bottom of your security to reduce opponent's Digimon DP.", CanUseCondition, card);
  140. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  141. activateClass.SetHashString("TrashSecuirtyToReduceDP_BT15_042");
  142. cardEffects.Add(activateClass);
  143. string EffectDiscription()
  144. {
  145. return "[On Play] By trashing the top or bottom card of your security stack, 1 of your opponent's Digimon gets -9000 DP until the end of your opponent's turn.";
  146. }
  147. bool CanUseCondition(Hashtable hashtable)
  148. {
  149. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  150. }
  151. bool CanActivateCondition(Hashtable hashtable)
  152. {
  153. if (CardEffectCommons.IsExistOnBattleArea(card))
  154. {
  155. if (card.Owner.SecurityCards.Count >= 1)
  156. {
  157. return true;
  158. }
  159. }
  160. return false;
  161. }
  162. bool CanSelectPermanentCondition(Permanent permanent)
  163. {
  164. if(CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  165. {
  166. if (permanent.HasDP)
  167. {
  168. return true;
  169. }
  170. }
  171. return false;
  172. }
  173. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  174. {
  175. if (card.Owner.SecurityCards.Count >= 1)
  176. {
  177. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  178. {
  179. new SelectionElement<bool>(message: $"Security Top", value : true, spriteIndex: 0),
  180. new SelectionElement<bool>(message: $"Security Bottom", value : false, spriteIndex: 1),
  181. };
  182. string selectPlayerMessage = "Which will you trash the top or bottom card of the security?";
  183. string notSelectPlayerMessage = "The opponent is selecting whether to trash the top or bottom card of security.";
  184. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  185. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  186. bool fromTop = GManager.instance.userSelectionManager.SelectedBoolValue;
  187. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  188. card.Owner,
  189. 1,
  190. activateClass,
  191. fromTop).DestroySecurity());
  192. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  193. {
  194. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  195. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  196. selectPermanentEffect.SetUp(
  197. selectPlayer: card.Owner,
  198. canTargetCondition: CanSelectPermanentCondition,
  199. canTargetCondition_ByPreSelecetedList: null,
  200. canEndSelectCondition: null,
  201. maxCount: maxCount,
  202. canNoSelect: false,
  203. canEndNotMax: false,
  204. selectPermanentCoroutine: SelectPermanentCoroutine,
  205. afterSelectPermanentCoroutine: null,
  206. mode: SelectPermanentEffect.Mode.Custom,
  207. cardEffect: activateClass);
  208. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -9000.", "The opponent is selecting 1 Digimon that will get DP -9000.");
  209. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  210. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  211. {
  212. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -9000, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  213. }
  214. }
  215. }
  216. }
  217. }
  218. #endregion
  219. #region When Digivolving
  220. if (timing == EffectTiming.OnEnterFieldAnyone)
  221. {
  222. ActivateClass activateClass = new ActivateClass();
  223. activateClass.SetUpICardEffect("Trash the top or bottom of your security to reduce opponent's Digimon DP.", CanUseCondition, card);
  224. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  225. activateClass.SetHashString("TrashSecuirtyToReduceDP_BT15_042");
  226. cardEffects.Add(activateClass);
  227. string EffectDiscription()
  228. {
  229. return "[When Digivolving] By trashing the top or bottom card of your security stack, 1 of your opponent's Digimon gets -9000 DP until the end of your opponent's turn.";
  230. }
  231. bool CanUseCondition(Hashtable hashtable)
  232. {
  233. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  234. }
  235. bool CanActivateCondition(Hashtable hashtable)
  236. {
  237. if (CardEffectCommons.IsExistOnBattleArea(card))
  238. {
  239. if (card.Owner.SecurityCards.Count >= 1)
  240. {
  241. return true;
  242. }
  243. }
  244. return false;
  245. }
  246. bool CanSelectPermanentCondition(Permanent permanent)
  247. {
  248. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  249. {
  250. if (permanent.HasDP)
  251. {
  252. return true;
  253. }
  254. }
  255. return false;
  256. }
  257. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  258. {
  259. if (card.Owner.SecurityCards.Count >= 1)
  260. {
  261. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  262. {
  263. new SelectionElement<bool>(message: $"Security Top", value : true, spriteIndex: 0),
  264. new SelectionElement<bool>(message: $"Security Bottom", value : false, spriteIndex: 1),
  265. };
  266. string selectPlayerMessage = "Which will you trash the top or bottom card of the security?";
  267. string notSelectPlayerMessage = "The opponent is selecting whether to trash the top or bottom card of security.";
  268. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  269. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  270. bool fromTop = GManager.instance.userSelectionManager.SelectedBoolValue;
  271. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  272. card.Owner,
  273. 1,
  274. activateClass,
  275. fromTop).DestroySecurity());
  276. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  277. {
  278. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  279. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  280. selectPermanentEffect.SetUp(
  281. selectPlayer: card.Owner,
  282. canTargetCondition: CanSelectPermanentCondition,
  283. canTargetCondition_ByPreSelecetedList: null,
  284. canEndSelectCondition: null,
  285. maxCount: maxCount,
  286. canNoSelect: false,
  287. canEndNotMax: false,
  288. selectPermanentCoroutine: SelectPermanentCoroutine,
  289. afterSelectPermanentCoroutine: null,
  290. mode: SelectPermanentEffect.Mode.Custom,
  291. cardEffect: activateClass);
  292. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -9000.", "The opponent is selecting 1 Digimon that will get DP -9000.");
  293. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  294. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  295. {
  296. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -9000, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  297. }
  298. }
  299. }
  300. }
  301. }
  302. #endregion
  303. return cardEffects;
  304. }
  305. }