-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcf.js
75 lines (75 loc) · 35.3 KB
/
cf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
var c=null,g=c;function j(a,b){if(typeof b!="number")return!1;return b<a?1:b>a?-1:0};function k(a,b){if(b===c||typeof b=="undefined")b=a,a=0;a<0?b+=Math.abs(a):b-=a;return Math.floor(Math.random()*b)+a}function aa(a,b){return j(b.i.length,a.i.length)}function ba(a,b){return j(b.X,a.X)}function n(a){var b=0,d;for(d in a)b+=a[d].b;return b}function ca(a,b){if(b in a)return a[b];return 0}
function da(a,b){var d=[],e;for(e in g.a){var f=g.a[e],h;for(h in f.z){var i=f.z[h];if(i.i==a.i){d.push(f);break}}}for(e=d.length-1;e>=0;e--)for(h in f=d[e],f.z){i=f.z[h];if(i.i==a.i)if(i.count==1)continue;else{if(ca(b,i.b)>=i.count-1)continue}else if(ca(b,i.b)>=i.count)continue;d.splice(e,1);break}return d}function o(a,b,d,e){this.u=a;this.j=b;this.ga=d;this.Y=e}o.prototype.toString=function(){return"rgba("+this.u+", "+this.j+", "+this.ga+", "+this.Y+")"};function ea(){this.m=this.a=this.c=c;this.m={};this.m[0]=new q("Non-Metals","#0F0");this.m[1]=new q("Noble gases","#09F");this.m[2]=new q("Alkali Metals","#F90");this.m[3]=new q("Alkaline earth metals","#FE0");this.m[4]=new q("Metalloids","#9C9");this.m[5]=new q("Halogens","#0F9");this.m[6]=new q("Post-transition metals","#CCC");this.c=[];this.c.push(new r("H","Hydrogen",1,1));this.c.push(new r("He","Helium",2,2));this.c.push(new r("Li","Lithium",3,1));this.c.push(new r("Be","Beryllium",4,2));this.c.push(new r("B",
"Boron",5,3));this.c.push(new r("C","Carbon",6,4));this.c.push(new r("N","Nitrogen",7,5));this.c.push(new r("O","Oxygen",8,6));this.c.push(new r("F","Fluorine",9,7));this.c.push(new r("Ne","Neon",10,8));this.c.push(new r("Na","Sodium",11,1));this.c.push(new r("Mg","Magnesium",12,2));this.c.push(new r("Al","Aluminum",13,3));this.c.push(new r("Si","Silicon",14,4));this.c.push(new r("P","Phosphorus",15,5));this.c.push(new r("S","Sulfur",16,6));this.c.push(new r("Cl","Chlorine",17,7));this.c.push(new r("Ar",
"Argon",18,8));this.c.push(new r("K","Potassium",19,1));this.c.push(new r("Ca","Calcium",20,2));this.a=[];this.a.push(new s("AlBO","aluminium boron oxide"));this.a.push(new s("AlBO2","aluminium borate"));this.a.push(new s("AlCl","aluminium monochloride"));this.a.push(new s("AlClF","aluminium chloride fluoride"));this.a.push(new s("AlClF2","aluminium chloride fluoride"));this.a.push(new s("AlClO","aluminium chloride oxide"));this.a.push(new s("AlCl2F","aluminium chloride fluoride"));this.a.push(new s("AlF",
"aluminium monofluoride"));this.a.push(new s("AlFO","aluminium monofluoride monoxide"));this.a.push(new s("AlF2","aluminium difluoride"));this.a.push(new s("AlF2O","aluminium difluoride oxide"));this.a.push(new s("AlF3","aluminium trifluoride"));this.a.push(new s("AlF4Li","lithium tetrafluoroaluminate"));this.a.push(new s("AlLiO2","lithium aluminate"));this.a.push(new s("AlN","aluminium nitride"));this.a.push(new s("AlNaO2","sodium aluminate"));this.a.push(new s("AlO","aluminium monoxide"));this.a.push(new s("AlOSi",
"aluminium silicon monoxide"));this.a.push(new s("AlO2","Aluminium(IV) oxide"));this.a.push(new s("AlP","aluminium monophosphide"));this.a.push(new s("AlPO4","aluminium phosphate"));this.a.push(new s("Al2O","dialuminium monoxide"));this.a.push(new s("Al2O2","dialuminium dioxide"));this.a.push(new s("Al2O3","aluminium oxide"));this.a.push(new s("Al2S","dialuminium monosulfide"));this.a.push(new s("ArClF","argon chloride fluoride"));this.a.push(new s("ArClH","argon chloride hydride"));this.a.push(new s("ArFH",
"argon fluoride hydride"));this.a.push(new s("BCl3","boron trichloride"));this.a.push(new s("BF3","boron trifluoride"));this.a.push(new s("BN","boron nitride"));this.a.push(new s("BP","boron(III) phosphide"));this.a.push(new s("BPO4","boron(III) orthophosphate"));this.a.push(new s("B2F4","boron trifluoride"));this.a.push(new s("B2H6","diborane"));this.a.push(new s("BH3","borane"));this.a.push(new s("B2O3","boron(III) oxide"));this.a.push(new s("B2S3","boron sulfide"));this.a.push(new s("B3N3H6","borazine"));
this.a.push(new s("B4C","boron carbide"));this.a.push(new s("BeB2","beryllium boride"));this.a.push(new s("BeCl2","beryllium chloride"));this.a.push(new s("BeF2","beryllium fluoride"));this.a.push(new s("BeO","beryllium oxide"));this.a.push(new s("BeS","beryllium sulfide"));this.a.push(new s("BeSO4","beryllium sulfate"));this.a.push(new s("Be2C","beryllium carbide"));this.a.push(new s("Be3N2","beryllium nitride"));this.a.push(new s("CCl2F2","dichlorodifluoromethane"));this.a.push(new s("CHCl3","chloroform"));
this.a.push(new s("CH2Cl2","dichloromethane"));this.a.push(new s("CH2O","formaldehyde"));this.a.push(new s("CH3Cl","chloromethane"));this.a.push(new s("CH4","methane"));this.a.push(new s("CO","carbon monoxide"));this.a.push(new s("COCl2","phosgene"));this.a.push(new s("CO2","carbon dioxide"));this.a.push(new s("CO3","carbon trioxide"));this.a.push(new s("CS2","carbon disulfide"));this.a.push(new s("C2F4","tetrafluoroethylene"));this.a.push(new s("C2H2","acetylene"));this.a.push(new s("C2H3Cl","vinyl chloride"));
this.a.push(new s("C2H4","ethylene"));this.a.push(new s("C2H4Cl2","ethylene dichloride"));this.a.push(new s("C2H4O2","acetic acid"));this.a.push(new s("C2H5NO2","glycine"));this.a.push(new s("C2H6","ethane"));this.a.push(new s("C2H6OS","dimethyl sulfoxide"));this.a.push(new s("C3H6","cyclopropane"));this.a.push(new s("C3H7NO2","alanine"));this.a.push(new s("C3H7NO3","serine"));this.a.push(new s("C3H8","propane"));this.a.push(new s("C3H8O","propanol"));this.a.push(new s("C4H8","cyclobutane"));this.a.push(new s("C4H8O",
"tetrahydrofuran"));this.a.push(new s("C4H10","butane"));this.a.push(new s("C4H10O","diethyl ether"));this.a.push(new s("C5H5N","pyridine"));this.a.push(new s("C5H10","cyclopentane"));this.a.push(new s("C5H12","pentane"));this.a.push(new s("C6H4O2","orthobenzoquinone"));this.a.push(new s("C6H5F","fluorobenzene"));this.a.push(new s("C6H6","benzene"));this.a.push(new s("C6H6O2","catechol"));this.a.push(new s("C6H12","cyclohexane"));this.a.push(new s("C6H14","hexane"));this.a.push(new s("C7H8","toluene"));
this.a.push(new s("C7H16","heptane"));this.a.push(new s("C8H8","cubane"));this.a.push(new s("CaB6","calcium boride"));this.a.push(new s("CaCO3","calcium carbonate"));this.a.push(new s("CaC2","calcium carbide"));this.a.push(new s("CaCl2","calcium chloride"));this.a.push(new s("CaF2","calcium fluoride"));this.a.push(new s("CaH2","calcium hydride"));this.a.push(new s("CaO","calcium oxide"));this.a.push(new s("CaO2","calcium peroxide"));this.a.push(new s("CaS","calcium sulfide"));this.a.push(new s("CaSiO3",
"calcium metasilicate"));this.a.push(new s("ClF","chlorine fluoride"));this.a.push(new s("ClF3","chlorine trifluoride"));this.a.push(new s("ClO2","chlorine dioxide"));this.a.push(new s("ClO3F","chlorine trioxide fluoride"));this.a.push(new s("Cl2","chlorine"));this.a.push(new s("Cl2O3","chlorine trioxide"));this.a.push(new s("FLi","lithium fluoride"));this.a.push(new s("FLiO","lithium hypofluorite"));this.a.push(new s("FLi2","dilithium monofluoride"));this.a.push(new s("FMg","magnesium monofluoride"));
this.a.push(new s("FN","fluoroimidogen"));this.a.push(new s("FNO","nitrosyl fluoride"));this.a.push(new s("FNO2","nitryl fluoride"));this.a.push(new s("FNO3","fluorine nitrate"));this.a.push(new s("FNS","thiazyl fluoride"));this.a.push(new s("FNa","sodium fluoride"));this.a.push(new s("FNa2","disodium monofluoride"));this.a.push(new s("FO","oxygen monofluoride"));this.a.push(new s("FO2","dioxygen monofluoride"));this.a.push(new s("FO3S","fluorosulfate radical"));this.a.push(new s("FP","phosphorus monofluoride"));
this.a.push(new s("FPS","phosphenothious fluoride"));this.a.push(new s("FPS2","phosphenodithioic fluoride"));this.a.push(new s("FS","monosulfur monofluoride"));this.a.push(new s("F2","fluorine"));this.a.push(new s("F2K2","dipotassium difluoride"));this.a.push(new s("F2Li2","lithium fluoride"));this.a.push(new s("F2Mg","magnesium fluoride"));this.a.push(new s("F2N","difluoroamino radical"));this.a.push(new s("F2N2O","nitrosodifluoroamine"));this.a.push(new s("F2Na2","disodium difluoride"));this.a.push(new s("F2O",
"difluorine monoxide"));this.a.push(new s("F2OS","thionyl fluoride"));this.a.push(new s("F2OSi","difluorooxosilane"));this.a.push(new s("F2O2","perfluoroperoxide"));this.a.push(new s("F2O2S","sulfuryl fluoride"));this.a.push(new s("F2P","phosphorus difluoride"));this.a.push(new s("F2S","sulfur difluoride"));this.a.push(new s("F2S2","difluorodisulfane"));this.a.push(new s("F2S2","thiothionyl fluoride"));this.a.push(new s("F2S2","thiothionyl fluoride"));this.a.push(new s("F2Si","difluorosilylene"));
this.a.push(new s("F3Li3","trilithium trifluoride"));this.a.push(new s("F3N","nitrogen trifluoride"));this.a.push(new s("F3NO","nitrogen trifluoride oxide"));this.a.push(new s("F3NS","thiazyl trifluoride"));this.a.push(new s("F3OP","phosphoryl fluoride"));this.a.push(new s("F3P","phosphorus trifluoride"));this.a.push(new s("F3PS","thiophosphoryl fluoride"));this.a.push(new s("F3S","sulfur trifluoride"));this.a.push(new s("F3Si","trifluorosilyl radical"));this.a.push(new s("F4Mg2","dimagnesium tetrafluoride"));
this.a.push(new s("F4Mg2","magnesium fluoride"));this.a.push(new s("F4N2","tetrafluorohydrazine"));this.a.push(new s("F4OS","sulfur tetrafluoride oxide"));this.a.push(new s("F4S","sulfur tetrafluoride"));this.a.push(new s("F4Si","silicon tetrafluoride"));this.a.push(new s("F5P","phosphorus pentafluoride"));this.a.push(new s("H2B2","diborene"));this.a.push(new s("HCN","hydrocyanic acid"));this.a.push(new s("HCl","hydrochloric acid"));this.a.push(new s("HClO","hypochlorous acid"));this.a.push(new s("HClO2",
"chlorous acid"));this.a.push(new s("HClO3","chloric acid"));this.a.push(new s("HClO4","perchloric acid"));this.a.push(new s("HF","hydrofluoric acid"));this.a.push(new s("HNO2","nitrous acid"));this.a.push(new s("HNO3","nitric acid"));this.a.push(new s("HN3","hydrazoic acid"));this.a.push(new s("HOCl","hypochlorous acid"));this.a.push(new s("HOF","hypofluorous acid"));this.a.push(new s("H2","hydrogen"));this.a.push(new s("H2CO","formaldehyde"));this.a.push(new s("H2CO3","carbonic acid"));this.a.push(new s("H2CSO",
"sulfine"));this.a.push(new s("H2C2O4","oxalic acid"));this.a.push(new s("H2O","water"));this.a.push(new s("H2O2","hydrogen peroxide"));this.a.push(new s("H2S","hydrogen sulfide"));this.a.push(new s("H2SO3","sulfurous acid"));this.a.push(new s("H2SO4","sulfuric acid"));this.a.push(new s("H2SiO3","silicic acid"));this.a.push(new s("H3PO4","phosphoric acid"));this.a.push(new s("KH","potassium hydride"));this.a.push(new s("KCN","potassium cyanide"));this.a.push(new s("KC2H5O","potassium ethoxide"));
this.a.push(new s("KCl","potassium chloride"));this.a.push(new s("KClO3","potassium chlorate"));this.a.push(new s("KF","potassium fluoride"));this.a.push(new s("KHCO3","potassium bicarbonate"));this.a.push(new s("KHSO3","potassium hydrogen sulfite"));this.a.push(new s("KNa","potassium sodide"));this.a.push(new s("KNO3","potassium nitrate"));this.a.push(new s("KO","monopotassium monoxide"));this.a.push(new s("KOCl","potassium hypochlorite"));this.a.push(new s("KOH","potassium hydroxide"));this.a.push(new s("KO2",
"potassium superoxide"));this.a.push(new s("KO3","potassium ozonide"));this.a.push(new s("K2Na2","dipotassium disodium"));this.a.push(new s("K2O","potassium oxide"));this.a.push(new s("K2O2","potassium peroxide"));this.a.push(new s("K2S","potassium sulfide"));this.a.push(new s("LiCN","lithium cyanide"));this.a.push(new s("LiC2H5O","lithium ethoxide"));this.a.push(new s("LiHSO4","lithium hydrogen sulfate"));this.a.push(new s("LiNa","sodium lithium"));this.a.push(new s("LiNO3","lithium nitrate"));this.a.push(new s("Li2SO4",
"lithium sulfate"));this.a.push(new s("Li2SiO3","lithium metasilicate"));this.a.push(new s("LiCl","lithium chloride"));this.a.push(new s("LiH","lithium hydride"));this.a.push(new s("MgCO3","magnesium carbonate"));this.a.push(new s("MgC2O4","magnesium oxalate"));this.a.push(new s("MgCl2","magnesium chloride"));this.a.push(new s("MgF2","magnesium fluoride"));this.a.push(new s("MgO","magnesium oxide"));this.a.push(new s("MgS","magnesium sulfide"));this.a.push(new s("MgSO4","magnesium sulfate"));this.a.push(new s("MgSiO3",
"magnesium metasilicate"));this.a.push(new s("NH3","ammonia"));this.a.push(new s("NH4Cl","ammonium chloride"));this.a.push(new s("NH4ClO4","Ammonium perchlorate"));this.a.push(new s("NO","nitric oxide"));this.a.push(new s("NO2","nitrogen dioxide"));this.a.push(new s("NO2Cl","nytril chloride"));this.a.push(new s("N2","nitrogen"));this.a.push(new s("N2H4","hydrazine"));this.a.push(new s("N2O","nitrous oxide"));this.a.push(new s("N2O3","dinitrogen trioxide"));this.a.push(new s("N2O4","dinitrogen tetroxide"));
this.a.push(new s("N2O5","dinitrogen pentaoxide"));this.a.push(new s("N4H4","trans-tetrazene"));this.a.push(new s("NaCN","sodium cyanide"));this.a.push(new s("NaCl","sodium chloride"));this.a.push(new s("NaH","sodium hydride"));this.a.push(new s("NaHCO3","sodium bicarbonate"));this.a.push(new s("NaNO3","sodium nitrate"));this.a.push(new s("NaOH","sodium hydroxide"));this.a.push(new s("Na2CO3","sodium carbonate"));this.a.push(new s("Na2O2","sodium peroxide"));this.a.push(new s("Na2O","sodium oxide"));
this.a.push(new s("Na2S","sodium monosulfide"));this.a.push(new s("O2","dioxygen"));this.a.push(new s("OF2","oxygen difluoride"));this.a.push(new s("O2F2","dioxygen difluoride"));this.a.push(new s("O3","ozone"));this.a.push(new s("SF4","sulfur tetrafluoride"));this.a.push(new s("SOF2","thionyl difluoride"));this.a.push(new s("SO2","sulfur dioxide"));this.a.push(new s("SO2F2","sulfuryl difluoride"));this.a.push(new s("SO3","sulfur trioxide"));this.a.push(new s("SiC","silicon carbide"));this.a.push(new s("SiH4",
"silane"));this.a.push(new s("SiO2","silicon(IV) dioxide"));for(var a in this.c){var b=this.c[a];b.j=b.G;if(b.G>=3)b.j+=10;else if(b.b==2)b.j=18;b.la=b.b<3?1:b.b<11?2:b.b<19?3:4;switch(b.b){case 1:case 6:case 7:case 8:case 15:case 16:b.r=this.m[0];break;case 2:case 10:case 18:b.r=this.m[1];break;case 3:case 11:case 19:b.r=this.m[2];break;case 4:case 12:case 20:b.r=this.m[3];break;case 5:case 14:b.r=this.m[4];break;case 9:case 17:b.r=this.m[5];break;case 13:b.r=this.m[6]}}a=this.c.slice(0);a.sort(aa);
for(var d in this.a){var b=this.a[d],e=a;b.z=[];var f=0,h=b.r,i=void 0;for(i in e){var l=e[i],m=RegExp("("+e[i].i+")([0-9]*)"),p=m.exec(h,"");p&&p.length>0&&(h=h.replace(m,""),m=p[2]==""?1:parseInt(p[2]),f+=l.b*m,b.z.push(new fa(l.i,l.b,m)))}b.X=f}this.A=0;this.v=1;this.d=new t("You",Math.PI*3/4);this.g=new t("Enemy",Math.PI*5/4)}ea.prototype.P=function(){this.g.q+=this.A;this.d.P(this.v);this.g.P(this.v);this.d.C-=this.g.C;this.d.C+=this.v*1E3;this.g.C=0};function q(a,b){this.b=a;this.color=b}
function r(a,b,d,e){this.i=a;this.f=b;this.b=d;this.G=e;this.r=this.la=this.j=c}function s(a,b){this.r=a;this.b=b;this.z=this.X=c}s.prototype.toString=function(){return this.r+" ("+this.b+")"};function fa(a,b,d){this.i=a;this.b=b;this.count=d};var u=c,v=c,ga=c,w=c,x=c,y=c,A=c,B=c,D=c,E=c,F=c,G=[],ha={},H;function ia(){g=new ea;I=J;H.children=[];var a="",b;for(b in g.a)a+="<li>"+g.a[b].toString()+"</li>";document.getElementById("knownCompoundList").innerHTML="<ul>"+a+"</ul>";w=new ja;H.addChild(w);x=new ka(H);B=new la(v);B.sa();y=new ma(540,H,g.d);A=new ma(62,H,g.g);K()}
window.SetupChemFight=function(){u=new Stratiscape({containerId:"canvasContainer",canvasNotSupportedCallback:na,layers:[{name:"canvasCFBackground",x:0,y:0,width:960,height:640,zIndex:1,backgroundColor:"black;"},{name:"canvasCFForegroundHUD",x:10,y:10,width:940,height:620,zIndex:2,clickCallback:oa,dblclickCallback:ha.Ea,mouseHitId:"canvasMouseHitDetector"}]});if(u.canvasSupported)v=u.getLayer("canvasCFBackground"),ga=v.ctx,u.getLayer("canvasCFForeground"),H=u.getLayer("canvasCFForegroundHUD"),ga.globalAlpha=
1,v.addChild(new pa),setInterval(function(){u.draw()},1E3/60),ia(),qa()};function na(){$("#startGameOptionsContainer").Ga();$("#canvasContainer").Ha('<p style="color:white">Chem Fight requires an HTML 5 compatible browser.</p>')}function oa(a){if(!w.K(a.x,a.y))switch(I){case J:x.K(a.x,a.y);y.K(a.x,a.y);break;case L:case M:y.K(a.x,a.y)}}
function ra(a,b,d,e,f){if(f)if(f.va(a,b)){d=f.f;if(I==J)sa(g.d,d),H.needsDisplay=!0;else if(I==M)ta(g.d,d)&&B.add(d,!0,!0);else if(I==L&&g.d.e==c)ua(g.d,d),g.d.e=d,B.add(d,!0,!0);y.refresh();return f}else if(f.ua(a,b)){d=f.f;if(I==J)va(g.d,d),H.needsDisplay=!0;else if(I==M)a=g.d,d.b in a.l&&a.l[d.b]>0&&(a.l[d.b]-=1),N(g.d,d),B.remove(d.b);else if(I==L&&g.d.e!==c)N(g.d,d),B.remove(d.b),g.d.e=c;y.refresh();return f}for(var h in e){var i=e[h];if(i.isInBounds(a,b))return f&&d.removeChild(f),f=new O(i.x-
20,i.y-20,i.f,!1),d.addChild(f),f.Ca(!0),f}return c}function P(a,b,d,e,f){a=new wa(a,b,d,"#FFF",20,e,f);G.push(a);H.addChild(a)}
function qa(){var a=0;P(450,310,"Welcome to Chem Fight",1E4,0);a+=5E3;P(450,330,"Start by choosing atoms to purchase",1E4+a,a);a+=5E3;P(470,390,"Purchase atoms by clicking on an element",1E4+a,a);P(470,410,"then click the plus (+) button to add one atom",1E4+a,a);a+=5E3;P(470,430,"Return purchased atoms by clicking on an element",1E4+a,a);P(470,450,"then click the minus (-) button to remove the atom",1E4+a,a)}
function la(a){this.layer=a;this.k=[];this.add=function(a,d,e){var f=0,h=940,i=0,l=620;e&&(f=370,h=571,i=230,l=391);a=new xa(k(f,h),k(i,l),a,d);this.k.push(a);this.layer.addChild(a);a.Ba()};this.remove=function(a){for(var d=this.k.length-1;d>=0;d--){var e=this.k[d];if(e.f.b==a){e.Z();this.layer.removeChild(e);this.k.splice(d,1);break}}};this.clear=function(){for(var a in this.k)this.k[a].Z(),this.layer.removeChild(this.k[a]);this.k=[]};this.sa=function(){for(var a=g.c.length-1;a>=0;a--)this.add(g.c[a],
!0,!1)};this.na=function(){for(var a in this.k)this.k[a].za()};this.ta=function(a){for(var d in this.k){var e=this.k[d];if(a==e.f.b)return e}return c};this.ja=function(){for(var a in this.k)this.k[a].da=!0,this.k[a].M=10};this.ca=function(a,d){for(var e=this.k.length-1;e>=0;e--){var f=this.k[e];if(a==f.f.b){f.da=!1;f.ka=!0;f.M=10;f.p=10;f.D=d?d.fa:Math.PI;this.k.splice(e,1);break}}};this.xa=function(a,d){var e=this.ta(a.b);if(e!=c){for(var f=d.fa==Math.PI*5/4,h=0;h<e.f.b*2;h++)this.layer.addChild(new ya(e.x,
e.y,e.backgroundColor.toString(),f));this.remove(a.b)}}}
function ma(a,b,d){this.x=20;this.y=a;this.layer=b;this.ya=d;this.o=c;this.t=[];this.refresh=function(){var b=za(d),f;for(f in this.t)this.layer.removeChild(this.t[f]);this.t=[];for(var h in b){var i=b[h];f=new O(20+h*40,a,i,!0);f.ia=Q(this.ya,i.b);this.t.push(f);this.layer.addChild(f)}if(this.o)this.layer.removeChild(this.o),Q(g.d,this.o.f.b)==0?this.o=c:this.layer.addChild(this.o)};this.T=function(){if(this.o)this.layer.removeChild(this.o),this.o=c};this.K=function(a,b){var d=ra(a,b,this.layer,
this.t,this.o),i=d!=c;i?this.o=d:this.T();return i}}
function ka(a){this.x=160;this.y=250;this.layer=a;this.o=c;this.t=[];this.T=function(){if(this.o)this.layer.removeChild(this.o),this.o=c};this.K=function(a,d){var e=ra(a,d,this.layer,this.t,this.o),f=e!=c;f?this.o=e:this.T();return f};this.ma=function(){for(var b in g.c){var d=g.c[b],d=new O(160+(d.j-1)*40,250+(d.la-1)*40,d,!1);this.t.push(d);a.addChild(d)}};this.clear=function(){this.T();for(var a in this.t)this.layer.removeChild(this.t[a]);this.t=[]}}
var ja=Stratiscape.DrawnObject.extend({init:function(){this.R=200;this.L=50;this.S=940-this.R-1;this.pa=620-this.L-2;this.Da=2;this.w=!1;this.F=c;this.ba=this.R;this.aa=this.L;this.U=this.S;this.V=this.pa-this.L-25},draw:function(a){I==R||I==S||I==T?(a.globalAlpha=0.4,a.fillStyle="rgba(51, 102, 153, 25)",a.fillRect(320,160,300,100),a.globalAlpha=1,a.strokeStyle="#008000",a.strokeRect(320,160,300,100),a.textAlign="center",a.textBaseline="middle",a.font="bolder 20px 'Lucida Sans Unicode', 'Lucida Grande', sans-serif",
a.fillStyle="#FE0",a.fillText("Your Score:",470,210),a.fillText(g.d.C+"",470,250)):(this.ha(a,this.pa,g.d),this.ha(a,this.Da,g.g));a.font="bolder 14px 'Lucida Sans Unicode', 'Lucida Grande', sans-serif";a.fillStyle="#FFF";a.textAlign="left";a.textBaseline="top";a.fillText("Enemy Elements",0,0);a.textBaseline="bottom";a.fillText("Your Elements",0,620);a.textAlign="center";a.textBaseline="middle";a.fillText("Round: "+g.v+", Turn: "+g.A,470,14);var b=this.R/2+25,d=125;switch(I){case J:a.fillText("Choose Elements to Purchase",
b,d);a.fillStyle="#FE0";a.font="12px 'Lucida Sans Unicode', 'Lucida Grande', sans-serif";d+=14;a.fillText("Your current Atom Bucks are on the bottom",b,d);d+=14;a.fillText("1 Atom Buck = 1 Proton (Atomic Number)",b,d);d+=14;a.fillText("(i.e. Helium costs 2 Atom Bucks each)",b,d);d+=14;a.fillText("After spending all your Atom Bucks,",b,d);d+=14;a.fillText("click the Done button.",b,d);d+=14;a.fillStyle="#00F";a.fillText("Noble gases are great for attacking,",b,d);d+=14;a.fillText("but cannot be used for defense.",
b,d);d+=14;a.fillText("Noble gases cost energy to purchase.",b,d);break;case L:a.fillText("Choose an Attacking Element",b,d);a.fillStyle="#FE0";a.font="12px 'Lucida Sans Unicode', 'Lucida Grande', sans-serif";d+=14;a.fillText("If your element does not form a compound",b,d);d+=14;a.fillText("with the opponents defending elements,",b,d);d+=14;a.fillText("it is considered a successful attack",b,d);d+=14;a.fillText("and the enemy loses life.",b,d);d+=14;a.fillStyle="#00F";a.fillText("Noble gases cannot be defended against.",
b,d);break;case M:a.fillText("Choose Elements to Defend with",b,d);a.fillStyle="#FE0";a.font="12px 'Lucida Sans Unicode', 'Lucida Grande', sans-serif";d+=14;a.fillText("If your chosen elements form a compound",b,d);d+=14;a.fillText("with the opponents attacking element,",b,d);d+=14;a.fillText("it is considered a successful defense.",b,d);d+=14;a.fillText("Unused defensive elements deduct energy,",b,d);d+=14;a.fillText("insufficient energy results in loss of life.",b,d);d+=14;a.fillStyle="#00F";a.fillText("Noble gases cannot be used for defense.",
b,d);break;case U:case V:a.fillText("The Battle Ensues",b,d);a.fillStyle="#FE0";a.font="12px 'Lucida Sans Unicode', 'Lucida Grande', sans-serif";d+=14;var e="",f="",h="";g.d.e===c?(f="You are defending with:",h=Aa(g.d),e="Opponent is attacking with "+g.g.e.i):(e="You are attacking with "+g.d.e.i,f="Opponent is defending with:",h=Aa(g.g));a.fillText(e,b,d);d+=14;a.fillText(f,b,d);d+=14;a.fillText(h,b,d);break;case T:a.fillText("You defeated your Opponent!",b,d);break;case S:a.fillText("You defeated all Opponents!",
b,d);break;case R:a.fillText("Your Opponent defeated You!",b,d)}this.w=!1;if(I==J&&(g.d.q==0||g.A>1))this.w=!0,this.F="Done Purchasing Elements";else if(I==M)this.w=!0,this.F="Done Choosing Defenders";else if(I==L&&g.d.e!==c)this.w=!0,this.F="Done Choosing Attacker";else if(I==V)this.w=!0,this.F="Continue";else if(I==T)this.w=!0,this.F="Next Round";else if(I==R)this.w=!0,this.F="Try Again";else if(I==S)this.w=!0,this.F="Play Again";if(this.w)a.font="bolder 12px 'Lucida Sans Unicode', 'Lucida Grande', sans-serif",
a.fillStyle="#FE0",a.fillText(this.F,this.U+this.ba/2,this.V+this.aa/2),a.strokeStyle="#008000",a.strokeRect(this.U,this.V,this.ba,this.aa);b=250;a.font="12px 'Lucida Sans Unicode', 'Lucida Grande', sans-serif";a.textAlign="left";a.textBaseline="top";for(var i in g.m)d=g.m[i],a.fillStyle=d.color,a.fillRect(0,b,18,18),a.fillText(d.b,25,b),b+=25;a.font="16px 'Lucida Sans Unicode', 'Lucida Grande', sans-serif";a.textAlign="center";a.textBaseline="middle";a.fillStyle="#FE0";if(I==M)g.g.e!=c&&a.fillText("Opponent's Attacking Element has: "+
g.g.e.G+(g.g.e.G==1?" valence electron.":" valence electrons."),470,155);else if(I==U)a.fillText("Checking for valid compounds for defense against: "+(g.d.e===c?g.g:g.d).e.f,470,155);else if(I==V)a.fillText(D,470,155),i=20,a.fillStyle="#FFF",F!==c&&(a.fillText(F,470,155+i),i+=20),E!==c&&a.fillText(E,470,155+i)},Fa:function(){},ha:function(a,b,d){a.globalAlpha=0.4;a.fillStyle="rgba(51, 102, 153, 25)";a.fillRect(this.S,b,this.R,this.L);a.globalAlpha=1;a.strokeStyle="#008000";a.strokeRect(this.S,b,this.R,
this.L);a.textAlign="left";a.textBaseline="top";a.font="bolder 12px 'Lucida Sans Unicode', 'Lucida Grande', sans-serif";a.fillStyle="#FE0";a.fillText(d.qa,this.S+2,b);a.font="bolder 25px 'Lucida Sans Unicode', 'Lucida Grande', sans-serif";a.fillStyle="#800000";a.beginPath();var e=16,f=b+25,h=this.S;a.arc(h+e,f,e/2,0,Math.PI*2,!0);a.arc(h+e*2,f,e/2,0,Math.PI*2,!0);a.closePath();a.fill();a.beginPath();f+=2;a.moveTo(h+e/2,f);a.lineTo(h+e*2.5,f);a.lineTo(h+e*1.5,f+e*1.4);a.closePath();a.fill();h+=40;
a.fillText(d.B+"",h,b+14);f-=2+e/2;h+=40;e/=2;var i=e/3,l=e*2/3;a.fillStyle="#00F";a.strokeStyle="#00F";a.beginPath();a.moveTo(h,f);e=[h+e,f+e,h,f+e,h+e,f+e*2,h,f+e*2,h+e,f+e*3,h+l,f+i+e*2,h+l+e,f+i+e*2,h+l,f+i+e,h+l+e,f+i+e];for(f=0;f<e.length;f+=2)a.lineTo(e[f],e[f+1]);a.closePath();a.stroke();a.fill();h+=16;a.fillText(d.s+"",h,b+14);h+=40;a.fillStyle="#FE0";a.fillText("$"+d.q,h,b+14)},K:function(a,b){if(this.w&&this.U<a&&a<this.U+this.ba&&this.V<b&&b<this.V+this.aa)return Ba(),!0;return!1}}),pa=
Stratiscape.DrawnObject.extend({draw:function(a){a.lineWidth=1;a.strokeStyle="#FE0";a.strokeRect(2,2,956,636);a.strokeStyle="#F90";a.strokeRect(0,0,960,640)}}),O=Stratiscape.DrawnObject.extend({init:function(a,b,d,e){this.i=40;this.x=a;this.y=b;this.f=d;this.backgroundColor=d.r.color;this.$=!1;this.n=16;this.I=a+45;this.J=b+5;this.N=a+25;this.O=b+5;this.Aa=e;this.ia=0},draw:function(a){var b=this.$?this.i*2:this.i;a.lineWidth=2;a.strokeStyle="#000";a.fillStyle=this.backgroundColor;a.fillRect(this.x,
this.y,b,b);a.strokeRect(this.x,this.y,b,b);a.textAlign="center";a.textBaseline="middle";a.font=b/4+"px 'Lucida Sans Unicode', 'Lucida Grande', sans-serif";a.fillStyle="#000";a.fillText(this.f.b,this.x+b/8+1,this.y+b/8);a.font="bolder "+b/2+"px 'Lucida Sans Unicode', 'Lucida Grande', sans-serif";a.fillText(this.f.i,this.x+b/2,this.y+b/2);if(this.$){a.font=b/6+"px 'Lucida Sans Unicode', 'Lucida Grande', sans-serif";a.fillText(this.f.f,this.x+b/2,this.y+b-b/8);var d=!1,e=!1;if(I==J)Ca(g.d,this.f)&&
(d=!0),Q(g.d,this.f.b)!=0&&(e=!0);else if(I==M){Q(g.d,this.f.b)!=0&&this.f.j!=18&&(d=!0);var f;f=g.d;var h=this.f.b;f=h in f.l?f.l[h]:0;f!=0&&(e=!0)}else I==L&&(g.d.e===c?d=!0:g.d.e.b==this.f.b&&(e=!0));a.strokeStyle="#000";a.beginPath();if(d)a.fillStyle="#008000",a.fillRect(this.I,this.J,this.n,this.n),a.moveTo(this.I+2,this.J+this.n/2),a.lineTo(this.I+this.n-2,this.J+this.n/2),a.moveTo(this.I+this.n/2,this.J+2),a.lineTo(this.I+this.n/2,this.J+this.n-2);if(e)a.fillStyle="#800000",a.fillRect(this.N,
this.O,this.n,this.n),a.moveTo(this.N+2,this.O+this.n/2),a.lineTo(this.N+this.n-2,this.O+this.n/2);a.stroke();a.closePath();d=[2,8,8,2];a.font="10px 'Lucida Sans Unicode', 'Lucida Grande', sans-serif";a.fillStyle="#000";a.textBaseline="top";f=e=0;var h=!1,i;for(i in d){e+=d[i];var l=d[i];this.f.b<=e&&(l=this.f.b-f+"",h=!0);a.fillText(l,this.x+b-8,this.y+10*i);f=e;if(h)break}}if(this.Aa)a.fillStyle="#00F",a.beginPath(),a.arc(this.x+b/2,this.y-30,15,0,Math.PI*2,!0),a.closePath(),a.fill(),a.fillStyle=
"#FE0",a.font="16px 'Lucida Sans Unicode', 'Lucida Grande', sans-serif",a.fillText(this.ia+"",this.x+b/2,this.y-30)},isInBounds:function(a,b){return this.x<a&&a<this.x+this.i&&this.y<b&&b<this.y+this.i},va:function(a,b){return this.I<a&&a<this.I+this.n&&this.J<b&&b<this.J+this.n},ua:function(a,b){return this.N<a&&a<this.N+this.n&&this.O<b&&b<this.O+this.n},Ca:function(a){this.$=a;this.layer.needsDisplay=!0}}),xa=Stratiscape.DrawnObject.extend({init:function(a,b,d,e){this.x=a;this.y=b;this.f=d;a=d.r.color;
a=a.charAt(0)=="#"?a.substr(1):a;b=c;a.length==3?(b=parseInt(a.substring(0,1),16),d=parseInt(a.substring(1,2),16),a=parseInt(a.substring(2,3),16),b=new o(b+b*16,d+d*16,a+a*16,255)):a.length==6&&(b=new o(parseInt(a.substring(0,2),16),parseInt(a.substring(2,4),16),parseInt(a.substring(4,6),16),255));this.backgroundColor=b;this.W=e;this.u=10+this.f.b*2;if(!e)this.u=20;this.p=1;this.D=k(0,360)*Math.PI/180;this.M=4;this.ka=this.da=this.ea=!1},draw:function(a){var b=new o(this.backgroundColor.u,this.backgroundColor.j,
this.backgroundColor.ga,this.backgroundColor.Y);a.fillStyle=b.toString();a.strokeStyle="#FFF";if(!this.W)b=new o(255,255,255,255),a.fillStyle=b.toString();var d=this.u*3,e=a.createRadialGradient(this.x,this.y,1,this.x,this.y,d);e.addColorStop(0,b.toString());b.Y=0;e.addColorStop(1,b.toString());a.fillStyle=e;a.fillRect(this.x-d,this.y-d,d*2,d*2);a.beginPath();a.arc(this.x,this.y,this.u,0,Math.PI*2,!0);a.closePath();a.fill();if(this.W)a.textAlign="center",a.textBaseline="middle",a.font="20px 'Lucida Sans Unicode', 'Lucida Grande', sans-serif",
a.fillStyle="#000",a.fillText(this.f.i,this.x,this.y)},za:function(){if(!this.W)this.u=10+this.f.b*2,this.W=!0,this.layer.needsDisplay=!0},Ba:function(){this.ea=!0;this.update()},Z:function(){this.ea=!1},wa:function(){return this.x-this.u<0||this.y-this.u<0||this.x+this.u>940||this.y+this.u>620},update:function(){var a=this.wa();if(this.ka){if(this.p=this.M,a){this.Z();this.layer.removeChild(this);return}}else this.da||a?this.D=Math.atan2(310-this.y,470-this.x):this.D+=k(-10,12)*Math.PI/180;this.p+=
k(-1,2);if(this.p<0)this.p=0;if(this.p>this.M)this.p=this.M;this.p!=0&&(this.x+=this.p*Math.cos(this.D),this.y+=this.p*Math.sin(this.D));if(this.ea){var b=this;setTimeout(function(){b.update()},100);this.layer.needsDisplay=!0}}}),ya=Stratiscape.DrawnObject.extend({init:function(a,b,d,e){this.x=a;this.y=b;this.color=d;this.p=k(30,51);this.D=(e?k(180,360):k(1,180))*Math.PI/180;var f=this;setTimeout(function(){f.update()},10)},draw:function(a){a.fillStyle=this.color;a.beginPath();a.arc(this.x,this.y,
5,0,Math.PI*2,!0);a.closePath();a.fill()},update:function(){this.p-=k(0,2);this.p>0&&(this.x+=this.p*Math.cos(this.D),this.y+=this.p*Math.sin(this.D));if(this.p>0){var a=this;setTimeout(function(){a.update()},50);if(this.layer)this.layer.needsDisplay=!0}else this.layer.removeChild(this)}}),wa=Stratiscape.DrawnObject.extend({init:function(a,b,d,e,f,h,i){this.x=a;this.y=b;this.text=d;this.color=e;this.font=f+"px 'Lucida Sans Unicode', 'Lucida Grande', sans-serif";this.oa=h;this.Q=i;this.H=1;if(this.Q>
0)this.H=0;var l=this;setTimeout(function(){l.remove()},h);this.update()},draw:function(a){a.globalAlpha=this.H;a.textAlign="center";a.textBaseline="middle";a.fillStyle=this.color;a.font=this.font;a.fillText(this.text,this.x,this.y);a.globalAlpha=1},update:function(){this.oa-=200;if(this.oa<=2E3&&this.H>0.09)this.H-=0.1;else if(this.Q>=200&&(this.Q-=200,this.Q<=2E3&&this.H<0.91&&(this.H+=0.1),this.Q<=0))this.H=1;if(this.layer)this.layer.needsDisplay=!0;var a=this;setTimeout(function(){a.layer&&a.update()},
200)},remove:function(){this.layer&&this.layer.removeChild(this)}});var I=c,W=c,J=1,L=2,M=3,U=4,V=5,T=6,R=7,S=8;function Da(){I=U;y.refresh();B.na();H.needsDisplay=!0;B.ja();setTimeout(function(){Ea()},2E3)}function Fa(){if(g.d.e.j==18)Ga(g.d,g.g);else{I=U;Ha(g.g,g.d.e.G);A.refresh();var a=Ia(g.g),b;for(b in a)B.add(a[b],!0,!0);H.needsDisplay=!0;B.ja();setTimeout(function(){Ea()},2E3)}}
function Ea(){var a=g.d.e===c?g.g:g.d,b=g.d.e===c?g.d:g.g,d;var e=da(a.e,b.l);e.length==0?d=c:(e.sort(ba),d=e[0]);e=Ia(b);E=F=c;if(d!==c){var f=d.X;b.q+=f;b.C+=f*10;b.s+=f*2;D="Defense Successful, Defender Earned "+f+" buck"+(f>1?"s":"")+" and "+f*2+" energy.";F="Compound: "+d.toString()+" formed.";for(var h in d.z){participant=d.z[h];for(f=0;f<participant.count;f++)if(f==0&&participant.b==a.e.b)B.ca(a.e.b);else for(var i=e.length-1;i>=0;i--)if(e[i].b==participant.b){B.ca(participant.b);e.splice(i,
1);break}}}else Ja(a,b),D="Attack Successful "+a.e.b+" damage dealt";h=a=0;for(var l in e)element=e[l],N(b,element),b.s-=element.b,a+=element.b,B.ca(element.b,b);if(b.s<0)h=b.s*-1,a-=h,b.B-=h,b.s=0;if(a!=0||h!=0)E=h+" Life lost and "+a+" Energy lost from unbonded defending elements.";I=V;H.needsDisplay=!0;Ka()}
function Ka(){g.d.B<=0?(I=R,P(470,310,"You lost all your Life",1E4,0),P(470,330,"Game Over!",1E4,3E3)):g.g.B<=0&&(g.v<3?(g.P(),I=T,P(470,310,"Opponent Defeated!",1E4,0),P(470,330,"Round Complete",1E4,3E3)):(g.P(),I=S,P(470,310,"You defeated all Opponents",1E4,0),P(470,330,"and won the Chem Fight!",1E4,0),P(470,350,"Congratulations!",1E4,3E3),P(470,370,"You are a chemical master!",1E4,3E3)))}
function Ba(){for(var a in G)G[a].remove();G=[];switch(I){case J:x.clear();for(a=g.g;a.q>0;){var b=c;if(g.v>1){for(var d=[],e=0;e<g.c.length;e++){var f=g.c[e];a.q>=f.b&&Q(a,f)==0&&d.push(f)}d.length>0&&(e=k(0,d.length),b=d[e].b-1)}b||(b=a.q+1<g.c.length?a.q+1:g.c.length,b=k(0,b));f=g.c[b];sa(a,f)}B.clear();I=M;W=L;K();break;case M:Da();break;case L:Fa();break;case V:X(g.d);X(g.g);A.refresh();y.refresh();I=W;I==L?(W=J,P(470,310,"Choose Attacker",6E3,1E3),La(g.d)):(W=L,K());H.needsDisplay=!0;break;
case T:a=g;a.A=0;a.v++;I=J;x.ma();g.A++;A.refresh();y.refresh();break;case R:case S:ia()}}function La(a){Ma(a)==0&&(P(470,310,"No Elements owned by Attacker",3E3,0),P(470,340,"Skipping to next Stage",3E3,0),setTimeout(function(){I==L?(I=J,K()):(I=V,Ba())},3E3))}function Ja(a,b){B.xa(a.e,b);b.B-=a.e.b;a.C+=a.e.b*10}function Ga(a,b){I=V;B.na();Ja(a,b);F=c;D="A noble gas attacked, unable to defend.";E=a.e.b+" damage dealt";H.needsDisplay=!0;Ka()}
function K(){if(I==M){A.refresh();La(g.g);var a;a=g.g;a.e=c;for(var b=g.c.length-1;b>=0;b--){var d=g.c[b];if(d.j==18&&d.b in a.h&&a.h[d.b]>0){a.e=d;break}}if(!a.e&&g.v>1){for(var e=[],b=g.c.length-1;b>=0;b--)d=g.c[b],d.j>1&&d.j<17&&e.push(d);if(e.length>0){for(b=d=0;b<e.length;b++)d+=Math.pow(2,b);for(b=0;b<e.length;b++)if(k(0,d+1)<=Math.pow(2,e.length-b-1)){a.e=e[b];break}}}if(!a.e)b=Z(a),a.e=b.length==0?c:b[k(0,b.length)];a.e&&ua(a,a.e);if(a=a.e)B.add(a,!1,!0),a.j==18?Ga(g.g,g.d):P(470,310,"Choose Defenders",
6E3,1E3)}else I==J&&(g.d.q+=g.A*2,g.g.q+=g.A*2,x.ma(),g.A++,g.A>1&&P(470,310,"Purchase more Elements",6E3,1E3))};function t(a,b){this.B=30;this.s=10;this.q=30;this.C=0;this.qa=a;this.fa=b;this.h={};this.e=c;this.l={}}t.prototype.P=function(a){var b=Z(this),d;for(d in b)va(this,b[d]);this.C+=(this.q+this.B)*10;this.C+=this.s*5;this.B=30+15*a;this.s=this.B/3;this.q=this.B;X(this);this.h={}};function X(a){a.e=c;a.l={}}function Q(a,b){if(b in a.h)return a.h[b];return 0}
function Aa(a){var b="",d;for(d in g.c){var e=g.c[d];if(e.b in a.l&&a.l[e.b]>0){b.length!=0&&(b+=", ");var f=a.l[e.b];b+=(f>1?f+"":"")+e.i}}b==""&&(b="<none>");return b}function Ia(a){var b=[],d;for(d in a.l)for(var e=a.l[d],f=g.c[d-1],h=0;h<e;h++)b.push(f);return b}function Ma(a){var b=0,d;for(d in a.h)b+=a.h[d];return b}function Z(a){var b=[],d;for(d in g.c){var e=g.c[d];if(e.b in a.h&&a.h[e.b]>0)for(var f=a.h[e.b];f>0;)b.push(e),f--}return b}
function za(a){var b=[],d;for(d in g.c){var e=g.c[d];e.b in a.h&&a.h[e.b]>0?b.push(e):e.b in a.l&&a.l[e.b]>0?b.push(e):a.e!==c&&a.e.b==e.b&&b.push(e)}return b}function Ca(a,b){if(a.q<b.b)return!1;if(b.j==18&&a.s<b.b/2)return!1;return!0}function sa(a,b){Ca(a,b)&&(N(a,b),a.q-=b.b,b.j==18&&(a.s-=b.b/2))}function N(a,b){b.b in a.h||(a.h[b.b]=0);a.h[b.b]+=1}function ua(a,b){b.b in a.h&&a.h[b.b]>0&&(a.h[b.b]-=1)}function va(a,b){b.b in a.h&&a.h[b.b]>0&&(a.h[b.b]-=1,a.q+=b.b,b.j==18&&(a.s+=b.b/2))}
function ta(a,b){if(Q(a,b.b)==0||b.j==18)return!1;b.b in a.l||(a.l[b.b]=0);a.l[b.b]+=1;a.h[b.b]-=1;return!0}
function Ha(a,b){var d=b==1?2:8,e=0,f=Z(a),h=!1;for(oe in f)e+=f[oe].G,f[oe].j==1&&(h=!0);d==2&&!h&&(d=8);d-=b;e=[];if(g.v>=3){var f=za(g.d),d=[],i;for(i in f)h=f[i],h.G==b&&d.push(h);for(var l in d){var f=d[l],h=da(f,a.h),m;for(m in h){var p=h[m];i=[];for(var z in p.z)for(var C=p.z[z],Y=0;Y<C.count;Y++)Y==0&&C.i==f.i||i.push(g.c[C.b-1]);i.length>0&&e.push(i)}}}else{l=[];m=[];for(p in f)h=f[p],h.j!=18&&(z=[],z.push(h),m.push(z),l.push(h));e=Na(a,d,m,0,l)}if(e.length>0)for(oe in e.sort(a.ra),l=e[0],
g.v==1&&(l=e[k(0,e.length)]),l)ta(a,l[oe])}t.prototype.ra=function(a,b){return j(n(a),n(b))};function Na(a,b,d,e,f){var h=[],i;for(i in d){var l=d[i],m;m=0;var p=void 0;for(p in l)m+=l[p].G;if(m==b)h.push(l);else if(m>b)continue;for(m=e+1;m<f.length;m++){p=l.slice(0);p.push(f[m]);var z=[];z.push(p);var p=Na(a,b,z,m,f),C;for(C in p)h.push(p[C])}}return h};