fix to fixIDs on CIs not saving, new locations features for wynnGPS (unfinished)

This commit is contained in:
ferricles 2021-03-22 14:33:10 -07:00
parent 5ebbb2264d
commit a17cdb9e16
52 changed files with 9086 additions and 23 deletions

View file

@ -27,7 +27,7 @@ function getCustomFromHash(hash) {
if (version === "1") {
//do the things
if (fixID) {
statMap.set("fixId", true);
statMap.set("fixID", true);
}
while (tag !== "") {
let id = ci_save_order[Base64.toInt(tag.slice(0,2))];

View file

@ -1,4 +1,4 @@
const MAP_DB_VERSION = 1;
const MAP_DB_VERSION = 3;
// @See https://github.com/mdn/learning-area/blob/master/javascript/apis/client-side-storage/indexeddb/video-store/index.js
@ -8,26 +8,44 @@ var terrs = new Map(); //terr name : location: rectangle def {startX, startY, en
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 maplocs = []; //literally the object array from maploc_compress
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 get_tx = mdb.transaction(['map_db','maploc_db'], 'readonly');
let map_store = get_tx.objectStore('map_db');
let maploc_store = get_tx.objectStore('maploc_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;
}
get_tx = mdb.transaction(['maploc_db'], 'readonly');
map_store = get_tx.objectStore('maploc_db');
let request6 = maploc_store.getAll();
request6.onerror = function(event) {
console.log("Could not read local map locations db...");
}
request6.onsuccess = function(event) {
console.log("Successfully read local locations map db.");
maplocs = request6.result;
init_map_maps();
init_func();
}
await get_tx.complete;
mdb.close();
}
@ -41,10 +59,15 @@ async function load_map(init_func) {
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;
url = baseUrl + "/maploc_compress.json";
url = url.replace(/\w+.html/, "");
result = await (await fetch(url)).json();
maplocs = result.locations;
console.log(terrdata);
console.log(maplocs);
// https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore/clear
@ -57,13 +80,21 @@ async function load_map(init_func) {
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?
}
let add_tx3 = mdb.transaction(['maploc_db'], 'readwrite');
let maploc_store = add_tx3.objectStore('maploc_db');
for (const i in maplocs) {
add_promises.push(maploc_store.add(maplocs[i],i));
}
add_promises.push(add_tx2.complete);
add_promises.push(add_tx3.complete);
Promise.all(add_promises).then((values) => {
mdb.close();
@ -74,7 +105,10 @@ async function load_map(init_func) {
function load_map_init(init_func) {
//uncomment below line to force reload
//window.indexedDB.deleteDatabase("map_db", MAP_DB_VERSION)
// window.indexedDB.deleteDatabase("map_db", MAP_DB_VERSION);
// window.indexedDB.deleteDatabase("maploc_db", MAP_DB_VERSION);
let request = window.indexedDB.open("map_db", MAP_DB_VERSION)
request.onerror = function() {
console.log("DB failed to open...");
@ -103,11 +137,19 @@ function load_map_init(init_func) {
catch (error) {
console.log("Could not delete map DB. This is probably fine");
}
try {
mdb.deleteObjectStore('maploc_db');
}
catch (error) {
console.log("Could not delete map location DB. This is probably fine");
}
mdb.createObjectStore('map_db');
mdb.createObjectStore('maploc_db');
console.log("DB setup complete...");
}
}
function init_map_maps() {
@ -120,4 +162,5 @@ function init_map_maps() {
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});
}
}

View file

@ -71,4 +71,8 @@
.nomargin{
margin-top: 2px;
margin-bottom: 2px;
}
td{
vertical-align: top;
}

View file

@ -73,4 +73,7 @@
.nomargin{
margin-top: 2px;
margin-bottom: 2px;
}
td{
vertical-align: top;
}

View file

@ -70,7 +70,7 @@
<button class = "left" id = "claims-button" onclick = "toggleButton('claims-button'); toggleClaims()">Show Claims</button>
<button class = "left" id = "routes-button" onclick = "toggleButton('routes-button'); toggleRoutes()">Show Routes</button>
<button class = "left" id = "resources-button" onclick = "toggleButton('resources-button'); toggleResources()">Show Resources</button>
<!--button id = "merchants-button" onclick = "toggleButton('merchants-button'); toggleMerchants()">Show Merchants</button-->
<button class = "left" id = "locations-button" onclick = "toggleButton('locations-button'); toggleLocations()">Show Locations</button>
<button class = "left" id = "pull-button" onclick = "refreshData()">Refresh Data</button>
<p class = "left" style = "color:red">Do NOT refresh too often.</p>
</div>
@ -105,6 +105,14 @@
<li><img src= "media/icons/new/Gears.png" style ="max-width:16px;max-height:16px" class = "Ore"/> Production</li>
<li>Double image means double generation</li>
</ul>
</div>
</td>
<td>
<div id = "locations-key" style = "display:none">
<p class = "left">Locations Key:</p>
<ul id = "locationlist">
</ul>
</div>
</td>

76
map.js
View file

@ -39,12 +39,13 @@ let claimObjs = [];
//let guildObjs = [];
let routeObjs = [];
let resourceObjs = [];
let locationObjs = [];
let drawterrs = false;
let drawclaims = false;
let drawroutes = false;
let drawresources = false;
let drawmerchants = false;
let drawlocations = false;
//latitude, longitude is y, x!!!!
const bounds = [[0,0], [6484, 4090]];
@ -125,6 +126,7 @@ function init(){ //async just in case we need async stuff
console.log("Territory Resources", resources);
console.log("List of guilds on the map:", guilds);
console.log("Guilds and their guild tags:", guildTags);
console.log("Map locations:", maplocs);
}
/** Places the marker at x, y.
@ -241,6 +243,70 @@ function pullguilds() {
}
}
/** Toggles all location icons/markers on the map.
*
*/
function toggleLocations() {
let key_elem = document.getElementById("locationlist");
function drawLocations() {
let imgs = ["Content_Dungeon.png", "Content_CorruptedDungeon.png", "Content_Quest.png", "Merchant_Emerald.png", "NPC_Blacksmith.png", "NPC_ItemIdentifier.png", "NPC_PowderMaster.png", "Merchant_Potion.png", "Merchant_Armour.png", "Merchant_Weapon.png", "Merchant_Liquid.png", "Merchant_Other.png", "Merchant_Scroll.png", "Merchant_Accessory.png", "Merchant_Tool.png", "painting.png", "Profession_Weaponsmithing.png", "Profession_Armouring.png", "Profession_Alchemism.png", "Profession_Jeweling.png", "Profession_Tailoring.png", "Profession_Scribing.png", "Profession_Cooking.png", "Profession_Woodworking.png", "Content_Miniquest.png", "Special_RootsOfCorruption.png", "Special_FastTravel.png", "Special_LightRealm.png", "Special_Rune.png", "Content_UltimateDiscovery.png", "Merchant_KeyForge.png", "NPC_GuildMaster.png", "Content_GrindSpot.png", "Content_Cave.png", "NPC_TradeMarket.png", "Content_BossAltar.png", "Content_Raid.png", "Merchant_Dungeon.png", "tnt.png", "Merchant_Seasail.png", "Merchant_Horse.png"];
for (const loc of maplocs) {
//loc has name, icon, x, y, z. don't care about y
if (loc.icon) {
let latlng = xytolatlng(loc.x,loc.z);
let locObj = L.marker(latlng, {icon: L.icon({
//iconUrl: '/media/icons/' + (newIcons ? "new/" : "old/" ) + loc.icon,
iconUrl: '/media/icons/maplocstemp/'+ loc.icon,
iconSize: [16,16],
iconAnchor: [8,8],
shadowUrl: '/media/icons/' + (newIcons ? "new/" : "old/" ) + 'shadow.png',
shadowSize: [1,1],
shadowAnchor: [8,8],
className: "marker"
})});
locObj.addTo(map);
locationObjs.push(locObj);
}
}
document.getElementById("locations-key").style.display = "";
for (const img of imgs) {
let li = document.createElement("li");
let i = document.createElement("img");
i.src = "./media/icons/maplocstemp/" + img;
i.style.maxWidth = "16px";
i.style.maxHeight = "16px";
li.appendChild(i);
let name = img.replace(".png","");
let type = "";
if (name.includes("_")) {type = name.split("_")[0]; name = name.split("_")[1]}
name = name.replaceAll(/([A-Z])/g, ` $1`).trim() + (type ? " (" + type + ") ": "");
li.innerHTML = li.innerHTML + name;
key_elem.appendChild(li);
}
console.log("Drew all map locations");
}
function deleteLocations() {
for (const location of locationObjs) {
map.removeLayer(location);
}
locationObjs = [];
key_elem.innerHTML = "";
document.getElementById("locations-key").style.display = "none";
console.log("Erased all map locations");
}
drawlocations = !drawlocations;
if (drawlocations) {drawLocations()}
else {deleteLocations()}
}
/** These functions toggle drawing of their related objects
@ -248,6 +314,7 @@ function pullguilds() {
*/
function toggleTerritories() {
function drawTerritories() {
for (const [terr,terrbounds] of terrs) {
let coords = [xytolatlng(terrbounds.startX,terrbounds.startY), xytolatlng(terrbounds.startX,terrbounds.endY), xytolatlng(terrbounds.endX,terrbounds.endY), xytolatlng(terrbounds.endX,terrbounds.startY)];
@ -513,11 +580,6 @@ function eraseTerritoryStats() {
terr_stats_elem.innerHTML = ""; //jank
}
/** Toggles all merchant icons/markers on the map. TODO.
*
*/
function toggleMerchants() {
}
load_map_init(init);
load_map_init(init);

1
maploc.json Normal file

File diff suppressed because one or more lines are too long

8922
maploc_clean.json Normal file

File diff suppressed because it is too large Load diff

1
maploc_compress.json Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

View file

@ -1,4 +1,13 @@
#A workspace for processing info/one-time operations
import math
for i in range(151):
print(-0.0000000066695* math.exp(-0.00924033 * i + 18.9) + 1.0771)
from PIL import Image
imgs = ["Content_Dungeon.png", "Content_CorruptedDungeon.png", "Content_Quest.png", "Merchant_Emerald.png", "NPC_Blacksmith.png", "NPC_ItemIdentifier.png", "NPC_PowderMaster.png", "Merchant_Potion.png", "Merchant_Armour.png", "Merchant_Weapon.png", "Merchant_Liquid.png", "Merchant_Other.png", "Merchant_Scroll.png", "Merchant_Accessory.png", "Merchant_Tool.png", "painting.png", "Profession_Weaponsmithing.png", "Profession_Armouring.png", "Profession_Alchemism.png", "Profession_Jeweling.png", "Profession_Tailoring.png", "Profession_Scribing.png", "Profession_Cooking.png", "Profession_Woodworking.png", "Content_Miniquest.png", "Special_RootsOfCorruption.png", "Special_FastTravel.png", "Special_LightRealm.png", "Special_Rune.png", "Content_UltimateDiscovery.png", "Merchant_KeyForge.png", "NPC_GuildMaster.png", "Content_GrindSpot.png", "Content_Cave.png", "NPC_TradeMarket.png", "Content_BossAltar.png", "Content_Raid.png", "Merchant_Dungeon.png", "tnt.png", "Merchant_Seasail.png", "Merchant_Horse.png"]
im1 = Image.open("./media/icons/maplocstemp/Content_BossAltar.png")
for name in imgs:
img = im1.copy()
img.save("./media/icons/maplocstemp/" + name, "PNG")
# img = Image.new(mode = "RGB", size = (32,32))
# img.putalpha(0)
# for name in imgs:
# img.save("./media/icons/maplocstemp/" + name, "PNG")

View file

@ -29,8 +29,8 @@ with open("terrs_clean.json", "w") as outfile:
'''with open("terrs.json", "r") as infile:
data = json.load(infile)["territories"]'''
with open("terrs_clean.json", "r") as infile:
newdata = json.load(infile)
'''with open("terrs_clean.json", "r") as infile:
newdata = json.load(infile)'''
'''for t in newdata:
del newdata[t]["attacker"]
@ -46,8 +46,18 @@ for t in data:
data[t]["doubleemeralds"] = response[t]["DoubleEmerald"]
data[t]["doubleresource"] = response[t]["DoubleResource"]'''
with open("terrs_clean.json", "w") as outfile:
'''with open("terrs_clean.json", "w") as outfile:
json.dump(newdata,outfile,indent=2)
with open("terrs_compress.json", "w") as outfile:
json.dump(newdata,outfile)
json.dump(newdata,outfile)'''
response = requests.get('https://api.wynncraft.com/public_api.php?action=mapLocations').json()
del response["request"]
with open("maploc.json", "w") as outfile:
json.dump(response, outfile)
with open("maploc_clean.json", "w") as outfile:
json.dump(response, outfile, indent = 2)
with open("maploc_compress.json", "w") as outfile:
json.dump(response, outfile)