projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Refactoring: BaseGame, Game, ComputerGame (ProblemGame?)
[vchess.git]
/
client
/
src
/
playCompMove.js
diff --git
a/client/src/playCompMove.js
b/client/src/playCompMove.js
index
d6b0cea
..
ddaeba3
100644
(file)
--- a/
client/src/playCompMove.js
+++ b/
client/src/playCompMove.js
@@
-1,18
+1,19
@@
+// 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
// For asynchronous computer move search
-onmessage = function(e)
+
+//self.addEventListener('message', (e) =>
+onmessage = async function(e)
{
switch (e.data[0])
{
case "scripts":
{
switch (e.data[0])
{
case "scripts":
- self.importScripts(
- '/javascripts/base_rules.js',
- '/javascripts/utils/array.js',
- '/javascripts/variants/' + e.data[1] + '.js');
- self.V = eval(e.data[1] + "Rules");
+ const vModule = await import("@/variants/" + e.data[1] + ".js");
+ self.V = vModule.VariantRules;
break;
case "init":
const fen = e.data[1];
break;
case "init":
const fen = e.data[1];
- self.vr = new
VariantRules
(fen);
+ self.vr = new
self.V
(fen);
break;
case "newmove":
self.vr.play(e.data[1]);
break;
case "newmove":
self.vr.play(e.data[1]);