-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
128 changed files
with
3,198 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,3 +48,5 @@ npm-debug.log.* | |
*.css.d.ts | ||
*.sass.d.ts | ||
*.scss.d.ts | ||
|
||
backend/lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"level": 3 | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 added
BIN
+2.25 KB
backend/out/production/Gear/com/fribbels/enums/OptimizationColumn.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+12.3 KB
backend/out/production/Gear/com/fribbels/handler/HeroesRequestHandler.class
Binary file not shown.
Binary file added
BIN
+6.8 KB
backend/out/production/Gear/com/fribbels/handler/ItemsRequestHandler.class
Binary file not shown.
Binary file added
BIN
+11.1 KB
backend/out/production/Gear/com/fribbels/handler/OcrRequestHandler.class
Binary file not shown.
Binary file added
BIN
+22.2 KB
backend/out/production/Gear/com/fribbels/handler/OptimizationRequestHandler.class
Binary file not shown.
Binary file added
BIN
+3.76 KB
backend/out/production/Gear/com/fribbels/handler/RequestHandler.class
Binary file not shown.
Binary file added
BIN
+929 Bytes
backend/out/production/Gear/com/fribbels/handler/SystemRequestHandler.class
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+5.15 KB
backend/out/production/Gear/com/fribbels/model/Hero$HeroBuilder.class
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+4.5 KB
backend/out/production/Gear/com/fribbels/model/HeroStats$HeroStatsBuilder.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+1.62 KB
...on/Gear/com/fribbels/model/MiniOptimizationResponse$MiniOptimizationResponseBuilder.class
Binary file not shown.
Binary file added
BIN
+1.53 KB
backend/out/production/Gear/com/fribbels/model/MiniOptimizationResponse.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+1.42 KB
...d/out/production/Gear/com/fribbels/request/BaseStatsRequest$BaseStatsRequestBuilder.class
Binary file not shown.
Binary file added
BIN
+1.37 KB
backend/out/production/Gear/com/fribbels/request/BaseStatsRequest.class
Binary file not shown.
Binary file added
BIN
+2.2 KB
...out/production/Gear/com/fribbels/request/BonusStatsRequest$BonusStatsRequestBuilder.class
Binary file not shown.
Binary file added
BIN
+2.92 KB
backend/out/production/Gear/com/fribbels/request/BonusStatsRequest.class
Binary file not shown.
Binary file added
BIN
+1.71 KB
...on/Gear/com/fribbels/request/EquipItemsOnHeroRequest$EquipItemsOnHeroRequestBuilder.class
Binary file not shown.
Binary file added
BIN
+1.53 KB
backend/out/production/Gear/com/fribbels/request/EquipItemsOnHeroRequest.class
Binary file not shown.
Binary file added
BIN
+2.29 KB
...oduction/Gear/com/fribbels/request/GetResultRowsRequest$GetResultRowsRequestBuilder.class
Binary file not shown.
Binary file added
BIN
+2.67 KB
backend/out/production/Gear/com/fribbels/request/GetResultRowsRequest.class
Binary file not shown.
Binary file added
BIN
+1.32 KB
backend/out/production/Gear/com/fribbels/request/HeroesRequest$HeroesRequestBuilder.class
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+1022 Bytes
backend/out/production/Gear/com/fribbels/request/IdRequest$IdRequestBuilder.class
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+1.26 KB
backend/out/production/Gear/com/fribbels/request/IdsRequest$IdsRequestBuilder.class
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+1.3 KB
backend/out/production/Gear/com/fribbels/request/ItemsRequest$ItemsRequestBuilder.class
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+1.32 KB
backend/out/production/Gear/com/fribbels/request/Ocr2Request$Ocr2RequestBuilder.class
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+14.3 KB
...production/Gear/com/fribbels/request/OptimizationRequest$OptimizationRequestBuilder.class
Binary file not shown.
Binary file added
BIN
+24.5 KB
backend/out/production/Gear/com/fribbels/request/OptimizationRequest.class
Binary file not shown.
Binary file added
BIN
+1.42 KB
...duction/Gear/com/fribbels/response/GetAllHeroesResponse$GetAllHeroesResponseBuilder.class
Binary file not shown.
Binary file added
BIN
+1.32 KB
backend/out/production/Gear/com/fribbels/response/GetAllHeroesResponse.class
Binary file not shown.
Binary file added
BIN
+1.41 KB
...roduction/Gear/com/fribbels/response/GetAllItemsResponse$GetAllItemsResponseBuilder.class
Binary file not shown.
Binary file added
BIN
+1.31 KB
backend/out/production/Gear/com/fribbels/response/GetAllItemsResponse.class
Binary file not shown.
Binary file added
BIN
+1.2 KB
...roduction/Gear/com/fribbels/response/GetHeroByIdResponse$GetHeroByIdResponseBuilder.class
Binary file not shown.
Binary file added
BIN
+1.2 KB
backend/out/production/Gear/com/fribbels/response/GetHeroByIdResponse.class
Binary file not shown.
Binary file added
BIN
+1.2 KB
...roduction/Gear/com/fribbels/response/GetItemByIdResponse$GetItemByIdResponseBuilder.class
Binary file not shown.
Binary file added
BIN
+1.2 KB
backend/out/production/Gear/com/fribbels/response/GetItemByIdResponse.class
Binary file not shown.
Binary file added
BIN
+1.54 KB
...ction/Gear/com/fribbels/response/GetResultRowsResponse$GetResultRowsResponseBuilder.class
Binary file not shown.
Binary file added
BIN
+1.61 KB
backend/out/production/Gear/com/fribbels/response/GetResultRowsResponse.class
Binary file not shown.
Binary file added
BIN
+2.07 KB
backend/out/production/Gear/com/fribbels/response/OcrResponse$OcrResponseBuilder.class
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+1.13 KB
...duction/Gear/com/fribbels/response/OptimizationResponse$OptimizationResponseBuilder.class
Binary file not shown.
Binary file added
BIN
+1.04 KB
backend/out/production/Gear/com/fribbels/response/OptimizationResponse.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+23.5 KB
backend/out/test/Gear/com/fribbels/core/OptimizationRequestHandlerTest.class
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Manifest-Version: 1.0 | ||
Main-Class: com.fribbels.Main | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
Oops, something went wrong.