jocly
Version:
Board games 3D/2D UI and AI web library
1 lines • 25.1 kB
JavaScript
exports.view=View={Game:{},Board:{},Move:{}},function(){function e(e){return Math.floor(Math.random()*e)}function t(e){this.duration=e,this.sound=null,this.animations=[],this.addAnim=function(e,i,t){var a=$.extend(!0,{base:this.duration},t);this.animations.push({id:e,params:i,timings:a})},this.addSound=function(e){this.sound=e},this.play=function(e,i,t){function a(){0==--n&&i()}null!=this.sound&&t.PlaySound(this.sound);for(var n=this.animations.length,r=0;r<this.animations.length;r++){var s=this.animations[r];e.updateGadget(s.id,s.params,s.timings,a)}}}function a(){var e=this;this.name="scenario",this.init=function(){e.sequences=[]},this.createSequence=function(i){var a=new t(i);return e.sequences.push(a),a},this.play=function(i,t,a){function n(i){r==e.sequences.length-1?e.sequences[r].play(i,t,a):e.sequences[r].play(i,function(){r++,n(i)},a)}var r=0;n(i)},this.getLastSeq=function(){var i=null;return e.sequences.length>0&&(i=e.sequences[e.sequences.length-1]),i},this.init()}var n,r,s,d,o,l=1066,c=.859285714,p=[1,0],u=[0,1],h=.2,g=500,m=g+550,v={1:[[-6300,4100,g],[-4700,5e3,g],[-3200,4800,g],[1e3,-5200,g],[2600,-5300,g],[3100,-3900,g]],"-1":[[1e3,-5200,g],[2600,-5300,g],[3100,-3900,g],[-6300,4100,g],[-4700,5e3,g],[-3200,4800,g]]},f=[[1200,200],[1400,200],[1600,200],[1200,0],[1400,0],[1600,0]],E=[[0,200],[200,200],[400,200],[0,0],[200,0],[400,0]],b=[[600,200],[800,200],[1e3,200],[600,0],[800,0],[1e3,0]],y={1:[0,0,0,180,180,180],"-1":[180,180,180,0,0,0]},w={1:[90,45,0,315,225,270],"-1":[315,225,270,90,45,0]},S={1:[0,315,270,225,180,135,90,45],"-1":[180,135,90,45,0,315,270,225]};View.Game.xdInit=function(e){function i(e){var i=this,t=new THREE.PlaneGeometry(4,3,1,1),a=new THREE.MeshPhongMaterial({color:16777215,map:e,shading:THREE.FlatShading}),n=new THREE.Mesh(t,a);return i.objectReady(n),null}if(n=this.mViewOptions.fullPath,"undefined"!=typeof THREE){var t=n+"/res/xd-view/textures/skybox/",a=23,r=[t+"sb-nord.jpg",t+"sb-sud.jpg",t+"sb-top.jpg",t+"sb-bottom.jpg",t+"sb-ouest.jpg",t+"sb-est.jpg"],s=(new THREE.CubeTextureLoader).load(r);d=new THREE.MeshPhongMaterial({color:13421823,specular:1118481,shininess:100,envMap:s,combine:THREE.AddOperation,shading:THREE.SmoothShading,reflectivity:1}),o=new THREE.MeshPhongMaterial({color:17578,specular:1118481,shininess:100,envMap:s,combine:THREE.AddOperation,shading:THREE.FlatShading,reflectivity:.6})}e.createGadget("board",{"2d":{type:"image",file:n+"/res/images/ps-background.jpg",width:12030,height:10337}}),e.createGadget("goala",{base:{x:-1e3,y:5250},"2d":{type:"sprite",file:n+"/res/images/ps-images.png",clipx:200,clipy:400,clipwidth:200,clipheight:200,x:-859,y:4511,width:1718,height:1718,z:6},"3d":{type:"meshfile",file:n+"/res/xd-view/meshes/goals3.js"}}),e.createGadget("goalb",{base:{x:-1e3,y:-5250},"2d":{type:"sprite",file:n+"/res/images/ps-images.png",clipx:200,clipy:400,clipwidth:200,clipheight:200,x:-859,y:-4511,width:1718,height:1718,z:6,rotate:180},"3d":{type:"meshfile",file:n+"/res/xd-view/meshes/goals3.js"}}),e.createGadget("ball",{"2d":{type:"sprite",file:n+"/res/images/ps-images.png",clipx:0,clipy:400,clipwidth:200,clipheight:200,width:859,height:859,z:3},"3d":{type:"custommesh3d",create:function(e){var i=this;return this.getMaterialMap(n+"/res/xd-view/meshes/soccer-texture2.jpg",function(t){if(!t)return e(null);var a=new THREE.MeshPhongMaterial({color:12303291,specular:4473924,shininess:20,combine:THREE.MixOperation,shading:THREE.SmoothShading,map:t}),r="smoothedfilegeo|0|"+n+"/res/xd-view/meshes/soccerball2.js";i.getResource(r,function(i,t){i.computeVertexNormals();var n=new THREE.Mesh(i,a);e(n)})}),null}}});for(var l=["mama","daddy","baby"],c=0;c<6;c++)!function(i){var t=l[i%3],a=i<3?"A":"B";e.createGadget("penguin#"+i,{"2d":{type:"sprite",file:n+"/res/images/ps-images.png",clipwidth:200,clipheight:200,width:1031,height:1031,z:4},"3d":{type:"custommesh3d",scale:[.2,.2,.2],morphing:p,create:function(e){var i=this;return this.getMaterialMap(n+"/res/xd-view/meshes/"+t+"-"+a+"-diffusex512.jpg",function(a){if(!a)return e(null);var r=new THREE.MeshPhongMaterial({color:16777215,specular:1118481,shininess:50,combine:THREE.MixOperation,shading:THREE.SmoothShading,morphTargets:!0,map:a}),s="smoothedfilegeo|0|"+n+"/res/xd-view/meshes/"+t+"-animated.js";i.getResource(s,function(i,t){i.computeVertexNormals();var a=new THREE.Mesh(i,r);e(a)})}),null}}})}(c);for(var u=0;u<64;u++)!function(i){e.createGadget("text#"+i,{"2d":{type:"element",width:386,height:386,initialClasses:"notation",css:{"text-align":"center"},z:2,display:function(e,t,a){e.css({"font-size":.6*a+"pt","line-height":1*a+"px"}).text(i)}},"3d":{type:"custommesh3d",create:function(){var e=this;return this.getResource("font|"+n+"/res/xd-view/fonts/helvetiker_regular.typeface.json",function(t){var a=new THREE.TextGeometry(""+i,{size:.25,height:.05,curveSegments:6,font:t});a.center();var n=new THREE.MeshPhongMaterial({color:0}),r=new THREE.Mesh(a,n);e.objectReady(r)}),null}}}),e.createGadget("cell#"+i,{"3d":{type:"custommesh3d",scale:[1.1,1.1,1],create:function(e){var t="smoothedfilegeo|0|"+n+"/res/xd-view/meshes/icecube1.js";return this.getResource(t,function(t,a){t.computeVertexNormals();var n=Math.floor(i/8),r=i%8,s=new THREE.Mesh(t,(n+r)%2?d:o);e(s)}),null},flatShading:!0,rotate:90*Math.ceil(4*Math.random())}})}(u);for(var g=[{name:"up",width:1546,clipx:300,clipy:600,clipwidth:300,y:2148},{name:"slide",width:1546,clipx:600,clipy:600,clipwidth:300,y:3694},{name:"penguin0",width:1031,clipx:0,clipy:200,clipwidth:200,y:-1460},{name:"penguin1",width:1031,clipx:200,clipy:200,clipwidth:200,y:-2921},{name:"penguin2",width:1031,clipx:200,clipy:200,clipwidth:200,y:-4382}],c=0;c<g.length;c++)!function(i){e.createGadget(i.name+"-image",{"2d":{type:"sprite",file:n+"/res/images/ps-images.png",clipwidth:i.clipwidth,clipheight:200,width:i.width,height:1200,clipx:i.clipx,clipy:i.clipy,x:4726,y:i.y,z:4}}),e.createGadget(i.name+"-background",{"2d":{type:"sprite",file:n+"/res/images/ps-images.png",clipwidth:300,clipheight:200,width:2062,height:1203,clipx:0,clipy:600,x:4726,y:i.y,z:3}}),e.createGadget(i.name+"-highlight",{"2d":{type:"element",width:2234,height:1374,x:4726,y:i.y,z:2,css:{"background-color":"Orange","border-radius":"10%"}}});var t=!1;"up"===i.name&&(t=!0),e.createGadget(i.name+"-clicker",{"2d":{type:"element",width:2234,height:1374,x:4726,y:i.y,z:10,initialClasses:"clicker",opacity:0,css:{"border-radius":"10%"}},"3d":{type:t?"meshfile":"",scale:[h,h,5*h],flatShading:!0,z:1500,rotateX:90,file:n+"/res/xd-view/meshes/arrow.js",materials:{"mat.arrow":{color:35071}}}})}(g[c]);e.createGadget("cancel-image",{"2d":{type:"sprite",file:n+"/res/images/ps-images.png",clipwidth:200,clipheight:200,width:1031,height:1031,clipx:600,clipy:400,x:4897,y:172,z:4}}),e.createGadget("cancel-highlight",{"2d":{type:"element",width:1203,height:1203,x:4897,y:171,z:2,css:{"background-color":"transparent",border:"6px solid Magenta","border-radius":"50%"}}}),e.createGadget("cancel-clicker",{"2d":{type:"element",width:2234,height:1374,x:4897,y:171,z:10,initialClasses:"clicker",opacity:0,css:{"border-radius":"10%"}}});for(var c=0;c<8;c++)e.createGadget("rotator-image#"+c,{"2d":{type:"sprite",file:n+"/res/images/ps-images.png",clipwidth:200,clipheight:200,width:1031,height:1031,clipx:400,clipy:400,z:4}}),e.createGadget("rotator-highlight#"+c,{"2d":{type:"element",width:1031,height:1031,z:2,css:{"background-color":"transparent",border:"6px solid Orange","border-radius":"50%"}}}),e.createGadget("rotator-clicker#"+c,{"2d":{type:"element",width:1200,height:1200,z:10,initialClasses:"clicker",opacity:0,css:{"border-radius":"50%"}}}),e.createGadget("rotator-plot#"+c,{"2d":{type:"element",width:429,height:429,z:1,css:{"background-color":"White","border-radius":"50%"}}});e.createGadget("rotator-subject",{"2d":{type:"sprite",file:n+"/res/images/ps-images.png",clipwidth:200,clipheight:200,width:1031,height:1031,clipx:600,clipy:200,x:4124,y:3007,z:4,rotate:0}}),e.createGadget("rotator-circle",{"2d":{type:"element",width:2577,height:2577,x:4124,y:3007,z:1,css:{"background-color":"transparent",border:"6px solid White","border-radius":"50%"}}}),e.createGadget("surround",{"3d":{type:"custom3d",width:1e5,height:1e5,depth:1e5,scale:[1,1,1],rotate:90,create:function(){var e=n+"/res/xd-view/textures/skybox/",i=[e+"sb-nord.jpg",e+"sb-sud.jpg",e+"sb-top.jpg",e+"sb-bottom.jpg",e+"sb-ouest.jpg",e+"sb-est.jpg"],t=(new THREE.CubeTextureLoader).load(i),a=new THREE.MeshBasicMaterial({color:16777215,envMap:t,refractionRatio:.95}),r={uniforms:{tCube:{type:"t",value:null},tFlip:{type:"f",value:-1}},vertexShader:["varying vec3 vViewPosition;","void main() {","vec4 mPosition = modelMatrix * vec4( position, 1.0 );","vViewPosition = cameraPosition - mPosition.xyz;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform samplerCube tCube;","uniform float tFlip;","varying vec3 vViewPosition;","void main() {","vec3 wPos = cameraPosition - vViewPosition;","gl_FragColor = textureCube( tCube, vec3( tFlip * wPos.x, wPos.yz ) );","}"].join("\n")};r.uniforms.tCube.value=t;var a=new THREE.ShaderMaterial({fragmentShader:r.fragmentShader,vertexShader:r.vertexShader,uniforms:r.uniforms,depthWrite:!1,side:THREE.BackSide});return new THREE.Mesh(new THREE.CubeGeometry(3e3,3e3,3e3),a)}}}),e.createGadget("ocean",{"3d":{harbor:!1,type:"meshfile",file:n+"/res/xd-view/meshes/ocean.js",scale:[100,100,3],z:-400,smooth:0}}),e.createGadget("iceberg",{"3d":{type:"custommesh3d",z:500,create:function(e){var i=this,t=1;return function(){if(0==--t){var a="smoothedfilegeo|0|"+n+"/res/xd-view/meshes/banquise4.js";i.getResource(a,function(i,t){i.computeVertexNormals();var a=new THREE.Mesh(i,d);e(a)})}}(),null}}});for(var c=0;c<60;c++){var a=.1+.9*Math.random(),m=1e3*(15+50*Math.random()),v=Math.random()*Math.PI*2;e.createGadget("iceberg#"+c,{"3d":{harbor:!1,type:"meshfile",file:n+"/res/xd-view/meshes/iceberg-small.js",scale:[a,a,a],x:m*Math.cos(v),y:m*Math.sin(v),rotateX:360*Math.random(),rotate:360*Math.random(),z:-900,smooth:0}})}e.createGadget("videoa",{"3d":{type:"video3d",makeMesh:function(e){return i.call(this,e)},z:2e3,x:7e3,y:-7e3,rotate:-45,scale:[2,2,2]}}),e.createGadget("videoabis",{"3d":{type:"video3d",makeMesh:function(e){return i.call(this,e)},z:1e3,x:9930,y:-3930,rotate:-45,scale:[.5,.5,.5]}}),e.createGadget("videob",{"3d":{type:"video3d",makeMesh:function(e){return i.call(this,e)},z:2e3,x:-7e3,y:7e3,rotate:-225,scale:[2,2,2]}}),e.createGadget("videobbis",{"3d":{type:"video3d",makeMesh:function(e){return i.call(this,e)},z:1e3,x:-9930,y:3930,rotate:-225,scale:[.5,.5,.5]}})},View.Game.xdBuildScene=function(e){r=[];for(var i=0;i<64;i++){var t=Math.floor(i/8),a=i%8,n=(t-3.5)*l,s=(a-3.5)*l,d=135*Math.PI/180,o=n*Math.cos(d)+s*Math.sin(d),p=-n*Math.sin(d)+s*Math.cos(d);-1==this.mViewAs&&(o=-o,p=-p),r.push([-1e3+o,p,g])}for(var u=0;u<8;u++){var o=4800-this.mViewAs*Math.cos((45*u-90)*Math.PI/180)*1500,p=3500+this.mViewAs*Math.sin((45*u-90)*Math.PI/180)*1500;e.updateGadget("rotator-image#"+u,{"2d":{x:o*c,y:p*c,rotate:45*-u+(-1==this.mViewAs?180:0)}}),e.updateGadget("rotator-highlight#"+u,{"2d":{x:o*c,y:p*c}}),e.updateGadget("rotator-clicker#"+u,{"2d":{x:o*c,y:p*c}}),e.updateGadget("rotator-plot#"+u,{"2d":{x:o*c,y:p*c}})}e.updateGadget("board",{base:{visible:!0}}),e.updateGadget("goala",{base:{visible:!0},"3d":{scale:[1.4,1,1],flatShading:!1,materials:{filet:{wireframe:!0}},z:g}}),e.updateGadget("goalb",{base:{visible:!0},"3d":{scale:[1.4,1,1],flatShading:!1,materials:{filet:{wireframe:!0}},rotate:180,z:g}});for(var i=0;i<64;i++){var h=r[i];e.updateGadget("text#"+i,{base:{visible:this.mNotation},"2d":{x:h[0]*c,y:h[1]*c},"3d":{x:h[0],y:h[1],z:h[2],rotateX:-90,color:255}}),e.updateGadget("cell#"+i,{"3d":{x:h[0],y:h[1],z:0,rotate:45,visible:!0,receiveShadow:!0}})}e.updateGadget("surround",{"3d":{visible:!0}}),e.updateGadget("ocean",{"3d":{visible:!0,receiveShadow:!0}}),e.updateGadget("iceberg",{"3d":{visible:!0,receiveShadow:!0,rotate:45,scale:[1.05,1.05,1],x:-950}});for(var u=0;u<60;u++)e.updateGadget("iceberg#"+u,{"3d":{visible:!0}});e.updateGadget("videoa",{"3d":{visible:!0,playerSide:1}}),e.updateGadget("videoabis",{"3d":{visible:!0,playerSide:-1}}),e.updateGadget("videob",{"3d":{visible:!0,playerSide:-1}}),e.updateGadget("videobbis",{"3d":{visible:!0,playerSide:1}})},View.Board.penguinCoord=function(e,i,t){if(t<0)return v[e.mViewAs][i];var a=r[t][2];return(this.ball>=0&&this.ball==t||this.ball<0&&(27==t||28==t||35==t||36==t))&&(a=m),[r[t][0],r[t][1],a]},View.Board.penguinClip=function(e,i,t,a){return t<0?f[i]:a<0?E[i]:b[i]},View.Board.penguinMorph=function(e,i,t,a){return t<0?p:a<0?p:u},View.Board.penguinRotation=function(e,i,t,a){return t<0?w[e.mViewAs][i]:a<0?y[e.mViewAs][i]:S[e.mViewAs][a]},View.Board.xdDisplay=function(e,i){var t;t=-1==this.ball?[-1e3,0,g]:r[this.ball],e.updateGadget("ball",{base:{visible:!0,x:t[0],y:t[1]},"2d":{x:t[0]*c,y:t[1]*c},"3d":{z:800,scale:[.3,.3,.3]}});for(var a=0;a<this.penguins.length;a++){var n=this.penguins[a],t=this.penguinCoord(i,a,n.p),s=this.penguinClip(i,a,n.p,n.d),d=this.penguinRotation(i,a,n.p,n.d),o=this.penguinMorph(i,a,n.p,n.d);e.updateGadget("penguin#"+a,{base:{visible:!0,x:t[0],y:t[1],rotate:d},"2d":{x:t[0]*c,y:t[1]*c,clipx:s[0],clipy:s[1]},"3d":{castShadow:!0,z:t[2],morphing:o,rotate:180-d}})}},View.Board.xdBuildHTStateMachine=function(e,t,a){function d(t,a){for(D.ball>=0&&D.ball==t&&e.updateGadget("ball",{"3d":{click:a}}),i=0;i<6;i++)D.penguins[i].p>0&&D.penguins[i].p==t&&e.updateGadget("penguin#"+i,{"3d":{click:a}})}function o(i,t,n){var r=D.penguinCoord(a,i,D.penguins[i].p);e.updateGadget("penguin#"+i,{"3d":{click:t}}),d(D.penguins[i].p,t),v(r,t),f(r,n);var s=i%3,o=E[i];e.updateGadget("penguin"+s+"-image",{"2d":{visible:!0,clipx:o[0],clipy:o[1]}}),e.updateGadget("penguin"+s+"-background",{"2d":{visible:!0}}),e.updateGadget("penguin"+s+"-highlight",{"2d":{visible:!0}}),e.updateGadget("penguin"+s+"-clicker",{base:{visible:!0,click:t}})}function p(e,i,t){var a=r[e];d(e,i),v(a,i),f(a,t)}function u(i,t,n){if(null!==i){var s=r[i];v(s,t),m(s,n)}e.updateGadget("rotator-plot#"+n,{"2d":{visible:!0}}),e.updateGadget("rotator-highlight#"+n,{"2d":{visible:!0}}),e.updateGadget("rotator-clicker#"+n,{"2d":{visible:!0,click:t}});var d=b[z.i];e.updateGadget("rotator-subject",{"2d":{visible:!0,click:t,clipx:d[0],clipy:d[1],rotate:S[a.mViewAs][z.md]}}),e.updateGadget("rotator-circle",{"2d":{visible:!0}})}function m(i,t){var r="arrow#"+j.length;j.push(r),e.createGadget(r,{base:{x:i[0],y:i[1],width:1.3*l,height:1.3*l,rotate:S[a.mViewAs][t]},"2d":{type:"sprite",file:n+"/res/images/ps-images.png",clipwidth:200,clipheight:200,x:i[0]*c,y:i[1]*c,width:1031,height:1031,clipx:800,clipy:400,z:1},"3d":{z:i[2],type:"meshfile",scale:[h,h,h],flatShading:!0,file:n+"/res/xd-view/meshes/arrow.js",materials:{"mat.arrow":{color:16763904,opacity:1,specular:{r:0,g:0,b:0}}},rotate:-S[a.mViewAs][t]}}),e.updateGadget(r,{base:{visible:!0}})}function v(i,t){var a="clicker#"+j.length;j.push(a),e.createGadget(a,{base:{x:i[0],y:i[1],width:1.1*l,height:1.1*l,visible:!0,click:t},"2d":{type:"element",initialClasses:"clicker",opacity:0,css:{"border-radius":"50%"},z:10,x:i[0]*c,y:i[1]*c,width:1.1*l*c,height:1.1*l*c},"3d":{z:g,type:"meshfile",file:n+"/res/xd-view/meshes/ring-target.js",flatShading:!0,castShadow:!1,smooth:0,rotate:45,scale:[L,L,L],materials:{square:{transparent:!0,opacity:0},ring:{transparent:!0,opacity:0,specular:{r:0,g:0,b:0}}}}}),e.updateGadget(a,{base:{visible:!0}})}function f(i,t){var a="highlighter#"+j.length,r="Orange"==t?16763904:16711884;j.push(a),e.createGadget(a,{base:{x:i[0],y:i[1],width:1.1*l,height:1.1*l,visible:!0},"2d":{type:"element",css:{"background-color":"transparent",border:"6px solid "+t,"border-radius":"50%"},z:1,x:i[0]*c,y:i[1]*c,width:1.1*l*c,height:1.1*l*c},"3d":{z:g,type:"meshfile",file:n+"/res/xd-view/meshes/ring-target.js",flatShading:!0,smooth:0,rotate:45,scale:[L,L,L],materials:{square:{transparent:!0,opacity:0},ring:{color:r,opacity:1,specular:{r:0,g:0,b:0}}}}}),e.updateGadget(a,{base:{visible:!0}})}function w(i,t,a){e.updateGadget(i+"-image",{"2d":{visible:!0}}),e.updateGadget(i+"-background",{"2d":{visible:!0}}),e.updateGadget(i+"-highlight",{"2d":{visible:!0}});var n=[0,0,g];void 0!==a&&(n=r[a]),e.updateGadget(i+"-clicker",{base:{visible:!0,click:t},"3d":{x:n[0],y:n[1]}})}function x(i){e.updateGadget("cancel-image",{"2d":{visible:!0}}),e.updateGadget("cancel-highlight",{"2d":{visible:!0}}),e.updateGadget("cancel-clicker",{"2d":{visible:!0,click:function(){t.smQueueEvent("E_CANCEL",{})}}})}function G(i){j.forEach(function(i){e.removeGadget(i)}),["ball","penguin#0","penguin#1","penguin#2","penguin#3","penguin#4","penguin#5"].forEach(function(i){e.updateGadget(i,{base:{click:null}})}),["up","slide","penguin0","penguin1","penguin2"].forEach(function(i){e.updateGadget(i+"-image",{"2d":{visible:!1}}),e.updateGadget(i+"-background",{"2d":{visible:!1}}),e.updateGadget(i+"-highlight",{"2d":{visible:!1}}),e.updateGadget(i+"-clicker",{base:{visible:!1,click:null}})});for(var t=0;t<8;t++)e.updateGadget("rotator-image#"+t,{"2d":{visible:!1}}),e.updateGadget("rotator-highlight#"+t,{"2d":{visible:!1}}),e.updateGadget("rotator-plot#"+t,{"2d":{visible:!1}}),e.updateGadget("rotator-clicker#"+t,{"2d":{visible:!1,click:null}});e.updateGadget("rotator-subject",{"2d":{visible:!1}}),e.updateGadget("rotator-circle",{"2d":{visible:!1}}),e.updateGadget("cancel-image",{"2d":{visible:!1}}),e.updateGadget("cancel-highlight",{"2d":{visible:!1}}),e.updateGadget("cancel-clicker",{"2d":{visible:!1,click:null}})}function _(e){var i={};D.mMoves.forEach(function(e){i[e.i]=!0});for(var a in i)!function(e){o(e,function(){s=D.penguins[e].p,z.i=e,D.penguins[e].p<0?t.smQueueEvent("E_DRY",{}):t.smQueueEvent("E_SELECT",{})},"Orange")}(a)}function M(i){D.psAnimateDry(e,a,z.i,function(){t.smQueueEvent("E_DRY_DONE",{})})}function T(i){D.psAnimateSlide(e,a,z.i,z.p,z.md,function(){t.smQueueEvent("E_SELECT_DIR",{})})}function A(i){var n={};P.forEach(function(e){e.i==z.i&&(n[e.p]=e)});var r=0,d=0;for(var o in n){n[o].md>=0&&d++,r++}if(1==r)return z.p=o,z.md=n[o].md,void(z.md<0?(z.d=-1,t.smQueueEvent("E_STANDUP",{})):t.smQueueEvent("E_MOVE",{}));p(s,function(){t.smQueueEvent("E_CANCEL",{})},"Magenta");for(var o in n)!function(i){var r=n[i];if(r.md<0)w("up",function(){z.p=r.p,z.md=r.md,z.d=r.d,t.smQueueEvent("E_STANDUP",{})},i);else if(1==d&&w("slide",function(){z.p=r.p,z.md=r.md,z.d=r.d,t.smQueueEvent("E_MOVE",{})}),p(i,function(){z.p=r.p,z.md=r.md,D.ball>=0&&D.penguins[r.i].p==D.ball?(z.d=r.d,t.smQueueEvent("E_KICK",{})):t.smQueueEvent("E_MOVE",{})},"Orange"),d>1)if(e.updateGadget("rotator-image#"+n[i].md,{"2d":{visible:!0}}),e.updateGadget("rotator-highlight#"+n[i].md,{"2d":{visible:!0}}),e.updateGadget("rotator-clicker#"+n[i].md,{"2d":{visible:!0,click:function(){z.p=r.p,z.md=r.md,D.ball>=0&&D.penguins[r.i].p==D.ball?(z.d=r.d,t.smQueueEvent("E_KICK",{})):t.smQueueEvent("E_MOVE",{})}}}),D.ball>=0&&D.penguins[z.i].p==D.ball)e.updateGadget("rotator-subject",{"2d":{visible:!0,clipx:0,clipy:400,rotate:y[a.mViewAs][z.i]}});else{var s=E[z.i];e.updateGadget("rotator-subject",{"2d":{visible:!0,clipx:s[0],clipy:s[1],rotate:y[a.mViewAs][z.i]}})}}(o)}function R(i){var n={};P.forEach(function(e){e.i==z.i&&e.p==z.p&&e.md==z.md&&(n[e.d]=e)});var r=0;for(var s in n)r++;if(1==r)return z.d=s,void t.smQueueEvent("E_DIR",{});for(var s in n)!function(e){u(a.g.Graph[z.p][e],function(){z.d=e,t.smQueueEvent("E_DIR",{})},e)}(s);var d=S[a.mViewAs][z.md];e.updateGadget("rotator-subject",{"2d":{rotate:d}})}function C(i){D.psAnimateDir(e,a,z.i,z.p,z.d,function(){t.smQueueEvent("E_DIR_DONE",{})})}function N(i){D.psAnimateStandup(e,a,z.i,function(){t.smQueueEvent("E_STANDUP_DONE",{})})}function V(i){D.psAnimateKick(e,a,z.i,z.p,z.md,function(){t.smQueueEvent("E_KICK_DONE",{})})}function k(e){a.MakeMove(z)}function I(i){var t=z.i,n=D.penguins[z.i],d=D.penguinCoord(a,z.i,n.p),o=D.penguinClip(a,z.i,n.p,n.d),l=D.penguinRotation(a,z.i,n.p,n.d),p=D.penguinMorph(a,z.i,n.p,n.d);z.p<0?z.i=-1:(n.p<0&&(d=r[s],l=y[a.mViewAs][z.i]),z.p=-1,z.md=-1),e.updateGadget("penguin#"+t,{base:{x:d[0],y:d[1],rotate:l},"2d":{clipx:o[0],clipy:o[1],x:d[0]*c,y:d[1]*c},"3d":{z:d[2],morphing:p,rotate:180-l}}),d=[-1e3,0,g],D.ball>=0&&(d=r[D.ball]),e.updateGadget("ball",{base:{x:d[0],y:d[1]},"2d":{x:d[0]*c,y:d[1]*c}})}var D=this,z={i:-1,p:-1,md:-1,d:-1},P=this.mMoves,j=[],L=.6;t.smTransition("S_INIT","E_INIT","S_SELECT_PENGUIN",[]),t.smEntering("S_SELECT_PENGUIN",[_]),t.smTransition("S_SELECT_PENGUIN","E_DRY","S_ANIM_DRY",[M]),t.smTransition("S_SELECT_PENGUIN","E_SELECT","S_SELECT",[]),t.smTransition("S_ANIM_DRY","E_DRY_DONE","S_SELECT",[]),t.smEntering("S_SELECT",[A,x]),t.smTransition("S_SELECT","E_MOVE","S_ANIM_TARGET",[T]),t.smTransition("S_SELECT","E_STANDUP","S_ANIM_STANDUP",[N]),t.smTransition("S_SELECT","E_KICK","S_ANIM_KICK",[V]),t.smTransition("S_SELECT","E_CANCEL","S_SELECT_PENGUIN",[I]),t.smTransition("S_ANIM_TARGET","E_SELECT_DIR","S_SELECT_DIR",[]),t.smTransition("S_ANIM_STANDUP","E_STANDUP_DONE","S_DONE",[k]),t.smTransition("S_ANIM_KICK","E_KICK_DONE","S_DONE",[k]),t.smEntering("S_SELECT_DIR",[R,x]),t.smTransition("S_SELECT_DIR","E_DIR","S_ANIM_DIR",[C]),t.smTransition("S_SELECT_DIR","E_CANCEL","S_SELECT",[I]),t.smTransition("S_ANIM_DIR","E_DIR_DONE","S_DONE",[k]),t.smLeaving(["S_SELECT_PENGUIN","S_SELECT","S_SELECT_DIR"],[G]),t.smTransition(["S_DONE","S_SELECT_PENGUIN","S_SELECT","S_SELECT_DIR","S_ANIM_DRY","S_ANIM_TARGET","S_ANIM_STANDUP","S_ANIM_KICK"],"E_END","S_DONE",[G])},View.Board.psAnimateDry=function(e,i,t,a){var n=b[t];e.updateGadget("penguin#"+t,{"2d":{clipx:n[0],clipy:n[1],z:5},"3d":{morphing:u}},{base:1,"3d":200},function(){s=1==i.mWho?0:63;var n=r[s],d=v[i.mViewAs][t],o=Math.atan2(n[1]-d[1],n[0]-d[0])/Math.PI*180+90;e.updateGadget("penguin#"+t,{base:{rotate:o},"3d":{rotate:180-o}},300,function(){i.PlaySound("slide0"),e.updateGadget("penguin#"+t,{base:{x:n[0],y:n[1]},"2d":{x:n[0]*c,y:n[1]*c},"3d":{z:n[2]}},600,function(){e.updateGadget("penguin#"+t,{base:{rotate:y[i.mViewAs][t]},"2d":{z:4},"3d":{rotate:180-y[i.mViewAs][t]}},300,function(){a()})})})})},View.Board.psAnimateSlide=function(i,t,n,d,o,l){var h,g=this,m=r[s],v=g.penguinCoord(t,n,d);h=s==d?y[t.mViewAs][n]:Math.atan2(v[1]-m[1],v[0]-m[0])/Math.PI*180+90;var f=new a,w=f.createSequence(300),S=b[n];w.addAnim("penguin#"+n,{base:{rotate:h},"2d":{clipx:S[0],clipy:S[1]},"3d":{rotate:180-h,morphing:u}});var x=f.createSequence(500);x.addSound("slide"+e(5));var G=!1;if(g.ball<0&&(27==d||28==d||35==d||36==d)&&(G=!0,x.addAnim("ball",{base:{x:v[0],y:v[1]},"2d":{x:v[0]*c,y:v[1]*c}})),d==g.ball&&(G=!0),x.addAnim("penguin#"+n,{base:{x:v[0],y:v[1]},"2d":{x:v[0]*c,y:v[1]*c},"3d":{z:v[2]}}),G){x.addSound("haha");var S=E[n];x.addAnim("penguin#"+n,{"2d":{clipx:S[0],clipy:S[1]},"3d":{morphing:p}},{"2d":1,"3d":300})}this.psGetAnimsSlidePush(f,t,d,o),f.play(i,l,t)},View.Board.psGetAnimsSlidePush=function(e,i,t,a){var n=e.getLastSeq();if(null!=n)for(var s=0,d=this.board[t];null!=d&&null!=t;){var o=i.g.Graph[t][a],l=r[t],h=null==o?v[i.mViewAs][d.i]:r[o],g=Math.atan2(h[1]-l[1],h[0]-l[0])/Math.PI*180+90,m=b[d.i];if(n.addAnim("penguin#"+d.i,{base:{rotate:g,x:h[0],y:h[1]},"2d":{clipx:m[0],clipy:m[1],x:h[0]*c,y:h[1]*c},"3d":{z:h[2],morphing:u,rotate:180-g}}),null==o){var f=e.createSequence(400);m=E[d.i];var y=this.penguinRotation(i,d.i,-1);f.addSound("getup1"),f.addAnim("penguin#"+d.i,{"2d":{clipx:m[0],clipy:m[1],rotate:y},"3d":{morphing:p,rotate:180-y}})}s++,t=o,d=this.board[t]}},View.Board.psAnimateDir=function(e,i,t,a,n,d){var o=(r[s],r[a],y[i.mViewAs][t]);n>0&&(o=S[i.mViewAs][n]),e.updateGadget("penguin#"+t,{base:{rotate:o},"3d":{rotate:180-o}},300,function(){d()})},View.Board.psAnimateStandup=function(i,t,a,n){var r=E[a],s=y[t.mViewAs][a],d="getup"+e(2);t.PlaySound(d),i.updateGadget("penguin#"+a,{base:{clipx:r[0],clipy:r[1],rotate:s},"3d":{morphing:p,rotate:180-s}},{"2d":1,"3d":300},function(){n()})},View.Board.psAnimateKick=function(e,i,t,n,s,d){var o=this,l=S[i.mViewAs][s],h=new a,v=h.createSequence(300);v.addAnim("penguin#"+t,{base:{rotate:l},"3d":{rotate:180-l}}),v=h.createSequence(600),v.addSound("kick");var f=r[n];v.addAnim("ball",{base:{x:f[0],y:f[1]},"2d":{x:f[0]*c,y:f[1]*c}}),v.addAnim("penguin#"+t,{base:{rotate:l},"3d":{rotate:180-l,morphing:u,z:g}});var b=o.board[n];if(b){var w=E[b.i],l=y[i.mViewAs][b.i];v.addAnim("penguin#"+b.i,{base:{rotate:l},"2d":{clipx:w[0],clipy:w[1]},"3d":{rotate:180-l,morphing:p,z:m}})}h.play(e,d,i)},View.Board.psPlayedMove=function(e,i,t){function a(){t.md>=0?n.ball>=0&&r.p==n.ball?n.psAnimateKick(e,i,t.i,t.p,t.md,function(){i.MoveShown()}):n.psAnimateSlide(e,i,t.i,t.p,t.md,function(){t.d<0?i.MoveShown():n.psAnimateDir(e,i,t.i,t.p,t.d,function(){i.MoveShown()})}):n.psAnimateStandup(e,i,t.i,function(){i.MoveShown()})}var n=this,r=this.penguins[t.i];r.p<0?this.psAnimateDry(e,i,t.i,function(){a()}):(s=r.p,a())},View.Board.xdPlayedMove=function(e,i,t){return i.mOldBoard.psPlayedMove(e,i,t),!1}}();