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 {
|
||||
font-family: 'Droid Sans', 'Arial Narrow', Arial, sans-serif;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#root {
|
||||
|
@ -220,15 +220,17 @@ const Table = () => {
|
||||
`Try refreshing your browser in a few seconds.`;
|
||||
console.error(error);
|
||||
setError(error);
|
||||
throw error;
|
||||
throw new Error(error);
|
||||
}
|
||||
return res.json();
|
||||
}).then((update) => {
|
||||
if (update.id !== gameId) {
|
||||
console.log(`New game started: ${update.id}`);
|
||||
console.log(`Game available: ${update.id}`);
|
||||
history.push(`${gamesPath}/${update.id}`);
|
||||
setGameId(update.id);
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
}, [ gameId, setGameId ]);
|
||||
|
||||
|
@ -213,11 +213,14 @@ const Board = () => {
|
||||
><div className="Tile-Shape"/></div>;
|
||||
};
|
||||
|
||||
const sendPlacement = useCallback((type, index) => {
|
||||
const staticSendCallback = (type, index) => {
|
||||
ws.send(JSON.stringify({
|
||||
type, index
|
||||
}));
|
||||
}, [ws]);
|
||||
};
|
||||
const refStaticSendCallback = useRef(staticSendCallback);
|
||||
useEffect(() => { refStaticSendCallback.current = staticSendCallback; });
|
||||
const sendPlacement = refStaticSendCallback.current;
|
||||
|
||||
const onRoadClicked = useCallback((road) => {
|
||||
console.log(`Road clicked: ${road.index}`);
|
||||
|
@ -43,6 +43,11 @@ const Placard = ({type, disabled, count, buildActive, setBuildActive}) => {
|
||||
setBuildActive(false);
|
||||
};
|
||||
|
||||
|
||||
if (!type) {
|
||||
return <></>;
|
||||
}
|
||||
|
||||
if (type === 'B') { type = 'blue'; }
|
||||
else if (type === 'O') { type = 'orange'; }
|
||||
else if (type === 'R') { type = 'red'; }
|
||||
|
@ -891,7 +891,7 @@ const colorToWord = (color) => {
|
||||
const getActiveCount = (game) => {
|
||||
let active = 0;
|
||||
for (let color in game.players) {
|
||||
if (game.players[color].name) {
|
||||
if (!game.players[color].name) {
|
||||
continue;
|
||||
}
|
||||
active++;
|
||||
@ -1000,7 +1000,7 @@ const setPlayerColor = (game, session, color) => {
|
||||
name: session.name,
|
||||
color: session.color,
|
||||
live: session.live,
|
||||
private: session.player
|
||||
private: session.player,
|
||||
});
|
||||
sendUpdateToPlayers(game, update);
|
||||
};
|
||||
@ -2858,6 +2858,10 @@ const setGameState = (game, session, state) => {
|
||||
if (game.state !== '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.`);
|
||||
game.state = state;
|
||||
|
||||
@ -3271,7 +3275,7 @@ const gotoLobby = (game, session) => {
|
||||
|
||||
router.ws("/ws/:id", async (ws, req) => {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -3832,6 +3836,7 @@ const resetGame = (game) => {
|
||||
largestArmy: '',
|
||||
largestArmySize: 0,
|
||||
winner: undefined,
|
||||
active: 0
|
||||
});
|
||||
|
||||
/* Populate the game corner and road placement data as cleared */
|
||||
@ -3888,6 +3893,7 @@ const resetGame = (game) => {
|
||||
for (let key in game.sessions) {
|
||||
const session = game.sessions[key];
|
||||
if (session.color) {
|
||||
game.active++;
|
||||
session.player = game.players[session.color];
|
||||
session.player.status = 'Active';
|
||||
session.player.lastActive = Date.now();
|
||||
@ -3910,7 +3916,7 @@ const createGame = (id) => {
|
||||
break;
|
||||
}
|
||||
}
|
||||
console.log(`${info} creating ${id}`);
|
||||
console.log(`${info}: creating ${id}`);
|
||||
|
||||
const game = {
|
||||
id: id,
|
||||
@ -3922,7 +3928,8 @@ const createGame = (id) => {
|
||||
W: newPlayer('W')
|
||||
},
|
||||
sessions: {},
|
||||
unselected: []
|
||||
unselected: [],
|
||||
active: 0
|
||||
};
|
||||
|
||||
[ "pips", "borders", "tiles" ].forEach((field) => {
|
||||
@ -4036,4 +4043,27 @@ router.get("/", (req, res/*, next*/) => {
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user