Permalink
Browse files

Tourneys checks indicators

  • Loading branch information...
Manuel-777 committed Jan 20, 2019
1 parent 242ba1b commit 8ae9a521a57f77b2eee5c8f967846e7a9f7cb46c
Showing with 86 additions and 1 deletion.
  1. +48 −0 window_main/index.css
  2. +5 −0 window_main/renderer.js
  3. +33 −1 window_main/tournaments.js
@@ -532,6 +532,10 @@ span i {
-webkit-transition: all .2s ease-in;
}

.black_bright {
color: #A18E87 !important;
}

.green_bright {
color: #D3EBB0 !important;
}
@@ -556,6 +560,34 @@ span i {
color: #FAE5D2 !important;
}

.black_bright_bg {
background-color: #A18E87 !important;
}

.green_bright_bg {
background-color: #D3EBB0 !important;
}

.blue_bright_bg {
background-color: #BDD6FF !important;
}

.orange_bright_bg {
background-color: #FFBA85 !important;
}

.red_bright_bg {
background-color: #FF9B78 !important;
}

.yellow_bright_bg {
background-color: #FFDF9E !important;
}

.white_bright_bg {
background-color: #FAE5D2 !important;
}

.green {
color: rgba(183, 200, 158, 1) !important;
}
@@ -2307,6 +2339,22 @@ a:hover {
overflow: auto;
}

.tou_check_cont {
display: flex;
}

.tou_checks {
justify-content: center;
display: flex;
margin: 8px 0 12px 0;
}

.tou_check {
width: 32px;
margin: 0 1px;
height: 8px;
}

.tou_container {
display: flex;
cursor: pointer;
@@ -28,6 +28,7 @@ const remote = require('electron').remote;

const open_tournaments_tab = require('./tournaments').open_tournaments_tab;
const open_tournament = require('./tournaments').open_tournament;
const set_tou_state = require('./tournaments').set_tou_state;
const open_deck = require('./deck_details').open_deck
const open_decks_tab = require('./decks').open_decks_tab;
const open_history_tab = require('./history').open_history_tab;
@@ -155,6 +156,10 @@ ipc.on('set_discord_tag', (event, arg) => {
}
});

ipc.on('set_tou_state', (event, arg) => {
set_tou_state(arg);
});

//
ipc.on('too_slow', function () {
pop('Loading is taking too long, please read our <a class="trouble_link">troubleshooting guide</a>.', 0);
@@ -25,6 +25,8 @@ let originalDeck = null;
let tou = null;
let listInterval = [];

let touStates = {};

// Should separate these two into smaller functions
function open_tournaments_tab(arg, opentab = true) {
let mainDiv = document.getElementById("ux_0");
@@ -322,6 +324,10 @@ function open_tournament(t) {
}, 250);
}

let checks = $(`<div class="tou_checks"></div>`);
generateChecks(tou.current_check, tou.current_game, tou.current_seat).appendTo(checks);
checks.appendTo(mainDiv);

$('.copy_mtga').click(() => {
pop("Copied to clipboard", 1000);
ipc_send('set_clipboard', tou.current_opponent);
@@ -602,6 +608,31 @@ function open_tournament(t) {
});
}

function set_tou_state(state) {
touStates[state.tid] = state;
if (state.tid == tou._id) {
$('.tou_checks').html('');
$('.tou_checks').append(generateChecks(state.check, state.game, state.seat));
}
}

function generateChecks(state, game, seat) {
let checks = $('<div class="tou_check_cont"></div>');
state.forEach((c, index) => {
let ch;
let ss = index % 2;
if (Math.floor(index / 2) <= game) {
ch = $(`<div title="${ss == seat ? 'You' : tou.current_opponent.slice(0, -6)}" class="tou_check ${c ? 'green_bright_bg' : 'red_bright_bg'}"></div>`);
}
else {
ch = $(`<div title="${ss == seat ? 'You' : tou.current_opponent.slice(0, -6)}" class="tou_check black_bright_bg"></div>`);
}
ch.appendTo(checks);
});

return checks;
}

function selectTourneyDeck() {
tournamentDeck = document.getElementById("deck_select").value;
decks.forEach((_deck) => {
@@ -707,5 +738,6 @@ function moveCard(_cardTile) {

module.exports = {
open_tournaments_tab: open_tournaments_tab,
open_tournament: open_tournament
open_tournament: open_tournament,
set_tou_state: set_tou_state
}

0 comments on commit 8ae9a52

Please sign in to comment.