2017-05-23 12:29:10 +02:00
|
|
|
"use strict";function callConstructor(e){return new(e.bind.apply(e,arguments))}function applyToConstructor(e,r){var t=concat(null,toArr(r));return new(e.bind.apply(e,t))}function nextTick(e){setTimeout(e,0)}function DeckManager(){this.getDeckNames()}function TextualRule(e,r,t){this.prop=e,this.map=r,this.exact=t}function NumericRule(e,r){this.prop=e,this.keywords=r}function Searcher(){this.rules=[ColorRule,CrossRule,TypeRule,RarityRule,RiseRule,TrapRule,AcceRule,SkillRule,NoBurstRule,TimmingRule,LimitingRule,ClassRule,PowerRule,LevelRule,LimitRule,NumberRule,IllustRule,WxidRule,NameRule]}var concat=Array.prototype.concat.bind([]),toArr=function(e){return e?"string"==typeof e?[]:Array.prototype.slice.call(e,0):[]},isArr=Array.isArray,inArr=function(e,r){return-1!=toArr(r).indexOf(e)},removeFromArr=function(e,r){var t=r.indexOf(e);return!(t<0)&&(r.splice(t,1),!0)},isStr=function(e){return"string"==typeof e},isObj=function(e){return e&&"object"==typeof e&&!isArr(e)},isNum=function(e){return"number"==typeof e},isFunc=function(e){return"function"==typeof e},pEach=function(e,r,t){return e.reduce(function(e,t){return e.then(function(){return r(t)})},Promise.resolve())};DeckManager.prototype.getDeckNames=function(){var e=localStorage.getItem("deck_filenames");return this._deckNames=e?JSON.parse(e):[],this._deckNames},DeckManager.prototype._updateDeckNames=function(){this._deckNames.sort(),localStorage.setItem("deck_filenames",JSON.stringify(this._deckNames))},DeckManager.prototype.createDeck=function(e,r){return!inArr(e,this._deckNames)&&(this._deckNames.push(e),this._updateDeckNames(),this.saveDeck(e,r),!0)},DeckManager.prototype.renameDeck=function(e,r){if(!inArr(e,this._deckNames))return!1;if(inArr(r,this._deckNames))return!1;var t=this.loadDeck(e);return this.deleteDeck(e),this.createDeck(r,t),!0},DeckManager.prototype.deleteDeck=function(e){return!!removeFromArr(e,this._deckNames)&&(this._updateDeckNames(),localStorage.removeItem("deck_file_"+e),!0)},DeckManager.prototype.loadDeck=function(e){var r=localStorage.getItem("deck_file_"+e);return r?JSON.parse(r):null},DeckManager.prototype.saveDeck=function(e,r){return!!inArr(e,this._deckNames)&&(localStorage.setItem("deck_file_"+e,JSON.stringify(r)),!0)},DeckManager.prototype.checkMainDeck=function(e){if(!isArr(e))return!1;if(40!==e.length)return!1;for(var r=[],t=0;t<e.length;t++){var n=CardInfo[e[t]];if(!n)return!1;if(!(n=CardInfo[n.cid]))return!1;r.push(n)}return!r.some(function(e){return"LRIG"===e.cardType||("ARTS"===e.cardType||("RESONA"===e.cardType||void 0))})&&(20===this.burstCount(e)&&(!!this.checkDuplicate(e)&&r))},DeckManager.prototype.checkLrigDeck=function(e){if(!isArr(e))return!1;if(e.length>10)return!1;for(var r=[],t=0;t<e.length;t++){var n=CardInfo[e[t]];if(!n)return!1;if(!(n=CardInfo[n.cid]))return!1;r.push(n)}return!r.some(function(e){return"SIGNI"===e.cardType||("SPELL"===e.cardType||void 0)})&&(!!r.some(function(e){return"LRIG"===e.cardType&&0===e.level})&&(!!this.checkDuplicate(e)&&r))},DeckManager.prototype.checkMayusRoom=function(e){for(var r=[],t=0;t<e.length;t++){var n=CardInfo[e[t]];if(!n)return!1;if(!(n=CardInfo[n.cid]))return!1;r.push(n)}if(r.some(function(e){return 33===e.cid})&&r.some(function(e){return 34===e.cid||84===e.cid}))return!1;if(r.some(function(e){return 1202===e.cid})&&r.some(function(e){return 884===e.cid||1369===e.cid}))return!1;if(r.some(function(e){return 534===e.cid})&&r.some(function(e){return 408===e.cid||570===e.cid}))return!1;if(r.some(function(e){return 814===e.cid})&&r.some(function(e){return 1090===e.cid}))return!1;if(r.some(function(e){return 649===e.cid})&&r.some(function(e){return 1562===e.cid}))return!1;if(r.some(function(e){return 957===e.cid})&&r.some(function(e){return 1652===e.cid}))return!1;for(var i={37:2,34:2,178:2,1501:2,534:1,474:0,23:0,689:0,1030:0,1457:0,1212:0},t=0;t<r.length;t++){var n=r[t],u=n.cid;if(u in i&&--i[u]<0)return!1}return!0},DeckManager.prototype.checkDeck=function(e,r){return!(!this.checkMainDeck(e.mainDeck)||!this.checkLrigDeck(e.lrigDeck))&&(!1===r||this.checkMayusRoom(e.mainDeck.concat(e.lrig
|