Browse Source

Parse skills and certs from char tree

master
Chris Smith 15 years ago
parent
commit
b7153056c2

+ 1
- 1
src/uk/co/md87/evetool/Main.java View File

@@ -51,7 +51,7 @@ public class Main {
51 51
         api.setApiKey("yaISaqXrSnaQPnRSFi4ODeWjSzWu2gNq1h6F0tVevtSGr5dzoEkZ6YrzHeBzzgNg");
52 52
         api.setUserID("403848");
53 53
         api.setCharID("113499922");
54
-        System.out.println(api.getCharacterSheet());
54
+        System.out.println(api.getCharacterSheet().getResult().getCertificates());
55 55
     }
56 56
 
57 57
 }

+ 29
- 5
src/uk/co/md87/evetool/api/wrappers/CharacterSheet.java View File

@@ -60,28 +60,52 @@ public class CharacterSheet {
60 60
         this.race = resultElement.getChild("race").getContent();
61 61
         this.bloodline = resultElement.getChild("bloodLine").getContent();
62 62
         this.gender = resultElement.getChild("gender").getContent();
63
+        this.balance = Double.parseDouble(resultElement.getChild("balance").getContent());
64
+
63 65
         this.clone = new BasicCloneInfo();
64 66
         // TODO: Clone
65
-        this.balance = Double.parseDouble(resultElement.getChild("balance").getContent());
67
+
66 68
         this.implants = new ArrayList<Implant>();
67 69
         // TODO: Implants
70
+
68 71
         this.attributes = new HashMap<Attribute, Integer>();
69 72
         // TODO: Attributes
73
+
70 74
         this.skills = new ArrayList<TrainedSkill>();
71
-        // TODO: Skills
75
+        parseSkills(resultElement.getRowset("skills"));
76
+
72 77
         this.certificates = new ArrayList<Integer>();
73
-        // TODO: Certs
78
+        parseCertificates(resultElement.getRowset("certificates"));
74 79
 
75 80
         final int id = Integer.parseInt(resultElement.getChild("characterID").getContent());
76 81
         final String name = resultElement.getChild("name").getContent();
77 82
 
78 83
         final String corpName = resultElement.getChild("corporationName").getContent();
79
-        final int corpId = Integer.parseInt(resultElement.getChild("corporationID").getContent());
84
+        final int corpId = Integer.parseInt(resultElement
85
+                .getChild("corporationID").getContent());
80 86
 
81 87
         charInfo = new BasicCharInfo(name, id, new BasicCorpInfo(corpName, corpId));
82 88
     }
83 89
 
84
-    protected BasicCharInfo getBasicInformation() {
90
+    protected void parseSkills(final ApiElement rowset) {
91
+        // TODO: Nice methods in ApiElement for getting [numeric] atts/children
92
+        // TODO: Nice way to quickly parse rowsets?
93
+        for (ApiElement row : rowset.getChildren()) {
94
+            final int id = Integer.parseInt(row.getAttributes().get("typeID"));
95
+            final int level = Integer.parseInt(row.getAttributes().get("level"));
96
+            final int sp = Integer.parseInt(row.getAttributes().get("skillpoints"));
97
+            skills.add(new TrainedSkill(id, level, sp));
98
+        }
99
+    }
100
+
101
+    protected void parseCertificates(final ApiElement rowset) {
102
+        for (ApiElement row : rowset.getChildren()) {
103
+            final int id = Integer.parseInt(row.getAttributes().get("certificateID"));
104
+            certificates.add(id);
105
+        }
106
+    }
107
+
108
+    public BasicCharInfo getBasicInformation() {
85 109
         return charInfo;
86 110
     }
87 111
 

+ 16
- 1
src/uk/co/md87/evetool/api/wrappers/data/TrainedSkill.java View File

@@ -24,10 +24,25 @@ package uk.co.md87.evetool.api.wrappers.data;
24 24
 
25 25
 /**
26 26
  *
27
- * TODO: Implement TrainedSkill
28 27
  * TODO: Document TrainedSkill
29 28
  * @author chris
30 29
  */
31 30
 public class TrainedSkill {
32 31
 
32
+    private final int id;
33
+    private final int level;
34
+    private final int skillpoints;
35
+
36
+    public TrainedSkill(int id, int level, int skillpoints) {
37
+        this.id = id;
38
+        this.level = level;
39
+        this.skillpoints = skillpoints;
40
+    }
41
+
42
+    /** {@inheritDoc} */
43
+    @Override
44
+    public String toString() {
45
+        return "[" + id + " @ " + skillpoints + " (lvl " + level + ")]";
46
+    }
47
+
33 48
 }

Loading…
Cancel
Save