Permanent.cs 120 KB

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