projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Play against computer almost OK: need to fix Board component
[vchess.git]
/
client
/
src
/
playCompMove.js
diff --git
a/client/src/playCompMove.js
b/client/src/playCompMove.js
index
45da511
..
ddaeba3
100644
(file)
--- a/
client/src/playCompMove.js
+++ b/
client/src/playCompMove.js
@@
-1,19
+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(
- '//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js',
- '/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]);