Path: blob/main/projects/cookie-clicker/minigameGrimoire.js
4626 views
var M={};1M.parent=Game.Objects['Wizard tower'];2M.parent.minigame=M;3M.launch=function()4{5var M=this;6M.name=M.parent.minigameName;7M.init=function(div)8{9//populate div with html and initialize values1011M.spells={12'conjure baked goods':{13name:'Conjure Baked Goods',14desc:'Summon half an hour worth of your CpS, capped at 15% of your cookies owned.',15failDesc:'Trigger a 15-minute clot and lose 15 minutes of CpS.',16icon:[21,11],17costMin:2,18costPercent:0.4,19win:function()20{21var val=Math.max(7,Math.min(Game.cookies*0.15,Game.cookiesPs*60*30));22Game.Earn(val);23Game.Notify('Conjure baked goods!','You magic <b>'+Beautify(val)+' cookie'+(val==1?'':'s')+'</b> out of thin air.',[21,11],6);24Game.Popup('<div style="font-size:80%;">+'+Beautify(val)+' cookie'+(val==1?'':'s')+'!</div>',Game.mouseX,Game.mouseY);25},26fail:function()27{28var buff=Game.gainBuff('clot',60*15,0.5);29var val=Math.min(Game.cookies*0.15,Game.cookiesPs*60*15)+13;30val=Math.min(Game.cookies,val);31Game.Spend(val);32Game.Notify(buff.name,buff.desc,buff.icon,6);33Game.Popup('<div style="font-size:80%;">Backfire!<br>Summoning failed! Lost '+Beautify(val)+' cookie'+(val==1?'':'s')+'!</div>',Game.mouseX,Game.mouseY);34},35},36'hand of fate':{37name:'Force the Hand of Fate',38desc:'Summon a random golden cookie. Each existing golden cookie makes this spell +15% more likely to backfire.',39failDesc:'Summon an unlucky wrath cookie.',40icon:[22,11],41costMin:10,42costPercent:0.6,43failFunc:function(fail)44{45return fail+0.15*Game.shimmerTypes['golden'].n;46},47win:function()48{49var newShimmer=new Game.shimmer('golden',{noWrath:true});50var choices=[];51choices.push('frenzy','multiply cookies');52if (!Game.hasBuff('Dragonflight')) choices.push('click frenzy');53if (Math.random()<0.1) choices.push('cookie storm','cookie storm','blab');54if (Game.BuildingsOwned>=10 && Math.random()<0.25) choices.push('building special');55//if (Math.random()<0.2) choices.push('clot','cursed finger','ruin cookies');56if (Math.random()<0.15) choices=['cookie storm drop'];57if (Math.random()<0.0001) choices.push('free sugar lump');58newShimmer.force=choose(choices);59if (newShimmer.force=='cookie storm drop')60{61newShimmer.sizeMult=Math.random()*0.75+0.25;62}63Game.Popup('<div style="font-size:80%;">Promising fate!</div>',Game.mouseX,Game.mouseY);64},65fail:function()66{67var newShimmer=new Game.shimmer('golden',{wrath:true});68var choices=[];69choices.push('clot','ruin cookies');70if (Math.random()<0.1) choices.push('cursed finger','blood frenzy');71if (Math.random()<0.003) choices.push('free sugar lump');72if (Math.random()<0.1) choices=['blab'];73newShimmer.force=choose(choices);74Game.Popup('<div style="font-size:80%;">Backfire!<br>Sinister fate!</div>',Game.mouseX,Game.mouseY);75},76},77'stretch time':{78name:'Stretch Time',79desc:'All active buffs gain 10% more time (up to 5 more minutes).',80failDesc:'All active buffs are shortened by 20% (up to 10 minutes shorter).',81icon:[23,11],82costMin:8,83costPercent:0.2,84win:function()85{86var changed=0;87for (var i in Game.buffs)88{89var me=Game.buffs[i];90var gain=Math.min(Game.fps*60*5,me.maxTime*0.1);91me.maxTime+=gain;92me.time+=gain;93changed++;94}95if (changed==0){Game.Popup('<div style="font-size:80%;">No buffs to alter!</div>',Game.mouseX,Game.mouseY);return -1;}96Game.Popup('<div style="font-size:80%;">Zap! Buffs lengthened.</div>',Game.mouseX,Game.mouseY);97},98fail:function()99{100var changed=0;101for (var i in Game.buffs)102{103var me=Game.buffs[i];104var loss=Math.min(Game.fps*60*10,me.time*0.2);105me.time-=loss;106me.time=Math.max(me.time,0);107changed++;108}109if (changed==0){Game.Popup('<div style="font-size:80%;">No buffs to alter!</div>',Game.mouseX,Game.mouseY);return -1;}110Game.Popup('<div style="font-size:80%;">Backfire!<br>Fizz! Buffs shortened.</div>',Game.mouseX,Game.mouseY);111},112},113'spontaneous edifice':{114name:'Spontaneous Edifice',115desc:'The spell picks a random building you could afford if you had twice your current cookies, and gives it to you for free. The building selected must be under 400, and cannot be your most-built one (unless it is your only one).',116failDesc:'Lose a random building.',117icon:[24,11],118costMin:20,119costPercent:0.75,120win:function()121{122var buildings=[];123var max=0;124var n=0;125for (var i in Game.Objects)126{127if (Game.Objects[i].amount>max) max=Game.Objects[i].amount;128if (Game.Objects[i].amount>0) n++;129}130for (var i in Game.Objects)131{if ((Game.Objects[i].amount<max || n==1) && Game.Objects[i].getPrice()<=Game.cookies*2 && Game.Objects[i].amount<400) buildings.push(Game.Objects[i]);}132if (buildings.length==0){Game.Popup('<div style="font-size:80%;">No buildings to improve!</div>',Game.mouseX,Game.mouseY);return -1;}133var building=choose(buildings);134building.buyFree(1);135Game.Popup('<div style="font-size:80%;">A new '+building.single+'<br>bursts out of the ground.</div>',Game.mouseX,Game.mouseY);136},137fail:function()138{139if (Game.BuildingsOwned==0){Game.Popup('<div style="font-size:80%;">Backfired, but no buildings to destroy!</div>',Game.mouseX,Game.mouseY);return -1;}140var buildings=[];141for (var i in Game.Objects)142{if (Game.Objects[i].amount>0) buildings.push(Game.Objects[i]);}143var building=choose(buildings);144building.sacrifice(1);145Game.Popup('<div style="font-size:80%;">Backfire!<br>One of your '+building.plural+'<br>disappears in a puff of smoke.</div>',Game.mouseX,Game.mouseY);146},147},148'haggler\'s charm':{149name:'Haggler\'s Charm',150desc:'Upgrades are 2% cheaper for 1 minute.',151failDesc:'Upgrades are 2% more expensive for an hour.<q>What\'s that spell? Loadsamoney!</q>',152icon:[25,11],153costMin:10,154costPercent:0.1,155win:function()156{157Game.killBuff('Haggler\'s misery');158var buff=Game.gainBuff('haggler luck',60,2);159Game.Popup('<div style="font-size:80%;">Upgrades are cheaper!</div>',Game.mouseX,Game.mouseY);160},161fail:function()162{163Game.killBuff('Haggler\'s luck');164var buff=Game.gainBuff('haggler misery',60*60,2);165Game.Popup('<div style="font-size:80%;">Backfire!<br>Upgrades are pricier!</div>',Game.mouseX,Game.mouseY);166},167},168'summon crafty pixies':{169name:'Summon Crafty Pixies',170desc:'Buildings are 2% cheaper for 1 minute.',171failDesc:'Buildings are 2% more expensive for an hour.',172icon:[26,11],173costMin:10,174costPercent:0.2,175win:function()176{177Game.killBuff('Nasty goblins');178var buff=Game.gainBuff('pixie luck',60,2);179Game.Popup('<div style="font-size:80%;">Crafty pixies!<br>Buildings are cheaper!</div>',Game.mouseX,Game.mouseY);180},181fail:function()182{183Game.killBuff('Crafty pixies');184var buff=Game.gainBuff('pixie misery',60*60,2);185Game.Popup('<div style="font-size:80%;">Backfire!<br>Nasty goblins!<br>Buildings are pricier!</div>',Game.mouseX,Game.mouseY);186},187},188'gambler\'s fever dream':{189name:'Gambler\'s Fever Dream',190desc:'Cast a random spell at half the magic cost, with twice the chance of backfiring.',191icon:[27,11],192costMin:3,193costPercent:0.05,194win:function()195{196var spells=[];197var selfCost=M.getSpellCost(M.spells['gambler\'s fever dream']);198for (var i in M.spells)199{if (i!='gambler\'s fever dream' && (M.magic-selfCost)>=M.getSpellCost(M.spells[i])*0.5) spells.push(M.spells[i]);}200if (spells.length==0){Game.Popup('<div style="font-size:80%;">No eligible spells!</div>',Game.mouseX,Game.mouseY);return -1;}201var spell=choose(spells);202var cost=M.getSpellCost(spell)*0.5;203setTimeout(function(spell,cost,seed){return function(){204if (Game.seed!=seed) return false;205var out=M.castSpell(spell,{cost:cost,failChanceMax:0.5,passthrough:true});206if (!out)207{208M.magic+=selfCost;209setTimeout(function(){210Game.Popup('<div style="font-size:80%;">That\'s too bad!<br>Magic refunded.</div>',Game.mouseX,Game.mouseY);211},1500);212}213}}(spell,cost,Game.seed),1000);214Game.Popup('<div style="font-size:80%;">Casting '+spell.name+'<br>for '+Beautify(cost)+' magic...</div>',Game.mouseX,Game.mouseY);215},216},217'resurrect abomination':{218name:'Resurrect Abomination',219desc:'Instantly summon a wrinkler if conditions are fulfilled.',220failDesc:'Pop one of your wrinklers.',221icon:[28,11],222costMin:20,223costPercent:0.1,224win:function()225{226var out=Game.SpawnWrinkler();227if (!out){Game.Popup('<div style="font-size:80%;">Unable to spawn a wrinkler!</div>',Game.mouseX,Game.mouseY);return -1;}228Game.Popup('<div style="font-size:80%;">Rise, my precious!</div>',Game.mouseX,Game.mouseY);229},230fail:function()231{232var out=Game.PopRandomWrinkler();233if (!out){Game.Popup('<div style="font-size:80%;">Backfire!<br>But no wrinkler was harmed.</div>',Game.mouseX,Game.mouseY);return -1;}234Game.Popup('<div style="font-size:80%;">Backfire!<br>So long, ugly...</div>',Game.mouseX,Game.mouseY);235},236},237'diminish ineptitude':{238name:'Diminish Ineptitude',239desc:'Spells backfire 10 times less for the next 5 minutes.',240failDesc:'Spells backfire 5 times more for the next 10 minutes.',241icon:[29,11],242costMin:5,243costPercent:0.2,244win:function()245{246Game.killBuff('Magic inept');247var buff=Game.gainBuff('magic adept',5*60,10);248Game.Popup('<div style="font-size:80%;">Ineptitude diminished!</div>',Game.mouseX,Game.mouseY);249},250fail:function()251{252Game.killBuff('Magic adept');253var buff=Game.gainBuff('magic inept',10*60,5);254Game.Popup('<div style="font-size:80%;">Backfire!<br>Ineptitude magnified!</div>',Game.mouseX,Game.mouseY);255},256},257};258M.spellsById=[];var n=0;259for (var i in M.spells){M.spells[i].id=n;M.spellsById[n]=M.spells[i];n++;}260261262M.computeMagicM=function()263{264var towers=Math.max(M.parent.amount,1);265var lvl=Math.max(M.parent.level,1);266M.magicM=Math.floor(4+Math.pow(towers,0.6)+Math.log((towers+(lvl-1)*10)/15+1)*15);267//old formula :268/*269M.magicM=8+Math.min(M.parent.amount,M.parent.level*5)+Math.ceil(M.parent.amount/10);270if (M.magicM>200)271{272//diminishing returns starting at 200, being 5% as fast by 400273var x=M.magicM;274var top=x-200;275top/=200;276var top2=top;277top*=(1-top/2);278if (top2>=1) top=0.5;279top=top*0.95+top2*0.05;280top*=200;281x=top+200;282M.magicM=x;283}284*/285M.magic=Math.min(M.magicM,M.magic);286}287288M.getFailChance=function(spell)289{290var failChance=0.15;291if (Game.hasBuff('Magic adept')) failChance*=0.1;292if (Game.hasBuff('Magic inept')) failChance*=5;293if (spell.failFunc) failChance=spell.failFunc(failChance);294return failChance;295}296297M.castSpell=function(spell,obj)298{299var obj=obj||{};300var out=0;301var cost=0;302var fail=false;303if (typeof obj.cost!=='undefined') cost=obj.cost; else cost=M.getSpellCost(spell);304if (M.magic<cost) return false;305var failChance=M.getFailChance(spell);306if (typeof obj.failChanceSet!=='undefined') failChance=obj.failChanceSet;307if (typeof obj.failChanceAdd!=='undefined') failChance+=obj.failChanceAdd;308if (typeof obj.failChanceMult!=='undefined') failChance*=obj.failChanceMult;309if (typeof obj.failChanceMax!=='undefined') failChance=Math.max(failChance,obj.failChanceMax);310Math.seedrandom(Game.seed+'/'+M.spellsCastTotal);311if (!spell.fail || Math.random()<(1-failChance)) {out=spell.win();} else {fail=true;out=spell.fail();}312Math.seedrandom();313if (out!=-1)314{315if (!spell.passthrough && !obj.passthrough)316{317M.spellsCast++;318M.spellsCastTotal++;319if (M.spellsCastTotal>=9) Game.Win('Bibbidi-bobbidi-boo');320if (M.spellsCastTotal>=99) Game.Win('I\'m the wiz');321if (M.spellsCastTotal>=999) Game.Win('A wizard is you');322}323324M.magic-=cost;325M.magic=Math.max(0,M.magic);326327var rect=l('grimoireSpell'+spell.id).getBoundingClientRect();328Game.SparkleAt((rect.left+rect.right)/2,(rect.top+rect.bottom)/2-24);329330if (fail) PlaySound('snd/spellFail.mp3',0.75); else PlaySound('snd/spell.mp3',0.75);331return true;332}333PlaySound('snd/spellFail.mp3',0.75);334return false;335}336337M.getSpellCost=function(spell)338{339var out=spell.costMin;340if (spell.costPercent) out+=M.magicM*spell.costPercent;341return Math.floor(out);342}343M.getSpellCostBreakdown=function(spell)344{345var str='';346if (spell.costPercent) str+=Beautify(spell.costMin)+' magic +'+Beautify(Math.ceil(spell.costPercent*100))+'% of max magic';347else str+=Beautify(spell.costMin)+' magic';348return str;349}350351M.spellTooltip=function(id)352{353return function(){354var me=M.spellsById[id];355me.icon=me.icon||[28,12];356var cost=Beautify(M.getSpellCost(me));357var costBreakdown=M.getSpellCostBreakdown(me);358if (cost!=costBreakdown) costBreakdown=' <small>('+costBreakdown+')</small>'; else costBreakdown='';359var backfire=M.getFailChance(me);360var str='<div style="padding:8px 4px;min-width:350px;">'+361'<div class="icon" style="float:left;margin-left:-8px;margin-top:-8px;background-position:'+(-me.icon[0]*48)+'px '+(-me.icon[1]*48)+'px;"></div>'+362'<div class="name">'+me.name+'</div>'+363'<div>Magic cost : <b style="color:#'+(cost<=M.magic?'6f6':'f66')+';">'+cost+'</b>'+costBreakdown+'</div>'+364(me.fail?('<div><small>Chance to backfire : <b style="color:#f66">'+Math.ceil(100*backfire)+'%</b></small></div>'):'')+365'<div class="line"></div><div class="description"><b>Effect :</b> <span class="green">'+(me.descFunc?me.descFunc():me.desc)+'</span>'+(me.failDesc?('<div style="height:8px;"></div><b>Backfire :</b> <span class="red">'+me.failDesc+'</span>'):'')+'</div></div>';366return str;367};368}369370var str='';371str+='<style>'+372'#grimoireBG{background:url(img/shadedBorders.png),url(img/BGgrimoire.jpg);background-size:100% 100%,auto;position:absolute;left:0px;right:0px;top:0px;bottom:16px;}'+373'#grimoireContent{position:relative;box-sizing:border-box;padding:4px 24px;}'+374'#grimoireBar{max-width:95%;margin:4px auto;height:16px;}'+375'#grimoireBarFull{transform:scale(1,2);transform-origin:50% 0;height:50%;}'+376'#grimoireBarText{transform:scale(1,0.8);width:100%;position:absolute;left:0px;top:0px;text-align:center;color:#fff;text-shadow:-1px 1px #000,0px 0px 4px #000,0px 0px 6px #000;margin-top:2px;}'+377'#grimoireSpells{text-align:center;width:100%;padding:8px;box-sizing:border-box;}'+378'.grimoireIcon{pointer-events:none;margin:2px 6px 0px 6px;width:48px;height:48px;opacity:0.8;position:relative;}'+379'.grimoirePrice{pointer-events:none;}'+380'.grimoireSpell{box-shadow:4px 4px 4px #000;cursor:pointer;position:relative;color:#f33;opacity:0.8;text-shadow:0px 0px 4px #000,0px 0px 6px #000;font-weight:bold;font-size:12px;display:inline-block;width:60px;height:74px;background:url(img/spellBG.png);}'+381'.grimoireSpell.ready{color:rgba(255,255,255,0.8);opacity:1;}'+382'.grimoireSpell.ready:hover{color:#fff;}'+383'.grimoireSpell:hover{box-shadow:6px 6px 6px 2px #000;z-index:1000000001;top:-1px;}'+384'.grimoireSpell:active{top:1px;}'+385'.grimoireSpell.ready .grimoireIcon{opacity:1;}'+386'.grimoireSpell:hover{background-position:0px -74px;} .grimoireSpell:active{background-position:0px 74px;}'+387'.grimoireSpell:nth-child(4n+1){background-position:-60px 0px;} .grimoireSpell:nth-child(4n+1):hover{background-position:-60px -74px;} .grimoireSpell:nth-child(4n+1):active{background-position:-60px 74px;}'+388'.grimoireSpell:nth-child(4n+2){background-position:-120px 0px;} .grimoireSpell:nth-child(4n+2):hover{background-position:-120px -74px;} .grimoireSpell:nth-child(4n+2):active{background-position:-120px 74px;}'+389'.grimoireSpell:nth-child(4n+3){background-position:-180px 0px;} .grimoireSpell:nth-child(4n+3):hover{background-position:-180px -74px;} .grimoireSpell:nth-child(4n+3):active{background-position:-180px 74px;}'+390391'.grimoireSpell:hover .grimoireIcon{top:-1px;}'+392'.grimoireSpell.ready:hover .grimoireIcon{animation-name:bounce;animation-iteration-count:infinite;animation-duration:0.8s;}'+393'.noFancy .grimoireSpell.ready:hover .grimoireIcon{animation:none;}'+394395'#grimoireInfo{text-align:center;font-size:11px;margin-top:12px;color:rgba(255,255,255,0.75);text-shadow:-1px 1px 0px #000;}'+396'</style>';397str+='<div id="grimoireBG"></div>';398str+='<div id="grimoireContent">';399str+='<div id="grimoireSpells">';//did you know adding class="shadowFilter" to this cancels the "z-index:1000000001" that displays the selected spell above the tooltip? stacking orders are silly https://philipwalton.com/articles/what-no-one-told-you-about-z-index/400for (var i in M.spells)401{402var me=M.spells[i];403var icon=me.icon||[28,12];404str+='<div class="grimoireSpell titleFont" id="grimoireSpell'+me.id+'" '+Game.getDynamicTooltip('Game.ObjectsById['+M.parent.id+'].minigame.spellTooltip('+me.id+')','this')+'><div class="usesIcon shadowFilter grimoireIcon" style="background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;"></div><div class="grimoirePrice" id="grimoirePrice'+me.id+'">-</div></div>';405}406str+='</div>';407var icon=[29,14];408str+='<div id="grimoireBar" class="smallFramed meterContainer"><div '+Game.getDynamicTooltip('Game.ObjectsById['+M.parent.id+'].minigame.refillTooltip','this')+' id="grimoireLumpRefill" class="usesIcon shadowFilter lumpRefill" style="left:-40px;top:-17px;background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;"></div><div id="grimoireBarFull" class="meter filling"></div><div id="grimoireBarText" class="titleFont"></div><div '+Game.getTooltip('<div style="padding:8px;width:300px;font-size:11px;text-align:center;">This is your magic meter. Each spell costs magic to use.<div class="line"></div>Your maximum amount of magic varies depending on your amount of <b>Wizard towers</b>, and their level.<div class="line"></div>Magic refills over time. The lower your magic meter, the slower it refills.</div>')+' style="position:absolute;left:0px;top:0px;right:0px;bottom:0px;"></div></div>';409str+='<div id="grimoireInfo"></div>';410str+='</div>';411div.innerHTML=str;412M.magicBarL=l('grimoireBar');413M.magicBarFullL=l('grimoireBarFull');414M.magicBarTextL=l('grimoireBarText');415M.lumpRefill=l('grimoireLumpRefill');416M.infoL=l('grimoireInfo');417for (var i in M.spells)418{419var me=M.spells[i];420AddEvent(l('grimoireSpell'+me.id),'click',function(spell){return function(){PlaySound('snd/tick.mp3');M.castSpell(spell);}}(me));421}422423M.refillTooltip=function(){424return '<div style="padding:8px;width:300px;font-size:11px;text-align:center;">Click to refill <b>100 units</b> of your magic meter for <span class="price lump">1 sugar lump</span>.'+425(Game.canRefillLump()?'<br><small>(can be done once every '+Game.sayTime(Game.getLumpRefillMax(),-1)+')</small>':('<br><small class="red">(usable again in '+Game.sayTime(Game.getLumpRefillRemaining()+Game.fps,-1)+')</small>'))+426'</div>';427};428AddEvent(M.lumpRefill,'click',function(){429if (M.magic<M.magicM)430{Game.refillLump(1,function(){431M.magic+=100;432M.magic=Math.min(M.magic,M.magicM);433PlaySound('snd/pop'+Math.floor(Math.random()*3+1)+'.mp3',0.75);434});}435});436437M.computeMagicM();438M.magic=M.magicM;439M.spellsCast=0;440M.spellsCastTotal=0;441442//M.parent.switchMinigame(1);443}444M.save=function()445{446//output cannot use ",", ";" or "|"447var str=''+448parseFloat(M.magic)+' '+449parseInt(Math.floor(M.spellsCast))+' '+450parseInt(Math.floor(M.spellsCastTotal))+451' '+parseInt(M.parent.onMinigame?'1':'0')452;453return str;454}455M.load=function(str)456{457//interpret str; called after .init458//note : not actually called in the Game's load; see "minigameSave" in main.js459if (!str) return false;460var i=0;461var spl=str.split(' ');462M.computeMagicM();463M.magic=parseFloat(spl[i++]||M.magicM);464M.spellsCast=parseInt(spl[i++]||0);465M.spellsCastTotal=parseInt(spl[i++]||0);466var on=parseInt(spl[i++]||0);if (on && Game.ascensionMode!=1) M.parent.switchMinigame(1);467}468M.reset=function()469{470M.computeMagicM();471M.magic=M.magicM;472M.spellsCast=0;473}474M.logic=function()475{476//run each frame477if (Game.T%5==0) {M.computeMagicM();}478M.magicPS=Math.max(0.002,Math.pow(M.magic/Math.max(M.magicM,100),0.5))*0.002;479M.magic+=M.magicPS;480M.magic=Math.min(M.magic,M.magicM);481if (Game.T%5==0)482{483for (var i in M.spells)484{485var me=M.spells[i];486var cost=M.getSpellCost(me);487l('grimoirePrice'+me.id).innerHTML=Beautify(cost);488if (M.magic<cost) l('grimoireSpell'+me.id).className='grimoireSpell titleFont';489else l('grimoireSpell'+me.id).className='grimoireSpell titleFont ready';490}491}492}493M.draw=function()494{495//run each draw frame496M.magicBarTextL.innerHTML=Math.min(Math.floor(M.magicM),Beautify(M.magic))+'/'+Beautify(Math.floor(M.magicM))+(M.magic<M.magicM?(' (+'+Beautify((M.magicPS||0)*Game.fps,2)+'/s)'):'');497M.magicBarFullL.style.width=((M.magic/M.magicM)*100)+'%';498M.magicBarL.style.width=(M.magicM*3)+'px';499M.infoL.innerHTML='Spells cast : '+Beautify(M.spellsCast)+' (total : '+Beautify(M.spellsCastTotal)+')';500}501M.init(l('rowSpecial'+M.parent.id));502}503var M=0;504505