mirror of
https://github.com/correl/mage.git
synced 2025-04-10 09:11:04 -09:00
picks file parsing and new cards ratings
This commit is contained in:
parent
28e3755333
commit
5f74002205
4 changed files with 2081 additions and 1006 deletions
Mage.Client/src/main/resources
Mage.Plugins/Mage.Rating.Plugin
Mage.Server.Plugins/Mage.Player.AI/src/main/resources
File diff suppressed because it is too large
Load diff
|
@ -20,7 +20,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mage</groupId>
|
<groupId>org.mage</groupId>
|
||||||
<artifactId>Mage-Card-Plugin</artifactId>
|
<artifactId>Mage-Card-Plugin</artifactId>
|
||||||
<version>0.6</version>
|
<version>0.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mage</groupId>
|
<groupId>org.mage</groupId>
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.mage.plugins.rating.results;
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.FilenameFilter;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -21,6 +22,7 @@ public class ResultHandler {
|
||||||
private static Map<String, Integer> ratings = new LinkedHashMap<String, Integer>();
|
private static Map<String, Integer> ratings = new LinkedHashMap<String, Integer>();
|
||||||
private static String newLine = System.getProperty("line.separator");
|
private static String newLine = System.getProperty("line.separator");
|
||||||
private static Pattern scorePattern = Pattern.compile("([^|]*)[|]+ > [|]+([^|]*)");
|
private static Pattern scorePattern = Pattern.compile("([^|]*)[|]+ > [|]+([^|]*)");
|
||||||
|
private static Pattern pickPattern = Pattern.compile("[\\w\\d]{3}\\|(.*)\\|(.*)\\|(.*)");
|
||||||
private static Logger log = Logger.getLogger(ResultHandler.class);
|
private static Logger log = Logger.getLogger(ResultHandler.class);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -62,6 +64,7 @@ public class ResultHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ratingFile.createNewFile()) {
|
if (ratingFile.createNewFile()) {
|
||||||
|
loadPickFiles("picks");
|
||||||
for (File f : file.listFiles()) {
|
for (File f : file.listFiles()) {
|
||||||
if (!f.getName().equals("rating.txt")) {
|
if (!f.getName().equals("rating.txt")) {
|
||||||
parseFile(f);
|
parseFile(f);
|
||||||
|
@ -79,6 +82,37 @@ public class ResultHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadPickFiles(String directory) throws Exception {
|
||||||
|
File directoryFile = new File(directory);
|
||||||
|
if (directoryFile.exists()) {
|
||||||
|
for (File f: directoryFile.listFiles(new FilenameFilter() {
|
||||||
|
@Override
|
||||||
|
public boolean accept(File dir, String name) {
|
||||||
|
return name.endsWith(".txt");
|
||||||
|
}
|
||||||
|
})) {
|
||||||
|
log.info("Load pick file " + f.getName());
|
||||||
|
loadPickFile(f);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.info("No pics directory found! Copy it from Utils");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadPickFile(File f) throws Exception {
|
||||||
|
Scanner s = new Scanner(f);
|
||||||
|
while (s.hasNextLine()) {
|
||||||
|
String line = s.nextLine();
|
||||||
|
Matcher m = pickPattern.matcher(line);
|
||||||
|
if (m.matches()) {
|
||||||
|
String card = m.group(1);
|
||||||
|
Float stdRate = Float.parseFloat(m.group(2));
|
||||||
|
int rate = (int)((15 - stdRate + 1) * 1000);
|
||||||
|
ratings.put(card, rate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void parseFile(File f) throws Exception {
|
private void parseFile(File f) throws Exception {
|
||||||
Scanner s = new Scanner(f);
|
Scanner s = new Scanner(f);
|
||||||
while (s.hasNextLine()) {
|
while (s.hasNextLine()) {
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue