Commit da1b67e1 authored by Eike Schaubeck's avatar Eike Schaubeck
Browse files

added more filters to guild

Took 1 hour 0 minutes
parent 4b5ef7fe
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>
\ No newline at end of file
......@@ -3,6 +3,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import help.swgoh.api.SwgohAPI;
import utilitys.Tuple;
import java.util.*;
import java.util.concurrent.ExecutionException;
......@@ -122,4 +123,21 @@ public class Guild {
return map;
}
public Map<String, List<Tuple<Player, Char>>> getPlayersAbouveStarAndGear(SwgohAPI api, int minStars, int minGear) throws ExecutionException, InterruptedException {
Map<String, List<Tuple<Player, Char>>> map = new HashMap<>();
List<String> names = Player.getAllCharNames(api);
for (String name : names) {
List<Tuple<Player, Char>> players = new LinkedList<>();
for (Player p : this.players) {
for (Char c : p.getCharacters()) {
if (c.getName().equals(name) && c.getGear() >= minGear && c.getStars() >= minStars) {
players.add(new Tuple<>(p,c));
}
}
}
map.put(name.substring(5, name.length()-5), players);
}
return map;
}
}
import help.swgoh.api.SwgohAPI;
import help.swgoh.api.SwgohAPIBuilder;
import utilitys.ApiAccess;
import utilitys.Tuple;
import java.util.*;
import java.util.concurrent.ExecutionException;
......@@ -43,22 +45,12 @@ public class Main {
int gear = Integer.parseInt(sc.nextLine());
System.out.println("Which min stars?");
int stars = Integer.parseInt(sc.nextLine());
Map<String, Integer> map = g.countCharsAbouveStarAndGear(api, stars, gear);
Object[] a = map.entrySet().toArray();
Arrays.sort(a, new Comparator() {
public int compare(Object o1, Object o2) {
return ((Map.Entry<String, Integer>) o2).getValue()
.compareTo(((Map.Entry<String, Integer>) o1).getValue());
}
});
for (Object e : a) {
System.out.println(((Map.Entry<String, Integer>) e).getKey() + " : "
+ ((Map.Entry<String, Integer>) e).getValue());
}
Map<String, List<Tuple<Player, Char>>> map = g.getPlayersAbouveStarAndGear(api, stars, gear);
map = Utils.sortByListSize(map);
System.out.println("bla");
}
}
}
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import utilitys.Tuple;
public class Utils {
public static Map<String, List<Tuple<Player, Char>>> sortByListSize(Map<String, List<Tuple<Player, Char>>> unsorted) {
Map<String, List<Tuple<Player, Char>>> sorted = new LinkedHashMap<>();
int max = -1;
String best = "";
while (!unsorted.isEmpty()) {
for (String s : unsorted.keySet()) {
if (unsorted.get(s).size() > max) {
max = unsorted.get(s).size();
best = s;
}
}
sorted.put(best, unsorted.remove(best));
max = -1;
}
return sorted;
}
}
......@@ -5,7 +5,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import mods.stats.Stat;
import mods.stats.StatType;
import mods.stats.Tuple;
import utilitys.Tuple;
import java.util.LinkedList;
import java.util.List;
......@@ -153,13 +153,13 @@ public class Mod {
private static Mod createModfromJsonElement(JsonObject json, int counter) {
if (json.get("stat") != null) {
Tuple t = createStatsfromJsonArray(json.get("stat").getAsJsonArray());
Tuple<Stat, List<Stat>> t = createStatsfromJsonArray(json.get("stat").getAsJsonArray());
return new Mod(null, Place.values()[counter], json.get("level").getAsInt(), json.get("pips").getAsInt(),
json.get("tier").getAsInt(), t.getPrimStat(), t.getSecStats());
json.get("tier").getAsInt(), t.getFirstValue(), t.getSecondValue());
} else return null;
}
private static Tuple createStatsfromJsonArray(JsonArray json) {
private static Tuple<Stat, List<Stat>> createStatsfromJsonArray(JsonArray json) {
JsonElement e = json.get(0);
Stat primtStat = new Stat(getStatType(e.getAsJsonArray().get(0).getAsInt()),
e.getAsJsonArray().get(1).getAsDouble(), e.getAsJsonArray().get(2).getAsInt(), true);
......@@ -169,7 +169,7 @@ public class Mod {
secStats.add(new Stat(getStatType(e.getAsJsonArray().get(0).getAsInt()),
e.getAsJsonArray().get(1).getAsDouble(), e.getAsJsonArray().get(2).getAsInt(), false));
}
return new Tuple(primtStat, secStats);
return new Tuple<>(primtStat, secStats);
}
private static StatType getStatType(int value) {
......
package mods.stats;
import java.util.List;
public class Tuple {
private Stat primStat;
private List<Stat> secStats;
public Tuple(Stat primStat, List<Stat> secStats) {
this.primStat = primStat;
this.secStats = secStats;
}
public Stat getPrimStat() {
return primStat;
}
public void setPrimStat(Stat primStat) {
this.primStat = primStat;
}
public List<Stat> getSecStats() {
return secStats;
}
public void setSecStats(List<Stat> secStats) {
this.secStats = secStats;
}
}
package utilitys;
public class ApiAccess {
public static String getApiUsername() {
......
package utilitys;
import java.util.List;
public class Tuple<K, N> {
private K firstValue;
private N secondValue;
public Tuple(K firstValue, N secondValue) {
this.firstValue = firstValue;
this.secondValue = secondValue;
}
public K getFirstValue() {
return firstValue;
}
public void setFirstValue(K firstValue) {
this.firstValue = firstValue;
}
public N getSecondValue() {
return secondValue;
}
public void setSecondValue(N secondValue) {
this.secondValue = secondValue;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment