Skip to content

Commit

Permalink
Added backend, updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
fribbels committed Dec 13, 2020
1 parent 167b1c4 commit ad9c027
Show file tree
Hide file tree
Showing 128 changed files with 3,198 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ npm-debug.log.*
*.css.d.ts
*.sass.d.ts
*.scss.d.ts

backend/lib
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Fribbels Epic 7 Gear Optimizer
This is a tool for organizing gear and optimizing gear and unit builds for Epic 7. Gearing units can be time consuming and its not very easy to find optimal combinations of gear within the game, so I made this to help make the gearing process easier.

Please see the **Getting Started** section for instructions.
This is a tool for organizing gear and optimizing gear and unit builds for Epic 7. Gearing units can be time consuming and it's not very easy to find optimal combinations of gear within the game, so I made this to help make the gearing process easier.

Please see the [**Getting Started**](https://github.com/fribbels/Fribbels-E7-Optimizer#getting-started) section for instructions on how to use it.

Features include:

Expand All @@ -22,7 +23,7 @@ Hers's an example of the optimizer tab. There are a bunch of panels with options

#### Settings panel

![](https://i.imgur.com/eSw8bnM.png)
![](https://i.imgur.com/GHzzZCA.png)

This panel tracks settings for the other panels to use.

Expand Down Expand Up @@ -184,11 +185,11 @@ The app also does autosave to an 'autosave.json' on changes being made, but that

#### Import gear from Zarroc optimizer

If you're a user of the other gear optimizer from Zarroc2762, this lets you import your gear directly from your existing save file. It won't import heroes though, so you'll have to add those back in.
If you're a user of the other gear optimizer from [Zarroc optimizer](https://github.com/Zarroc2762/E7-Gear-Optimizer), this lets you import your gear directly from your existing save file. It won't import heroes though, so you'll have to add those back in.

## Getting Started

To get started with the app, you'll need to run image recognition on screenshots of your gear, which is built into the Importer tab. If you've previously used the Zarroc2762 optimizer, you can import the gear file directly from that into this app, with the instructions above.
To get started with the app, you'll need to run image recognition on screenshots of your gear, which is built into the Importer tab. If you've previously used the [Zarroc optimizer](https://github.com/Zarroc2762/E7-Gear-Optimizer), you can import the gear file directly from that into this app, with the instructions above.

1. Download the latest release of this app and extract it. The app can be run with FribbelsE7Optimizer.exe
2. Download an emulator to run E7 on
Expand All @@ -210,7 +211,7 @@ Each screenshot should look like this, and should be exactly 1600x900. I usually

## Closing thoughts

Hopefully this is useful for anyone looking for an easier way to gear their units. I know the Zarroc optimizer does a lot of similar things (https://github.com/Zarroc2762/E7-Gear-Optimizer) but it has been pretty unmaintained and out of date, so I decided to build my own to add some improvements to it. There's still a lot of room to improve and I plan on improving it as feedback comes in. I only work on this in my spare time, so please be patient with new features, or feel free to contribute to the code as well. Feel free to contact me on discord at fribbels#7526 with questions or suggestions.
Hopefully this is useful for anyone looking for an easier way to gear their units. I know the [Zarroc optimizer](https://github.com/Zarroc2762/E7-Gear-Optimizer) does a lot of similar things but it has been pretty unmaintained and out of date, so I decided to build my own app with a different optimization algorithm. There's still a lot of room to improve and I plan on adding new stuff as feedback comes in. I only work on this in my spare time, so please be patient with new features, or you can help contribute to the code as well. Feel free to contact me on discord at fribbels#7526 with questions or suggestions.

Planned features:
- TBD
33 changes: 33 additions & 0 deletions backend/Gear.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tst" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="lib" level="project" />
<orderEntry type="module-library" scope="TEST">
<library name="JUnit5.4">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/junit-jupiter-5.4.2.jar!/" />
<root url="jar://$MODULE_DIR$/lib/junit-jupiter-api-5.4.2.jar!/" />
<root url="jar://$MODULE_DIR$/lib/apiguardian-api-1.0.0.jar!/" />
<root url="jar://$MODULE_DIR$/lib/opentest4j-1.1.1.jar!/" />
<root url="jar://$MODULE_DIR$/lib/junit-platform-commons-1.4.2.jar!/" />
<root url="jar://$MODULE_DIR$/lib/junit-jupiter-params-5.4.2.jar!/" />
<root url="jar://$MODULE_DIR$/lib/junit-jupiter-engine-5.4.2.jar!/" />
<root url="jar://$MODULE_DIR$/lib/junit-platform-engine-1.4.2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="com.google.code.gson:gson:2.8.6" level="project" />
<orderEntry type="library" name="org.openpnp:opencv:3.4.2-1" level="project" />
<orderEntry type="library" name="commons-io:commons-io:2.7" level="project" />
<orderEntry type="library" name="org.bytedeco:tesseract-platform:4.0.0-1.5" level="project" />
</component>
</module>
Binary file not shown.
3 changes: 3 additions & 0 deletions backend/item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"level": 3
}
Binary file added backend/out/artifacts/Gear_jar/Gear.jar
Binary file not shown.
3 changes: 3 additions & 0 deletions backend/out/production/Gear/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: com.fribbels.Main

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions backend/response.txt

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions backend/src/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: com.fribbels.Main

48 changes: 48 additions & 0 deletions backend/src/com/fribbels/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.fribbels;

import com.fribbels.db.BaseStatsDb;
import com.fribbels.handler.OcrRequestHandler;
import com.fribbels.handler.OptimizationRequestHandler;
import com.fribbels.db.HeroDb;
import com.fribbels.db.ItemDb;
import com.fribbels.db.OptimizationDb;
import com.fribbels.handler.SystemRequestHandler;
import com.fribbels.handler.HeroesRequestHandler;
import com.fribbels.handler.ItemsRequestHandler;
import com.sun.net.httpserver.HttpServer;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Main {

private static HttpServer server;
private static ExecutorService executorService;
private static final HeroDb heroDb = new HeroDb();
private static final ItemDb itemDb = new ItemDb(heroDb);
private static final BaseStatsDb baseStatsDb = new BaseStatsDb();
private static final OptimizationDb optimizationDb = new OptimizationDb();

public static boolean interrupt = false;

public static void main(String[] args) throws IOException {
executorService = Executors.newFixedThreadPool(10);
start();
}

public static void start() throws IOException {
server = HttpServer.create(new InetSocketAddress("localhost", 8001), 0);

server.createContext("/system", new SystemRequestHandler());
server.createContext("/items", new ItemsRequestHandler(itemDb));
server.createContext("/optimization", new OptimizationRequestHandler(optimizationDb));
server.createContext("/heroes", new HeroesRequestHandler(heroDb, baseStatsDb, itemDb));
server.createContext("/ocr", new OcrRequestHandler());

System.out.println("START");
server.setExecutor(executorService);
server.start();
}
}
80 changes: 80 additions & 0 deletions backend/src/com/fribbels/core/FileIO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.fribbels.core;

import com.fribbels.model.HeroStats;
import com.google.common.base.Charsets;
import com.google.common.io.Files;
import com.google.gson.Gson;
import com.google.gson.stream.JsonWriter;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.util.List;

public class FileIO {

private static final Gson gson = new Gson();

public String readFile(final String filename) throws IOException {
final File requestFile = new File(filename);
final String requestString = Files.toString(requestFile, Charsets.UTF_8);

return requestString;
}

public void writeFile(final String data) throws IOException {
final File responseFile = new File("response.txt");
Files.write(data, responseFile, Charsets.UTF_8);
}

public void writeJsonToFile(final List<HeroStats> heroStats) throws IOException {
final FileOutputStream fileOutputStream = new FileOutputStream("response.txt");
// final JsonWriter jsonWriter = new JsonWriter(new FileWriter("response.txt"));
// jsonWriter.

JsonWriter writer = new JsonWriter(new OutputStreamWriter(fileOutputStream, "UTF-8"));
writer.beginArray();
for (int i = 0; i < heroStats.size(); i++) {
if (i > 1000) break;
final HeroStats stat = heroStats.get(i);
gson.toJson(stat, HeroStats.class, writer);
}
writer.endArray();
writer.close();
}

public void writeMiniOptimizationResponsesToFile(final long[] resultInts, final long size) throws IOException {
final FileOutputStream fileOutputStream = new FileOutputStream("response.txt");
// final JsonWriter jsonWriter = new JsonWriter(new FileWriter("response.txt"));
// jsonWriter.

JsonWriter writer = new JsonWriter(new OutputStreamWriter(fileOutputStream, StandardCharsets.UTF_8));
writer.beginArray();
for (int i = 0; i < size; i++) {
// if (resultInts[i] != 0) {
writer.value(resultInts[i]);
// }
}
writer.endArray();
writer.close();
fileOutputStream.close();
}

public String writeString(final long[] itemIds, final long size) throws IOException {
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

JsonWriter writer = new JsonWriter(new OutputStreamWriter(byteArrayOutputStream, StandardCharsets.UTF_8));
writer.beginArray();
for (int i = 0; i < size * 6; i++) {
writer.value(itemIds[i]);
}
writer.endArray();
writer.close();
byteArrayOutputStream.close();

return byteArrayOutputStream.toString();
}
}
134 changes: 134 additions & 0 deletions backend/src/com/fribbels/core/Sorter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
package com.fribbels.core;

import com.fribbels.enums.OptimizationColumn;
import com.fribbels.enums.SortOrder;
import com.fribbels.model.HeroStats;

import java.util.Arrays;
import java.util.Comparator;

public class Sorter {

public static void sortHeroes(final HeroStats[] data, final OptimizationColumn column, final SortOrder order) {
System.out.println("SORTING HEROES BY " + column + " " + order);
switch (order) {
case ASC:
switch (column) {
case ATK:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getAtk));
break;
case HP:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getHp));
break;
case DEF:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getDef));
break;
case SPD:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getSpd));
break;
case CR:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getCr));
break;
case CD:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getCd));
break;
case EFF:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getEff));
break;
case RES:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getRes));
break;
case DAC:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getDac));
break;
case CP:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getCp));
break;
case HPPS:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getHpps));
break;
case EHP:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getEhp));
break;
case EHPPS:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getEhpps));
break;
case DMG:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getDmg));
break;
case DMGPS:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getDmgps));
break;
case MCDMG:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getMcdmg));
break;
case MCDMGPS:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getMcdmgps));
break;
default:
System.err.println("INVALID COLUMN " + column);
}
break;

case DESC:
switch (column) {
case ATK:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getAtk).reversed());
break;
case HP:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getHp).reversed());
break;
case DEF:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getDef).reversed());
break;
case SPD:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getSpd).reversed());
break;
case CR:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getCr).reversed());
break;
case CD:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getCd).reversed());
break;
case EFF:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getEff).reversed());
break;
case RES:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getRes).reversed());
break;
case DAC:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getDac).reversed());
break;
case CP:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getCp).reversed());
break;
case HPPS:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getHpps).reversed());
break;
case EHP:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getEhp).reversed());
break;
case EHPPS:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getEhpps).reversed());
break;
case DMG:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getDmg).reversed());
break;
case DMGPS:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getDmgps).reversed());
break;
case MCDMG:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getMcdmg).reversed());
break;
case MCDMGPS:
Arrays.sort(data, Comparator.comparingInt(HeroStats::getMcdmgps).reversed());
break;
default:
System.err.println("INVALID COLUMN " + column);
}
break;
default:
System.err.println("INVALID ORDER " + order);
}
}
}
Loading

0 comments on commit ad9c027

Please sign in to comment.