some more code also i redid the board generator
This commit is contained in:
@@ -8,40 +8,69 @@ const BoardLookup = {
|
||||
'★': 'center-star'
|
||||
};
|
||||
|
||||
// This was automatically generated, the code for it is lonnnggg gone
|
||||
const BoardLocations = {
|
||||
'A1': 'TW',
|
||||
'D1': 'DL',
|
||||
'H1': 'TW',
|
||||
'L1': 'DL',
|
||||
'O1': 'TW',
|
||||
'B2': 'DW',
|
||||
'F2': 'TL',
|
||||
'J2': 'TL',
|
||||
'N2': 'DW',
|
||||
'C3': 'DW',
|
||||
'G3': 'DL',
|
||||
'I3': 'DL',
|
||||
'M3': 'DW',
|
||||
'A4': 'DL',
|
||||
'D4': 'DW',
|
||||
'H4': 'DL',
|
||||
'L4': 'DW',
|
||||
'O4': 'DL',
|
||||
'E5': 'DW',
|
||||
'K5': 'DW',
|
||||
'B6': 'TL',
|
||||
'F6': 'TL',
|
||||
'J6': 'TL',
|
||||
'N6': 'TL',
|
||||
'C7': 'DL',
|
||||
'G7': 'DL',
|
||||
'I7': 'DL',
|
||||
'M7': 'DL',
|
||||
'A8': 'TW',
|
||||
'D8': 'DL',
|
||||
'H8': '★',
|
||||
'L8': 'DL',
|
||||
'O8': 'TW'
|
||||
"0,0": "TW",
|
||||
"0,3": "DL",
|
||||
"0,7": "TW",
|
||||
"0,11": "DL",
|
||||
"0,14": "TW",
|
||||
"1,1": "DW",
|
||||
"1,5": "TL",
|
||||
"1,9": "TL",
|
||||
"1,13": "DW",
|
||||
"2,2": "DW",
|
||||
"2,6": "DL",
|
||||
"2,8": "DL",
|
||||
"2,12": "DW",
|
||||
"3,0": "DL",
|
||||
"3,3": "DW",
|
||||
"3,7": "DL",
|
||||
"3,11": "DW",
|
||||
"3,14": "DL",
|
||||
"4,4": "DW",
|
||||
"4,10": "DW",
|
||||
"5,1": "TL",
|
||||
"5,5": "TL",
|
||||
"5,9": "TL",
|
||||
"5,13": "TL",
|
||||
"6,2": "DL",
|
||||
"6,6": "DL",
|
||||
"6,8": "DL",
|
||||
"6,12": "DL",
|
||||
"7,0": "TW",
|
||||
"7,3": "DL",
|
||||
"7,7": "★",
|
||||
"7,11": "DL",
|
||||
"7,14": "TW",
|
||||
"8,2": "DL",
|
||||
"8,6": "DL",
|
||||
"8,8": "DL",
|
||||
"8,12": "DL",
|
||||
"9,1": "TL",
|
||||
"9,5": "TL",
|
||||
"9,9": "TL",
|
||||
"9,13": "TL",
|
||||
"10,4": "DW",
|
||||
"10,10": "DW",
|
||||
"11,0": "DL",
|
||||
"11,3": "DW",
|
||||
"11,7": "DL",
|
||||
"11,11": "DW",
|
||||
"11,14": "DL",
|
||||
"12,2": "DW",
|
||||
"12,6": "DL",
|
||||
"12,8": "DL",
|
||||
"12,12": "DW",
|
||||
"13,1": "DW",
|
||||
"13,5": "TL",
|
||||
"13,9": "TL",
|
||||
"13,13": "DW",
|
||||
"14,0": "TW",
|
||||
"14,3": "DL",
|
||||
"14,7": "TW",
|
||||
"14,11": "DL",
|
||||
"14,14": "TW"
|
||||
};
|
||||
|
||||
function flip(y, size)
|
||||
@@ -52,8 +81,8 @@ function flip(y, size)
|
||||
window.onload = e => {
|
||||
for (const location in BoardLocations)
|
||||
{
|
||||
const x = location[0].toLowerCase();
|
||||
const y = location[1];
|
||||
const x = String.fromCharCode(parseInt(location.split(',')[0]) + 65).toLowerCase();
|
||||
const y = parseInt(location.split(',')[1]) + 1;
|
||||
|
||||
const boardLocation = document.querySelector(`#row-${y}`).querySelector(`#col-${x}`);
|
||||
|
||||
@@ -69,27 +98,4 @@ window.onload = e => {
|
||||
|
||||
boardLocation.innerHTML = localeThing;
|
||||
}
|
||||
|
||||
// flip it
|
||||
|
||||
for (const location in BoardLocations)
|
||||
{
|
||||
const x = location[0].toLowerCase();
|
||||
let y = location[1];
|
||||
|
||||
y = flip(y, 15);
|
||||
|
||||
const boardLocation = document.querySelector(`#row-${y}`).querySelector(`#col-${x}`);
|
||||
|
||||
boardLocation.classList.add(BoardLookup[BoardLocations[location]]);
|
||||
boardLocation.classList.add('unselectable');
|
||||
let localeThing = BoardLocations[location];
|
||||
|
||||
if (localStorage.getItem('locale') === "es" || localStorage.getItem('locale') === "pt")
|
||||
{
|
||||
localeThing = localeThing.replace('W', 'P');
|
||||
}
|
||||
|
||||
boardLocation.innerHTML = localeThing;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -75,6 +75,14 @@ function mouseUp(event)
|
||||
event.preventDefault();
|
||||
|
||||
if (selectedElement.pointerEvents != 'initial')
|
||||
{
|
||||
if (!selectedElement.velocity)
|
||||
{
|
||||
if (piecePlaced(selectedElement))
|
||||
{
|
||||
selectedElement.pointerEvents = 'initial';
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (magnitude(selectedElement.velocity) <= 1)
|
||||
{
|
||||
@@ -89,4 +97,5 @@ function mouseUp(event)
|
||||
selectedElement.pointerEvents = 'initial';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ let Users = [];
|
||||
// just shorthand, so long as i remember to keep it updated lmao
|
||||
let MyTurn = false;
|
||||
|
||||
let pastTurns = [];
|
||||
|
||||
function initGame(boardstate, tileset, myplayer, players)
|
||||
{
|
||||
// construct piece array
|
||||
@@ -90,6 +92,20 @@ function playMyTurn(stagedpieces)
|
||||
{
|
||||
if (!MyTurn) return false;
|
||||
|
||||
|
||||
|
||||
const turn = {
|
||||
playeruid: Users.filter(e => e.me)[0].uid,
|
||||
// servers job
|
||||
turn: -1,
|
||||
turntype: 'PLACE',
|
||||
// servers job
|
||||
outcome: {},
|
||||
}
|
||||
|
||||
console.log(stagedpieces);
|
||||
console.log(turn);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ function addPiecesToDrawer(pieces)
|
||||
domPiece.appendChild(score);
|
||||
Drawer.appendChild(domPiece);
|
||||
|
||||
ret.push (domPiece);
|
||||
ret.push(domPiece);
|
||||
}
|
||||
|
||||
setupPieces();
|
||||
@@ -99,6 +99,34 @@ function boardCoordsFromScreenSpace(ssx, ssy)
|
||||
return {x: x, y: y};
|
||||
}
|
||||
|
||||
function renderBoardState(pieces)
|
||||
{
|
||||
// adds all lol
|
||||
for (const piece of pieces)
|
||||
{
|
||||
if (!getPieceFromBoard(piece.pos.x, piece.pos.y))
|
||||
{
|
||||
const domPiece = document.createElement('piece');
|
||||
domPiece.innerText = piece.letter;
|
||||
domPiece.classList.add('unselectable');
|
||||
domPiece.classList.add('small-piece');
|
||||
domPiece.classList.add('played-piece');
|
||||
|
||||
const score = document.createElement('score');
|
||||
score.innerText = piece.score;
|
||||
|
||||
domPiece.dataset.coords = JSON.stringify(piece.pos);
|
||||
|
||||
domPiece.appendChild(score);
|
||||
Drawer.appendChild(domPiece);
|
||||
|
||||
placePieceOnBoard(domPiece, piece.pos.x, piece.pos.y)
|
||||
}
|
||||
}
|
||||
|
||||
setupPieces();
|
||||
}
|
||||
|
||||
// places for board coordinate (0-14)
|
||||
function placePieceOnBoard(piece, x, y)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user