fixed color management

This commit is contained in:
yamanq 2015-07-08 00:35:31 -04:00
parent 5af1261aad
commit 3db891a641

View File

@ -17,11 +17,6 @@ var claimedColors = {
"red": "#FF9999", "red": "#FF9999",
"blue": "#9999FF" "blue": "#9999FF"
} }
var redPlayer = "#E62E2E";
var redClaimed = "#FF9999";
var bluePlayer = "#4343D8";
var blueClaimed = "#9999FF";
document.getElementsByClassName('play')[0].onclick = function startGame() { document.getElementsByClassName('play')[0].onclick = function startGame() {
@ -39,9 +34,6 @@ document.getElementsByClassName('play')[0].onclick = function startGame() {
coordinate = [0,0]; coordinate = [0,0];
team = "blue"; team = "blue";
playerColor = playerColors[team];
claimColor = claimedColors[team];
// TODO IP Handling, most likely not necessary // TODO IP Handling, most likely not necessary
var login = document.getElementById("login"); var login = document.getElementById("login");
@ -129,7 +121,7 @@ function tableUpdate (coordinate, team) {
// Creation of Player // Creation of Player
function createPlayer() { function createPlayer() {
table.rows[coordinate[0]].cells[coordinate[1]].style.backgroundColor = playerColor; table.rows[coordinate[0]].cells[coordinate[1]].style.backgroundColor = playerColors[team];
table.rows[coordinate[0]].cells[coordinate[1]].className = "player "; table.rows[coordinate[0]].cells[coordinate[1]].className = "player ";
} }
@ -139,7 +131,7 @@ function movement(x,y) {
setTimeout(function() { setTimeout(function() {
try { try {
if (table.rows[coordinate[0] + y].cells[coordinate[1] + x].className.includes(team)) { if (table.rows[coordinate[0] + y].cells[coordinate[1] + x].className.includes(team)) {
table.rows[coordinate[0]].cells[coordinate[1]].style.backgroundColor = claimColor; table.rows[coordinate[0]].cells[coordinate[1]].style.backgroundColor = claimedColors[team];
document.getElementsByClassName('player')[0].className = ""; document.getElementsByClassName('player')[0].className = "";
spectatorMode(); spectatorMode();
} }
@ -147,8 +139,8 @@ function movement(x,y) {
table.rows[coordinate[0]].cells[coordinate[1]].className = table.rows[coordinate[0]].cells[coordinate[1]].className.replace("player ", ""); table.rows[coordinate[0]].cells[coordinate[1]].className = table.rows[coordinate[0]].cells[coordinate[1]].className.replace("player ", "");
table.rows[coordinate[0] + y].cells[coordinate[1] + x].className = "player "; table.rows[coordinate[0] + y].cells[coordinate[1] + x].className = "player ";
table.rows[coordinate[0] + y].cells[coordinate[1] + x].className += team; table.rows[coordinate[0] + y].cells[coordinate[1] + x].className += team;
table.rows[coordinate[0] + y].cells[coordinate[1] + x].style.backgroundColor = playerColor; table.rows[coordinate[0] + y].cells[coordinate[1] + x].style.backgroundColor = playerColors[team];
table.rows[coordinate[0]].cells[coordinate[1]].style.backgroundColor = claimColor; table.rows[coordinate[0]].cells[coordinate[1]].style.backgroundColor = claimedColors[team];
coordinate = [coordinate[0] + y, coordinate[1] + x]; coordinate = [coordinate[0] + y, coordinate[1] + x];
updateScore(); updateScore();
serverTransfer(coordinate,team,turn,username); serverTransfer(coordinate,team,turn,username);