Browse Source

Skill tree

master
Chris Smith 15 years ago
parent
commit
b53cf88e66

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

@@ -49,6 +49,7 @@ public class Main {
49 49
         api.setCharID("113499922");
50 50
         System.out.println(api.getCharacterList());
51 51
         System.out.println(api.getSkillInTraining());
52
+        System.out.println(api.getSkillTree());
52 53
     }
53 54
 
54 55
 }

+ 5
- 0
src/uk/co/md87/evetool/api/EveApi.java View File

@@ -40,6 +40,7 @@ import uk.co.md87.evetool.api.parser.ApiParser;
40 40
 import uk.co.md87.evetool.api.parser.ApiResult;
41 41
 import uk.co.md87.evetool.api.wrappers.CharacterList;
42 42
 import uk.co.md87.evetool.api.wrappers.SkillInTraining;
43
+import uk.co.md87.evetool.api.wrappers.SkillList;
43 44
 
44 45
 /**
45 46
  *
@@ -90,6 +91,10 @@ public class EveApi {
90 91
         return getResponse("/char/SkillInTraining.xml.aspx", SkillInTraining.class, true, true);
91 92
     }
92 93
 
94
+    public ApiResponse<SkillList> getSkillTree() {
95
+        return getResponse("/eve/SkillTree.xml.aspx ", SkillList.class, false, true);
96
+    }
97
+
93 98
     protected <T> ApiResponse<T> getResponse(final String method, final Class<T> type,
94 99
             final boolean needKey, final boolean needChar) {
95 100
         // TODO: Require userid + apikey

+ 2
- 0
src/uk/co/md87/evetool/api/io/ApiDownloader.java View File

@@ -99,7 +99,9 @@ public class ApiDownloader {
99 99
             try {
100 100
                 final String page = Downloader.getPage(getUrl(method), ourArgs);
101 101
                 final ApiResult res = parser.parseResult(page);
102
+                
102 103
                 cache.setCache(method, ourArgs, page, res.getCachedUntil().getTime());
104
+                // TODO: Time should be converted from GMT
103 105
 
104 106
                 return res;
105 107
             } catch (IOException ex) {

+ 12
- 0
src/uk/co/md87/evetool/api/parser/ApiElement.java View File

@@ -73,4 +73,16 @@ public class ApiElement {
73 73
         return null;
74 74
     }
75 75
 
76
+    public ApiElement getRowset(final String name) {
77
+        for (ApiElement child : getChildren()) {
78
+            if (child instanceof NamedApiElement
79
+                    && "rowset".equals(((NamedApiElement) child).getName())
80
+                    && name.equals(child.getAttributes().get("name"))) {
81
+                return child;
82
+            }
83
+        }
84
+
85
+        return null;
86
+    }
87
+
76 88
 }

+ 90
- 0
src/uk/co/md87/evetool/api/wrappers/SkillGroup.java View File

@@ -0,0 +1,90 @@
1
+/*
2
+ * Copyright (c) 2009 Chris Smith
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package uk.co.md87.evetool.api.wrappers;
24
+
25
+import uk.co.md87.evetool.api.wrappers.data.*;
26
+import java.util.ArrayList;
27
+import java.util.List;
28
+import java.util.Map;
29
+import uk.co.md87.evetool.api.parser.ApiElement;
30
+
31
+/**
32
+ *
33
+ * TODO: Document
34
+ * @author chris
35
+ */
36
+public class SkillGroup extends ArrayList<Skill> {
37
+
38
+    private final int id;
39
+    private final String name;
40
+
41
+    public SkillGroup(final ApiElement rowElement) {
42
+        this.name = rowElement.getAttributes().get("groupName");
43
+        this.id = Integer.parseInt(rowElement.getAttributes().get("groupID"));
44
+
45
+        for (ApiElement row : rowElement.getChild("rowset").getChildren()) {
46
+            addSkill(row);
47
+        }
48
+    }
49
+
50
+    public int getId() {
51
+        return id;
52
+    }
53
+
54
+    public String getName() {
55
+        return name;
56
+    }
57
+
58
+    protected void addSkill(final ApiElement row) {
59
+        final String skillName = row.getAttributes().get("typeName");
60
+        final int typeId = Integer.parseInt(row.getAttributes().get("typeID"));
61
+        final String desc = row.getChild("description").getContent();
62
+        final int rank = Integer.parseInt(row.getChild("rank").getContent());
63
+        final List<SkillRequirement> reqs = getReqs(row.getRowset("requiredSkills"));
64
+        final String primaryAttribute = row.getChild("requiredAttributes")
65
+                .getChild("primaryAttribute").getContent();
66
+        final String secondaryAttribute = row.getChild("requiredAttributes")
67
+                .getChild("secondaryAttribute").getContent();
68
+        final Map<String, String> bonuses = getBonuses(row.getRowset("skillBonusCollection"));
69
+
70
+        add(new Skill(this, skillName, typeId, desc, rank, reqs, primaryAttribute,
71
+                secondaryAttribute, bonuses));
72
+    }
73
+
74
+    protected List<SkillRequirement> getReqs(final ApiElement rowset) {
75
+        final List<SkillRequirement> reqs = new ArrayList<SkillRequirement>();
76
+
77
+        for (ApiElement row : rowset.getChildren()) {
78
+            reqs.add(new SkillRequirement(
79
+                    Integer.parseInt(row.getAttributes().get("typeID")),
80
+                    Integer.parseInt(row.getAttributes().get("skillLevel"))));
81
+        }
82
+
83
+        return reqs;
84
+    }
85
+
86
+    protected Map<String, String> getBonuses(final ApiElement rowset) {
87
+        return null; // TODO: Implement
88
+    }
89
+
90
+}

+ 42
- 0
src/uk/co/md87/evetool/api/wrappers/SkillList.java View File

@@ -0,0 +1,42 @@
1
+/*
2
+ * Copyright (c) 2009 Chris Smith
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package uk.co.md87.evetool.api.wrappers;
24
+
25
+import java.util.ArrayList;
26
+
27
+import uk.co.md87.evetool.api.parser.ApiElement;
28
+
29
+/**
30
+ *
31
+ * TODO: Document
32
+ * @author chris
33
+ */
34
+public class SkillList extends ArrayList<SkillGroup> {
35
+
36
+    public SkillList(final ApiElement resultElement) {
37
+        for (ApiElement row : resultElement.getRowset("skillGroups").getChildren()) {
38
+            add(new SkillGroup(row));
39
+        }
40
+    }
41
+
42
+}

+ 67
- 0
src/uk/co/md87/evetool/api/wrappers/data/Skill.java View File

@@ -0,0 +1,67 @@
1
+/*
2
+ * Copyright (c) 2009 Chris Smith
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package uk.co.md87.evetool.api.wrappers.data;
24
+
25
+import java.util.List;
26
+import java.util.Map;
27
+import uk.co.md87.evetool.api.wrappers.SkillGroup;
28
+
29
+/**
30
+ *
31
+ * TODO: Document
32
+ * @author chris
33
+ */
34
+public class Skill {
35
+
36
+    protected final SkillGroup group;
37
+    protected final String name;
38
+    protected final int id;
39
+    protected final String description;
40
+    protected final int rank;
41
+    protected final List<SkillRequirement> requirements;
42
+    protected final String primaryAttribute;
43
+    protected final String secondaryAttribute;
44
+    protected final Map<String, String> bonuses;
45
+
46
+    public Skill(final SkillGroup group, final String name, final int id,
47
+            final String description, final int rank,
48
+            final List<SkillRequirement> requirements,
49
+            final String primaryAttribute, final String secondaryAttribute,
50
+            final Map<String, String> bonuses) {
51
+        this.group = group;
52
+        this.name = name;
53
+        this.id = id;
54
+        this.description = description;
55
+        this.rank = rank;
56
+        this.requirements = requirements;
57
+        this.primaryAttribute = primaryAttribute;
58
+        this.secondaryAttribute = secondaryAttribute;
59
+        this.bonuses = bonuses;
60
+    }
61
+
62
+    @Override
63
+    public String toString() {
64
+        return "[" + name + " (" + id + ")]";
65
+    }
66
+
67
+}

+ 40
- 0
src/uk/co/md87/evetool/api/wrappers/data/SkillRequirement.java View File

@@ -0,0 +1,40 @@
1
+/*
2
+ * Copyright (c) 2009 Chris Smith
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package uk.co.md87.evetool.api.wrappers.data;
24
+
25
+/**
26
+ *
27
+ * TODO: Document
28
+ * @author chris
29
+ */
30
+public class SkillRequirement {
31
+
32
+    private final int skillId;
33
+    private final int requiredLevel;
34
+
35
+    public SkillRequirement(int skillId, int requiredLevel) {
36
+        this.skillId = skillId;
37
+        this.requiredLevel = requiredLevel;
38
+    }
39
+
40
+}

Loading…
Cancel
Save