Prepare new home
[vchess.git] / client / src / playCompMove.js
1 // For asynchronous computer move search
2 onmessage = function(e)
3 {
4 switch (e.data[0])
5 {
6 case "scripts":
7 self.importScripts(
8 '/javascripts/base_rules.js',
9 '/javascripts/utils/array.js',
10 '/javascripts/variants/' + e.data[1] + '.js');
11 self.V = eval(e.data[1] + "Rules");
12 break;
13 case "init":
14 const fen = e.data[1];
15 self.vr = new VariantRules(fen);
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 }