projects
/
vchess.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
baba607
)
Saving current state
author
Benjamin Auder
<benjamin.auder@somewhere>
Sun, 13 Jan 2019 14:16:52 +0000
(15:16 +0100)
committer
Benjamin Auder
<benjamin.auder@somewhere>
Sun, 13 Jan 2019 14:16:52 +0000
(15:16 +0100)
public/javascripts/components/board.js
patch
|
blob
|
blame
|
history
public/javascripts/components/game.js
patch
|
blob
|
blame
|
history
public/javascripts/variant.js
patch
|
blob
|
blame
|
history
views/layout.pug
patch
|
blob
|
blame
|
history
views/variant.pug
patch
|
blob
|
blame
|
history
diff --git
a/public/javascripts/components/board.js
b/public/javascripts/components/board.js
index
44c499c
..
0399410
100644
(file)
--- a/
public/javascripts/components/board.js
+++ b/
public/javascripts/components/board.js
@@
-1,7
+1,9
@@
Vue.component('my-board', {
// Last move cannot be guessed from here, and is required to highlight squares
// vr: object to check moves, print board...
Vue.component('my-board', {
// Last move cannot be guessed from here, and is required to highlight squares
// vr: object to check moves, print board...
- props: ["vr","lastMove","mode","orientation","userColor","gameOver"],
+ // mode: HH, HC or analyze
+ // userColor: for mode HH or HC
+ props: ["vr","lastMove","mode","orientation","userColor"],
data: function () {
return {
hints: (!localStorage["hints"] ? true : localStorage["hints"] === "1"),
data: function () {
return {
hints: (!localStorage["hints"] ? true : localStorage["hints"] === "1"),
diff --git
a/public/javascripts/components/game.js
b/public/javascripts/components/game.js
index
ca79125
..
555d392
100644
(file)
--- a/
public/javascripts/components/game.js
+++ b/
public/javascripts/components/game.js
@@
-4,6
+4,7
@@
// Game logic on a variant page: 3 modes, analyze, computer or human
Vue.component('my-game', {
// gameId: to find the game in storage (assumption: it exists)
// Game logic on a variant page: 3 modes, analyze, computer or human
Vue.component('my-game', {
// gameId: to find the game in storage (assumption: it exists)
+ // fen: to start from a FEN without identifiers (analyze mode)
props: ["gameId","fen","mode","allowChat","allowMovelist"],
data: function() {
return {
props: ["gameId","fen","mode","allowChat","allowMovelist"],
data: function() {
return {
@@
-22,6
+23,13
@@
Vue.component('my-game', {
compWorker: new Worker('/javascripts/playCompMove.js'),
timeStart: undefined, //time when computer starts thinking
vr: null, //VariantRules object, describing the game state + rules
compWorker: new Worker('/javascripts/playCompMove.js'),
timeStart: undefined, //time when computer starts thinking
vr: null, //VariantRules object, describing the game state + rules
+
+ // orientation :: button flip
+ // userColor: given by gameId, or fen (if no game Id)
+ // gameOver: known if gameId; otherwise assue false
+ // lastMove: update after every play, initialize with last move from list (if continuation)
+ //orientation ? userColor ? gameOver ? lastMove ?
+
};
},
watch: {
};
},
watch: {
@@
-82,7
+90,9
@@
Vue.component('my-game', {
`,
created: function() {
const url = socketUrl;
`,
created: function() {
const url = socketUrl;
- this.conn = new WebSocket(url + "/?sid=" + this.myid + "&page=" + variant._id);
+
+// TODO: connexion initialized in variant.js and passed as a prop
+
// TODO: after game, archive in indexedDB
// TODO: this events listener is central. Refactor ? How ?
const socketMessageListener = msg => {
// TODO: after game, archive in indexedDB
// TODO: this events listener is central. Refactor ? How ?
const socketMessageListener = msg => {
@@
-157,7
+167,6
@@
Vue.component('my-game', {
};
const socketCloseListener = () => {
};
const socketCloseListener = () => {
- this.conn = new WebSocket(url + "/?sid=" + this.myid + "&page=" + variant._id);
this.conn.addEventListener('message', socketMessageListener);
this.conn.addEventListener('close', socketCloseListener);
};
this.conn.addEventListener('message', socketMessageListener);
this.conn.addEventListener('close', socketCloseListener);
};
diff --git
a/public/javascripts/variant.js
b/public/javascripts/variant.js
index
453656c
..
7d30d73
100644
(file)
--- a/
public/javascripts/variant.js
+++ b/
public/javascripts/variant.js
@@
-3,13
+3,13
@@
new Vue({
data: {
display: "undefined", //default to main hall; see "created()" function
gameid: "undefined", //...yet
data: {
display: "undefined", //default to main hall; see "created()" function
gameid: "undefined", //...yet
-
+
+ conn: null,
+
// TEMPORARY: DEBUG
// TEMPORARY: DEBUG
- vr: null,
mode: "analyze",
orientation: "w",
userColor: "w",
mode: "analyze",
orientation: "w",
userColor: "w",
- gameOver: false,
},
created: function() {
// TODO: navigation becomes a little more complex
},
created: function() {
// TODO: navigation becomes a little more complex
@@
-18,6
+18,12
@@
new Vue({
const page = (hashPos >= 0 ? url.substr(hashPos+1) : "room");
this.setDisplay(page);
const page = (hashPos >= 0 ? url.substr(hashPos+1) : "room");
this.setDisplay(page);
+ this.conn = new WebSocket(url + "/?sid=" + this.myid + "&page=" + variant._id);
+ const socketCloseListener = () => {
+ this.conn = new WebSocket(url + "/?sid=" + this.myid + "&page=" + variant._id);
+ }
+ this.conn.onclose = socketCloseListener;
+
this.vr = new VariantRules( V.GenRandInitFen() );
},
methods: {
this.vr = new VariantRules( V.GenRandInitFen() );
},
methods: {
diff --git
a/views/layout.pug
b/views/layout.pug
index
e5883ee
..
cfaf85a
100644
(file)
--- a/
views/layout.pug
+++ b/
views/layout.pug
@@
-41,7
+41,7
@@
html
div
a(href="https://github.com/yagu0/vchess") Source code
p.clickable(onClick="document.getElementById('modalContact').checked=true")
div
a(href="https://github.com/yagu0/vchess") Source code
p.clickable(onClick="document.getElementById('modalContact').checked=true")
- =translations["Contact"]
+ =translations["Contact
form
"]
script(src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js")
script(src="/javascripts/utils/misc.js")
script(src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js")
script(src="/javascripts/utils/misc.js")
diff --git
a/views/variant.pug
b/views/variant.pug
index
16dd447
..
490a13a
100644
(file)
--- a/
views/variant.pug
+++ b/
views/variant.pug
@@
-32,8
+32,7
@@
block content
//my-problems(v-show="display=='problems'")
//my-game(v-show="display=='game'" :gameId="gameid")
my-board(:vr="vr" :mode="mode" :orientation="orientation"
//my-problems(v-show="display=='problems'")
//my-game(v-show="display=='game'" :gameId="gameid")
my-board(:vr="vr" :mode="mode" :orientation="orientation"
- :user-color="userColor" :game-over="gameOver"
- v-on:play-move="play")
+ :user-color="userColor" v-on:play-move="play")
block javascripts
script(src="/javascripts/utils/array.js")
block javascripts
script(src="/javascripts/utils/array.js")