You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

90 lines
2.0 KiB

"use strict"
let socket;
let debug = false,
viewPort = {x: 0, y: 0},
font,
settings;
let userInterface = true,
cards = [],
hidden,
game,
cardSize;
function preload(){
font = loadFont("data/styles/font.ttf");
settings = loadJSON('data/settings/settings.json');
loadCards();
}
function loadCards(){
loadJSON("data/settings/sources.json", createCards);
}
function setup(){
let ctx = createCanvas(50, 50);
ctx.parent("loader");
playerDomSetup(0);
hideDomElements();
$("body").show();
}
function draw(){
clear();
let angleStart = frameCount / 10 * PI;
noFill();
stroke("#33AA33");
strokeWeight(5);
arc(25, 25, 45, 45, angleStart, angleStart + PI + HALF_PI);
}
function loader(dom){
//$(dom).attr("disabled", "disabled");
//$("#loader").show();
}
function createCards(json){
cards = [];
let id = 0;
hidden = json.hidden;
for (let src of json.sources){
cards.push(new Card(id, src),
new Card(id + 1, src));
id += 2;
}
}
function cardClicked(card){
if (!game || !game.running || game.cards.includes(card)) return;
game.revealCard(false, card.id);
}
function playerDomSetup(playerCount, players){
for (let i = 0; i < playerCount; i++){
if (i % 2 == 0) $("#left > div:eq(" + i / 2 + ")").show();
else $("#right > div:eq(" + (i - 1) / 2 + ")").show();
}
for (let i = playerCount; i < 8; i++){
if (i % 2 == 0) $("#left > div:eq(" + i / 2 + ")").hide();
else $("#right > div:eq(" + (i - 1) / 2 + ")").hide();
}
if (players != null) for (let p of players) p.hasTurn(false);
}
function hideDomElements(){
//Only leaders shall see those
$("#showInterface_btn, #interface").hide();
//For all
$("#player-count, #player-name, .error-label, " +
"#join-lobby, #lobby, .setup:eq(1), .setup:eq(2), #p5_loading, #loader").hide();
}
function createEmpty(){
let empty = $("<div></div>");
empty.attr("class", "card empty");
return empty;
}