Move some comments, and remove some of them
[vchess.git] / client / src / playCompMove.js
index ddaeba3..b93a8d1 100644 (file)
@@ -1,26 +1,22 @@
-// TODO: https://github.com/webpack-contrib/worker-loader
-// https://stackoverflow.com/questions/48713072/how-to-get-js-function-into-webworker-via-importscripts
-// For asynchronous computer move search
-
-//self.addEventListener('message', (e) =>
+// Logic to play a computer move in a web worker
 onmessage = async function(e)
 {
-       switch (e.data[0])
-       {
-               case "scripts":
+  switch (e.data[0])
+  {
+    case "scripts":
       const vModule = await import("@/variants/" + e.data[1] + ".js");
-                       self.V = vModule.VariantRules;
-                       break;
-               case "init":
-                       const fen = e.data[1];
-                       self.vr = new self.V(fen);
-                       break;
-               case "newmove":
-                       self.vr.play(e.data[1]);
-                       break;
-               case "askmove":
-                       const compMove = self.vr.getComputerMove();
-                       postMessage(compMove);
-                       break;
-       }
+      self.V = vModule.VariantRules;
+      break;
+    case "init":
+      const fen = e.data[1];
+      self.vr = new self.V(fen);
+      break;
+    case "newmove":
+      self.vr.play(e.data[1]);
+      break;
+    case "askmove":
+      const compMove = self.vr.getComputerMove();
+      postMessage(compMove);
+      break;
+  }
 }