moved moving from client to server

This commit is contained in:
Wenszel
2021-04-30 13:17:49 +02:00
parent c8773ed546
commit b56c343d83
5 changed files with 67 additions and 6 deletions
@@ -11,7 +11,7 @@ const Dice = ({ rolledNumberCallback, nowMoving }) => {
const [rolledNumber, setRolledNumber] = useState();
const [images] = useState([one, two, three, four, five, six]);
const handleRoll = () => {
axios.get('http://localhost:3000/game/roll').then(response => {
axios.get('http://localhost:3000/game/roll', {withCredentials: true}).then(response => {
const utterance = new SpeechSynthesisUtterance(response.data.number);
speechSynthesis.speak(utterance);
setRolledNumber(response.data.number);
+1 -1
View File
@@ -55,7 +55,7 @@ const Map = ({ pawns, nowMoving, rolledNumber }) => {
y = event.clientY - rect.top;
for(const pawn of pawns){
if (ctx.isPointInPath(pawn.circle, x, y)) {
axios.post('http://localhost:3000/game/move', {pawnId: pawn._id, position: hintPawn.position}, {withCredentials: true})
axios.post('http://localhost:3000/game/move', {pawnId: pawn._id}, {withCredentials: true, mode: 'cors'})
.then(() => {
setHintPawn(null);
});