UNPKG

jocly

Version:

Board games 3D/2D UI and AI web library

1 lines 19.7 kB
exports.view=View={Game:{},Board:{},Move:{}},function(){function e(e,t){return e[0]==t[0]?e[1]>t[1]?90:-90:180+Math.atan2(t[0]-e[0],t[1]-e[1])*(180/Math.PI)}function t(e){for(var t=0,a=0;a<u.length;a++){var i=u[a].a*Math.PI/180,s=u[a].r,o=u[a].zoom,r=u[a].rotOffset,n=3.5;n*=o,e.createGadget("palmtrunc#"+a,{cartoon3d:{harbor:!1,type:"meshfile",file:e.game.mViewOptions.fullPath+"/res/xd-view/meshes/palmtreetrunc.js",scale:[n,n,n],z:3e3*o,x:h*s*Math.cos(i),y:h*s*Math.sin(i),rotate:r,smooth:0}});for(var d=0;d<p;d++)for(var l=0;l<m;l++){var n=1,n=7*n/(7+d)*o;e.createGadget("palmleaf#"+t,{cartoon3d:{harbor:!1,type:"meshfile",file:e.game.mViewOptions.fullPath+"/res/xd-view/meshes/leaves5.js",scale:[n,n,n],z:3e3*o*.99,x:h*s*Math.cos(i),y:h*s*Math.sin(i),rotate:r+380*(d/2+l+(Math.random()-.5)/5)/m,rotateY:d*(80/p),smooth:0,materials:{palmgreen:{side:THREE.DoubleSide}}}}),t++}}}function a(e){e.createGadget("light",{"3d":{type:"custom3d",create:function(){var e=new THREE.SpotLight(16777130,1,0,1.05,1,2);return $.extend(this.options,{intensity:0}),e},display:function(e,t,a){this.object3d.target.position.x=this.object3d.position.x,this.object3d.target.position.z=this.object3d.position.z;var i=this;(e||this.options.intensity!=t.intensity)&&(a?(this.animStart(t),setTimeout(function(){i.object3d.position.z=2e5,i.object3d.intensity=t.intensity,i.animEnd(t)},a)):this.object3d.intensity=t.intensity)},z:2e5,intensity:0}})}function i(e,t,a,i){var s,o=t.getVCoord(i),r=t.getVCoord(a.pos);s=o[0]>r[0]?o[1]>r[1]?[120,-60]:o[1]<r[1]?[60,-120]:[0,180]:o[1]>r[1]?[60,-120]:o[1]<r[1]?[-60,120]:[0,180];var n,d=s[0],l=s[1];n=Math.abs(d+360-(a.angle+360))>Math.abs(l+360-(a.angle+360))?l:d;var c=a.type+":"+a.s+":"+a.index;e.updateGadget(c,{"3d":{rotate:n}},500,function(){e.updateGadget(c,{"3d":{rotate:a.angle}},1500)})}function s(e,t,a,s){for(var r=(t.getVCoord(a.pos),0);r<s.length;r++)!function(s){attackerId=s.type+":"+s.s+":"+s.index,i(e,t,s,a.pos)}(s[r]);setTimeout(function(){o(e,t,a)},800)}function o(e,t,a){var i=a.type+":"+a.s+":"+a.index,s=t.getVCoord(a.pos);e.updateGadget("light",{"3d":{x:s[0],y:s[1],z:2e3,intensity:20,visible:!0}}),e.updateGadget("light",{"3d":{intensity:0,z:5e3}},200),e.updateGadget(i,{"3d":{rotateX:60}},1e3),e.updateGadget(i,{"3d":{z:-2e3}},2e3)}function r(e,t){function a(t){var a,i,s=e.g.Coord[t],o=n-1-s[0],r=s[1];return"onASide"==l?(a=r%2==0?(1+r/2*3)*c:-c/2+(r+1)/2*3*c,i=h*(o+1)):(a=h*(r+1),i=o%2==0?(1+o/2*3)*c:-c/2+(o+1)/2*3*c),[a,i]}e.mViewAs==JocGame.PLAYER_B&&(t=e.g.Graph.length-1-t);var i=a(38),s=i[0],o=i[1],r=a(t);return r=[r[0]-s,r[1]-o]}var n,d,l,c=750,h=c*Math.cos(Math.PI/6),p=3,m=5,u=[{r:18,a:210,zoom:.8,rotOffset:90},{r:15,a:215,zoom:1,rotOffset:270},{r:15,a:250,zoom:.7,rotOffset:170},{r:25,a:285,zoom:.6,rotOffset:0},{r:25,a:295,zoom:.8,rotOffset:270},{r:18,a:15,zoom:1,rotOffset:0},{r:25,a:170,zoom:1.2,rotOffset:0},{r:35,a:92,zoom:.8,rotOffset:270}];View.Game.getVCoord=function(e){return r(this,e)},View.Game.xdInit=function(e){function i(e){var t=this;return this.getResource("smoothedfilegeo|0|"+o+"/res/xd-view/meshes/barilscreen.js",function(a,i){for(var s=[],o=0;o<i.length;o++)if("screen"==i[o].name){var r=i[o].clone();r.map=e,r.overdraw=!0,s.push(r)}else s.push(i[o]);var n=new THREE.Mesh(a,new THREE.MultiMaterial(s));n.visible=!1,t.objectReady(n)}),null}var s=this,o=this.mViewOptions.fullPath;n=this.mOptions.maxLines,d=this.mOptions.maxCols,l=this.mOptions.orientation,a(e),e.createGadget("board",{official:{type:"image",file:o+"/res/images/oceanboard.jpg",width:12600,height:11340}}),e.createGadget("surround",{cartoon3d:{harbor:!1,type:"custom3d",width:1e5,height:1e5,depth:1e5,scale:[1,1,1],rotate:90,create:function(){var e=o+"/res/xd-view/textures/skybox/",t=[e+"px.jpg",e+"nx.jpg",e+"py.jpg",e+"ny.jpg",e+"pz.jpg",e+"nz.jpg"],a=(new THREE.CubeTextureLoader).load(t),i=new THREE.MeshBasicMaterial({color:16777215,envMap:a,refractionRatio:.95}),s={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")};s.uniforms.tCube.value=a;var i=new THREE.ShaderMaterial({fragmentShader:s.fragmentShader,vertexShader:s.vertexShader,uniforms:s.uniforms,depthWrite:!1,side:THREE.BackSide});return new THREE.Mesh(new THREE.CubeGeometry(3e3,3e3,3e3),i)}}}),e.createGadget("ocean",{cartoon3d:{harbor:!1,type:"meshfile",file:o+"/res/xd-view/meshes/ocean.js",scale:[200,200,3],z:-50,smooth:0},stylized3d:{type:"meshfile",file:o+"/res/xd-view/meshes/woodboard3.js",scale:[2.4,2.14,1],z:-130,smooth:0,flatShading:!0}}),e.createGadget("island",{cartoon3d:{harbor:!1,type:"meshfile",file:o+"/res/xd-view/meshes/landscape-smoothed.js",scale:[1,1,1],z:0,smooth:0}}),e.createGadget("flag",{cartoon3d:{type:"meshfile",file:o+"/res/xd-view/meshes/barilflagsquare.js",scale:[.6,.6,.6],z:0,rotate:90,x:10*h,smooth:0},stylized3d:{type:"meshfile",file:o+"/res/xd-view/meshes/stylized-flag.js",scale:[.6,.6,.6],z:0,rotate:90,x:10*h,smooth:0}}),e.createGadget("hexboard",{base:{x:0,y:0},cartoon3d:{visible:!0,receiveShadow:!0,type:"custommesh3d",radius:12*c*.95,rotate:30,thickness:210,z:-150,smooth:1,create:function(){var e=new THREE.CylinderGeometry(this.options.radius*this.SCALE3D,this.options.radius*this.SCALE3D,this.options.thickness*this.SCALE3D,64,1,!1),t=new THREE.MeshLambertMaterial({color:"#1630ff"});return new THREE.Mesh(e,t)}}}),t(e),e.createGadget("videoa",{"3d":{type:"video3d",castShadow:!1,makeMesh:function(e){i.call(this,e)}}}),e.createGadget("videob",{"3d":{type:"video3d",castShadow:!1,makeMesh:function(e){i.call(this,e)}}}),e.createGadget("videoa-sky",{"3d":{type:"video3d"}}),e.createGadget("videob-sky",{"3d":{type:"video3d"}});for(var r=0;r<this.g.Graph.length;r++){var p=this.g.Coord[r],m=n-1-p[0],u=p[1],E=this.getVCoord(r),f="rgba(0,0,128,0.1)",v="rgba(0,195,255,0.7)",g=16777215,S=.3;"c"==this.mOptions.boardLayout[m][u]&&(f="rgba(0,0,128,0.3)",v="rgba(0,195,255,0.9)",g=8421504,S=.2),e.createGadget("hex#"+r,{base:{x:E[0],y:E[1]},"2d":{type:"hexagon",width:2.6*c,height:2.6*c,radius:.98*c,lineWidthFactor:1,strokeStyle:"rgba(255,255,255,0.2)",fillStyle:f,css:{},z:1},stylized:{fillStyle:v,radius:.95*c},"3d":{receiveShadow:!0},cartoon3d:{type:"custommesh3d",radius:.95*c,thickness:.1*c,opacity:S,color:g,z:.04*-c,create:function(){var e=new THREE.CylinderGeometry(this.options.radius*this.SCALE3D,this.options.radius*this.SCALE3D,this.options.thickness*this.SCALE3D,6,1,!1),t=new THREE.MeshLambertMaterial({color:this.options.color,transparent:!0,opacity:this.options.opacity});return new THREE.Mesh(e,t)}},stylized3d:{type:"custommesh3d",radius:.95*c,thickness:.1*c,opacity:S,color:8421504,z:0,create:function(){var e=new THREE.CylinderGeometry(this.options.radius*this.SCALE3D,this.options.radius*this.SCALE3D,this.options.thickness*this.SCALE3D,6,1,!1),t=new THREE.MeshPhongMaterial({color:this.options.color,transparent:!0,opacity:this.options.opacity});return new THREE.Mesh(e,t)}}}),e.saveGadgetProps("hex#"+r,["opacity","color"],"initial"),e.createGadget("mask#"+r,{"2d":{type:"disk",width:2*h,height:2*h,x:E[0],y:E[1],z:5}}),function(t){e.createGadget("text#"+r,{"2d":{type:"element",width:h,height:.5*h,css:{color:"White","text-align":"center"},x:E[0],y:E[1]-500,z:4,display:function(e,a,i){e.css({"font-size":.6*i+"pt","line-height":1*i+"px"}).text(t)}},stylized:{y:E[1]-400,css:{color:"Black","text-align":"center"}},"3d":{type:"custommesh3d",z:20,rotateX:-90,create:function(){var e=this;return this.getResource("font|"+o+"/res/xd-view/fonts/helvetiker_regular.typeface.json",function(a){var i=new THREE.TextGeometry(""+t,{size:.25,height:.05,curveSegments:6,font:a}),s=new THREE.MeshBasicMaterial,o=new THREE.Mesh(i,s);e.objectReady(o)}),null}}})}(r)}for(var y={C:{type:"C",count:1,positionX:100,name:"admiral",scale:[1,.8,1],sscale:[.8,.65,.8],blackMaterial:{voiles:{map:this.mViewOptions.fullPath+"/res/xd-view/meshes/jarmada-admiral-voiles-pirate-uvs-512.jpg"},coque:{map:this.mViewOptions.fullPath+"/res/xd-view/meshes/jarmada-admiral-pirate-uvs-512.jpg"}}},c:{type:"c",count:2,positionX:200,name:"gallion",scale:[.9,.7,.9],sscale:[.8,.7,.9],blackMaterial:{voiles:{map:this.mViewOptions.fullPath+"/res/xd-view/meshes/jarmada-admiral-voiles-pirate-uvs-512.jpg"},coque:{map:this.mViewOptions.fullPath+"/res/xd-view/meshes/jarmada-gallion-pirate-uvs-512.jpg"}}},p:{type:"p",count:4,positionX:0,name:"frigate",scale:[1,1,1],sscale:[.7,.8,.7],blackMaterial:{voiles:{map:this.mViewOptions.fullPath+"/res/xd-view/meshes/jarmada-admiral-voiles-pirate-uvs-512.jpg"},coque:{map:this.mViewOptions.fullPath+"/res/xd-view/meshes/jarmada-frigate-pirate-uvs-512.jpg"}}},r:{type:"r",count:1,positionX:300,name:"rock",scale:[1,1,1],sscale:[.6,.6,.7],blackMaterial:{sand:{color:2105376},leaves:{color:8388608}}}},_=0;_<this.mBoard.pieces.length;_++){var C=this.mBoard.pieces[_],b=y[C.type],T=C.type+":"+C.s+":"+C.index;e.createGadget(T,{"2d":{type:"sprite",file:this.mViewOptions.fullPath+"/res/images/yohohores6.png",clipx:b.positionX,clipy:50*(C.s+1),clipwidth:100,clipheight:100,width:1200,height:1200,z:3},stylized:{file:this.mViewOptions.fullPath+"/res/images/yohohoresbasic5.png"},"3d":{type:"meshfile",z:C.z,rotate:1==C.s?0:180},stylized3d:{file:this.mViewOptions.fullPath+"/res/xd-view/meshes/stylized-"+b.name+".js",materials:{ivory:{color:1==C.s?11180441:2236962},opacity:.5},smooth:2,scale:b.sscale},cartoon3d:{file:this.mViewOptions.fullPath+"/res/xd-view/meshes/jarmada-"+b.name+".js",materials:-1==C.s?b.blackMaterial:{},scale:b.scale}})}this.g.BattleSounds=function(){return!0},this.g.YohohoSound=function(){var e="yohoho"+(Math.floor(4*Math.random())+1);s.g.BattleSounds()&&s.PlaySound(e)}},View.Game.xdBuildScene=function(e){e.updateGadget("light",{"3d":{visible:!0,intensity:0}});for(var t=0;t<this.g.Graph.length;t++){var a=this.getVCoord(t);e.updateGadget("hex#"+t,{base:{x:a[0],y:a[1]}}),e.updateGadget("mask#"+t,{base:{x:a[0],y:a[1]}}),e.updateGadget("text#"+t,{base:{x:a[0],y:a[1]-500},stylized:{y:a[1]-400},"3d":{x:a[0]-200,y:a[1]-300}})}e.updateGadget("board",{"2d":{visible:!0,rotate:this.mViewAs==JocGame.PLAYER_A?0:180}}),e.updateGadget("surround",{"3d":{visible:!0}}),e.updateGadget("ocean",{"3d":{visible:!0}}),e.updateGadget("island",{"3d":{visible:!0}});e.updateGadget("videoa",{"3d":{visible:!0,scale:[1.5,1.5,1.5],rotate:1==this.mViewAs?45:225,z:0,y:1==this.mViewAs?6e3:-6e3,x:1==this.mViewAs?-6e3:6e3,playerSide:1}}),e.updateGadget("videob",{"3d":{visible:!0,scale:[1.5,1.5,1.5],rotate:1==this.mViewAs?225:45,z:0,y:1==this.mViewAs?-6e3:6e3,x:1==this.mViewAs?6e3:-6e3,playerSide:-1}});e.updateGadget("videoa-sky",{"3d":{visible:!0,scale:[2,2,2],rotate:1==this.mViewAs?180:0,z:9e3,y:1==this.mViewAs?3e4:-3e4,playerSide:1}}),e.updateGadget("videob-sky",{"3d":{visible:!0,scale:[2,2,2],rotate:1==this.mViewAs?0:180,y:1==this.mViewAs?-3e4:3e4,z:9e3,playerSide:-1}}),e.updateGadget("flag",{cartoon3d:{visible:!0,rotate:this.mViewAs==JocGame.PLAYER_A?90:-90},stylized3d:{visible:!0,rotate:this.mViewAs==JocGame.PLAYER_A?-90:90}});for(var i=0;i<u.length*p*m;i++)e.updateGadget("palmleaf#"+i,{cartoon3d:{visible:!0}});for(var i=0;i<u.length;i++)e.updateGadget("palmtrunc#"+i,{cartoon3d:{visible:!0}});for(var t=0;t<this.g.Graph.length;t++)e.showGadget("hex#"+t),e.showGadget("mask#"+t),this.mNotation?e.showGadget("text#"+t):e.hideGadget("text#"+t)},View.Board.xdDisplay=function(e,t){for(var a=0;a<this.pieces.length;a++){var i=this.pieces[a],s=i.type+":"+i.s+":"+i.index;if(i.alive){var o=t.getVCoord(i.pos);e.updateGadget(s,{base:{visible:!0,x:o[0],y:o[1]},"3d":{rotate:t.mViewAs==JocGame.PLAYER_A?i.angle:i.angle-180,z:.05*c,rotateX:0}})}else e.hideGadget(s)}},View.Board.xdBuildHTStateMachine=function(t,a,i){function o(e,s){var o,r=null,n=null;if("object"==typeof e)r=e,n=r.type+":"+r.s+":"+r.index,o=r.pos;else{o=e;var d=T.board[o];d>=0&&(r=T.pieces[d],n=r.type+":"+r.s+":"+r.index)}var l,c,h,p;switch(s){case"piece":l="E_PIECE_CLICKED",c={piece:r},h="choice"+(i.mShowMoves?" choice-view":""),p=65280;break;case"position":l="E_DEST_CLICKED",c={pos:o},h="choice"+(i.mShowMoves?" choice-view":""),p=65280;break;case"attack":l="E_PIECE_CAPTURE",c={piece:r},h="choice"+(i.mShowMoves?" choice-view-capture":""),p=16711680;break;case"cancel":l="E_CLICK_CANCEL",c={pos:o},h="choice choice-view-cancel",p=16777215}t.updateGadget("mask#"+o,{base:{visible:!0,click:function(){a.smQueueEvent(l,c)}},"2d":{classes:h}}),t.updateGadget("hex#"+o,{"3d":{click:function(){a.smQueueEvent(l,c)}},cartoon3d:{color:p,opacity:1},stylized3d:{color:p,opacity:1}}),r&&t.updateGadget(n,{"3d":{click:function(){a.smQueueEvent(l,c)}}})}function r(e){}function n(e){if(w.risk){for(var t=0;t<w.capture.length;t++)o(w.capture[t].at,"attack");w.escape.length>0&&o(w.escape[0].f,"piece")}else{for(var t=0;t<x.length;t++)o(x[t].at,"attack");for(var t=0;t<T.pieces.length;t++){var a=T.pieces[t];a.alive&&a.s==T.mWho&&o(a,"piece")}}}function d(e){for(var a=0;a<i.g.Graph.length;a++)t.updateGadget("mask#"+a,{base:{click:null,visible:!1},"2d":{classes:""}}),t.updateGadget("hex#"+a,{"3d":{click:null}}),t.restoreGadgetProps("hex#"+a,"initial");for(var s=0;s<T.pieces.length;s++){var o=T.pieces[s];t.updateGadget(o.type+":"+o.s+":"+o.index,{"3d":{click:null}})}}function l(e){var a=e.piece,i=a.type+":"+a.s+":"+a.index;t.saveGadgetProps(i,["x","y","z","rotate","rotateX"],"beforefirst")}function c(e){var a=T.pieces[T.board[G.m[0].f]],i=a.type+":"+a.s+":"+a.index;t.restoreGadgetProps(i,"beforefirst")}function h(e){var a=e.piece.pos,s=T.board[a];if(s>=0&&T.pieces[s].s==-T.mWho)for(var o=0;o<x.length;o++)if(x[o].at==a){var r=x[o];i.g.BattleSounds()&&i.PlaySound("assault");for(var n=0;n<r.af.length;n++)t.updateGadget("mask#"+r.af[o],{base:{visible:!0},"2d":{classes:"attacker"}});return void t.updateGadget("mask#"+a,{base:{visible:!0},"2d":{classes:"attack"}})}G={t:"m",m:[{f:a},{}]}}function p(e){o(G.m[0].f,"cancel");for(var t=G.m[0].f,a=T.pieces[T.board[t]],s=T.YohohoReachablePositions(i,t,a.type,null,null),r=0;r<s.length;r++){o(s[r],"position")}}function m(e){G={}}function u(s){var o=s.pos;i.g.BattleSounds()&&i.PlaySound("move"),G.m[0].t=o;var r=i.getVCoord(o),n=i.getVCoord(G.m[0].f),d=T.pieces[T.board[G.m[0].f]],l=d.type+":"+d.s+":"+d.index;t.updateGadget(l,{base:{x:r[0],y:r[1]},"3d":{rotate:e(n,r)}},500,function(){a.smQueueEvent("E_ANIMATE_DONE",{})})}function E(e){var t=i.g.Coord[G.m[0].t],s=t[0],o=(t[1],T.pieces[T.board[G.m[0].f]].type);T.first||T.mWho==JocGame.PLAYER_A&&8==s&&"C"==o||T.mWho==JocGame.PLAYER_B&&0==s&&"C"==o?i.MakeMove(G):a.smQueueEvent("E_NO_END",{})}function f(e){o(G.m[0].t,"cancel");for(var t=0;t<T.pieces.length;t++){var a=T.pieces[t];a.alive&&a.s==T.mWho&&a.pos!=G.m[0].f&&o(a,"piece")}}function v(e){var a=e.piece.pos,s=T.board[a];if(s>=0&&T.pieces[s].s==-T.mWho)for(var o=0;o<x.length;o++)if(x[o].at==a){var r=x[o];i.g.BattleSounds()&&i.PlaySound("assault");for(var n=0;n<r.af.length;n++)t.updateGadget("mask#"+r.af[o],{base:{visible:!0},"2d":{classes:"attacker"}});return void t.updateGadget("mask#"+a,{base:{visible:!0},"2d":{classes:"attack"}})}G.m[1]={f:a}}function g(e){o(G.m[1].f,"cancel");for(var t=G.m[1].f,a=T.pieces[T.board[t]],s=T.YohohoReachablePositions(i,t,a.type,G.m[0].f,G.m[0].t),r=0;r<s.length;r++){o(s[r],"position")}}function S(e){delete G.m[1]}function y(s){var o=s.pos;if(i.g.BattleSounds()){var r=new(i.GetBoardClass())(i);r.CopyFrom(T),r.mWho=-T.mWho,r.mBoardClass=T.mBoardClass,r.ApplyMove(i,G),r.yohoho&&i.g.YohohoSound(),i.PlaySound("move")}G.m[1].t=o;var n=i.getVCoord(o),d=i.getVCoord(G.m[1].f),l=T.pieces[T.board[G.m[1].f]],c=l.type+":"+l.s+":"+l.index;t.updateGadget(c,{base:{x:n[0],y:n[1]},"3d":{rotate:e(d,n)}},500,function(){a.smQueueEvent("E_ANIMATE_DONE",{})})}function _(e){i.MakeMove(G)}function C(e){for(var o=e.piece.pos,r=0;r<x.length;r++)if(x[r].at==o){var n=x[r];i.g.BattleSounds()&&i.PlaySound("assault");for(var d=0;d<n.af.length;d++)t.updateGadget("mask#"+n.af[d],{base:{visible:!0},"2d":{classes:"attacker"}});t.updateGadget("mask#"+o,{base:{visible:!0},"2d":{classes:"attack"}}),setTimeout(function(){for(var e=0;e<n.af.length;e++)t.updateGadget("mask#"+n.af[e],{base:{visible:!1},"2d":{classes:""}});t.updateGadget("mask#"+o,{base:{visible:!1},"2d":{classes:""}}),a.smQueueEvent("E_ANIMATE_DONE",{})},4e3),G=x[r];for(var l=(i.getVCoord(o),[]),d=0;d<n.af.length;d++)l.push(T.pieces[T.board[n.af[d]]]);return void s(t,i,e.piece,l)}}function b(e){var a=G.m[0].f,s=T.pieces[T.board[a]],o=s.type+":"+s.s+":"+s.index,r=i.getVCoord(a);t.updateGadget(o,{base:{x:r[0],y:r[1]}})}var T=this,w=this.YohohoAmiralCapture(i,this.mWho),x=this.YohohoCaptures(i,this.mWho),G={};a.smTransition("S_INIT","E_INIT","S_SELECT_FIRST",[r]),a.smEntering("S_SELECT_FIRST",[n]),a.smTransition("S_SELECT_FIRST","E_PIECE_CLICKED","S_SELECT_FIRST_DEST",[l,h]),a.smTransition("S_SELECT_FIRST","E_PIECE_CAPTURE","S_ANIMATE_CAPTURE",[C]),a.smLeaving("S_SELECT_FIRST",[d]),a.smEntering("S_SELECT_FIRST_DEST",[p]),a.smTransition("S_SELECT_FIRST_DEST","E_CLICK_CANCEL","S_SELECT_FIRST",[m]),a.smTransition("S_SELECT_FIRST_DEST","E_DEST_CLICKED","S_ANIMATE_FIRST",[u]),a.smLeaving("S_SELECT_FIRST_DEST",[d]),a.smTransition("S_ANIMATE_FIRST","E_ANIMATE_DONE","S_CHECK_END",[E]),a.smTransition("S_CHECK_END","E_NO_END","S_SELECT_SECOND",[]),a.smEntering("S_SELECT_SECOND",[f]),a.smTransition("S_SELECT_SECOND","E_PIECE_CLICKED","S_SELECT_SECOND_DEST",[v]),a.smTransition("S_SELECT_SECOND","E_CLICK_CANCEL","S_SELECT_FIRST_DEST",[c,b,S]),a.smLeaving("S_SELECT_SECOND",[d]),a.smEntering("S_SELECT_SECOND_DEST",[g]),a.smTransition("S_SELECT_SECOND_DEST","E_CLICK_CANCEL","S_SELECT_SECOND",[S]),a.smTransition("S_SELECT_SECOND_DEST","E_DEST_CLICKED","S_ANIMATE_SECOND",[y]),a.smLeaving("S_SELECT_SECOND_DEST",[d]),a.smTransition("S_ANIMATE_SECOND","E_ANIMATE_DONE","S_DONE",[_]),a.smTransition("S_ANIMATE_CAPTURE","E_ANIMATE_DONE","S_DONE",[_]),a.smTransition(["S_SELECT_FIRST","S_SELECT_FIRST_DEST","S_SELECT_SECOND","S_SELECT_SECOND_DEST","S_ANIMATE_CAPTURE","S_ANIMATE_FIRST","S_ANIMATE_SECOND","S_CHECK_END","S_DONE"],"E_END","S_DONE",[d])},View.Board.xdPlayedMove=function(t,a,i){var o=this;if("m"==i.t){a.g.BattleSounds()&&a.PlaySound("move"),this.yohoho&&a.g.YohohoSound();var r=this.pieces[this.board[i.m[0].t]],n=r.type+":"+r.s+":"+r.index,d=a.getVCoord(i.m[0].t),l=a.getVCoord(i.m[0].f);t.updateGadget(n,{base:{x:d[0],y:d[1]},"3d":{rotate:e(l,d)}},1e3,function(){if(void 0===i.m[1].f)a.MoveShown();else{a.g.BattleSounds()&&a.PlaySound("move");var s=o.pieces[o.board[i.m[1].t]],r=s.type+":"+s.s+":"+s.index,n=a.getVCoord(i.m[1].t),d=a.getVCoord(i.m[1].f);t.updateGadget(r,{base:{x:n[0],y:n[1]},"3d":{rotate:e(d,n)}},500,function(){a.MoveShown()})}})}else if("a"==i.t){a.g.BattleSounds()&&a.PlaySound("assault");for(var c=0;c<i.af.length;c++)t.updateGadget("mask#"+i.af[c],{base:{visible:!0},"2d":{classes:"attacker"}});t.updateGadget("mask#"+i.at,{base:{visible:!0},"2d":{classes:"attack"}}),setTimeout(function(){for(var e=0;e<i.af.length;e++)t.updateGadget("mask#"+i.af[e],{base:{visible:!1},"2d":{classes:""}});t.updateGadget("mask#"+i.at,{base:{visible:!1},"2d":{classes:""}}),a.MoveShown()},4e3);for(var h=[],c=0;c<i.af.length;c++)h.push(a.mOldBoard.pieces[a.mOldBoard.board[i.af[c]]]);s(t,a,a.mOldBoard.pieces[a.mOldBoard.board[i.at]],h)}return!1}}();