projects
/
vchess.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
fd7aea3
)
Attempt to fix countdown for live games. Some issues with GameStorage.add now
author
Benjamin Auder
<benjamin.auder@somewhere>
Mon, 2 Dec 2019 09:14:44 +0000
(10:14 +0100)
committer
Benjamin Auder
<benjamin.auder@somewhere>
Mon, 2 Dec 2019 09:14:44 +0000
(10:14 +0100)
client/src/utils/gameStorage.js
patch
|
blob
|
blame
|
history
client/src/views/Game.vue
patch
|
blob
|
blame
|
history
client/src/views/Hall.vue
patch
|
blob
|
blame
|
history
server/db/create.sql
patch
|
blob
|
blame
|
history
diff --git
a/client/src/utils/gameStorage.js
b/client/src/utils/gameStorage.js
index
031f62f
..
a8aa6ed
100644
(file)
--- a/
client/src/utils/gameStorage.js
+++ b/
client/src/utils/gameStorage.js
@@
-47,6
+47,7
@@
function dbOperation(callback)
export const GameStorage =
{
// Optional callback to get error status
export const GameStorage =
{
// Optional callback to get error status
+ // TODO: this func called from Hall seems to not work now...
add: function(game, callback)
{
dbOperation((db) => {
add: function(game, callback)
{
dbOperation((db) => {
diff --git
a/client/src/views/Game.vue
b/client/src/views/Game.vue
index
6cb75f4
..
52e97c5
100644
(file)
--- a/
client/src/views/Game.vue
+++ b/
client/src/views/Game.vue
@@
-79,11
+79,16
@@
export default {
}
},
"game.clocks": function(newState) {
}
},
"game.clocks": function(newState) {
- this.virtualClocks = newState.map(s => ppt(s));
const currentTurn = this.vr.turn;
const colorIdx = ["w","b"].indexOf(currentTurn);
let countdown = newState[colorIdx] -
(Date.now() - this.game.initime[colorIdx])/1000;
const currentTurn = this.vr.turn;
const colorIdx = ["w","b"].indexOf(currentTurn);
let countdown = newState[colorIdx] -
(Date.now() - this.game.initime[colorIdx])/1000;
+ this.virtualClocks = [0,1].map(i => {
+ const removeTime = i == colorIdx
+ ? (Date.now() - this.game.initime[colorIdx])/1000
+ : 0;
+ return ppt(newState[i] - removeTime);
+ });
const myTurn = (currentTurn == this.game.mycolor);
let clockUpdate = setInterval(() => {
if (countdown <= 0 || this.vr.turn != currentTurn)
const myTurn = (currentTurn == this.game.mycolor);
let clockUpdate = setInterval(() => {
if (countdown <= 0 || this.vr.turn != currentTurn)
@@
-297,11
+302,15
@@
export default {
const vname = (variantCell.length > 0 ? variantCell[0].name : "");
if (!game.fen)
game.fen = game.fenStart; //game wasn't started
const vname = (variantCell.length > 0 ? variantCell[0].name : "");
if (!game.fen)
game.fen = game.fenStart; //game wasn't started
-
-
- // TODO: process rtime, clocks............ game.clocks doesn't exist anymore
-console.log(game);
-
+ const gtype = (game.timeControl.indexOf('d') >= 0 ? "corr" : "live");
+ if (gtype == "corr")
+ {
+ // corr game: needs to compute the clocks + initime
+ //if (game.players[i].rtime < 0) initime = Date.now(), else compute,
+ //also using move.played fields
+ game.clocks = [-1, -1];
+ game.initime = [0, 0];
+ }
const tc = extractTime(game.timeControl);
if (game.clocks[0] < 0) //game unstarted
{
const tc = extractTime(game.timeControl);
if (game.clocks[0] < 0) //game unstarted
{
@@
-316,6
+325,7
@@
console.log(game);
game,
// NOTE: assign mycolor here, since BaseGame could also bs VS computer
{
game,
// NOTE: assign mycolor here, since BaseGame could also bs VS computer
{
+ type: gtype,
increment: tc.increment,
vname: vname,
mycolor: [undefined,"w","b"][myIdx+1],
increment: tc.increment,
vname: vname,
mycolor: [undefined,"w","b"][myIdx+1],
diff --git
a/client/src/views/Hall.vue
b/client/src/views/Hall.vue
index
b7526cc
..
c22c1e1
100644
(file)
--- a/
client/src/views/Hall.vue
+++ b/
client/src/views/Hall.vue
@@
-561,6
+561,7
@@
export default {
const game = Object.assign({}, gameInfo, {
// (other) Game infos: constant
fenStart: gameInfo.fen,
const game = Object.assign({}, gameInfo, {
// (other) Game infos: constant
fenStart: gameInfo.fen,
+ created: Date.now(),
// Game state (including FEN): will be updated
moves: [],
clocks: [-1, -1], //-1 = unstarted
// Game state (including FEN): will be updated
moves: [],
clocks: [-1, -1], //-1 = unstarted
diff --git
a/server/db/create.sql
b/server/db/create.sql
index
56d4a24
..
0fb7456
100644
(file)
--- a/
server/db/create.sql
+++ b/
server/db/create.sql
@@
-43,6
+43,7
@@
create table Challenges (
foreign key (vid) references Variants(id)
);
foreign key (vid) references Variants(id)
);
+-- NOTE: no need for a "created" field, it's deduce from first move playing time
create table Games (
id integer primary key,
vid integer,
create table Games (
id integer primary key,
vid integer,