From e3a432cd5aa9aadbfdd7fd630ea8ccb84122ccb1 Mon Sep 17 00:00:00 2001 From: Yaman Date: Sun, 30 Aug 2015 18:54:47 -0400 Subject: [PATCH] add pull value --- clashingcomrades/static/main.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/clashingcomrades/static/main.js b/clashingcomrades/static/main.js index 67e7fec..4f10490 100644 --- a/clashingcomrades/static/main.js +++ b/clashingcomrades/static/main.js @@ -33,8 +33,10 @@ document.getElementsByClassName('play')[0].onclick = function startGame() { //********************* // TODO Get from server //********************* - playerCoordinate = [0,0]; - playerTeam = "blue"; + getInitial() + + + // TODO IP Handling, most likely not necessary @@ -50,6 +52,26 @@ document.getElementsByClassName('play')[0].onclick = function startGame() { document.onkeydown = movePlayer; } +function setInitial(initial) { + playerCoordinate = initial["coordinate"]; + playerTeam = initial["team"]; +} + +function getInitial() { + $.ajax({ + url: 'http://127.0.0.1:5000/game', + type: 'GET', + // data: '', + success: function(data) { + //called when successful + setInitial(data) + }, + error: function(e) { + //called when there is an error + //console.log(e.message); + } + }); +} function serverTransfer(coordinate,team,turn,username) { var move = { coordinate: coordinate,