Ice server info
Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
parent
25e4b45198
commit
a15fadf4f9
@ -1,5 +1,6 @@
|
|||||||
body {
|
body {
|
||||||
font-family: 'Droid Sans', 'Arial Narrow', Arial, sans-serif;
|
font-family: 'Droid Sans', 'Arial Narrow', Arial, sans-serif;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
#root {
|
#root {
|
||||||
|
@ -220,15 +220,17 @@ const Table = () => {
|
|||||||
`Try refreshing your browser in a few seconds.`;
|
`Try refreshing your browser in a few seconds.`;
|
||||||
console.error(error);
|
console.error(error);
|
||||||
setError(error);
|
setError(error);
|
||||||
throw error;
|
throw new Error(error);
|
||||||
}
|
}
|
||||||
return res.json();
|
return res.json();
|
||||||
}).then((update) => {
|
}).then((update) => {
|
||||||
if (update.id !== gameId) {
|
if (update.id !== gameId) {
|
||||||
console.log(`New game started: ${update.id}`);
|
console.log(`Game available: ${update.id}`);
|
||||||
history.push(`${gamesPath}/${update.id}`);
|
history.push(`${gamesPath}/${update.id}`);
|
||||||
setGameId(update.id);
|
setGameId(update.id);
|
||||||
}
|
}
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
}, [ gameId, setGameId ]);
|
}, [ gameId, setGameId ]);
|
||||||
|
|
||||||
|
@ -213,11 +213,14 @@ const Board = () => {
|
|||||||
><div className="Tile-Shape"/></div>;
|
><div className="Tile-Shape"/></div>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const sendPlacement = useCallback((type, index) => {
|
const staticSendCallback = (type, index) => {
|
||||||
ws.send(JSON.stringify({
|
ws.send(JSON.stringify({
|
||||||
type, index
|
type, index
|
||||||
}));
|
}));
|
||||||
}, [ws]);
|
};
|
||||||
|
const refStaticSendCallback = useRef(staticSendCallback);
|
||||||
|
useEffect(() => { refStaticSendCallback.current = staticSendCallback; });
|
||||||
|
const sendPlacement = refStaticSendCallback.current;
|
||||||
|
|
||||||
const onRoadClicked = useCallback((road) => {
|
const onRoadClicked = useCallback((road) => {
|
||||||
console.log(`Road clicked: ${road.index}`);
|
console.log(`Road clicked: ${road.index}`);
|
||||||
|
@ -43,6 +43,11 @@ const Placard = ({type, disabled, count, buildActive, setBuildActive}) => {
|
|||||||
setBuildActive(false);
|
setBuildActive(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
if (!type) {
|
||||||
|
return <></>;
|
||||||
|
}
|
||||||
|
|
||||||
if (type === 'B') { type = 'blue'; }
|
if (type === 'B') { type = 'blue'; }
|
||||||
else if (type === 'O') { type = 'orange'; }
|
else if (type === 'O') { type = 'orange'; }
|
||||||
else if (type === 'R') { type = 'red'; }
|
else if (type === 'R') { type = 'red'; }
|
||||||
|
@ -891,7 +891,7 @@ const colorToWord = (color) => {
|
|||||||
const getActiveCount = (game) => {
|
const getActiveCount = (game) => {
|
||||||
let active = 0;
|
let active = 0;
|
||||||
for (let color in game.players) {
|
for (let color in game.players) {
|
||||||
if (game.players[color].name) {
|
if (!game.players[color].name) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
active++;
|
active++;
|
||||||
@ -1000,7 +1000,7 @@ const setPlayerColor = (game, session, color) => {
|
|||||||
name: session.name,
|
name: session.name,
|
||||||
color: session.color,
|
color: session.color,
|
||||||
live: session.live,
|
live: session.live,
|
||||||
private: session.player
|
private: session.player,
|
||||||
});
|
});
|
||||||
sendUpdateToPlayers(game, update);
|
sendUpdateToPlayers(game, update);
|
||||||
};
|
};
|
||||||
@ -2858,6 +2858,10 @@ const setGameState = (game, session, state) => {
|
|||||||
if (game.state !== 'lobby') {
|
if (game.state !== 'lobby') {
|
||||||
return `You can only start the game from the lobby.`;
|
return `You can only start the game from the lobby.`;
|
||||||
}
|
}
|
||||||
|
const active = getActiveCount(game);
|
||||||
|
if (active < 2) {
|
||||||
|
return `You need at least two players to start the game.`;
|
||||||
|
}
|
||||||
addChatMessage(game, null, `${session.name} requested to start the game.`);
|
addChatMessage(game, null, `${session.name} requested to start the game.`);
|
||||||
game.state = state;
|
game.state = state;
|
||||||
|
|
||||||
@ -3271,7 +3275,7 @@ const gotoLobby = (game, session) => {
|
|||||||
|
|
||||||
router.ws("/ws/:id", async (ws, req) => {
|
router.ws("/ws/:id", async (ws, req) => {
|
||||||
if (!req.cookies || !req.cookies.player) {
|
if (!req.cookies || !req.cookies.player) {
|
||||||
ws.send({ type: 'error', error: `Unable to set session cookie` });
|
ws.send({ type: 'error', error: `Unable to find session cookie` });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3832,6 +3836,7 @@ const resetGame = (game) => {
|
|||||||
largestArmy: '',
|
largestArmy: '',
|
||||||
largestArmySize: 0,
|
largestArmySize: 0,
|
||||||
winner: undefined,
|
winner: undefined,
|
||||||
|
active: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Populate the game corner and road placement data as cleared */
|
/* Populate the game corner and road placement data as cleared */
|
||||||
@ -3888,6 +3893,7 @@ const resetGame = (game) => {
|
|||||||
for (let key in game.sessions) {
|
for (let key in game.sessions) {
|
||||||
const session = game.sessions[key];
|
const session = game.sessions[key];
|
||||||
if (session.color) {
|
if (session.color) {
|
||||||
|
game.active++;
|
||||||
session.player = game.players[session.color];
|
session.player = game.players[session.color];
|
||||||
session.player.status = 'Active';
|
session.player.status = 'Active';
|
||||||
session.player.lastActive = Date.now();
|
session.player.lastActive = Date.now();
|
||||||
@ -3910,7 +3916,7 @@ const createGame = (id) => {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(`${info} creating ${id}`);
|
console.log(`${info}: creating ${id}`);
|
||||||
|
|
||||||
const game = {
|
const game = {
|
||||||
id: id,
|
id: id,
|
||||||
@ -3922,7 +3928,8 @@ const createGame = (id) => {
|
|||||||
W: newPlayer('W')
|
W: newPlayer('W')
|
||||||
},
|
},
|
||||||
sessions: {},
|
sessions: {},
|
||||||
unselected: []
|
unselected: [],
|
||||||
|
active: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
[ "pips", "borders", "tiles" ].forEach((field) => {
|
[ "pips", "borders", "tiles" ].forEach((field) => {
|
||||||
@ -4036,4 +4043,27 @@ router.get("/", (req, res/*, next*/) => {
|
|||||||
return res.status(200).send({ player: playerId });
|
return res.status(200).send({ player: playerId });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.post("/:id?", async (req, res/*, next*/) => {
|
||||||
|
const { id } = req.params;
|
||||||
|
|
||||||
|
let playerId;
|
||||||
|
if (!req.cookies.player) {
|
||||||
|
playerId = crypto.randomBytes(16).toString('hex');
|
||||||
|
res.cookie('player', playerId);
|
||||||
|
} else {
|
||||||
|
playerId = req.cookies.player;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id) {
|
||||||
|
console.log(`[${playerId.substring(0,8)}]: Attempting load of ${id}`);
|
||||||
|
} else {
|
||||||
|
console.log(`[${playerId.substring(0,8)}]: Creating new game.`);
|
||||||
|
}
|
||||||
|
const game = await loadGame(id); /* will create game if it doesn't exist */
|
||||||
|
console.log(`[${playerId.substring(0,8)}]: ${game.id} loaded.`);
|
||||||
|
|
||||||
|
return res.status(200).send({ id: game.id });
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user