Skip to content
Permalink
Browse files

Compact lands in overlay

  • Loading branch information...
Manuel-777 committed May 22, 2019
1 parent ba65e1c commit 95cbfc24b62ae2c8aec83099c2139908e24505bd
Showing with 51 additions and 3 deletions.
  1. +4 −0 shared/database.js
  2. +1 −0 shared/util.js
  3. +1 −0 window_background/background.js
  4. +10 −0 window_main/settings.js
  5. +35 −3 window_overlay/overlay.js
@@ -22,6 +22,10 @@ class Database {
return true;
}

setCard(grpId, obj) {
this.cards[grpId] = obj;
}

get(grpId) {
let ret = this.cards[grpId];
return ret ? ret : false;
@@ -419,6 +419,7 @@ function get_card_type_sort(a) {
if (a.includes("Artifact", 0)) return 5;
if (a.includes("Enchantment", 0)) return 6;
if (a.includes("Land", 0)) return 7;
if (a.includes("Special", 0)) return 8;
return 0;
}

@@ -123,6 +123,7 @@ const defaultCfg = {
overlay_deck: true,
overlay_clock: true,
overlay_ontop: true,
overlay_lands: true,
export_format: "$Name,$Count,$Rarity,$SetName,$Collector",
back_color: "rgba(0,0,0,0.3)",
back_url: "",
@@ -213,6 +213,13 @@ function openSettingsTab(openSection = lastSettingsSection) {
settings.overlay_sideboard,
updateUserSettings
);
add_checkbox(
section,
"Compact lands",
"settings_overlay_lands",
settings.overlay_lands,
updateUserSettings
);

const sliderOpacity = $('<div class="slidecontainer_settings"></div>');
sliderOpacity.appendTo(section);
@@ -651,6 +658,8 @@ function updateUserSettings(_settings = {}) {
.checked;
const overlaySideboard = document.getElementById("settings_overlay_sideboard")
.checked;
const overlayLands = document.getElementById("settings_overlay_lands")
.checked;

const exportFormat = document.getElementById("settings_export_format").value;
settings = {
@@ -673,6 +682,7 @@ function updateUserSettings(_settings = {}) {
overlay_clock: overlayClock,
overlay_sideboard: overlaySideboard,
overlay_ontop: overlayOnTop,
overlay_lands: overlayLands,
anon_explore: anonExplore,
back_color: backColor,
back_url: backUrl,
@@ -5,6 +5,7 @@ global
cardsDb,
compare_cards,
CardsList,
Colors,
Deck,
eventsList,
eventsToFormat,
@@ -63,6 +64,7 @@ let oppName = "";
let turnPriority = 0;
let soundPriority = false;
let soundPriorityVolume = 1;
let overlayLands = true;
let overlayAlpha = 1;
let overlayAlphaBack = 1;
let oddsSampleSize = 1;
@@ -301,6 +303,7 @@ ipc.on("set_settings", function(event, settings) {
*/
overlayAlpha = settings.overlay_alpha;
overlayAlphaBack = settings.overlay_alpha_back;
overlayLands = settings.overlay_lands;
change_background(settings.back_url);

webFrame.setZoomFactor(settings.overlay_scale / 100);
@@ -571,13 +574,42 @@ function updateView() {

let mainCards = deckToDraw.mainboard;
mainCards.removeDuplicates();
// group lands
if (overlayLands && deckMode !== 3) {
let landsNumber = 0;
let landsChance = 0;
let landsColors = new Colors();
mainCards.get().forEach(card => {
let cardObj = cardsDb.get(card.id);
if (cardObj && cardObj.type.includes("Land", 0)) {
landsNumber += card.quantity;
landsChance += card.chance !== undefined ? card.chance : 0;
delete card.chance;
card.quantity = 0;
if (cardObj.frame) {
landsColors.addFromArray(cardObj.frame);
}
}
});
let lands = mainCards.add(100, landsNumber, true);
if (landsChance > 0) {
lands.chance = landsChance;
}

// Set lands frame colors
let landsObj = cardsDb.get(100);
landsObj.frame = landsColors.get();
cardsDb.setCard(100, landsObj);
}
mainCards.get().sort(sortFunc);
mainCards.get().forEach(card => {
var grpId = card.id;
if (deckMode == 2) {
let quantity = (card.chance != undefined ? card.chance : "0") + "%";
let tile = deckDrawer.cardTile(grpId, "a", quantity);
deckListDiv.append(tile);
let quantity = (card.chance !== undefined ? card.chance : "0") + "%";
if (!overlayLands || (overlayLands && quantity !== "0%")) {
let tile = deckDrawer.cardTile(grpId, "a", quantity);
deckListDiv.append(tile);
}
} else {
let tile = deckDrawer.cardTile(grpId, "a", card.quantity);
deckListDiv.append(tile);

0 comments on commit 95cbfc2

Please sign in to comment.
You can’t perform that action at this time.