diff --git a/atlas.js b/atlas.js index 005a059..34dc4a4 100644 --- a/atlas.js +++ b/atlas.js @@ -34,8 +34,25 @@ function atlasClick() { atlas_img.src = "favicon.png"; atlas_img.style.width = "100%"; atlas_img.style.height = "100%"; + atlas_img.style.maxWidth = "48px"; + atlas_img.style.maxHeight = "48px"; atlas_img.style.zIndex = 1; atlas.classList.add("atlas"); + let roll = Math.random(); + let rollchance = 0.03; + if (roll < rollchance) { + atlas_img.src = "/media/memes/lmoa.png"; + } else if (roll < 2*rollchance) { + atlas_img.src = "/media/memes/doom.png"; + } else if (roll < 3*rollchance) { + atlas_img.src = "/media/memes/agony.png"; + } else if (roll < 4*rollchance) { + atlas_img.src = "/media/memes/enraged.png"; + } else if (roll < 5*rollchance) { + atlas_img.src = "/media/memes/sunglaso.png"; + } else if (roll < 6*rollchance) { + atlas_img.src = "/media/memes/thonk.png"; + } atlas.appendChild(atlas_img); atlas.style = "background-image: radial-gradient(closest-side, #" + Math.round(255*Math.random()).toString(16)+Math.round(255*Math.random()).toString(16)+Math.round(255*Math.random()).toString(16) + " 0%," + "#121516 120%);"; diff --git a/items.js b/items.js index d31119b..943d21f 100644 --- a/items.js +++ b/items.js @@ -115,7 +115,6 @@ for (let x in special_mappings) { itemFilters.appendChild(el); } -//let itemTypes = [ "helmet", "chestplate", "leggings", "boots", "ring", "bracelet", "necklace", "wand", "spear", "bow", "dagger", "relik" ]; let itemCategories = [ "armor", "accessory", "weapon" ]; function applyQuery(items, query) { diff --git a/load.js b/load.js index d2e7a81..c5d2d5b 100644 --- a/load.js +++ b/load.js @@ -8,7 +8,6 @@ let sets; let itemMap; let idMap; let redirectMap; -let itemTypes = armorTypes.concat(accessoryTypes).concat(weaponTypes); let itemLists = new Map(); /* * Load item set from local DB. Calls init() on success. diff --git a/load_ing.js b/load_ing.js index 5ef2dc9..35abeda 100644 --- a/load_ing.js +++ b/load_ing.js @@ -61,7 +61,7 @@ async function load_ings(init_func) { let getUrl = window.location; let baseUrl = getUrl.protocol + "//" + getUrl.host + "/" + getUrl.pathname.split('/')[1]; let url = baseUrl + "/ingreds_compress.json"; - url = url.replace("/crafter.html", ""); //JANK + url = url.replace(/\w+.html/, "") ; let result = await (await fetch(url)).json(); result = await (await fetch(url)).json(); diff --git a/load_map.js b/load_map.js new file mode 100644 index 0000000..cc87bf0 --- /dev/null +++ b/load_map.js @@ -0,0 +1,123 @@ +const MAP_DB_VERSION = 1; + +// @See https://github.com/mdn/learning-area/blob/master/javascript/apis/client-side-storage/indexeddb/video-store/index.js + +let mdb; +let mreload = false; +var terrs = new Map(); //terr name : location: rectangle def {startX, startY, endX, endY +var claims = new Map(); //terr name: guild name +var neighbors = new Map(); //terr name: [neighbor names] +var resources = new Map(); //terr name: Map({emeralds: bool, doubleemeralds: bool, doubleresource: bool, resources: [], storage: []}) +var terrdata; + +/* + * Load item set from local DB. Calls init() on success. + */ +async function map_load_local(init_func) { + let get_tx = mdb.transaction(['map_db'], 'readonly'); + let map_store = get_tx.objectStore('map_db'); + let request5 = map_store.getAll(); + request5.onerror = function(event) { + console.log("Could not read local map db..."); + } + request5.onsuccess = function(event) { + console.log("Successfully read local map db."); + terrdata = request5.result; + init_map_maps(); + init_func(); + } + await get_tx.complete; + mdb.close(); +} + + +/* + * Load item set from remote DB (aka a big json file). Calls init() on success. + */ +async function load_map(init_func) { + + let getUrl = window.location; + let baseUrl = getUrl.protocol + "//" + getUrl.host + "/" + getUrl.pathname.split('/')[1]; + let url = baseUrl + "/terrs_compress.json"; + url = url.replace(/\w+.html/, "") ; + let result = await (await fetch(url)).json(); + + result = await (await fetch(url)).json(); + terrdata = result; + console.log(terrdata); + + + // https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore/clear + /*let clear_tx2 = db.transaction(['ing_db'], 'readwrite'); + let clear_ings = clear_tx2.objectStore('ing_db'); + let clear_tx3 = db.transaction(['recipe_db'], 'readwrite'); + let clear_recipes = clear_tx3.objectStore('recipe_db'); + await clear_ings.clear(); + await clear_recipes.clear(); + await clear_tx2.complete; + await clear_tx3.complete;*/ + let add_promises = []; + let add_tx2 = mdb.transaction(['map_db'], 'readwrite'); + let map_store = add_tx2.objectStore('map_db'); + console.log(map_store); + for (const terr of Object.entries(terrdata)) { + add_promises.push(map_store.add(terr[1],terr[0])); //WHY? WHY WOULD YOU STORE AS VALUE, KEY? WHY NOT KEEP THE NORMAL KEY, VALUE CONVENTION? + } + add_promises.push(add_tx2.complete); + + Promise.all(add_promises).then((values) => { + mdb.close(); + init_map_maps(); + init_func(); + }); +} + +function load_map_init(init_func) { + //uncomment below line to force reload + //window.indexedDB.deleteDatabase("map_db", MAP_DB_VERSION) + let request = window.indexedDB.open("map_db", MAP_DB_VERSION) + request.onerror = function() { + console.log("DB failed to open..."); + } + + request.onsuccess = function() { + mdb = request.result; + if (!mreload) { + console.log("Using stored data...") + map_load_local(init_func); + } + else { + console.log("Using new data...") + load_map(init_func); + } + } + + request.onupgradeneeded = function(e) { + mreload = true; + + let mdb = e.target.result; + + try { + mdb.deleteObjectStore('map_db'); + } + catch (error) { + console.log("Could not delete map DB. This is probably fine"); + } + + mdb.createObjectStore('map_db'); + + console.log("DB setup complete..."); + } +} + +function init_map_maps() { + for (const [terr,data] of Object.entries(terrdata)) { + terrs.set(data.territory,data.location); + claims.set(data.territory,data.guild); + if (!guilds.includes(data.guild)) { + guilds.push(data.guild); + } + neighbors.set(data.territory,data.neighbors); + resources.set(data.territory,{"resources":data.resources,"storage":data.storage,"emeralds":data.emeralds,"doubleemeralds":data.doubleemeralds,"doubleresource":data.doubleresource}); + } +} \ No newline at end of file diff --git a/map-narrow.css b/map-narrow.css index b0ef0cc..05b42e5 100644 --- a/map-narrow.css +++ b/map-narrow.css @@ -1,6 +1,10 @@ .mapdiv{ - height: 100vh; + height: 99vh; background: #121516; + width: 90vw; +} +.overall-container{ + margin-bottom: 10px; } .container{ width: 95%; @@ -12,5 +16,59 @@ display: grid; grid-template-columns: 1fr 1fr 1fr; grid-column-gap: 5px; - grid-auto-rows: minmax(60px, auto); + grid-auto-rows: minmax(32px, auto); +} +.leaflet-tooltip.labelp { + font-family: 'Nunito', sans-serif; + white-space: nowrap; + border: 0; + margin: 0; + padding: 0; + border-radius: 0; + border: rgba(0,0,0,0); + background-color: rgba(0,0,0,0); + display: block; + box-sizing: border-box; + box-shadow: none; + text-align: center; + text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, 0 0 1px #000; +} +.labelp { + position: relative; + word-break: break-word; + overflow-wrap: break-word; +} +.leaflet-tooltip-left { + border-left-color: transparent; +} +.leaflet-tooltip-right{ + border-right-color: transparent; +} +.Emeralds{ + border:2px solid #4ae024; +} +.Ore{ + border:2px solid #7d7b74; +} +.Wood{ + border:2px solid #855E42; +} +.Crops{ + border:2px solid #e3cea6; +} +.Fish{ + border:2px solid #a6d8e3; +} + + +.resourceimg { + border-radius: 2px; + z-index: 20000000; +} +.marker { + z-index: 200000000; +} +.nomargin{ + margin-top: 2px; + margin-bottom: 2px; } \ No newline at end of file diff --git a/map-wide.css b/map-wide.css index 283d2b1..68b6326 100644 --- a/map-wide.css +++ b/map-wide.css @@ -1,5 +1,5 @@ .mapdiv{ - height: 100vh; + height: 99vh; background: #121516; } .overall-container { @@ -7,16 +7,70 @@ grid-template-columns: 80% 20%; grid-column-gap: 5px; grid-auto-rows: minmax(60px, auto); + margin-bottom: 10px; } .coord-container { display: grid; grid-template-columns: 30% 30% 30%; grid-column-gap: 5px; - grid-auto-rows: minmax(60px, auto); + grid-auto-rows: minmax(32px, auto); } .container{ width: 95%; border: 3px solid #BCBCBC; - border-radius: 3px; - + border-radius: 3px; +} +.leaflet-tooltip.labelp { + font-family: 'Nunito', sans-serif; + font-size: 1.1em; + white-space: nowrap; + border: 0; + margin: 0; + padding: 0; + border-radius: 0; + border: rgba(0,0,0,0); + background-color: rgba(0,0,0,0); + box-sizing: border-box; + box-shadow: none; + text-align: center; + text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, 0 0 1px #000; +} +.labelp { + position: relative; + overflow-wrap: break-word; +} +.leaflet-tooltip-left { + border-left-color: transparent; +} +.leaflet-tooltip-right{ + border-right-color: transparent; +} +.Emeralds{ + border:2px solid #4ae024; +} +.Ore{ + border:2px solid #7d7b74; +} +.Wood{ + border:2px solid #855E42; +} +.Crops{ + border:2px solid #e3cea6; +} +.Fish{ + border:2px solid #a6d8e3; +} + + +.resourceimg { + border-radius: 2px; + z-index: 20000000; +} + +.marker{ + z-index: 200000000; +} +.nomargin{ + margin-top: 2px; + margin-bottom: 2px; } \ No newline at end of file diff --git a/map.html b/map.html index ef070e8..d2ed4b1 100644 --- a/map.html +++ b/map.html @@ -11,9 +11,9 @@ - - - + + + @@ -74,27 +74,75 @@
Options
- -Options
+ +X
+ +Z
+ +-
-
All Keys
++ | + ++ | + +