(function(){var D,E,F,G,w,t,q,l,A,B,H,g,m,u,r,x,f,h,I,v,s,d,y,n,z,J;g=[];m=[];l=void 0;A=B=0;f=[0,0];h=u=r=x=0;t=function(a,b){return a+Math.floor(Math.random()*b)};I=function(){if(null!=h)return h.Process()};H=function(){var a;a=l.getContext("2d");a.clearRect(0,0,B,A);a.save();null!=h&&0===x&&h.Draw(a);return a.restore()};window.onload=function(){var a,b,e,c,C,d,j;l=document.getElementById("canvas");if(!l||!l.getContext)return!1;B=l.width;A=l.height;l.onmousemove=function(a){var b;b=a.target.getBoundingClientRect();
f[0]=a.clientX-b.left;f[1]=a.clientY-b.top};l.onmousedown=function(a){C(a);a.preventDefault();return!1};l.ontouchstart=function(){C(event.touches[0]);event.preventDefault();return!1};C=function(a){var b;b=a.target.getBoundingClientRect();f[0]=a.clientX-b.left;f[1]=a.clientY-b.top;h.Touch()};e="ui_material.png ayamaruhito.png okoruhito.png tukue.png \u3052\u30fc\u3080\u304a\u30fc\u3070\u30fc.png title.png charactors.png title_back.png title_back_2.png manual.png".split(" ");c=(new Date).getTime();
d=0;for(j=e.length;d<j;d++)a=e[d],b=new Image,b.src="resource/"+a+"?"+c,x++,b.onload=function(){return x--},g.push(b);b=["box_select.wav","gameover.wav","title_select.wav","tukuedon.wav"];c=(new Date).getTime();c=0;for(e=b.length;c<e;c++)a=b[c],a=new Audio("resource/"+a),m.push(a);E();h=new w;setInterval(I,1E3/60);setInterval(H,1E3/60)};n="\u3054\u3081\u3093\u306a\u3055\u3044 \u3057\u3087\u3046\u3058\u304d\u3059\u307e\u3093\u304b\u3063\u305f \u3082\u3046\u3057\u308f\u3051\u3042\u308a\u307e\u305b\u3093\u3067\u3057\u305f \u306f\u3093\u305b\u3044\u306f\u3057\u3066\u3044\u308b \u3059\u307e\u306c\u3059\u307e\u306c \u3086\u308b\u3057\u3066\u304f\u3060\u3055\u3044\u306a\u3093\u3067\u3082\u3057\u307e\u3059\u304b\u3089 \u3069\u3052\u3056\u3057\u3066\u3067\u3082\u3044\u304d\u306e\u3073\u305f\u3044\u3067\u3059 \u3084\u3070\u3044\u3068\u304a\u3082\u3063\u305f\u304c\u304a\u3055\u3048\u304d\u308c\u306a\u304b\u3063\u305f \u304a\u308c\u306f\u308f\u308b\u304f\u306d\u3047 \u3053\u3093\u304b\u3044\u3082\u306a\u3093\u306e\u305b\u3044\u304b\u3082\u3048\u3089\u308c\u307e\u305b\u3093\u3067\u3057\u305f".split(" ");
y=[];z=0;for(J=n.length;z<J;z++)d=n[z],y.push(d.length);v=[];q=[];s=[];E=function(){var a,b,e,c;b=[];a=e=0;for(c=n.length;0<=c?e<c:e>c;a=0<=c?++e:--e)b.push(a),q.push(0),s.push(3);c=[];for(e=0;3>e;++e)c.push(function(){var c,e,d;d=[];c=0;for(e=b.length;c<e;c++)a=b[c],d.push(v.push(a));return d}());return c};var p=function(a,b,e,c){this.ID=a;this.wordSet=b;this.x=e;this.y=c;this.nowWord=0};p.prototype.size={width:240,height:96};p.prototype.Next=function(){return this.wordSet.shift()};p.prototype.Touch=
function(){return this.ID};p.prototype.Draw=function(a){a.save();a.drawImage(g[0],0,112*this.ID,280,112,this.x-20,this.y-8,280,112);a.font="bold 40px \u30e1\u30a4\u30ea\u30aa,\u30d2\u30e9\u30ae\u30ce";a.fillStyle="rgb(0,0,0)";a.fillText(""+this.wordSet[this.nowWord],this.x+this.size.width/2-20*this.wordSet[this.nowWord].length,this.y+this.size.height/2+10);return a.restore()};var j=function(){this.nowWord=this.angerGauge=this.passWord=this.drawScore=this.score=0;this.truthNumbers=[];this.lastTime=
0;this.wordBox=[];this.level=1;this.dividNumber=5;this.waitTimer=0;this.waitType=null;this.wordBuffer=[];this.throughWord="";this.levelupTimer=this.lastGetScore=0},k;k=[];j.prototype.Init=function(){return this.SetWord()};j.prototype.Process=function(){var a;this.score-this.drawScore&&(this.drawScore+=Math.round((this.score-this.drawScore)/5),50>this.score-this.drawScore&&(this.drawScore=this.score));0<this.wordBox.length&&(a=(new Date).getTime(),this.GainGauge(10+0.001*(a-this.lastTime)*this.level));
0===this.waitType&&0===this.waitTimer&&(this.SetWord(),this.waitType=null);1===this.waitType&&0===this.waitTimer&&(this.SetWord(),this.waitType=null);0<this.waitTimer&&this.waitTimer--;0<this.levelupTimer&&this.levelupTimer--;if(1E5<=this.angerGauge)return m[1].play(),r=this.score,a=!1,r>u&&(u=this.score,a=!0),h=new G(a)};j.prototype.Touch=function(){var a,b,e,c,d;if(0!==this.wordBox.length){b=null;d=this.wordBox;a=e=0;for(c=d.length;e<c;a=++e)a=d[a],f[0]>a.x&&(f[0]<a.x+a.size.width&&f[1]>a.y&&f[1]<
a.y+a.size.height)&&(b=a.Touch());if(null!=b){if(this.nowWordSet<this.maxWordSet&&this.truthNumbers[this.nowWordSet]===b){if(this.nowWordSet<this.maxWordSet-1)return m[0].play(),this.SetLastTime(),this.GainScore(50*(0.5+this.level/5)),this.LessGauge(50*(5-this.level)),this.NextWord();m[2].play();this.lastGetScore=Math.floor(40*y[this.nowWord]*(1+this.level/5));this.GainScore(this.lastGetScore);this.LessGauge(30*y[this.nowWord]*(5-this.level));this.wordBox=[];this.waitType=0;return this.waitTimer=
20*(5-this.level)}if(this.nowWordSet<this.maxWordSet&&this.truthNumbers[this.nowWordSet]!==b)return m[3].play(),this.GainGauge(2E3+500*this.level),this.wordBox=[],this.waitType=1,this.waitTimer=20+20*(5-this.level)}}};j.prototype.Draw=function(a){var b,e,c,d;a.save();a.drawImage(g[1],0,0);a.drawImage(g[3],0,0);1===this.waitType?(b=10-4*Math.sin(Math.PI*(this.waitTimer/10)/((1+this.level)/2)),a.drawImage(g[2],b,0)):a.drawImage(g[2],0,0);b=71+498*this.angerGauge/1E5;a.drawImage(g[0],0,337,b,140,0,320,
b,140);a.drawImage(g[0],0,477,640,140,0,320,640,140);a.fillStyle="rgb(0,0,0)";a.font="bold 20px \u30e1\u30a4\u30ea\u30aa,\u30d2\u30e9\u30ae\u30ce";a.fillText("LEVEL:"+this.level,0,20);0<this.levelupTimer&&(a.save(),a.fillStyle="rgba(255,32,32,"+Math.min(1,(this.levelupTimer-20)/20)+")",a.fillText("LEVELUP",Math.min(100,-100+4*(120-this.levelupTimer)),20),a.restore());a.fillText("SCORE:"+this.drawScore,0,40);0===this.waitType&&0<this.waitTimer&&(a.save(),a.fillStyle="rgba(255,32,32,"+Math.min(1,(this.waitTimer-
20)/20)+")",a.fillText("+"+this.lastGetScore,100,60),a.restore());d=this.wordBox;e=0;for(c=d.length;e<c;e++)b=d[e],b.Draw(a);a.font="bold 30px \u30e1\u30a4\u30ea\u30aa,\u30d2\u30e9\u30ae\u30ce";a.fillStyle="rgb(0,0,0)";0<this.wordBox.length&&(b=320-30*n[this.nowWord].length/2,a.fillText(""+this.throughWord,b,320),a.strokeText(""+n[this.nowWord],b,320));return a.restore()};j.prototype.SetWord=function(){var a,b,e,c,d;++this.passWord;this.passWord===3*this.level*this.level&&5>this.level&&(this.level++,
this.levelupTimer=120,this.dividNumber=5-Math.floor(this.level/2));e=t(0,v.length);this.nowWord=v[e];q[this.nowWord]++;a=c=b=0;for(d=n.length;0<=d?c<d:c>d;a=0<=d?++c:--c)if(q[a]<q[b]||q[b]&&s[a]<s[b])b=a;s[this.nowWord]--;s[b]++;v[e]=b;k=[[],[],[]];this.nowWordSet=0;this.maxWordSet=Math.ceil(n[this.nowWord].length/this.dividNumber);this.truthNumbers=[];this.wordBuffer=[];this.throughWord="";a=e=0;for(c=this.maxWordSet;0<=c?e<c:e>c;a=0<=c?++e:--e)this.wordBuffer.push(n[this.nowWord].substr(this.dividNumber*
a,this.dividNumber)),b=t(0,3),this.truthNumbers.push(b),k[b].push(this.wordBuffer[a]),k[(b+1)%3].push(this.TransRandomString(this.wordBuffer[a],this.dividNumber)),k[(b+2)%3].push(this.TransRandomString(this.wordBuffer[a],this.dividNumber));if(1>=k[0][this.maxWordSet-1].length){for(a=b=0;2>=b;a=++b)k[a][this.maxWordSet-2]+=n[this.nowWord].slice(-1),k[a].pop();this.maxWordSet-=1;this.truthNumbers.pop}this.wordBox=[];this.wordBox.push(new p(0,k[0],200,40));this.wordBox.push(new p(1,k[1],30,180));this.wordBox.push(new p(2,
k[2],350,180));this.SetLastTime()};j.prototype.TransRandomString=function(a,b){var d,c,g,f,j,h;b>a.length&&(b=a.length);d=[];g="";for(c=h=f=0;0<=b?h<b:h>b;c=0<=b?++h:--h){c=a.charCodeAt(c);if(!c)break;j=t(-1,3);c+=j;f+=j;d.push(c)}if(0===f)g=this.TransRandomString(a,b);else for(f=h=0;0<=b?h<b:h>b;f=0<=b?++h:--h)g+=String.fromCharCode(d[f]);return g};j.prototype.NextWord=function(){var a,b,d,c;c=this.wordBox;b=0;for(d=c.length;b<d;b++)a=c[b],a.Next();this.nowWordSet++;return this.throughWord+=this.wordBuffer.shift()};
j.prototype.LessGauge=function(a){this.angerGauge-=a;if(0>this.angerGauge)return this.angerGauge=0};j.prototype.GainGauge=function(a){return this.angerGauge+=a};j.prototype.GainScore=function(a){return this.score+=a};j.prototype.SetLastTime=function(){return this.lastTime=(new Date).getTime()};d=function(){this.pict=7!==t(0,16)?7:8;this.inTime=(new Date).getTime();this.passtime=0};d.prototype.Process=function(){return this.passtime=(new Date).getTime()-this.inTime};d.prototype.Touch=function(){if(!(1500>
this.passtime)&&(20<f[0]&&(340>f[0]&&420<f[1]&&468>f[1])&&(m[2].play(),h=new F),360<f[0]&&602>f[0]&&420<f[1]&&468>f[1]))return m[2].play(),h=new D};d.prototype.Draw=function(a){a.globalAlpha=Math.min(1,Math.max(0,(this.passtime-500)/1E3));a.drawImage(g[this.pict],-40,-40);a.drawImage(g[5],20,0);a.font="bold 30px \u30e1\u30a4\u30ea\u30aa,\u30d2\u30e9\u30ae\u30ce";a.fillStyle="rgb(255,255,255)";a.fillText("  "+u,200,360);a.strokeText("  "+u,200,360);a.fillText("  "+r,200,390);a.strokeText("  "+r,200,
390);a.drawImage(g[6],0,96,340,96,10,333,210,60);20<f[0]&&340>f[0]&&420<f[1]&&468>f[1]?a.drawImage(g[6],0,0,320,48,15,415,320,48):a.drawImage(g[6],0,0,320,48,20,420,320,48);return 360<f[0]&&602>f[0]&&420<f[1]&&468>f[1]?a.drawImage(g[6],0,48,320,48,355,415,320,48):a.drawImage(g[6],0,48,320,48,360,420,320,48)};w=d;d=function(){this.inTime=(new Date).getTime();this.exitCount=this.passtime=0};d.prototype.Process=function(){this.passtime=(new Date).getTime()-this.inTime;1<this.exitCount&&this.exitCount--;
if(1===this.exitCount)return h=new w};d.prototype.Touch=function(){if(1500<this.passtime)return m[2].play(),this.exitCount=60};d.prototype.Draw=function(a){a.globalAlpha=Math.min(1,Math.max(0,this.passtime/1E3));0<this.exitCount&&(a.globalAlpha=Math.min(1,Math.max(0,this.exitCount/60)));return a.drawImage(g[9],10,0)};D=d;d=function(){this.inTime=(new Date).getTime();this.passtime=0};d.prototype.Process=function(){this.passtime=(new Date).getTime()-this.inTime;if(3500<=this.passtime)return h=new j,
h.Init()};d.prototype.Touch=function(){};d.prototype.Draw=function(a){a.globalAlpha=Math.min(1,Math.max(0,(this.passtime-500)/500));a.drawImage(g[1],0,0);a.globalAlpha=Math.min(1,Math.max(0,(this.passtime-1E3)/500));a.drawImage(g[3],0,0);a.globalAlpha=Math.min(1,Math.max(0,(this.passtime-1200)/500));return a.drawImage(g[2],0,0)};F=d;d=function(a){this.scoreUpdate=a;this.inTime=(new Date).getTime();this.passtime=0};d.prototype.Process=function(){return this.passtime=(new Date).getTime()-this.inTime};
d.prototype.Touch=function(){if(4500<this.passtime)return m[2].play(),h=new w};d.prototype.Draw=function(a){1E3>this.passtime&&(a.globalAlpha=Math.min(1,Math.max(0,(1E3-this.passtime)/1E3)),a.drawImage(g[1],0,0),a.drawImage(g[3],0,0),a.drawImage(g[2],0,0));a.globalAlpha=Math.min(1,Math.max(0,(this.passtime-2500)/500));a.drawImage(g[4],0,0);a.drawImage(g[6],0,192,750,96,40,50,550,96);a.font="bold 30px \u30e1\u30a4\u30ea\u30aa,\u30d2\u30e9\u30ae\u30ce";3E3<this.passtime&&(a.font="bold 20px \u30e1\u30a4\u30ea\u30aa,\u30d2\u30e9\u30ae\u30ce",
a.globalAlpha=Math.min(1,Math.max(0,(this.passtime-1E3)/500)),a.fillText("Score : "+r,300,400),this.scoreUpdate&&a.fillText("New Recode!!",300,370));if(4E3<this.passtime)return a.font="bold 30px \u30e1\u30a4\u30ea\u30aa,\u30d2\u30e9\u30ae\u30ce",a.globalAlpha=Math.min(1,Math.max(0,(this.passtime-4E3)/1E3)),a.fillText("click to back to Title",300,460)};G=d}).call(this);
