Better menu ordering ?
[vchess.git] / client / src / playCompMove.js
CommitLineData
4486a21e 1// Logic to play a computer move in a web worker
e2732923 2onmessage = async function(e)
643479f8 3{
1c9f093d
BA
4 switch (e.data[0])
5 {
6 case "scripts":
e2732923 7 const vModule = await import("@/variants/" + e.data[1] + ".js");
1c9f093d
BA
8 self.V = vModule.VariantRules;
9 break;
10 case "init":
11 const fen = e.data[1];
12 self.vr = new self.V(fen);
13 break;
14 case "newmove":
15 self.vr.play(e.data[1]);
16 break;
17 case "askmove":
18 const compMove = self.vr.getComputerMove();
19 postMessage(compMove);
20 break;
21 }
643479f8 22}