Styled layout. TODO: variants page, and then index
[vchess.git] / client / src / playCompMove.js
CommitLineData
643479f8
BA
1// For asynchronous computer move search
2onmessage = function(e)
3{
4 switch (e.data[0])
5 {
6 case "scripts":
7 self.importScripts(
643479f8
BA
8 '/javascripts/base_rules.js',
9 '/javascripts/utils/array.js',
10 '/javascripts/variants/' + e.data[1] + '.js');
ab4f4bf2 11 self.V = eval(e.data[1] + "Rules");
643479f8
BA
12 break;
13 case "init":
14 const fen = e.data[1];
8d7e2786 15 self.vr = new VariantRules(fen);
643479f8
BA
16 break;
17 case "newmove":
18 self.vr.play(e.data[1]);
19 break;
20 case "askmove":
21 const compMove = self.vr.getComputerMove();
22 postMessage(compMove);
23 break;
24 }
25}