Permanent.cs 127 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System;
  5. using System.Linq;
  6. public class Permanent
  7. {
  8. public Permanent(List<CardSource> cardSources)
  9. {
  10. SetCardSources(cardSources);
  11. }
  12. public void SetCardSources(List<CardSource> cardSources)
  13. {
  14. List<CardSource> newCardSources = cardSources.Clone();
  15. //TODO: Attempted fix for random face up secuirty/flipped sources
  16. //newCardSources.Reverse();
  17. foreach (CardSource cardSource in newCardSources)
  18. {
  19. AddCardSource(cardSource);
  20. }
  21. }
  22. public FieldCardFrame PermanentFrame
  23. {
  24. get
  25. {
  26. if (TopCard != null)
  27. {
  28. int index = Array.IndexOf(TopCard.Owner.FieldPermanents, this);
  29. if (0 <= index && index <= TopCard.Owner.fieldCardFrames.Count - 1)
  30. {
  31. return TopCard.Owner.fieldCardFrames[index];
  32. }
  33. }
  34. return null;
  35. }
  36. }
  37. public bool oldIsTapped_playCard { get; set; }
  38. #region Level
  39. public int Level
  40. {
  41. get
  42. {
  43. int Level = 0;
  44. if (TopCard != null)
  45. {
  46. Level = TopCard.Level;
  47. if (!TopCard.HasLevel)
  48. {
  49. Level = 1145140;
  50. }
  51. #region レベルを変更する効果
  52. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  53. {
  54. foreach (Permanent permanent in player.GetFieldPermanents())
  55. {
  56. #region 場のパーマネントの効果
  57. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  58. {
  59. if (cardEffect is IChangePermanentLevelEffect)
  60. {
  61. if (cardEffect.CanUse(null))
  62. {
  63. Level = ((IChangePermanentLevelEffect)cardEffect).GetPermanentLevel(Level, this);
  64. }
  65. }
  66. }
  67. #endregion
  68. }
  69. #region プレイヤーの効果
  70. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  71. {
  72. if (cardEffect is IChangePermanentLevelEffect)
  73. {
  74. if (cardEffect.CanUse(null))
  75. {
  76. Level = ((IChangePermanentLevelEffect)cardEffect).GetPermanentLevel(Level, this);
  77. }
  78. }
  79. }
  80. #endregion
  81. }
  82. #endregion
  83. }
  84. return Level;
  85. }
  86. }
  87. #endregion
  88. #region Place all evolution sources in the trash
  89. public IEnumerator DiscardEvoRoots(bool ignoreOverflow = false, bool putToTrash = true)
  90. {
  91. List<CardSource> evoRoots = DigivolutionCards.Clone();
  92. List<CardSource> linkRoots = LinkedCards.Clone();
  93. if (!ignoreOverflow)
  94. {
  95. yield return ContinuousController.instance.StartCoroutine(new AceOverflowClass(evoRoots).Overflow());
  96. yield return ContinuousController.instance.StartCoroutine(new AceOverflowClass(linkRoots).Overflow());
  97. }
  98. foreach (CardSource cardSource1 in evoRoots)
  99. {
  100. if (putToTrash)
  101. {
  102. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddTrashCard(cardSource1));
  103. }
  104. else
  105. {
  106. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(cardSource1));
  107. }
  108. }
  109. foreach (CardSource cardSource2 in linkRoots)
  110. {
  111. if (putToTrash)
  112. {
  113. yield return ContinuousController.instance.StartCoroutine(RemoveLinkedCard(cardSource2));
  114. }
  115. else
  116. {
  117. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(cardSource2));
  118. }
  119. }
  120. }
  121. #endregion
  122. #region Whether this permanent has DP
  123. public bool HasDP
  124. {
  125. get
  126. {
  127. if (TopCard == null)
  128. {
  129. return false;
  130. }
  131. if (!IsDigimon)
  132. {
  133. return false;
  134. }
  135. if (!TopCard.HasDP && TopCard.IsDigiEgg)
  136. {
  137. return false;
  138. }
  139. #region Effect of not having DP
  140. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  141. {
  142. foreach (Permanent permanent in player.GetFieldPermanents())
  143. {
  144. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  145. {
  146. if (cardEffect1 is IDontHaveDPEffect)
  147. {
  148. if (cardEffect1.CanUse(null))
  149. {
  150. if (((IDontHaveDPEffect)cardEffect1).DontHaveDP(this))
  151. {
  152. return false;
  153. }
  154. }
  155. }
  156. }
  157. }
  158. }
  159. #endregion
  160. return true;
  161. }
  162. }
  163. #endregion
  164. #region Base DP
  165. public int BaseDP
  166. {
  167. get
  168. {
  169. int BaseDP = 0;
  170. if (HasDP)
  171. {
  172. BaseDP = TopCard.BaseCardDP;
  173. BaseDP += TopCard.BaseDP;
  174. #region 基礎DPを変更する効果
  175. List<ICardEffect> cardEffects_ChangeDP = new List<ICardEffect>();
  176. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  177. {
  178. foreach (Permanent permanent in player.GetFieldPermanents())
  179. {
  180. #region 場のパーマネントの効果
  181. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  182. {
  183. if (cardEffect is IChangeBaseDPEffect)
  184. {
  185. if (cardEffect.CanUse(null))
  186. {
  187. if (((IChangeBaseDPEffect)cardEffect).PermanentCondition(this))
  188. {
  189. if (((IChangeBaseDPEffect)cardEffect).IsMinusDP())
  190. {
  191. if (this.ImmuneFromDPMinus(cardEffect))
  192. {
  193. continue;
  194. }
  195. }
  196. if (!TopCard.CanNotBeAffected(cardEffect))
  197. {
  198. cardEffects_ChangeDP.Add(cardEffect);
  199. }
  200. }
  201. }
  202. }
  203. }
  204. #endregion
  205. }
  206. #region プレイヤーの効果
  207. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  208. {
  209. if (cardEffect is IChangeBaseDPEffect)
  210. {
  211. if (cardEffect.CanUse(null))
  212. {
  213. if (((IChangeBaseDPEffect)cardEffect).PermanentCondition(this))
  214. {
  215. if (((IChangeBaseDPEffect)cardEffect).IsMinusDP())
  216. {
  217. if (this.ImmuneFromDPMinus(cardEffect))
  218. {
  219. continue;
  220. }
  221. }
  222. if (!TopCard.CanNotBeAffected(cardEffect))
  223. {
  224. cardEffects_ChangeDP.Add(cardEffect);
  225. }
  226. }
  227. }
  228. }
  229. }
  230. #endregion
  231. }
  232. List<ICardEffect> cardEffects_ChangeDP_isUpDown = new List<ICardEffect>();
  233. List<ICardEffect> cardEffects_ChangeDP_NotIsUpDown = new List<ICardEffect>();
  234. foreach (ICardEffect cardEffect in cardEffects_ChangeDP)
  235. {
  236. if (cardEffect is IChangeBaseDPEffect)
  237. {
  238. if (cardEffect.CanUse(null))
  239. {
  240. if (((IChangeBaseDPEffect)cardEffect).IsUpDown())
  241. {
  242. cardEffects_ChangeDP_isUpDown.Add(cardEffect);
  243. }
  244. else
  245. {
  246. cardEffects_ChangeDP_NotIsUpDown.Add(cardEffect);
  247. }
  248. }
  249. }
  250. }
  251. foreach (ICardEffect cardEffect in cardEffects_ChangeDP_isUpDown)
  252. {
  253. if (cardEffect is IChangeBaseDPEffect)
  254. {
  255. if (cardEffect.CanUse(null))
  256. {
  257. BaseDP = ((IChangeBaseDPEffect)cardEffect).GetDP(BaseDP, this);
  258. }
  259. }
  260. }
  261. foreach (ICardEffect cardEffect in cardEffects_ChangeDP_NotIsUpDown)
  262. {
  263. if (cardEffect is IChangeBaseDPEffect)
  264. {
  265. if (cardEffect.CanUse(null))
  266. {
  267. BaseDP = ((IChangeBaseDPEffect)cardEffect).GetDP(BaseDP, this);
  268. }
  269. }
  270. }
  271. #endregion
  272. if (BaseDP < 0)
  273. {
  274. BaseDP = 0;
  275. }
  276. }
  277. return BaseDP;
  278. }
  279. }
  280. #endregion
  281. #region DP
  282. public int DP
  283. {
  284. get
  285. {
  286. int DP = -1;
  287. if (HasDP)
  288. {
  289. DP = BaseDP;
  290. #region DP By Effect
  291. List<ICardEffect> cardEffects_ChangeDP = new List<ICardEffect>();
  292. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  293. {
  294. #region Effects of permanents in play
  295. foreach (Permanent permanent in player.GetFieldPermanents())
  296. {
  297. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  298. {
  299. if (cardEffect is IChangeDPEffect)
  300. {
  301. if (cardEffect.CanUse(null))
  302. {
  303. if (((IChangeDPEffect)cardEffect).PermanentCondition(this))
  304. {
  305. if (((IChangeDPEffect)cardEffect).IsMinusDP())
  306. {
  307. if (this.ImmuneFromDPMinus(cardEffect))
  308. {
  309. continue;
  310. }
  311. }
  312. if (!TopCard.CanNotBeAffected(cardEffect))
  313. {
  314. cardEffects_ChangeDP.Add(cardEffect);
  315. }
  316. }
  317. }
  318. }
  319. }
  320. }
  321. #endregion
  322. #region Effects of face up security
  323. foreach (CardSource cardSource in player.SecurityCards)
  324. {
  325. if (cardSource.IsFlipped)
  326. continue;
  327. foreach (ICardEffect cardEffect in cardSource.EffectList(EffectTiming.None))
  328. {
  329. if (cardEffect is IChangeDPEffect)
  330. {
  331. if (cardEffect.CanUse(null))
  332. {
  333. if (((IChangeDPEffect)cardEffect).PermanentCondition(this))
  334. {
  335. if (((IChangeDPEffect)cardEffect).IsMinusDP())
  336. {
  337. if (this.ImmuneFromDPMinus(cardEffect))
  338. {
  339. continue;
  340. }
  341. }
  342. if (!TopCard.CanNotBeAffected(cardEffect))
  343. {
  344. cardEffects_ChangeDP.Add(cardEffect);
  345. }
  346. }
  347. }
  348. }
  349. }
  350. }
  351. #endregion
  352. #region Player effect
  353. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  354. {
  355. if (cardEffect is IChangeDPEffect)
  356. {
  357. if (cardEffect.CanUse(null))
  358. {
  359. if (((IChangeDPEffect)cardEffect).PermanentCondition(this))
  360. {
  361. if (((IChangeDPEffect)cardEffect).IsMinusDP())
  362. {
  363. if (this.ImmuneFromDPMinus(cardEffect))
  364. {
  365. continue;
  366. }
  367. }
  368. if (!TopCard.CanNotBeAffected(cardEffect))
  369. {
  370. cardEffects_ChangeDP.Add(cardEffect);
  371. }
  372. }
  373. }
  374. }
  375. }
  376. #endregion
  377. }
  378. List<ICardEffect> cardEffects_ChangeDP_isUpDown = new List<ICardEffect>();
  379. List<ICardEffect> cardEffects_ChangeDP_NotIsUpDown = new List<ICardEffect>();
  380. foreach (ICardEffect cardEffect in cardEffects_ChangeDP)
  381. {
  382. if (cardEffect is IChangeDPEffect)
  383. {
  384. if (cardEffect.CanUse(null))
  385. {
  386. if (((IChangeDPEffect)cardEffect).IsUpDown())
  387. {
  388. cardEffects_ChangeDP_isUpDown.Add(cardEffect);
  389. }
  390. else
  391. {
  392. cardEffects_ChangeDP_NotIsUpDown.Add(cardEffect);
  393. }
  394. }
  395. }
  396. }
  397. foreach (ICardEffect cardEffect in cardEffects_ChangeDP_isUpDown)
  398. {
  399. if (cardEffect is IChangeDPEffect)
  400. {
  401. if (cardEffect.CanUse(null))
  402. {
  403. DP = ((IChangeDPEffect)cardEffect).GetDP(DP, this);
  404. }
  405. }
  406. }
  407. foreach (ICardEffect cardEffect in cardEffects_ChangeDP_NotIsUpDown)
  408. {
  409. if (cardEffect is IChangeDPEffect)
  410. {
  411. if (cardEffect.CanUse(null))
  412. {
  413. DP = ((IChangeDPEffect)cardEffect).GetDP(DP, this);
  414. }
  415. }
  416. }
  417. #endregion
  418. #region DP Boosts
  419. foreach(DPBoost boost in Boosts)
  420. {
  421. DP += boost.DP;
  422. }
  423. #endregion
  424. DP += LinkedDP;
  425. if (DP < 0)
  426. {
  427. DP = 0;
  428. }
  429. }
  430. return DP;
  431. }
  432. }
  433. public int LinkedDP { get; set; }
  434. public List<DPBoost> Boosts = new List<DPBoost>();
  435. public void AddBoost(DPBoost boost)
  436. {
  437. if (Boosts.Any(x => x.ID == boost.ID))
  438. Boosts.First(x => x.ID == boost.ID).DP = boost.DP;
  439. else
  440. Boosts.Add(boost);
  441. }
  442. public void RemoveBoost(string ID)
  443. {
  444. if (Boosts.Any(x => x.ID == ID))
  445. Boosts.Remove(Boosts.First(x => x.ID == ID));
  446. }
  447. public class DPBoost
  448. {
  449. public DPBoost(string id, int dp, Func<bool> cond)
  450. {
  451. ID = id;
  452. DP = dp;
  453. Condition = cond;
  454. }
  455. public string ID = "";
  456. public int DP = 0;
  457. public Func<bool> Condition = null;
  458. }
  459. #endregion
  460. #region Will it not receive negative DP effect?
  461. public bool ImmuneFromDPMinus(ICardEffect cardEffect)
  462. {
  463. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  464. {
  465. foreach (Permanent permanent in player.GetFieldPermanents())
  466. {
  467. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  468. {
  469. if (cardEffect1 is IImmuneFromDPMinusEffect)
  470. {
  471. if (cardEffect1.CanUse(null))
  472. {
  473. if (((IImmuneFromDPMinusEffect)cardEffect1).ImmuneFromDPMinus(this, cardEffect))
  474. {
  475. return true;
  476. }
  477. }
  478. }
  479. }
  480. }
  481. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  482. {
  483. if (cardEffect1 is IImmuneFromDPMinusEffect)
  484. {
  485. if (cardEffect1.CanUse(null))
  486. {
  487. if (((IImmuneFromDPMinusEffect)cardEffect1).ImmuneFromDPMinus(this, cardEffect))
  488. {
  489. return true;
  490. }
  491. }
  492. }
  493. }
  494. }
  495. return false;
  496. }
  497. #endregion
  498. #region Can be returned to your hand?
  499. public bool CannotReturnToHand(ICardEffect cardEffect)
  500. {
  501. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  502. {
  503. foreach (Permanent permanent in player.GetFieldPermanents())
  504. {
  505. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  506. {
  507. if (cardEffect1 is ICannotReturnToHandEffect)
  508. {
  509. if (cardEffect1.CanUse(null))
  510. {
  511. if (((ICannotReturnToHandEffect)cardEffect1).CannotReturnToHand(this, cardEffect))
  512. {
  513. return true;
  514. }
  515. }
  516. }
  517. }
  518. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  519. {
  520. if (cardEffect1 is ICannotReturnToHandEffect)
  521. {
  522. if (cardEffect1.CanUse(null))
  523. {
  524. if (((ICannotReturnToHandEffect)cardEffect1).CannotReturnToHand(this, cardEffect))
  525. {
  526. return true;
  527. }
  528. }
  529. }
  530. }
  531. }
  532. }
  533. return false;
  534. }
  535. #endregion
  536. #region Can be returned to deck?
  537. public bool CannotReturnToLibrary(ICardEffect cardEffect)
  538. {
  539. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  540. {
  541. foreach (Permanent permanent in player.GetFieldPermanents())
  542. {
  543. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  544. {
  545. if (cardEffect1 is ICannotReturnToLibraryEffect)
  546. {
  547. if (cardEffect1.CanUse(null))
  548. {
  549. if (((ICannotReturnToLibraryEffect)cardEffect1).CannotReturnToLibrary(this, cardEffect))
  550. {
  551. return true;
  552. }
  553. }
  554. }
  555. }
  556. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  557. {
  558. if (cardEffect1 is ICannotReturnToLibraryEffect)
  559. {
  560. if (cardEffect1.CanUse(null))
  561. {
  562. if (((ICannotReturnToLibraryEffect)cardEffect1).CannotReturnToLibrary(this, cardEffect))
  563. {
  564. return true;
  565. }
  566. }
  567. }
  568. }
  569. }
  570. }
  571. return false;
  572. }
  573. #endregion
  574. #region Immune From De-Digivolve
  575. public bool ImmuneFromDeDigivolve()
  576. {
  577. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  578. {
  579. foreach (Permanent permanent in player.GetFieldPermanents())
  580. {
  581. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  582. {
  583. if (cardEffect1 is IImmuneFromDeDigivolveEffect)
  584. {
  585. if (cardEffect1.CanUse(null))
  586. {
  587. if (((IImmuneFromDeDigivolveEffect)cardEffect1).ImmuneDeDigivolve(this))
  588. {
  589. return true;
  590. }
  591. }
  592. }
  593. }
  594. }
  595. }
  596. return false;
  597. }
  598. #endregion
  599. #region Immune From Trashing Stack
  600. public bool ImmuneFromStackTrashing(ICardEffect effect)
  601. {
  602. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  603. {
  604. foreach (Permanent permanent in player.GetFieldPermanents())
  605. {
  606. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  607. {
  608. if (cardEffect1 is IImmuneFromStackTrashingEffect)
  609. {
  610. if (cardEffect1.CanUse(null))
  611. {
  612. if (((IImmuneFromStackTrashingEffect)cardEffect1).ImmuneStackTrashing(this, effect))
  613. {
  614. return true;
  615. }
  616. }
  617. }
  618. }
  619. }
  620. }
  621. return false;
  622. }
  623. #endregion
  624. #region Card Sources
  625. public List<CardSource> cardSources = new List<CardSource>();
  626. #endregion
  627. #region Stacked Cards
  628. public List<CardSource> StackCards => cardSources.Filter(cardSource => !LinkedCards.Contains(cardSource));
  629. #endregion
  630. #region Digivolution Cards
  631. public List<CardSource> DigivolutionCards => cardSources.Filter(cardSource => cardSource != TopCard && !LinkedCards.Contains(cardSource));
  632. #endregion
  633. #region Linked Cards
  634. public int LinkedMax
  635. {
  636. get
  637. {
  638. int Max = 1;
  639. #region Effect of changing the number of sheets to undergo security check
  640. List<ICardEffect> cardEffects_ChangeLinkedMax = new List<ICardEffect>();
  641. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  642. {
  643. foreach (Permanent permanent in player.GetFieldPermanents())
  644. {
  645. #region Effects of permanents in play
  646. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  647. {
  648. if (cardEffect is IChangeLinkMaxEffect)
  649. {
  650. if (((IChangeLinkMaxEffect)cardEffect).PermanentCondition(this))
  651. {
  652. if (cardEffect.CanUse(null))
  653. {
  654. if (!TopCard.CanNotBeAffected(cardEffect))
  655. {
  656. cardEffects_ChangeLinkedMax.Add(cardEffect);
  657. }
  658. }
  659. }
  660. }
  661. }
  662. #endregion
  663. }
  664. #region player effect
  665. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  666. {
  667. if (cardEffect is IChangeLinkMaxEffect)
  668. {
  669. if (((IChangeLinkMaxEffect)cardEffect).PermanentCondition(this))
  670. {
  671. if (cardEffect.CanUse(null))
  672. {
  673. if (!TopCard.CanNotBeAffected(cardEffect))
  674. {
  675. cardEffects_ChangeLinkedMax.Add(cardEffect);
  676. }
  677. }
  678. }
  679. }
  680. }
  681. #endregion
  682. }
  683. List<ICardEffect> cardEffects_ChangeLinkedMax_UpToConstant = new List<ICardEffect>();
  684. List<ICardEffect> cardEffects_ChangeLinkedMax_UpDownValue = new List<ICardEffect>();
  685. List<ICardEffect> cardEffects_ChangeLinkedMax_DownToConstant = new List<ICardEffect>();
  686. foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax)
  687. {
  688. if (cardEffect is IChangeLinkMaxEffect)
  689. {
  690. if (cardEffect.CanUse(null))
  691. {
  692. switch (((IChangeLinkMaxEffect)cardEffect).isUpDown())
  693. {
  694. case CalculateOrder.UpToConstant:
  695. cardEffects_ChangeLinkedMax_UpToConstant.Add(cardEffect);
  696. break;
  697. case CalculateOrder.UpDownValue:
  698. cardEffects_ChangeLinkedMax_UpDownValue.Add(cardEffect);
  699. break;
  700. case CalculateOrder.DownToConstant:
  701. cardEffects_ChangeLinkedMax_DownToConstant.Add(cardEffect);
  702. break;
  703. }
  704. }
  705. }
  706. }
  707. foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax_UpToConstant)
  708. {
  709. if (cardEffect is IChangeLinkMaxEffect)
  710. {
  711. if (cardEffect.CanUse(null))
  712. {
  713. Max = ((IChangeLinkMaxEffect)cardEffect).GetLinkMax(Max, this, InvertSecutiryValue);
  714. }
  715. }
  716. }
  717. foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax_UpDownValue)
  718. {
  719. if (cardEffect is IChangeLinkMaxEffect)
  720. {
  721. if (cardEffect.CanUse(null))
  722. {
  723. Max = ((IChangeLinkMaxEffect)cardEffect).GetLinkMax(Max, this, InvertSecutiryValue);
  724. }
  725. }
  726. }
  727. foreach (ICardEffect cardEffect in cardEffects_ChangeLinkedMax_DownToConstant)
  728. {
  729. if (cardEffect is IChangeLinkMaxEffect)
  730. {
  731. if (cardEffect.CanUse(null))
  732. {
  733. Max = ((IChangeLinkMaxEffect)cardEffect).GetLinkMax(Max, this, InvertSecutiryValue);
  734. }
  735. }
  736. }
  737. #endregion
  738. return Max;
  739. }
  740. }
  741. public List<CardSource> LinkedCards = new List<CardSource>();
  742. #endregion
  743. #region Add Card Source
  744. public void AddCardSource(CardSource cardSource)
  745. {
  746. cardSources.Insert(0, cardSource);
  747. if (!cardSource.IsFlipped)
  748. cardSource.SetFace("Permanent.AddSourceCard");
  749. else
  750. cardSource.SetReverse();
  751. }
  752. #endregion
  753. #region Add digivolution cards to top of sources
  754. /// <summary>
  755. /// IEnumerator to add a list of CardSource to a permanents top sources, CAN NOT be used to put a field permanent under must use IPlacePermanentToDigivolutionCards
  756. /// </summary>
  757. /// <param name="addedDigivolutionCards"></param>
  758. /// <param name="cardEffect"></param>
  759. /// <param name="skipEffectAndActivateSkill"></param>
  760. /// <returns></returns>
  761. public IEnumerator AddDigivolutionCardsTop(List<CardSource> addedDigivolutionCards, ICardEffect cardEffect)
  762. {
  763. List<CardSource> addedCards = new List<CardSource>();
  764. bool isFromSameDigimon = false;
  765. bool isFromDigimon = false;
  766. foreach (CardSource addedDigivolutionCard in addedDigivolutionCards)
  767. {
  768. if (cardSources.Contains(addedDigivolutionCard))
  769. {
  770. isFromSameDigimon = true;
  771. }
  772. if (CardEffectCommons.IsExistOnBattleArea(addedDigivolutionCard))
  773. {
  774. if (addedDigivolutionCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  775. {
  776. isFromDigimon = true;
  777. }
  778. }
  779. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  780. if (!this.IsToken && !addedDigivolutionCard.IsToken)
  781. {
  782. this.cardSources.Insert(1, addedDigivolutionCard);
  783. if (!addedDigivolutionCard.IsFlipped || addedDigivolutionCard.IsBeingRevealed || GManager.instance.turnStateMachine.gameContext.IsSecurityLooking)
  784. addedDigivolutionCard.SetFace("Permanent.AddDigivolutionCardsTop");
  785. addedCards.Add(addedDigivolutionCard);
  786. }
  787. }
  788. if (addedCards.Count >= 1)
  789. {
  790. if (ShowingPermanentCard != null)
  791. {
  792. yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
  793. }
  794. #region "進化元が増えた時"の効果
  795. #region Hashtable Setting
  796. Hashtable hashtable = new Hashtable()
  797. {
  798. {"Permanent", this},
  799. {"CardEffect", cardEffect},
  800. {"CardSources", addedCards},
  801. {"isFromSameDigimon", isFromSameDigimon},
  802. {"isFromDigimon", isFromDigimon},
  803. };
  804. #endregion
  805. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.OnAddDigivolutionCards));
  806. #endregion
  807. }
  808. }
  809. #endregion
  810. #region Add digivolution cards to bottom of sources
  811. /// <summary>
  812. /// IEnumerator to add a list of CardSource to a permanents bottom sources, CAN NOT be used to put a field permanent under must use IPlacePermanentToDigivolutionCards
  813. /// </summary>
  814. /// <param name="addedDigivolutionCards"></param>
  815. /// <param name="cardEffect"></param>
  816. /// <param name="skipEffectAndActivateSkill"></param>
  817. /// <returns></returns>
  818. public IEnumerator AddDigivolutionCardsBottom(List<CardSource> addedDigivolutionCards, ICardEffect cardEffect, bool skipEffectAndActivateSkill = false, bool isFacedown = false)
  819. {
  820. List<CardSource> addedCards = new List<CardSource>();
  821. bool isFromSameDigimon = false;
  822. bool isFromDigimon = false;
  823. foreach (CardSource addedDigivolutionCard in addedDigivolutionCards)
  824. {
  825. if (addedDigivolutionCard.PermanentOfThisCard() != null)
  826. {
  827. if (addedDigivolutionCard.PermanentOfThisCard() != this)
  828. {
  829. if (addedDigivolutionCard.PermanentOfThisCard().TopCard == addedDigivolutionCard)
  830. {
  831. IPlacePermanentToDigivolutionCards placePermanent = new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { addedDigivolutionCard.PermanentOfThisCard(), this } }, false, cardEffect, skipEffectAndActivateSkill);
  832. yield return ContinuousController.instance.StartCoroutine(placePermanent.PlacePermanentToDigivolutionCards());
  833. if (!placePermanent.Placed)
  834. {
  835. continue;
  836. }
  837. }
  838. }
  839. }
  840. if (CardEffectCommons.IsExistOnBattleArea(addedDigivolutionCard))
  841. {
  842. if (addedDigivolutionCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  843. {
  844. isFromDigimon = true;
  845. }
  846. }
  847. if (cardSources.Contains(addedDigivolutionCard))
  848. {
  849. isFromSameDigimon = true;
  850. if (addedDigivolutionCard == TopCard)
  851. {
  852. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  853. ShowingPermanentCard.ShowPermanentData(true);
  854. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(
  855. addedDigivolutionCard,
  856. this));
  857. }
  858. }
  859. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedDigivolutionCard));
  860. if (!IsToken && !addedDigivolutionCard.IsToken)
  861. {
  862. cardSources.Add(addedDigivolutionCard);
  863. if (isFacedown)
  864. addedDigivolutionCard.SetReverse();
  865. else
  866. addedDigivolutionCard.SetFace("Permanent.AddDigivolutionCardsBottom");
  867. addedCards.Add(addedDigivolutionCard);
  868. }
  869. }
  870. if (addedCards.Count >= 1 && !skipEffectAndActivateSkill)
  871. {
  872. if (ShowingPermanentCard != null)
  873. {
  874. yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
  875. }
  876. #region Effect of "when the number of evolution sources increases"
  877. #region Hashtable Setting
  878. Hashtable hashtable = new Hashtable()
  879. {
  880. {"Permanent", this},
  881. {"CardEffect", cardEffect},
  882. {"CardSources", addedCards},
  883. {"isFromSameDigimon", isFromSameDigimon},
  884. {"isFromDigimon", isFromDigimon},
  885. };
  886. #endregion
  887. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.OnAddDigivolutionCards));
  888. #endregion
  889. }
  890. }
  891. #endregion
  892. #region Add Link cards
  893. /// <summary>
  894. /// IEnumerator to add a list of CardSource to a permanents top sources, CAN NOT be used to put a field permanent under must use IPlacePermanentToLinkCards
  895. /// </summary>
  896. /// <param name="addedLinkCards"></param>
  897. /// <param name="cardEffect"></param>
  898. /// <param name="skipEffectAndActivateSkill"></param>
  899. /// <returns></returns>
  900. public IEnumerator AddLinkCard(CardSource addedLinkCard, ICardEffect cardEffect)
  901. {
  902. bool addedCard = false;
  903. bool isFromDigimon = false;
  904. if (CardEffectCommons.IsExistOnBattleArea(addedLinkCard))
  905. {
  906. if (addedLinkCard.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  907. {
  908. isFromDigimon = true;
  909. }
  910. }
  911. if (LinkedCards.Count >= LinkedMax)
  912. {
  913. if(LinkedMax > 1)
  914. yield return ContinuousController.instance.StartCoroutine(RemoveLinkedCard(null,((LinkedCards.Count + 1) - LinkedMax)));
  915. else
  916. yield return ContinuousController.instance.StartCoroutine(RemoveLinkedCard(LinkedCards[0]));
  917. }
  918. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedLinkCard));
  919. if (!this.IsToken && !addedLinkCard.IsToken)
  920. {
  921. LinkedCards.Insert(0, addedLinkCard);
  922. LinkedDP += addedLinkCard.LinkDP;
  923. this.cardSources.Insert(1, addedLinkCard);
  924. addedLinkCard.SetFace("Permanent.AddLinkCard");
  925. addedCard = true;
  926. }
  927. if (addedCard)
  928. {
  929. if (ShowingPermanentCard != null)
  930. {
  931. yield return ContinuousController.instance.StartCoroutine(ShowingPermanentCard.ShowAddDigivolutionCardEffect());
  932. }
  933. #region Add Linked Card
  934. #region Hashtable Setting
  935. Hashtable hashtable = new Hashtable()
  936. {
  937. {"Permanent", this},
  938. {"CardEffect", cardEffect},
  939. {"Card", addedLinkCard},
  940. {"isFromDigimon", isFromDigimon},
  941. };
  942. #endregion
  943. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.WhenLinked));
  944. #endregion
  945. }
  946. }
  947. #endregion
  948. #region RemoveCardSource
  949. public IEnumerator RemoveCardSource(CardSource cardSource)
  950. {
  951. yield return null;
  952. cardSources.Remove(cardSource);
  953. }
  954. #endregion
  955. #region Remove Linked Card
  956. public IEnumerator RemoveLinkedCard(CardSource cardSource, int removeCount = 0, bool trashCard = true)
  957. {
  958. if (LinkedCards.Contains(cardSource))
  959. {
  960. LinkedDP -= cardSource.LinkDP;
  961. LinkedCards.Remove(cardSource);
  962. if (trashCard)
  963. {
  964. yield return ContinuousController.instance.StartCoroutine(RemoveCardSource(cardSource));
  965. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddTrashCard(cardSource));
  966. }
  967. }
  968. if(removeCount > 0)
  969. {
  970. int maxCount = Mathf.Min(removeCount, LinkedCards.Count);
  971. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  972. selectCardEffect.SetUp(
  973. canTargetCondition: (CardSource) => true,
  974. canTargetCondition_ByPreSelecetedList: null,
  975. canEndSelectCondition: null,
  976. canNoSelect: () => false,
  977. selectCardCoroutine: null,
  978. afterSelectCardCoroutine: null,
  979. message: $"Select {maxCount} card to trash.",
  980. maxCount: removeCount,
  981. canEndNotMax: false,
  982. isShowOpponent: true,
  983. mode: SelectCardEffect.Mode.Discard,
  984. root: SelectCardEffect.Root.Custom,
  985. customRootCardList: LinkedCards,
  986. canLookReverseCard: true,
  987. selectPlayer: TopCard.Owner,
  988. cardEffect: null);
  989. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  990. }
  991. //TODO: Add event call if something was removed
  992. }
  993. #endregion
  994. #region Top Card
  995. public CardSource TopCard
  996. {
  997. get
  998. {
  999. if (cardSources.Count >= 1)
  1000. {
  1001. if (LinkedCards.Count > 0)
  1002. return cardSources.First(source => !LinkedCards.Contains(source));
  1003. else
  1004. return cardSources[0];
  1005. }
  1006. return null;
  1007. }
  1008. }
  1009. #endregion
  1010. #region Permanent effect list
  1011. #region このパーマネントの効果リスト
  1012. public List<ICardEffect> EffectList(EffectTiming timing)
  1013. {
  1014. return EffectList_ForCard(timing, TopCard);
  1015. }
  1016. #endregion
  1017. #region このポケモンの追加効果リスト
  1018. public List<ICardEffect> EffectList_Added(EffectTiming timing)
  1019. {
  1020. List<ICardEffect> _EffectList = new List<ICardEffect>();
  1021. if (TopCard != null)
  1022. {
  1023. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerDrawPhaseEffects)
  1024. {
  1025. ICardEffect cardEffect = GetCardEffect(timing);
  1026. if (cardEffect != null)
  1027. {
  1028. _EffectList.Add(cardEffect);
  1029. }
  1030. }
  1031. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerTurnEndEffects)
  1032. {
  1033. ICardEffect cardEffect = GetCardEffect(timing);
  1034. if (cardEffect != null)
  1035. {
  1036. _EffectList.Add(cardEffect);
  1037. }
  1038. }
  1039. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEachTurnEndEffects)
  1040. {
  1041. ICardEffect cardEffect = GetCardEffect(timing);
  1042. if (cardEffect != null)
  1043. {
  1044. _EffectList.Add(cardEffect);
  1045. }
  1046. }
  1047. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOpponentTurnEndEffects)
  1048. {
  1049. ICardEffect cardEffect = GetCardEffect(timing);
  1050. if (cardEffect != null)
  1051. {
  1052. _EffectList.Add(cardEffect);
  1053. }
  1054. }
  1055. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEndBattleEffects)
  1056. {
  1057. ICardEffect cardEffect = GetCardEffect(timing);
  1058. if (cardEffect != null)
  1059. {
  1060. _EffectList.Add(cardEffect);
  1061. }
  1062. }
  1063. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerTurnStartEffects)
  1064. {
  1065. ICardEffect cardEffect = GetCardEffect(timing);
  1066. if (cardEffect != null)
  1067. {
  1068. _EffectList.Add(cardEffect);
  1069. }
  1070. }
  1071. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilNextUntapEffects)
  1072. {
  1073. ICardEffect cardEffect = GetCardEffect(timing);
  1074. if (cardEffect != null)
  1075. {
  1076. _EffectList.Add(cardEffect);
  1077. }
  1078. }
  1079. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in PermanentEffects)
  1080. {
  1081. ICardEffect cardEffect = GetCardEffect(timing);
  1082. if (cardEffect != null)
  1083. {
  1084. _EffectList.Add(cardEffect);
  1085. }
  1086. }
  1087. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEndAttackEffects)
  1088. {
  1089. ICardEffect cardEffect = GetCardEffect(timing);
  1090. if (cardEffect != null)
  1091. {
  1092. _EffectList.Add(cardEffect);
  1093. }
  1094. }
  1095. _EffectList = _EffectList.Filter(cardEffect => cardEffect != null);
  1096. foreach (ICardEffect cardEffect in _EffectList)
  1097. {
  1098. if (cardEffect != null)
  1099. {
  1100. if (cardEffect.EffectSourceCard == null)
  1101. {
  1102. cardEffect.SetEffectSourceCard(TopCard);
  1103. }
  1104. cardEffect.SetIsInheritedEffect(false);
  1105. }
  1106. }
  1107. }
  1108. return _EffectList;
  1109. }
  1110. #endregion
  1111. #region このパーマネントの効果リスト(引数:CardSource)
  1112. public List<ICardEffect> EffectList_ForCard(EffectTiming timing, CardSource _cardSource)
  1113. {
  1114. List<ICardEffect> _EffectList = new List<ICardEffect>();
  1115. if (TopCard != null && _cardSource != null)
  1116. {
  1117. foreach (CardSource cardSource in cardSources)
  1118. {
  1119. if (cardSource != null)
  1120. {
  1121. if (!cardSource.IsFlipped)
  1122. {
  1123. bool isTopCard = cardSource == TopCard;
  1124. if (!isTopCard)
  1125. {
  1126. if (!IsDigimon)
  1127. {
  1128. continue;
  1129. }
  1130. }
  1131. foreach (ICardEffect cardEffect in cardSource.cEntity_EffectController.GetCardEffects(timing, cardSource))
  1132. {
  1133. if (cardEffect != null)
  1134. {
  1135. if (cardEffect.IsInheritedEffect && !isTopCard)
  1136. {
  1137. _EffectList.Add(cardEffect);
  1138. continue;
  1139. }
  1140. if (cardEffect.IsLinkedEffect && cardSource.IsLinked)
  1141. {
  1142. _EffectList.Add(cardEffect);
  1143. continue;
  1144. }
  1145. if(isTopCard && !cardEffect.IsInheritedEffect && !cardEffect.IsLinkedEffect)
  1146. {
  1147. _EffectList.Add(cardEffect);
  1148. }
  1149. }
  1150. }
  1151. }
  1152. }
  1153. }
  1154. foreach (ICardEffect cardEffect in EffectList_Added(timing))
  1155. {
  1156. if (cardEffect != null)
  1157. {
  1158. _EffectList.Add(cardEffect);
  1159. }
  1160. }
  1161. foreach (ICardEffect cardEffect in _EffectList)
  1162. {
  1163. if (cardEffect != null)
  1164. {
  1165. if (cardEffect.EffectSourceCard == null)
  1166. {
  1167. cardEffect.SetEffectSourceCard(_cardSource);
  1168. }
  1169. }
  1170. }
  1171. }
  1172. return _EffectList;
  1173. }
  1174. #endregion
  1175. #region 自分のターン終了時に消える効果
  1176. public List<Func<EffectTiming, ICardEffect>> UntilOwnerTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  1177. #endregion
  1178. #region 自分のドローフェイズ終了時に消える効果
  1179. public List<Func<EffectTiming, ICardEffect>> UntilOwnerDrawPhaseEffects = new List<Func<EffectTiming, ICardEffect>>();
  1180. #endregion
  1181. #region お互いのターン終了時に消える効果
  1182. public List<Func<EffectTiming, ICardEffect>> UntilEachTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  1183. #endregion
  1184. #region 相手のターン終了時に消える効果
  1185. public List<Func<EffectTiming, ICardEffect>> UntilOpponentTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  1186. #endregion
  1187. #region バトル終了時に消える効果
  1188. public List<Func<EffectTiming, ICardEffect>> UntilEndBattleEffects = new List<Func<EffectTiming, ICardEffect>>();
  1189. #endregion
  1190. #region 攻撃終了時に消える効果
  1191. public List<Func<EffectTiming, ICardEffect>> UntilEndAttackEffects = new List<Func<EffectTiming, ICardEffect>>();
  1192. #endregion
  1193. #region 自分のターン開始時に消える効果
  1194. public List<Func<EffectTiming, ICardEffect>> UntilOwnerTurnStartEffects = new List<Func<EffectTiming, ICardEffect>>();
  1195. #endregion
  1196. #region 次にアンタップする時に消える効果
  1197. public List<Func<EffectTiming, ICardEffect>> UntilNextUntapEffects = new List<Func<EffectTiming, ICardEffect>>();
  1198. #endregion
  1199. #region 場を離れるまで残る効果
  1200. public List<Func<EffectTiming, ICardEffect>> PermanentEffects = new List<Func<EffectTiming, ICardEffect>>();
  1201. #endregion
  1202. #endregion
  1203. #region 起動型効果を宣言できるか
  1204. public bool CanDeclareSkill() => CanDeclareSkillList().Count > 0;
  1205. #endregion
  1206. #region 宣言可能な起動型効果リスト
  1207. public List<ICardEffect> CanDeclareSkillList()
  1208. {
  1209. List<ICardEffect> CanDeclareSkillList = new List<ICardEffect>();
  1210. if (TopCard != null)
  1211. {
  1212. foreach (ICardEffect _cardEffect in EffectList(EffectTiming.OnDeclaration))
  1213. {
  1214. if (_cardEffect is ActivateICardEffect)
  1215. {
  1216. if (_cardEffect.CanUse(null))
  1217. {
  1218. CanDeclareSkillList.Add(_cardEffect);
  1219. }
  1220. }
  1221. }
  1222. }
  1223. return CanDeclareSkillList;
  1224. }
  1225. #endregion
  1226. #region このパーマネントが場に出たターン
  1227. public int EnterFieldTurnCount { get; set; } = -1;
  1228. #endregion
  1229. #region このパーマネントを表す場のオブジェクト
  1230. public FieldPermanentCard ShowingPermanentCard { get; set; }
  1231. #endregion
  1232. #region Whether this permanent can be selected by the effect
  1233. public bool CanSelectBySkill(ICardEffect skill)
  1234. {
  1235. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1236. {
  1237. #region Effects of field permanents
  1238. foreach (Permanent permanent in player.GetFieldPermanents())
  1239. {
  1240. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1241. {
  1242. if (cardEffect is ICanNotSelectBySkillEffect)
  1243. {
  1244. if (cardEffect.CanUse(null))
  1245. {
  1246. if (((ICanNotSelectBySkillEffect)cardEffect).CanNotSelectBySkill(this, skill))
  1247. {
  1248. return false;
  1249. }
  1250. }
  1251. }
  1252. }
  1253. }
  1254. #endregion
  1255. }
  1256. return true;
  1257. }
  1258. #endregion
  1259. #region Number of sheets to undergo security check
  1260. public int InvertSecutiryValue
  1261. {
  1262. get
  1263. {
  1264. int Invert = 0;
  1265. List<ICardEffect> cardEffects_InvertStrike = new List<ICardEffect>();
  1266. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1267. {
  1268. foreach (Permanent permanent in player.GetFieldPermanents())
  1269. {
  1270. #region Effects of permanents in play
  1271. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1272. {
  1273. if (cardEffect is IInvertSAttackEffect)
  1274. {
  1275. if (cardEffect.CanUse(null))
  1276. {
  1277. if (!TopCard.CanNotBeAffected(cardEffect))
  1278. {
  1279. cardEffects_InvertStrike.Add(cardEffect);
  1280. }
  1281. }
  1282. }
  1283. }
  1284. #endregion
  1285. }
  1286. #region player effect
  1287. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1288. {
  1289. if (cardEffect is IInvertSAttackEffect)
  1290. {
  1291. if (cardEffect.CanUse(null))
  1292. {
  1293. if (!TopCard.CanNotBeAffected(cardEffect))
  1294. {
  1295. cardEffects_InvertStrike.Add(cardEffect);
  1296. }
  1297. }
  1298. }
  1299. }
  1300. #endregion
  1301. }
  1302. foreach (ICardEffect cardEffect in cardEffects_InvertStrike)
  1303. {
  1304. Invert = ((IInvertSAttackEffect)cardEffect).InversionValue(this, Invert);
  1305. }
  1306. return Mathf.Clamp(Invert,-1,1);
  1307. }
  1308. }
  1309. public List<int> SecurityAttackChanges
  1310. {
  1311. get
  1312. {
  1313. List<int> SecurityAttackChanges = new List<int>();
  1314. int Strike = 1;
  1315. List<ICardEffect> cardEffects_ChangeDirectStrike = new List<ICardEffect>();
  1316. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1317. {
  1318. foreach (Permanent permanent in player.GetFieldPermanents())
  1319. {
  1320. #region 場のパーマネントの効果
  1321. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1322. {
  1323. if (cardEffect is IChangeSAttackEffect)
  1324. {
  1325. if (cardEffect.CanUse(null))
  1326. {
  1327. if (!TopCard.CanNotBeAffected(cardEffect))
  1328. {
  1329. if (((IChangeSAttackEffect)cardEffect).isUpDown() == CalculateOrder.UpDownValue)
  1330. {
  1331. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1332. }
  1333. }
  1334. }
  1335. }
  1336. }
  1337. #endregion
  1338. }
  1339. #region プレイヤーの効果
  1340. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1341. {
  1342. if (cardEffect is IChangeSAttackEffect)
  1343. {
  1344. if (cardEffect.CanUse(null))
  1345. {
  1346. if (!TopCard.CanNotBeAffected(cardEffect))
  1347. {
  1348. if (((IChangeSAttackEffect)cardEffect).isUpDown() == CalculateOrder.UpDownValue)
  1349. {
  1350. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1351. }
  1352. }
  1353. }
  1354. }
  1355. }
  1356. #endregion
  1357. }
  1358. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike)
  1359. {
  1360. if (cardEffect is IChangeSAttackEffect)
  1361. {
  1362. if (cardEffect.CanUse(null))
  1363. {
  1364. int Strike1 = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, 0);
  1365. if (Strike1 != Strike)
  1366. {
  1367. SecurityAttackChanges.Add(Strike1 - Strike);
  1368. }
  1369. }
  1370. }
  1371. }
  1372. return SecurityAttackChanges;
  1373. }
  1374. }
  1375. public bool HasSecurityAttackChanges
  1376. {
  1377. get
  1378. {
  1379. if (!IsDigimon)
  1380. {
  1381. return false;
  1382. }
  1383. return SecurityAttackChanges.Count >= 1;
  1384. }
  1385. }
  1386. public int Strike_AllowMinus
  1387. {
  1388. get
  1389. {
  1390. int Strike = 1;
  1391. #region Effect of changing the number of sheets to undergo security check
  1392. List<ICardEffect> cardEffects_ChangeDirectStrike = new List<ICardEffect>();
  1393. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1394. {
  1395. foreach (Permanent permanent in player.GetFieldPermanents())
  1396. {
  1397. #region Effects of permanents in play
  1398. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1399. {
  1400. if (cardEffect is IChangeSAttackEffect)
  1401. {
  1402. if (((IChangeSAttackEffect)cardEffect).PermanentCondition(this))
  1403. {
  1404. if (cardEffect.CanUse(null))
  1405. {
  1406. if (!TopCard.CanNotBeAffected(cardEffect))
  1407. {
  1408. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1409. }
  1410. }
  1411. }
  1412. }
  1413. }
  1414. #endregion
  1415. }
  1416. #region player effect
  1417. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1418. {
  1419. if (cardEffect is IChangeSAttackEffect)
  1420. {
  1421. if (((IChangeSAttackEffect)cardEffect).PermanentCondition(this))
  1422. {
  1423. if (cardEffect.CanUse(null))
  1424. {
  1425. if (!TopCard.CanNotBeAffected(cardEffect))
  1426. {
  1427. cardEffects_ChangeDirectStrike.Add(cardEffect);
  1428. }
  1429. }
  1430. }
  1431. }
  1432. }
  1433. #endregion
  1434. }
  1435. List<ICardEffect> cardEffects_ChangeDirectStrike_UpToConstant = new List<ICardEffect>();
  1436. List<ICardEffect> cardEffects_ChangeDirectStrike_UpDownValue = new List<ICardEffect>();
  1437. List<ICardEffect> cardEffects_ChangeDirectStrike_DownToConstant = new List<ICardEffect>();
  1438. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike)
  1439. {
  1440. if (cardEffect is IChangeSAttackEffect)
  1441. {
  1442. if (cardEffect.CanUse(null))
  1443. {
  1444. switch (((IChangeSAttackEffect)cardEffect).isUpDown())
  1445. {
  1446. case CalculateOrder.UpToConstant:
  1447. cardEffects_ChangeDirectStrike_UpToConstant.Add(cardEffect);
  1448. break;
  1449. case CalculateOrder.UpDownValue:
  1450. cardEffects_ChangeDirectStrike_UpDownValue.Add(cardEffect);
  1451. break;
  1452. case CalculateOrder.DownToConstant:
  1453. cardEffects_ChangeDirectStrike_DownToConstant.Add(cardEffect);
  1454. break;
  1455. }
  1456. }
  1457. }
  1458. }
  1459. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_UpToConstant)
  1460. {
  1461. if (cardEffect is IChangeSAttackEffect)
  1462. {
  1463. if (cardEffect.CanUse(null))
  1464. {
  1465. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
  1466. }
  1467. }
  1468. }
  1469. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_UpDownValue)
  1470. {
  1471. if (cardEffect is IChangeSAttackEffect)
  1472. {
  1473. if (cardEffect.CanUse(null))
  1474. {
  1475. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
  1476. }
  1477. }
  1478. }
  1479. foreach (ICardEffect cardEffect in cardEffects_ChangeDirectStrike_DownToConstant)
  1480. {
  1481. if (cardEffect is IChangeSAttackEffect)
  1482. {
  1483. if (cardEffect.CanUse(null))
  1484. {
  1485. Strike = ((IChangeSAttackEffect)cardEffect).GetSAttack(Strike, this, InvertSecutiryValue);
  1486. }
  1487. }
  1488. }
  1489. #endregion
  1490. return Strike;
  1491. }
  1492. }
  1493. public int Strike
  1494. {
  1495. get
  1496. {
  1497. int Strike = Strike_AllowMinus;
  1498. if (Strike < 0)
  1499. {
  1500. Strike = 0;
  1501. }
  1502. return Strike;
  1503. }
  1504. }
  1505. #endregion
  1506. #region このパーマネントがタップされているかどうか
  1507. public bool OldIsSuspended = false;
  1508. public bool IsSuspended = false;
  1509. public int DPWhenSuspended = 114514;
  1510. #endregion
  1511. #region Whether this permanent can unsuspend
  1512. public bool CanUnsuspend
  1513. {
  1514. get
  1515. {
  1516. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1517. {
  1518. #region Effects of field permanents
  1519. foreach (Permanent permanent in player.GetFieldPermanents())
  1520. {
  1521. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1522. {
  1523. if (cardEffect is ICanNotUnsuspendEffect)
  1524. {
  1525. if (cardEffect.CanUse(null))
  1526. {
  1527. if (((ICanNotUnsuspendEffect)cardEffect).CanNotUnsuspend(this))
  1528. {
  1529. return false;
  1530. }
  1531. }
  1532. }
  1533. }
  1534. }
  1535. #endregion
  1536. #region Effects of players
  1537. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1538. {
  1539. if (cardEffect is ICanNotUnsuspendEffect)
  1540. {
  1541. if (cardEffect.CanUse(null))
  1542. {
  1543. if (((ICanNotUnsuspendEffect)cardEffect).CanNotUnsuspend(this))
  1544. {
  1545. return false;
  1546. }
  1547. }
  1548. }
  1549. }
  1550. #endregion
  1551. }
  1552. return true;
  1553. }
  1554. }
  1555. #endregion
  1556. #region このパーマネントが移動できるかどうか
  1557. public bool CanMove
  1558. {
  1559. get
  1560. {
  1561. if (TopCard != null)
  1562. {
  1563. #region the effects of permanents
  1564. if (GManager.instance.turnStateMachine.gameContext.Players
  1565. .Map(player => player.GetFieldPermanents())
  1566. .Flat()
  1567. .Map(permanent => permanent.EffectList(EffectTiming.None))
  1568. .Flat()
  1569. .Some(cardEffect => cardEffect is ICanNotMoveEffect
  1570. && cardEffect.CanUse(null)
  1571. && ((ICanNotMoveEffect)cardEffect).CanNotMove(TopCard, null)))
  1572. {
  1573. return false;
  1574. }
  1575. #endregion
  1576. #region the effects of players
  1577. if (GManager.instance.turnStateMachine.gameContext.Players
  1578. .Map(player => player.EffectList(EffectTiming.None))
  1579. .Flat()
  1580. .Some(cardEffect => cardEffect is ICanNotMoveEffect
  1581. && cardEffect.CanUse(null)
  1582. && ((ICanNotMoveEffect)cardEffect).CanNotMove(TopCard, null)))
  1583. {
  1584. return false;
  1585. }
  1586. #endregion
  1587. #region the effects of itself
  1588. if (this == null)
  1589. {
  1590. if (EffectList(EffectTiming.None)
  1591. .Some(cardEffect => cardEffect is ICanNotMoveEffect
  1592. && cardEffect.CanUse(null)
  1593. && ((ICanNotMoveEffect)cardEffect).CanNotMove(TopCard, null)))
  1594. {
  1595. return false;
  1596. }
  1597. }
  1598. #endregion
  1599. if (TopCard.PermanentOfThisCard().PermanentFrame.isBreedingAreaFrame())
  1600. {
  1601. if (!TopCard.Owner.GetBreedingAreaPermanents().Contains(this))
  1602. {
  1603. return false;
  1604. }
  1605. }
  1606. else
  1607. {
  1608. if (TopCard.Owner.GetBreedingAreaPermanents().Count > 0)
  1609. return false;
  1610. }
  1611. if (!IsDigimon)
  1612. return false;
  1613. if (TopCard.IsDigiEgg && DP <= 0)
  1614. return false;
  1615. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame()) == 0)
  1616. {
  1617. return false;
  1618. }
  1619. }
  1620. else
  1621. {
  1622. return false;
  1623. }
  1624. return true;
  1625. }
  1626. }
  1627. #endregion
  1628. #region このパーマネントが攻撃できるかどうか
  1629. public bool CanAttack(ICardEffect cardEffect, bool withoutTap = false, bool isVortex = false)
  1630. {
  1631. // can not attack with empty cards
  1632. if (TopCard == null)
  1633. {
  1634. return false;
  1635. }
  1636. // can not attack during opponent's turn
  1637. if (TopCard.Owner != GManager.instance.turnStateMachine.gameContext.TurnPlayer)
  1638. {
  1639. return false;
  1640. }
  1641. //Can not attack during another attack
  1642. if (GManager.instance.attackProcess.IsAttacking)
  1643. return false;
  1644. // can not attack to player
  1645. if (!CanAttackTargetDigimon(null, cardEffect, withoutTap, isVortex))
  1646. {
  1647. // can not attack to opponent's Digimon
  1648. if (TopCard.Owner.Enemy.GetFieldPermanents().Count((permanent) => CanAttackTargetDigimon(permanent, cardEffect, withoutTap, isVortex)) == 0)
  1649. {
  1650. return false;
  1651. }
  1652. }
  1653. return true;
  1654. }
  1655. #endregion
  1656. #region このパーマネントが対象の攻撃パーマネントをブロックできるかどうか
  1657. public bool CanBlock(Permanent AttackingPermanent)
  1658. {
  1659. if (TopCard == null)
  1660. {
  1661. return false;
  1662. }
  1663. if (!IsDigimon)
  1664. {
  1665. return false;
  1666. }
  1667. if (IsSuspended)
  1668. {
  1669. return false;
  1670. }
  1671. if (!CanSuspend)
  1672. {
  1673. return false;
  1674. }
  1675. if (PermanentFrame != null)
  1676. {
  1677. if (!PermanentFrame.IsBattleAreaFrame())
  1678. {
  1679. return false;
  1680. }
  1681. }
  1682. if (!AttackingPermanent.IsDigimon)
  1683. return false;
  1684. if (!AttackingPermanent.CanSwitchAttackTarget)
  1685. return false;
  1686. #region "Unblockable" effect
  1687. #region Effects of permanents in play
  1688. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1689. {
  1690. foreach (Permanent permanent in player.GetFieldPermanents())
  1691. {
  1692. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1693. {
  1694. if (cardEffect is ICannotBlockEffect)
  1695. {
  1696. if (cardEffect.CanUse(null))
  1697. {
  1698. if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
  1699. {
  1700. return false;
  1701. }
  1702. }
  1703. }
  1704. }
  1705. }
  1706. }
  1707. #endregion
  1708. #region player effect
  1709. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1710. {
  1711. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1712. {
  1713. if (cardEffect is ICannotBlockEffect)
  1714. {
  1715. if (cardEffect.CanUse(null))
  1716. {
  1717. if (((ICannotBlockEffect)cardEffect).CannotBlock(AttackingPermanent, this))
  1718. {
  1719. if (!TopCard.CanNotBeAffected(cardEffect))
  1720. {
  1721. return false;
  1722. }
  1723. }
  1724. }
  1725. }
  1726. }
  1727. }
  1728. #endregion
  1729. #endregion
  1730. return true;
  1731. }
  1732. #endregion
  1733. #region 対象のパーマネントを攻撃できるか
  1734. public bool CanAttackTargetDigimon(Permanent Defender, ICardEffect cardEffect, bool withoutTap = false, bool isVortex = false)
  1735. {
  1736. if (TopCard != null)
  1737. {
  1738. if (!IsDigimon)
  1739. {
  1740. return false;
  1741. }
  1742. if (!withoutTap)
  1743. {
  1744. if (IsSuspended)
  1745. {
  1746. return false;
  1747. }
  1748. if (!CanSuspend)
  1749. {
  1750. return false;
  1751. }
  1752. }
  1753. if (PermanentFrame != null)
  1754. {
  1755. if (!PermanentFrame.IsBattleAreaFrame())
  1756. {
  1757. return false;
  1758. }
  1759. }
  1760. if (EnterFieldTurnCount == GManager.instance.turnStateMachine.TurnCount)
  1761. {
  1762. if (!HasRush && !isVortex)
  1763. {
  1764. return false;
  1765. }
  1766. }
  1767. #region 「対象の防御パーマネントを攻撃できない」効果
  1768. #region 場のパーマネントの効果
  1769. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1770. {
  1771. foreach (Permanent permanent in player.GetFieldPermanents())
  1772. {
  1773. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1774. {
  1775. if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
  1776. {
  1777. if (cardEffect1.CanUse(null))
  1778. {
  1779. if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
  1780. {
  1781. if (!TopCard.CanNotBeAffected(cardEffect1))
  1782. {
  1783. return false;
  1784. }
  1785. }
  1786. }
  1787. }
  1788. }
  1789. }
  1790. }
  1791. #endregion
  1792. #region プレイヤーの効果
  1793. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1794. {
  1795. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1796. {
  1797. if (cardEffect1 is ICanNotAttackTargetDefendingPermanentEffect)
  1798. {
  1799. if (cardEffect1.CanUse(null))
  1800. {
  1801. if (((ICanNotAttackTargetDefendingPermanentEffect)cardEffect1).CanNotAttackTargetDefendingPermanent(this, Defender))
  1802. {
  1803. if (!TopCard.CanNotBeAffected(cardEffect1))
  1804. {
  1805. return false;
  1806. }
  1807. }
  1808. }
  1809. }
  1810. }
  1811. }
  1812. #endregion
  1813. #endregion
  1814. if (Defender != null)
  1815. {
  1816. if (Defender.TopCard != null)
  1817. {
  1818. if (Defender.TopCard.Owner == TopCard.Owner.Enemy)
  1819. {
  1820. if (Defender.IsDigimon && Defender.TopCard.Owner.GetBattleAreaPermanents().Contains(Defender))
  1821. {
  1822. if (Defender.IsSuspended)
  1823. {
  1824. return true;
  1825. }
  1826. #region 「対象の防御パーマネントを攻撃できる」効果
  1827. #region 場のパーマネントの効果
  1828. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1829. {
  1830. foreach (Permanent permanent in player.GetFieldPermanents())
  1831. {
  1832. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1833. {
  1834. if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
  1835. {
  1836. if (cardEffect1.CanUse(null))
  1837. {
  1838. if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
  1839. {
  1840. return true;
  1841. }
  1842. }
  1843. }
  1844. }
  1845. }
  1846. }
  1847. #endregion
  1848. #region プレイヤーの効果
  1849. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  1850. {
  1851. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1852. {
  1853. if (cardEffect1 is ICanAttackTargetDefendingPermanentEffect)
  1854. {
  1855. if (cardEffect1.CanUse(null))
  1856. {
  1857. if (((ICanAttackTargetDefendingPermanentEffect)cardEffect1).CanAttackTargetDefendingPermanent(this, Defender, cardEffect))
  1858. {
  1859. return true;
  1860. }
  1861. }
  1862. }
  1863. }
  1864. }
  1865. #endregion
  1866. #endregion
  1867. }
  1868. }
  1869. }
  1870. }
  1871. else
  1872. {
  1873. return true;
  1874. }
  1875. }
  1876. return false;
  1877. }
  1878. #endregion
  1879. #region Is Unblockable
  1880. public bool IsUnblockable
  1881. {
  1882. get
  1883. {
  1884. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.None))
  1885. {
  1886. if (cardEffect is CannotBlockClass)
  1887. {
  1888. if (cardEffect.EffectName == "Unblockable")
  1889. {
  1890. return true;
  1891. }
  1892. }
  1893. }
  1894. return false;
  1895. }
  1896. }
  1897. #endregion
  1898. #region Has Blocker
  1899. public bool HasBlocker
  1900. {
  1901. get
  1902. {
  1903. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1904. {
  1905. #region Effects of permanents in play
  1906. foreach (Permanent permanent in player.GetFieldPermanents())
  1907. {
  1908. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1909. {
  1910. if (cardEffect is IBlockerEffect)
  1911. {
  1912. if (cardEffect.CanTrigger(null))
  1913. {
  1914. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  1915. {
  1916. return true;
  1917. }
  1918. }
  1919. }
  1920. }
  1921. }
  1922. #endregion
  1923. #region Effects of faceup security
  1924. foreach (CardSource source in player.SecurityCards)
  1925. {
  1926. if (source.IsFlipped)
  1927. continue;
  1928. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.None))
  1929. {
  1930. if (cardEffect is IBlockerEffect)
  1931. {
  1932. if (cardEffect.CanTrigger(null))
  1933. {
  1934. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  1935. {
  1936. return true;
  1937. }
  1938. }
  1939. }
  1940. }
  1941. }
  1942. #endregion
  1943. #region プレイヤーの効果
  1944. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1945. {
  1946. if (cardEffect is IBlockerEffect)
  1947. {
  1948. if (cardEffect.CanTrigger(null))
  1949. {
  1950. if (((IBlockerEffect)cardEffect).IsBlocker(this))
  1951. {
  1952. return true;
  1953. }
  1954. }
  1955. }
  1956. }
  1957. #endregion
  1958. }
  1959. return false;
  1960. }
  1961. }
  1962. #endregion
  1963. #region Has Jamming
  1964. public bool HasJamming
  1965. {
  1966. get
  1967. {
  1968. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1969. {
  1970. foreach (Permanent permanent in player.GetFieldPermanents())
  1971. {
  1972. #region 場のパーマネントの効果
  1973. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1974. {
  1975. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  1976. {
  1977. if (cardEffect.CanTrigger(null))
  1978. {
  1979. if (cardEffect.EffectName == "Jamming")
  1980. {
  1981. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
  1982. {
  1983. return true;
  1984. }
  1985. }
  1986. }
  1987. }
  1988. }
  1989. #endregion
  1990. }
  1991. #region プレイヤーの効果
  1992. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1993. {
  1994. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  1995. {
  1996. if (cardEffect.CanTrigger(null))
  1997. {
  1998. if (cardEffect.EffectName == "Jamming")
  1999. {
  2000. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).PermanentCondition(this))
  2001. {
  2002. return true;
  2003. }
  2004. }
  2005. }
  2006. }
  2007. }
  2008. #endregion
  2009. }
  2010. return false;
  2011. }
  2012. }
  2013. #endregion
  2014. #region Has Ice Clad
  2015. public bool HasIceclad
  2016. {
  2017. get
  2018. {
  2019. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2020. {
  2021. #region Ice clad permanent effects
  2022. foreach (ICardEffect cardEffect in EffectList(EffectTiming.None))
  2023. {
  2024. if (cardEffect is IIcecladEffect)
  2025. {
  2026. if (cardEffect.CanTrigger(null))
  2027. {
  2028. if (((IIcecladEffect)cardEffect).HasIceclad(this))
  2029. {
  2030. return true;
  2031. }
  2032. }
  2033. }
  2034. }
  2035. #endregion
  2036. #region Ice clad Player Effects
  2037. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2038. {
  2039. if (cardEffect is IIcecladEffect)
  2040. {
  2041. if (cardEffect.CanTrigger(null))
  2042. {
  2043. if (((IIcecladEffect)cardEffect).HasIceclad(this))
  2044. {
  2045. return true;
  2046. }
  2047. }
  2048. }
  2049. }
  2050. #endregion
  2051. }
  2052. return false;
  2053. }
  2054. }
  2055. #endregion
  2056. #region Whether this permanent has Pierce
  2057. public bool HasPierce
  2058. {
  2059. get
  2060. {
  2061. if (IsDigimon)
  2062. {
  2063. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDetermineDoSecurityCheck))
  2064. {
  2065. if (cardEffect is ActivateICardEffect)
  2066. {
  2067. if (cardEffect.CanTrigger(CardEffectCommons.PierceCheckHashtableOfPermanent(this)))
  2068. {
  2069. if (cardEffect.EffectName == "Pierce")
  2070. {
  2071. return true;
  2072. }
  2073. if (cardEffect.EffectName == "Piercing")
  2074. {
  2075. return true;
  2076. }
  2077. }
  2078. }
  2079. }
  2080. }
  2081. return false;
  2082. }
  2083. }
  2084. #endregion
  2085. #region Has Reboot
  2086. public bool HasReboot
  2087. {
  2088. get
  2089. {
  2090. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2091. {
  2092. foreach (Permanent permanent in player.GetFieldPermanents())
  2093. {
  2094. #region 場のパーマネントの効果
  2095. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2096. {
  2097. if (cardEffect is IRebootEffect)
  2098. {
  2099. if (cardEffect.CanTrigger(null))
  2100. {
  2101. if (((IRebootEffect)cardEffect).HasReboot(this))
  2102. {
  2103. return true;
  2104. }
  2105. }
  2106. }
  2107. }
  2108. #endregion
  2109. }
  2110. #region プレイヤーの効果
  2111. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2112. {
  2113. if (cardEffect is IRebootEffect)
  2114. {
  2115. if (cardEffect.CanTrigger(null))
  2116. {
  2117. if (((IRebootEffect)cardEffect).HasReboot(this))
  2118. {
  2119. return true;
  2120. }
  2121. }
  2122. }
  2123. }
  2124. #endregion
  2125. }
  2126. return false;
  2127. }
  2128. }
  2129. #endregion
  2130. #region Has Raid
  2131. public bool HasRaid
  2132. {
  2133. get
  2134. {
  2135. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
  2136. {
  2137. if (cardEffect is ActivateICardEffect)
  2138. {
  2139. if (cardEffect.EffectName == "Raid")
  2140. {
  2141. return true;
  2142. }
  2143. }
  2144. }
  2145. return false;
  2146. }
  2147. }
  2148. #endregion
  2149. #region Has Rush
  2150. public bool HasRush
  2151. {
  2152. get
  2153. {
  2154. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2155. {
  2156. foreach (Permanent permanent in player.GetFieldPermanents())
  2157. {
  2158. #region 場のパーマネントの効果
  2159. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2160. {
  2161. if (cardEffect is IRushEffect)
  2162. {
  2163. if (cardEffect.CanTrigger(null))
  2164. {
  2165. if (((IRushEffect)cardEffect).HasRush(this))
  2166. {
  2167. return true;
  2168. }
  2169. }
  2170. }
  2171. }
  2172. #endregion
  2173. }
  2174. #region プレイヤーの効果
  2175. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2176. {
  2177. if (cardEffect is IRushEffect)
  2178. {
  2179. if (cardEffect.CanTrigger(null))
  2180. {
  2181. if (((IRushEffect)cardEffect).HasRush(this))
  2182. {
  2183. return true;
  2184. }
  2185. }
  2186. }
  2187. }
  2188. #endregion
  2189. }
  2190. return false;
  2191. }
  2192. }
  2193. #endregion
  2194. #region Has Retaliation
  2195. public bool HasRetaliation
  2196. {
  2197. get
  2198. {
  2199. if (RetaliationCount >= 1)
  2200. {
  2201. return true;
  2202. }
  2203. return false;
  2204. }
  2205. }
  2206. #endregion
  2207. #region Retaliation Count
  2208. public int RetaliationCount
  2209. {
  2210. get
  2211. {
  2212. int count = 0;
  2213. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  2214. {
  2215. if (cardEffect is ActivateICardEffect)
  2216. {
  2217. if (cardEffect.EffectName == "Retaliation")
  2218. {
  2219. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  2220. {
  2221. count++;
  2222. }
  2223. }
  2224. }
  2225. }
  2226. return count;
  2227. }
  2228. }
  2229. #endregion
  2230. #region Has Fortitude
  2231. public bool HasFortitude
  2232. {
  2233. get
  2234. {
  2235. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  2236. {
  2237. if (cardEffect is ActivateICardEffect)
  2238. {
  2239. if (cardEffect.EffectName == "Fortitude")
  2240. {
  2241. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  2242. {
  2243. return true;
  2244. }
  2245. }
  2246. }
  2247. }
  2248. return false;
  2249. }
  2250. }
  2251. #endregion
  2252. #region Has Blitz
  2253. public bool HasBlitz
  2254. {
  2255. get
  2256. {
  2257. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnEnterFieldAnyone))
  2258. {
  2259. if (cardEffect is ActivateICardEffect)
  2260. {
  2261. if (cardEffect.CanTrigger(CardEffectCommons.WhenDigivolutionCheckHashtableOfPermanent(this)) || cardEffect.CanTrigger(CardEffectCommons.OnPlayCheckHashtableOfPermanent(this)))
  2262. {
  2263. if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
  2264. {
  2265. if (cardEffect.EffectDiscription.Contains("Blitz"))
  2266. {
  2267. return true;
  2268. }
  2269. }
  2270. }
  2271. }
  2272. }
  2273. return false;
  2274. }
  2275. }
  2276. #endregion
  2277. #region Has Evade
  2278. public bool HasEvade
  2279. {
  2280. get
  2281. {
  2282. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2283. {
  2284. if (cardEffect is ActivateICardEffect)
  2285. {
  2286. Hashtable hashtable = new Hashtable()
  2287. {
  2288. {"Permanents", new List<Permanent>() { this }}
  2289. };
  2290. if (cardEffect.CanTrigger(hashtable))
  2291. {
  2292. if (cardEffect.EffectName == "Evade")
  2293. {
  2294. return true;
  2295. }
  2296. }
  2297. }
  2298. }
  2299. return false;
  2300. }
  2301. }
  2302. #endregion
  2303. #region Has Mind Link
  2304. public bool HasMindLink
  2305. {
  2306. get
  2307. {
  2308. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDeclaration))
  2309. {
  2310. if (cardEffect is ActivateICardEffect)
  2311. {
  2312. if (cardEffect.CanTrigger(null))
  2313. {
  2314. if (!String.IsNullOrEmpty(cardEffect.EffectDiscription))
  2315. {
  2316. if (cardEffect.EffectDiscription.Contains("Mind Link"))
  2317. {
  2318. return true;
  2319. }
  2320. }
  2321. }
  2322. }
  2323. }
  2324. return false;
  2325. }
  2326. }
  2327. #endregion
  2328. #region Has Barrier
  2329. public bool HasBarrier
  2330. {
  2331. get
  2332. {
  2333. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2334. {
  2335. if (cardEffect is ActivateICardEffect)
  2336. {
  2337. Hashtable hashtable = new Hashtable();
  2338. hashtable.Add("Permanents", new List<Permanent>() { this });
  2339. hashtable.Add("battle", new IBattle(null, null, null));
  2340. if (cardEffect.CanTrigger(hashtable))
  2341. {
  2342. if (cardEffect.EffectName == "Barrier")
  2343. {
  2344. return true;
  2345. }
  2346. }
  2347. }
  2348. }
  2349. return false;
  2350. }
  2351. }
  2352. #endregion
  2353. #region Has Alliance
  2354. public bool HasAlliance
  2355. {
  2356. get
  2357. {
  2358. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2359. {
  2360. foreach (Permanent permanent in player.GetFieldPermanents())
  2361. {
  2362. #region Permanent Effects
  2363. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.OnAllyAttack))
  2364. {
  2365. if (cardEffect is IAllianceEffect)
  2366. {
  2367. if (cardEffect.CanTrigger(null))
  2368. {
  2369. if (((IAllianceEffect)cardEffect).HasAlliance(this))
  2370. {
  2371. return true;
  2372. }
  2373. }
  2374. }
  2375. }
  2376. #endregion
  2377. }
  2378. #region Effects of faceup security
  2379. foreach (CardSource source in player.SecurityCards)
  2380. {
  2381. if (source.IsFlipped)
  2382. continue;
  2383. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.OnAllyAttack))
  2384. {
  2385. if (cardEffect is IAllianceEffect)
  2386. {
  2387. if (cardEffect.CanTrigger(null))
  2388. {
  2389. if (((IAllianceEffect)cardEffect).HasAlliance(this))
  2390. {
  2391. return true;
  2392. }
  2393. }
  2394. }
  2395. }
  2396. }
  2397. #endregion
  2398. #region Player Effects
  2399. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.OnAllyAttack))
  2400. {
  2401. if (cardEffect is IAllianceEffect)
  2402. {
  2403. if (cardEffect.CanTrigger(null))
  2404. {
  2405. if (((IAllianceEffect)cardEffect).HasAlliance(this))
  2406. {
  2407. return true;
  2408. }
  2409. }
  2410. }
  2411. }
  2412. #endregion
  2413. }
  2414. return false;
  2415. }
  2416. }
  2417. #endregion
  2418. #region Has Collision
  2419. public bool HasCollision
  2420. {
  2421. get
  2422. {
  2423. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.OnAllyAttack))
  2424. {
  2425. if (cardEffect is ActivateICardEffect)
  2426. {
  2427. if (cardEffect.EffectName == "Collision")
  2428. {
  2429. return true;
  2430. }
  2431. }
  2432. }
  2433. return false;
  2434. }
  2435. }
  2436. #endregion
  2437. #region Has Partition
  2438. public bool HasPartition
  2439. {
  2440. get
  2441. {
  2442. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2443. {
  2444. if (cardEffect is ActivateICardEffect)
  2445. {
  2446. if (cardEffect.EffectName == "Partition")
  2447. {
  2448. return true;
  2449. }
  2450. }
  2451. }
  2452. return false;
  2453. }
  2454. }
  2455. #endregion
  2456. #region Has Scapegoat
  2457. public bool HasScapegoat
  2458. {
  2459. get
  2460. {
  2461. foreach (ICardEffect cardEffect in this.EffectList(EffectTiming.WhenPermanentWouldBeDeleted))
  2462. {
  2463. if (cardEffect is ActivateICardEffect)
  2464. {
  2465. if (cardEffect.EffectName == "<Scapegoat>")
  2466. {
  2467. return true;
  2468. }
  2469. }
  2470. }
  2471. return false;
  2472. }
  2473. }
  2474. #endregion
  2475. #region 消滅時効化を持つか
  2476. public bool HasOnDeletionEffect
  2477. {
  2478. get
  2479. {
  2480. foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
  2481. {
  2482. if (cardEffect is ActivateICardEffect)
  2483. {
  2484. if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
  2485. {
  2486. if (!string.IsNullOrEmpty(cardEffect.EffectDiscription))
  2487. {
  2488. if (cardEffect.IsOnDeletion)
  2489. {
  2490. return true;
  2491. }
  2492. }
  2493. }
  2494. }
  2495. }
  2496. return false;
  2497. }
  2498. }
  2499. #endregion
  2500. #region バトルしているか
  2501. public IBattle battle { get; set; } = null;
  2502. #endregion
  2503. #region Can Be Destroyed
  2504. public bool CanBeDestroyed()
  2505. {
  2506. #region 消滅しない効果
  2507. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2508. {
  2509. foreach (Permanent permanent in player.GetFieldPermanents())
  2510. {
  2511. #region 場のパーマネントの効果
  2512. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2513. {
  2514. if (cardEffect is ICanNotBeDestroyedEffect)
  2515. {
  2516. if (cardEffect.CanUse(null))
  2517. {
  2518. if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
  2519. {
  2520. return false;
  2521. }
  2522. }
  2523. }
  2524. }
  2525. #endregion
  2526. }
  2527. #region プレイヤーの効果
  2528. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2529. {
  2530. if (cardEffect is ICanNotBeDestroyedEffect)
  2531. {
  2532. if (cardEffect.CanUse(null))
  2533. {
  2534. if (((ICanNotBeDestroyedEffect)cardEffect).CanNotBeDestroyed(this))
  2535. {
  2536. return false;
  2537. }
  2538. }
  2539. }
  2540. }
  2541. #endregion
  2542. }
  2543. #endregion
  2544. return true;
  2545. }
  2546. #endregion
  2547. #region Can Be Destroyed By Battle
  2548. public bool CanBeDestroyedByBattle(Permanent AttackingPermanent, Permanent DefendingPermanent, CardSource DefendingCard)
  2549. {
  2550. if (!CanBeDestroyed())
  2551. {
  2552. return false;
  2553. }
  2554. #region Given Effects
  2555. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2556. {
  2557. foreach (Permanent permanent in player.GetFieldPermanents())
  2558. {
  2559. #region Permanents
  2560. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2561. {
  2562. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2563. {
  2564. if (cardEffect.CanUse(null))
  2565. {
  2566. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2567. {
  2568. return false;
  2569. }
  2570. }
  2571. }
  2572. }
  2573. #endregion
  2574. }
  2575. #region Effects of faceup security
  2576. foreach (CardSource source in player.SecurityCards)
  2577. {
  2578. if (source.IsFlipped)
  2579. continue;
  2580. foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.None))
  2581. {
  2582. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2583. {
  2584. if (cardEffect.CanUse(null))
  2585. {
  2586. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2587. {
  2588. return false;
  2589. }
  2590. }
  2591. }
  2592. }
  2593. }
  2594. #endregion
  2595. #region Player Effects
  2596. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2597. {
  2598. if (cardEffect is ICanNotBeDestroyedByBattleEffect)
  2599. {
  2600. if (cardEffect.CanUse(null))
  2601. {
  2602. if (((ICanNotBeDestroyedByBattleEffect)cardEffect).CanNotBeDestroyedByBattle(this, AttackingPermanent, DefendingPermanent, DefendingCard))
  2603. {
  2604. return false;
  2605. }
  2606. }
  2607. }
  2608. }
  2609. #endregion
  2610. }
  2611. #endregion
  2612. return true;
  2613. }
  2614. #endregion
  2615. #region このパーマネントが効果で消滅するか
  2616. public bool CanBeDestroyedBySkill(ICardEffect cardEffect)
  2617. {
  2618. if (this.TopCard != null)
  2619. {
  2620. if (this.TopCard.CanNotBeAffected(cardEffect))
  2621. {
  2622. return false;
  2623. }
  2624. if (!CanBeDestroyed())
  2625. {
  2626. return false;
  2627. }
  2628. #region 効果で消滅しない効果
  2629. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2630. {
  2631. foreach (Permanent permanent in player.GetFieldPermanents())
  2632. {
  2633. #region 場のパーマネントの効果
  2634. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  2635. {
  2636. if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
  2637. {
  2638. if (cardEffect1.CanUse(null))
  2639. {
  2640. if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
  2641. {
  2642. return false;
  2643. }
  2644. }
  2645. }
  2646. }
  2647. #endregion
  2648. }
  2649. #region プレイヤーの効果
  2650. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  2651. {
  2652. if (cardEffect1 is ICanNotBeDestroyedBySkillEffect)
  2653. {
  2654. if (cardEffect1.CanUse(null))
  2655. {
  2656. if (((ICanNotBeDestroyedBySkillEffect)cardEffect1).CanNotBeDestroyedBySkill(this, cardEffect))
  2657. {
  2658. return false;
  2659. }
  2660. }
  2661. }
  2662. }
  2663. #endregion
  2664. }
  2665. #endregion
  2666. }
  2667. return true;
  2668. }
  2669. #endregion
  2670. #region Can Leave Field
  2671. public bool CanBeRemoved()
  2672. {
  2673. #region Effect that never disappears
  2674. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2675. {
  2676. foreach (Permanent permanent in player.GetFieldPermanents())
  2677. {
  2678. #region Effects of permanents in play
  2679. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2680. {
  2681. if (cardEffect is ICanNotBeRemovedEffect)
  2682. {
  2683. if (cardEffect.CanUse(null))
  2684. {
  2685. if (((ICanNotBeRemovedEffect)cardEffect).CanNotBeRemoved(this))
  2686. {
  2687. return false;
  2688. }
  2689. }
  2690. }
  2691. }
  2692. #endregion
  2693. }
  2694. #region player effect
  2695. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2696. {
  2697. if (cardEffect is ICanNotBeRemovedEffect)
  2698. {
  2699. if (cardEffect.CanUse(null))
  2700. {
  2701. if (((ICanNotBeRemovedEffect)cardEffect).CanNotBeRemoved(this))
  2702. {
  2703. return false;
  2704. }
  2705. }
  2706. }
  2707. }
  2708. #endregion
  2709. }
  2710. #endregion
  2711. return true;
  2712. }
  2713. #endregion
  2714. #region トークンかどうか
  2715. public bool IsToken
  2716. {
  2717. get
  2718. {
  2719. if (TopCard != null)
  2720. {
  2721. if (TopCard.IsToken)
  2722. {
  2723. return true;
  2724. }
  2725. }
  2726. return false;
  2727. }
  2728. }
  2729. #endregion
  2730. #region そのパーマネントが消滅・バウンス待機状態か
  2731. public bool willBeRemoveField { get; set; } = false;
  2732. #endregion
  2733. #region Is a Digimon card
  2734. public bool IsDigimon
  2735. {
  2736. get
  2737. {
  2738. if (TopCard != null)
  2739. {
  2740. if (TopCard.IsFlipped)
  2741. return false;
  2742. if (TopCard.IsDigimon || TopCard.IsDigiEgg)
  2743. {
  2744. return true;
  2745. }
  2746. #region Effect of treating it as a Digimon
  2747. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2748. {
  2749. foreach (Permanent permanent in player.GetFieldPermanents())
  2750. {
  2751. #region Effects of permanents in play
  2752. foreach (ICardEffect cardEffect in permanent.EffectList_Added(EffectTiming.None))
  2753. {
  2754. if (cardEffect is ITreatAsDigimonEffect)
  2755. {
  2756. if (cardEffect.CanTrigger(null))
  2757. {
  2758. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  2759. {
  2760. return true;
  2761. }
  2762. }
  2763. }
  2764. }
  2765. #endregion
  2766. }
  2767. #region player effect
  2768. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2769. {
  2770. if (cardEffect is ITreatAsDigimonEffect)
  2771. {
  2772. if (cardEffect.CanTrigger(null))
  2773. {
  2774. if (((ITreatAsDigimonEffect)cardEffect).IsDigimon(this))
  2775. {
  2776. return true;
  2777. }
  2778. }
  2779. }
  2780. }
  2781. #endregion
  2782. }
  2783. #endregion
  2784. }
  2785. return false;
  2786. }
  2787. }
  2788. #endregion
  2789. #region Is a Tamer card
  2790. public bool IsTamer
  2791. {
  2792. get
  2793. {
  2794. if (TopCard != null)
  2795. {
  2796. if (TopCard.IsFlipped)
  2797. return false;
  2798. if (TopCard.IsTamer)
  2799. {
  2800. return true;
  2801. }
  2802. }
  2803. return false;
  2804. }
  2805. }
  2806. #endregion
  2807. #region Is an Option card
  2808. public bool IsOption
  2809. {
  2810. get
  2811. {
  2812. if (TopCard != null)
  2813. {
  2814. if (TopCard.IsOption)
  2815. {
  2816. return true;
  2817. }
  2818. }
  2819. return false;
  2820. }
  2821. }
  2822. #endregion
  2823. #region Levels handled by Jogress
  2824. public List<int> Levels_ForJogress(CardSource cardSource)
  2825. {
  2826. List<int> levels = new List<int>();
  2827. if (cardSource != null)
  2828. {
  2829. if (cardSource.HasLevel)
  2830. {
  2831. levels.Add(this.Level);
  2832. }
  2833. #region Effect of "adding levels handled by jogless evolution"
  2834. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2835. {
  2836. foreach (Permanent permanent in player.GetFieldPermanents())
  2837. {
  2838. #region Effects of permanents in play
  2839. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2840. {
  2841. if (cardEffect is IAddJogressLevelsEffect)
  2842. {
  2843. if (cardEffect.CanUse(null))
  2844. {
  2845. foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
  2846. {
  2847. levels.Add(level);
  2848. }
  2849. }
  2850. }
  2851. }
  2852. #endregion
  2853. }
  2854. #region player effect
  2855. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2856. {
  2857. if (cardEffect is IAddJogressLevelsEffect)
  2858. {
  2859. if (cardEffect.CanUse(null))
  2860. {
  2861. foreach (int level in ((IAddJogressLevelsEffect)cardEffect).GetJogressLevels(cardSource, this))
  2862. {
  2863. levels.Add(level);
  2864. }
  2865. }
  2866. }
  2867. }
  2868. #endregion
  2869. }
  2870. #endregion
  2871. }
  2872. return levels;
  2873. }
  2874. #endregion
  2875. #region Names handled by Jogress
  2876. public List<string> Names_ForDNA(CardSource cardSource)
  2877. {
  2878. List<string> names = new List<string>();
  2879. if (cardSource != null)
  2880. {
  2881. foreach(string name in cardSource.CardNames)
  2882. names.Add(name);
  2883. #region Effect of "adding names handled by DNA evolution"
  2884. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  2885. {
  2886. foreach (Permanent permanent in player.GetFieldPermanents())
  2887. {
  2888. #region Effects of permanents in play
  2889. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2890. {
  2891. if (cardEffect is IAddDNANamesEffect)
  2892. {
  2893. if (cardEffect.CanUse(null))
  2894. {
  2895. foreach (string name in ((IAddDNANamesEffect)cardEffect).GetDNANames(cardSource, this))
  2896. {
  2897. names.Add(name);
  2898. }
  2899. }
  2900. }
  2901. }
  2902. #endregion
  2903. }
  2904. #region player effect
  2905. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2906. {
  2907. if (cardEffect is IAddDNANamesEffect)
  2908. {
  2909. if (cardEffect.CanUse(null))
  2910. {
  2911. foreach (string name in ((IAddDNANamesEffect)cardEffect).GetDNANames(cardSource, this))
  2912. {
  2913. names.Add(name);
  2914. }
  2915. }
  2916. }
  2917. }
  2918. #endregion
  2919. }
  2920. #endregion
  2921. }
  2922. return names;
  2923. }
  2924. #endregion
  2925. #region バトルで消滅したか
  2926. public bool IsDestroyedByBattle { get; set; } = false;
  2927. #endregion
  2928. #region 消滅に使用された効果
  2929. public ICardEffect DestroyingEffect { get; set; } = null;
  2930. #endregion
  2931. #region 他のパーマネントの下に置くのに使用された効果
  2932. public ICardEffect PlaceOtherPermanentEffect { get; set; } = null;
  2933. #endregion
  2934. #region 手札バウンス に使用された効果
  2935. public ICardEffect HandBounceEffect { get; set; } = null;
  2936. #endregion
  2937. #region 山札バウンス に使用された効果
  2938. public ICardEffect LibraryBounceEffect { get; set; } = null;
  2939. #endregion
  2940. #region 登場に使用された効果
  2941. public ICardEffect PlayingEffect { get; set; } = null;
  2942. #endregion
  2943. #region 進化に使用された効果
  2944. public ICardEffect DigivolvingEffect { get; set; } = null;
  2945. #endregion
  2946. #region Whether this digimon is placed in the trash by not having a DP
  2947. public bool IsPlaceToTrashDueToNotHavingDP { get; set; } = true;
  2948. #endregion
  2949. #region Whether this permanent can suspend
  2950. public bool CanSuspend
  2951. {
  2952. get
  2953. {
  2954. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  2955. {
  2956. #region Effects of field permanents
  2957. foreach (Permanent permanent in player.GetFieldPermanents())
  2958. {
  2959. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  2960. {
  2961. if (cardEffect is ICanNotSuspendEffect)
  2962. {
  2963. if (cardEffect.CanUse(null))
  2964. {
  2965. if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
  2966. {
  2967. return false;
  2968. }
  2969. }
  2970. }
  2971. }
  2972. }
  2973. #endregion
  2974. #region Effects of players
  2975. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  2976. {
  2977. if (cardEffect is ICanNotSuspendEffect)
  2978. {
  2979. if (cardEffect.CanUse(null))
  2980. {
  2981. if (((ICanNotSuspendEffect)cardEffect).CanNotSuspend(this))
  2982. {
  2983. return false;
  2984. }
  2985. }
  2986. }
  2987. }
  2988. #endregion
  2989. }
  2990. return true;
  2991. }
  2992. }
  2993. #endregion
  2994. #region このデジモンのアタックの対象が変更できるか
  2995. public bool CanSwitchAttackTarget
  2996. {
  2997. get
  2998. {
  2999. #region アタックの対象が変更できない効果
  3000. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  3001. {
  3002. foreach (Permanent permanent in player.GetFieldPermanents())
  3003. {
  3004. #region 場のパーマネントの効果
  3005. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  3006. {
  3007. if (cardEffect is ICanNotSwitchAttackTargetEffect)
  3008. {
  3009. if (cardEffect.CanUse(null))
  3010. {
  3011. if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
  3012. {
  3013. return false;
  3014. }
  3015. }
  3016. }
  3017. }
  3018. #endregion
  3019. }
  3020. #region プレイヤーの効果
  3021. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3022. {
  3023. if (cardEffect is ICanNotSwitchAttackTargetEffect)
  3024. {
  3025. if (cardEffect.CanUse(null))
  3026. {
  3027. if (((ICanNotSwitchAttackTargetEffect)cardEffect).CanNotBeSwitchAttackTarget(this))
  3028. {
  3029. return false;
  3030. }
  3031. }
  3032. }
  3033. }
  3034. #endregion
  3035. }
  3036. #endregion
  3037. return true;
  3038. }
  3039. }
  3040. #endregion
  3041. #region このデジモンを場からデジクロス条件の代わりにできるか
  3042. public bool CanSubstituteForDigiXrosCondition(CardSource cardSource)
  3043. {
  3044. #region デジクロス条件の代わりにできる効果
  3045. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  3046. {
  3047. foreach (Permanent permanent in player.GetFieldPermanents())
  3048. {
  3049. #region 場のパーマネントの効果
  3050. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  3051. {
  3052. if (cardEffect is ICanSelectDigiXrosEffect)
  3053. {
  3054. if (cardEffect.CanUse(null))
  3055. {
  3056. if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
  3057. {
  3058. return true;
  3059. }
  3060. }
  3061. }
  3062. }
  3063. #endregion
  3064. }
  3065. #region プレイヤーの効果
  3066. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3067. {
  3068. if (cardEffect is ICanSelectDigiXrosEffect)
  3069. {
  3070. if (cardEffect.CanUse(null))
  3071. {
  3072. if (((ICanSelectDigiXrosEffect)cardEffect).CanSelect(cardSource, this))
  3073. {
  3074. return true;
  3075. }
  3076. }
  3077. }
  3078. }
  3079. #endregion
  3080. }
  3081. #endregion
  3082. return false;
  3083. }
  3084. #endregion
  3085. #region Can Substitue for Assembly
  3086. public bool CanSubstituteForAssemblyCondition(CardSource cardSource)
  3087. {
  3088. #region Effects that can be used in place of Assembly conditions
  3089. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  3090. {
  3091. foreach (Permanent permanent in player.GetFieldPermanents())
  3092. {
  3093. #region Effects of permanents in play
  3094. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  3095. {
  3096. if (cardEffect is ICanSelectAssemblyEffect)
  3097. {
  3098. if (cardEffect.CanUse(null))
  3099. {
  3100. if (((ICanSelectAssemblyEffect)cardEffect).CanSelect(cardSource, this))
  3101. {
  3102. return true;
  3103. }
  3104. }
  3105. }
  3106. }
  3107. #endregion
  3108. }
  3109. #region player effect
  3110. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  3111. {
  3112. if (cardEffect is ICanSelectAssemblyEffect)
  3113. {
  3114. if (cardEffect.CanUse(null))
  3115. {
  3116. if (((ICanSelectAssemblyEffect)cardEffect).CanSelect(cardSource, this))
  3117. {
  3118. return true;
  3119. }
  3120. }
  3121. }
  3122. }
  3123. #endregion
  3124. }
  3125. #endregion
  3126. return false;
  3127. }
  3128. #endregion
  3129. #region 登場した直後のLevel
  3130. public int LevelJustAfterPlayed { get; set; } = -1;
  3131. #endregion
  3132. #region 登場した直後のPlay Cost
  3133. public int PlayCostJustAfterPlayed { get; set; } = -1;
  3134. #endregion
  3135. #region 登場した直後のCardNames
  3136. public List<string> CardNamesJustAfterPlayed { get; set; } = new List<string>();
  3137. #endregion
  3138. #region 進化した直後のCardNames
  3139. public List<string> CardNamesJustAfterDigivolved { get; set; } = new List<string>();
  3140. #endregion
  3141. #region 登場した直後のTraits
  3142. public List<string> TraitsJustAfterPlayed { get; set; } = new List<string>();
  3143. #endregion
  3144. #region 場を離れる直前のDP
  3145. public int DPJustBeforeRemoveField { get; set; } = -1;
  3146. #endregion
  3147. #region 場を離れる直前のLevel
  3148. public int LevelJustBeforeRemoveField { get; set; } = -1;
  3149. #endregion
  3150. #region 場を離れる直前のCost
  3151. public int CostJustBeforeRemoveField { get; set; } = -1;
  3152. #endregion
  3153. #region 場を離れる直前のカード名
  3154. public List<string> CardNamesJustBeforeRemoveField { get; set; } = new List<string>();
  3155. #endregion
  3156. #region Card Traits Just Before Removed Field
  3157. public List<string> CardTraitsJustBeforeRemoveField { get; set; } = new List<string>();
  3158. #endregion
  3159. #region バースト進化で手札に戻ったか
  3160. public bool IsReturnedToHandByBurstDigivolution { get; set; } = false;
  3161. #endregion
  3162. #region Is Linked Card Added as Source By App Fusion
  3163. public bool IsAddedAsSourceByAppFusion { get; set; } = false;
  3164. #endregion
  3165. #region バースト進化したか
  3166. public bool IsBurstDigivolved { get; set; } = false;
  3167. #endregion
  3168. #region Did it App Fusion?
  3169. public bool IsAppFusion { get; set; } = false;
  3170. #endregion
  3171. #region 効果で場に出たオプションか
  3172. public bool IsPlayedOptionPermanent { get; set; } = false;
  3173. #endregion
  3174. #region 進化元を持たないか
  3175. public bool HasNoDigivolutionCards => DigivolutionCards.Count == 0;
  3176. #endregion
  3177. #region Has face down Digivolution Cards
  3178. public bool HasFaceDownDigivolutionCards => DigivolutionCards.Any(x => x.IsFlipped);
  3179. #endregion
  3180. #region Has No Link Cards
  3181. public bool HasNoLinkCards => LinkedCards.Count == 0;
  3182. #endregion
  3183. #region Digivolution cards' colors
  3184. public List<CardColor> DigivolutionCardsColors
  3185. {
  3186. get
  3187. {
  3188. List<CardColor> cardColors = new List<CardColor>();
  3189. foreach (CardSource cardSource in DigivolutionCards)
  3190. {
  3191. if (cardSource.IsFlipped)
  3192. continue;
  3193. foreach (CardColor cardColor in cardSource.CardColors)
  3194. {
  3195. if (!cardColors.Contains(cardColor))
  3196. {
  3197. cardColors.Add(cardColor);
  3198. }
  3199. }
  3200. }
  3201. return cardColors.Distinct().ToList();
  3202. }
  3203. }
  3204. #endregion
  3205. #region Show "Unsuspend" effect object
  3206. public void ShowUnsuspendEffect()
  3207. {
  3208. if (TopCard != null)
  3209. {
  3210. if (ShowingPermanentCard != null)
  3211. {
  3212. if (ShowingPermanentCard.WillUntapObject != null)
  3213. {
  3214. ShowingPermanentCard.WillUntapObject.transform.parent.gameObject.SetActive(true);
  3215. ShowingPermanentCard.WillUntapObject.SetActive(true);
  3216. }
  3217. }
  3218. }
  3219. }
  3220. #endregion
  3221. #region Show "Return to deck" effect object
  3222. public void ShowDeckBounceEffect()
  3223. {
  3224. if (TopCard != null)
  3225. {
  3226. if (willBeRemoveField)
  3227. {
  3228. if (ShowingPermanentCard != null)
  3229. {
  3230. if (ShowingPermanentCard.WillBeDeckBounceObject != null)
  3231. {
  3232. ShowingPermanentCard.WillBeDeckBounceObject.transform.parent.gameObject.SetActive(true);
  3233. ShowingPermanentCard.WillBeDeckBounceObject.SetActive(true);
  3234. }
  3235. }
  3236. }
  3237. }
  3238. }
  3239. #endregion
  3240. #region Hide "Return to deck" effect object
  3241. public void HideDeckBounceEffect()
  3242. {
  3243. if (TopCard != null)
  3244. {
  3245. if (ShowingPermanentCard != null)
  3246. {
  3247. if (ShowingPermanentCard.WillBeDeckBounceObject != null)
  3248. {
  3249. ShowingPermanentCard.WillBeDeckBounceObject.SetActive(false);
  3250. }
  3251. }
  3252. }
  3253. }
  3254. #endregion
  3255. #region Show "Return to hand" effect object
  3256. public void ShowHandBounceEffect()
  3257. {
  3258. if (TopCard != null)
  3259. {
  3260. if (willBeRemoveField)
  3261. {
  3262. if (ShowingPermanentCard != null)
  3263. {
  3264. if (ShowingPermanentCard.WillBeHandBounceObject != null)
  3265. {
  3266. ShowingPermanentCard.WillBeHandBounceObject.transform.parent.gameObject.SetActive(true);
  3267. ShowingPermanentCard.WillBeHandBounceObject.SetActive(true);
  3268. }
  3269. }
  3270. }
  3271. }
  3272. }
  3273. #endregion
  3274. #region Hide "Return to hand" effect object
  3275. public void HideHandBounceEffect()
  3276. {
  3277. if (TopCard != null)
  3278. {
  3279. if (ShowingPermanentCard != null)
  3280. {
  3281. if (ShowingPermanentCard.WillBeHandBounceObject != null)
  3282. {
  3283. ShowingPermanentCard.WillBeHandBounceObject.SetActive(false);
  3284. }
  3285. }
  3286. }
  3287. }
  3288. #endregion
  3289. #region Show "Delete" effect object
  3290. public void ShowDeleteEffect()
  3291. {
  3292. if (TopCard != null)
  3293. {
  3294. if (willBeRemoveField)
  3295. {
  3296. if (ShowingPermanentCard != null)
  3297. {
  3298. if (ShowingPermanentCard.WillBeDeletedObject != null)
  3299. {
  3300. ShowingPermanentCard.WillBeDeletedObject.transform.parent.gameObject.SetActive(true);
  3301. ShowingPermanentCard.WillBeDeletedObject.SetActive(true);
  3302. }
  3303. }
  3304. }
  3305. }
  3306. }
  3307. #endregion
  3308. #region Hide "Delete" effect object
  3309. public void HideDeleteEffect()
  3310. {
  3311. if (TopCard != null)
  3312. {
  3313. if (ShowingPermanentCard != null)
  3314. {
  3315. if (ShowingPermanentCard.WillBeDeletedObject != null)
  3316. {
  3317. ShowingPermanentCard.WillBeDeletedObject.SetActive(false);
  3318. }
  3319. }
  3320. }
  3321. }
  3322. #endregion
  3323. #region Show "Remove Field" effect object
  3324. public void ShowWillRemoveFieldEffect()
  3325. {
  3326. if (TopCard != null)
  3327. {
  3328. if (willBeRemoveField)
  3329. {
  3330. if (ShowingPermanentCard != null)
  3331. {
  3332. if (ShowingPermanentCard.WillRemoveFieldObject != null)
  3333. {
  3334. ShowingPermanentCard.WillRemoveFieldObject.transform.parent.gameObject.SetActive(true);
  3335. ShowingPermanentCard.WillRemoveFieldObject.SetActive(true);
  3336. }
  3337. }
  3338. }
  3339. }
  3340. }
  3341. #endregion
  3342. #region Hide "Remove Field" effect object
  3343. public void HideWillRemoveFieldEffect()
  3344. {
  3345. if (TopCard != null)
  3346. {
  3347. if (ShowingPermanentCard != null)
  3348. {
  3349. if (ShowingPermanentCard.WillRemoveFieldObject != null)
  3350. {
  3351. ShowingPermanentCard.WillRemoveFieldObject.SetActive(false);
  3352. }
  3353. }
  3354. }
  3355. }
  3356. #endregion
  3357. #region Show "Digivolution" effect object
  3358. public void ShowWillEvolutionEffect()
  3359. {
  3360. if (TopCard != null)
  3361. {
  3362. if (ShowingPermanentCard != null)
  3363. {
  3364. if (ShowingPermanentCard.WillEvolutionObject != null)
  3365. {
  3366. ShowingPermanentCard.WillEvolutionObject.transform.parent.gameObject.SetActive(true);
  3367. ShowingPermanentCard.WillEvolutionObject.SetActive(true);
  3368. }
  3369. }
  3370. }
  3371. }
  3372. #endregion
  3373. #region Hide "Digivolution" effect object
  3374. public void HideWillEvolutionEffect()
  3375. {
  3376. if (TopCard != null)
  3377. {
  3378. if (ShowingPermanentCard != null)
  3379. {
  3380. if (ShowingPermanentCard.WillEvolutionObject != null)
  3381. {
  3382. ShowingPermanentCard.WillEvolutionObject.SetActive(false);
  3383. }
  3384. }
  3385. }
  3386. }
  3387. #endregion
  3388. }