hive-bedrock-api 0.1.0-beta.8 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,6 +11,8 @@ $ yarn add hive-bedrock-api
11
11
 
12
12
  ## Usage
13
13
 
14
+ See [API.md](docs/API.md) for detailed documentation.
15
+
14
16
  ### Fetch Player Infomation
15
17
 
16
18
  ```ts
@@ -60,6 +62,13 @@ const { data, error } = await getMonthlyStats("ucdfiddes", GAME.BlockDrop, {
60
62
  year: 2023,
61
63
  month: 1, // January
62
64
  });
65
+
66
+ // Same as before, but with a Date object
67
+ const previousMonth = new Date();
68
+ previousMonth.setMonth(0); // January
69
+ const { data, error } = await getMonthlyStats("ucdfiddes", GAME.BlockDrop, {
70
+ date: previousMonth,
71
+ });
63
72
  ```
64
73
 
65
74
  ### Fetch All-Time Leaderboard
@@ -67,7 +76,7 @@ const { data, error } = await getMonthlyStats("ucdfiddes", GAME.BlockDrop, {
67
76
  ```ts
68
77
  import { getAllTimeLeaderboard, GAME } from "hive-bedrock-api";
69
78
 
70
- // Returns asingle game
79
+ // Returns a single game
71
80
  const { data, error } = await getAllTimeLeaderboard(GAME.TreasureWars);
72
81
  ```
73
82
 
@@ -76,7 +85,7 @@ const { data, error } = await getAllTimeLeaderboard(GAME.TreasureWars);
76
85
  ```ts
77
86
  import { getMonthlyLeaderboard, GAME } from "hive-bedrock-api";
78
87
 
79
- // Returns asingle game
88
+ // Returns a single game
80
89
  const { data, error } = await getMonthlyLeaderboard(GAME.TreasureWars);
81
90
 
82
91
  // Returns a single game from a previous month
@@ -106,3 +115,5 @@ Different API responses are edited by the wrapper to provide more data:
106
115
  - A new value for "losses" is provided
107
116
  - A new value for "kdr" is provided
108
117
  - "xp" is converted and a "level" is provided
118
+
119
+ See [API.md](docs/API.md#game-statistics-types) for specific fields and their corresponding types per game.
@@ -108,6 +108,7 @@ exports.formats = (_a = {
108
108
  return game;
109
109
  },
110
110
  _a[GAME_INFO_1.GAME.TheBridge] = function (game) {
111
+ var _a, _b;
111
112
  if (!game)
112
113
  return null;
113
114
  if ("m_solo_deaths" in game) {
@@ -130,6 +131,12 @@ exports.formats = (_a = {
130
131
  game.victories = game.m_solo_victories;
131
132
  delete game.m_solo_victories;
132
133
  }
134
+ if ("played" in game && "victories" in game) {
135
+ game.losses = (_b = (_a = game.played) !== null && _a !== void 0 ? _a : 0 - game.victories) !== null && _b !== void 0 ? _b : 0;
136
+ game.win_percentage = game.victories / game.played;
137
+ if (isNaN(game.win_percentage))
138
+ game.win_percentage = 0;
139
+ }
133
140
  return game;
134
141
  },
135
142
  _a);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hive-bedrock-api",
3
- "version": "0.1.0-beta.8",
3
+ "version": "1.0.1",
4
4
  "description": "An API wrapper for the Hive Minecraft Bedrock Edition server.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",