Graph database Analysis of the Steam Network
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.1 KiB

  1. package net.jrtechs.www.model;
  2. import org.json.JSONObject;
  3. import java.util.List;
  4. import java.util.Map;
  5. /**
  6. * Example URL: http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key=XXXXXXXXXXXXXXXXX&steamid=76561197960434622&format=json
  7. */
  8. public class Game
  9. {
  10. public static String KEY_DB = "game";
  11. public static String KEY_STEAM_GAME_ID = "appid";
  12. public static String KEY_GAME_NAME = "name";
  13. public static String KEY_GAME_ICON = "img_icon_url";
  14. public static String KEY_GAME_LOGO = "img_logo_url";
  15. public static String KEY_RELATIONSHIP = "owns";
  16. //other
  17. public static String KEY_PLAY_TIME = "playtime_forever";
  18. private Integer appID;
  19. private String icon;
  20. private String logo;
  21. private String name;
  22. private Integer timePlayed;
  23. public Game(JSONObject g)
  24. {
  25. this.appID = g.getInt(Game.KEY_STEAM_GAME_ID);
  26. this.name = g.getString(KEY_GAME_NAME);
  27. this.icon = g.getString(KEY_GAME_ICON);
  28. this.logo = g.getString(KEY_GAME_LOGO);
  29. this.timePlayed = g.getInt(KEY_PLAY_TIME);
  30. }
  31. public Game(Map<String, Object> graph)
  32. {
  33. System.out.println(graph);
  34. this.appID= (Integer)((List<Object>) graph.get(KEY_STEAM_GAME_ID)).get(0);
  35. this.name = (String)((List<Object>) graph.get(KEY_GAME_NAME)).get(0);
  36. this.icon = (String)((List<Object>) graph.get(KEY_GAME_ICON)).get(0);
  37. this.logo = (String)((List<Object>) graph.get(KEY_GAME_LOGO)).get(0);
  38. this.timePlayed = 0;
  39. }
  40. public Integer getAppID()
  41. {
  42. return appID;
  43. }
  44. public String getIcon()
  45. {
  46. return icon;
  47. }
  48. public String getLogo()
  49. {
  50. return logo;
  51. }
  52. public String getName()
  53. {
  54. return name;
  55. }
  56. public Integer getTimePlayed()
  57. {
  58. return timePlayed;
  59. }
  60. @Override
  61. public String toString()
  62. {
  63. return "Game{" +
  64. "appID=" + appID +
  65. ", icon='" + icon + '\'' +
  66. ", logo='" + logo + '\'' +
  67. ", name='" + name + '\'' +
  68. ", timePlayed=" + timePlayed +
  69. '}';
  70. }
  71. }