darkforest-eth / plugins Goto Github PK
View Code? Open in Web Editor NEWA showcase of Dark Forest plugins from the community!
Home Page: https://plugins.zkga.me
License: GNU General Public License v3.0
A showcase of Dark Forest plugins from the community!
Home Page: https://plugins.zkga.me
License: GNU General Public License v3.0
After using most of them a while I have some concerns on which I will work in free time, but anyone can too :)
Here is my list:
Besides that I have some ideas on new plugins on which I will work in free time.
Cheers and stay strong!
This is a catch-all issue for things people want as plugins useful when observing or "casting" a game.
From Jordan:
queued-move.js needs to be updated to match the chosen gas price in settings instead of just using the default 1 gwei hard coded in the file.
This could fix issues with other plugins that rely on that resource for sends.
The MinerManager arguments changed
I wrote my own very simple function to get planets in range and compared it to the default one,
The custom simple one is 3-4 faster, but maybe its not as good somehow? maybe i did something wrong
function getRange(planet, percentEnergySending = 100) {
if (percentEnergySending === 0) return 0;
return Math.max(Math.log2(percentEnergySending / 5), 0) * planet.range;
}
function getDistance(p1, p2) {
let x = p2.location.coords.x - p1.location.coords.x;
let y = p2.location.coords.y - p1.location.coords.y;
return Math.sqrt(x*x + y*y);
}
function perfTest() {
var planetId = "*put your planet id here*";
var planet = df.getPlanetWithId(planetId);
let ds = new Date();
let l = df.getPlanetsInRange(planetId);
let de = new Date();
console.log("planetCount: "+l.length+" time: "+(de.getTime()-ds.getTime()))
let xs = new Date();
let allPlanets = df.getAllPlanets();
let arr = [];
let range = getRange(planet);
for (var p of allPlanets) {
if (!p.location) continue;
if (!p.location.coords) continue;
if (getDistance(planet, p) < range)
arr.push(p);
}
let xe = new Date();
console.log("planetCount: "+arr.length+" time: "+(xe.getTime()-xs.getTime()))
}
perfTest();
output:
planetCount: 16804 time: 54
planetCount: 16804 time: 17
Example:
Take a plugin window (any plugin) and minimize it.
Now move it to the bottom of the screen and maximize it again.
Its area should now be off-screen.
If you now click the window anywhere (even close button) it will not react to the click but instead position itself upwards so its area is again on the screen.
Suggestions:
If a plugin window grows too big, parts of it will spawn off-screen. (for example Player List - if you have many players on your map)
Is there a way to position your plugin somehow with code?
Or to make it so it will move on-screen again automatically?
It will ignore the worm hole connection and return the wrong time.
I did not test it with photon cannons, might also return the wrong time.
Likely due to chunks consolidation into 1024
I did some research and found out that there is another way to store data on the client side.
We don't want to use localStorage because it contains the private key, but what about indexedDB?
It takes much more code to use it but I tried to make a small code example for people to use:
The 2 functions can be used to load and save one object to the database, inside the object you can put whatever you want (i think). But there is of course a size limit on how much you can store in the DB. The indexedDBName should be different for each plugin.
var indexedDBName = "pluginNameDB";
function loadDataFromIndexedDB() {
let resolve, reject; let promise = new Promise((res, rej) => { resolve=res; reject=rej; });
const dbOpen = window.indexedDB.open(indexedDBName, 1);
dbOpen.onupgradeneeded = (ev) => {
const db = ev.target.result;
const store = db.createObjectStore("ObjStore", { keyPath: "id", autoIncrement: true, });
store.createIndex("Idx", "Idx", { unique: false });
};
dbOpen.onsuccess = (ev) => {
const db = ev.target.result;
const store = db.transaction("ObjStore", "readonly").objectStore("ObjStore");
const query = store.get(1);
query.onerror = (ev) => {
console.error(indexedDBName+" indexedDB query error", ev.target.error.message);
reject(ev.target.error.message);
};
query.onsuccess = (ev) => {
db.close();
if (query.result) {
resolve(query.result.Idx);
} else {
resolve(null);
}
};
};
return promise;
}
function writeDataToIndexedDB(data) {
let resolve, reject; let promise = new Promise((res, rej) => { resolve=res; reject=rej; });
const dbOpen = window.indexedDB.open(indexedDBName, 1);
dbOpen.onupgradeneeded = (ev) => {
const db = ev.target.result;
const store = db.createObjectStore("ObjStore", { keyPath: "id", autoIncrement: true, });
store.createIndex("Idx", "Idx", { unique: false });
};
dbOpen.onsuccess = (ev) => {
const db = ev.target.result;
const transaction = db.transaction("ObjStore", "readwrite");
const store = transaction.objectStore("ObjStore");
store.put({ id: 1, Idx: data });
transaction.onerror = (ev) => {
console.error(indexedDBName+" indexedDB transaction error", ev.target.error.message);
reject(ev.target.error.message);
};
transaction.oncomplete = (ev) => {
db.close();
resolve();
};
};
return promise;
}
What do you think? Can this be used?
This looks good but were going to need to continue to figure out how to not confuse people with the fact that its a list of players YOU CAN SEE. not a global list. For instance on my screen df_dao is #1 score with a total of 5 planets
I agree that this is a problem, i am not sure how to fix it.
Maybe display a message the first time the plugin is started that tells them this information and how the plugin works?
Maybe localStorage could be used to detect if the plugin was first started? It could store the version number of the plugin and when it sees the number does not exist or is lower it will override it and show the information message that explains the plugin.
Is this a good way or bad way of doing it? I never used localStorage
Future requests:
Id also like to a descending order sort on second click maybe, and maybe see an indicator for ascending descending sort and which column is currently being sorted by.
I agree this would be good.
What i also thought about:
Common - 5k points
Rare - 20k points
Epic - 200k points
Legendary - 3M points
Mythic - 20M points
This allows to sort by artifact score.
We should probably just lowercase the string always.
I vendored Icons as https://github.com/darkforest-eth/plugins/blob/master/javascript/game/Icons.js but the core team now provides the Icons as a CustomElement in https://github.com/darkforest-eth/packages/tree/master/ui
The vendored icons need to be replaced with the new components.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.