bancho.js 0.10.1 → 0.11.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/CHANGELOG.md +16 -0
- package/README.md +1 -1
- package/index.d.ts +6 -2
- package/lib/BanchoClient.js +6 -2
- package/lib/BanchoUser.js +1 -1
- package/lib/Multiplayer/BanchoLobby.js +10 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Pre-release
|
|
2
2
|
|
|
3
|
+
## Version 0.11
|
|
4
|
+
|
|
5
|
+
### Version 0.11.1
|
|
6
|
+
|
|
7
|
+
- Fix typings compilation on recent TypeScript versions
|
|
8
|
+
|
|
9
|
+
### Version 0.11.0
|
|
10
|
+
|
|
11
|
+
- **Add ability to set default gamemode for fetching users from API**
|
|
12
|
+
In order to optimize API calls in your application, you can rely on bancho.js' existing API data.
|
|
13
|
+
The new `gamemode` parameter in the bancho.js config object allows you to specify which gamemode data to receive when fetching an user to save more API calls in certain applications.
|
|
14
|
+
|
|
15
|
+
- **BanchoLobby: When updating from an FFA to a team-based mode, reset teams**
|
|
16
|
+
When enabling teams, all players in the lobby are assigned a default team by Bancho. They're assigned predictably based on their slots.
|
|
17
|
+
bancho.js now applies the same logic when changing team mode.
|
|
18
|
+
|
|
3
19
|
## Version 0.10
|
|
4
20
|
|
|
5
21
|
### Version 0.10.1
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://nodei.co/npm/bancho.js/)
|
|
4
4
|
[](https://git.cartooncraft.fr/ThePooN/bancho.js/commits/master)
|
|
5
5
|
|
|
6
|
-
## Current release: 0.
|
|
6
|
+
## Current release: 0.11.1
|
|
7
7
|
|
|
8
8
|
# Introduction
|
|
9
9
|
|
package/index.d.ts
CHANGED
|
@@ -353,7 +353,7 @@ declare module "bancho.js" {
|
|
|
353
353
|
* Current size of the lobby
|
|
354
354
|
*/
|
|
355
355
|
size: number
|
|
356
|
-
gamemode: nodesu.
|
|
356
|
+
gamemode: nodesu.ModeType
|
|
357
357
|
/**
|
|
358
358
|
* Beatmap fetched from the API (late/not as reliable, use beatmapId when possible)
|
|
359
359
|
*
|
|
@@ -794,7 +794,11 @@ declare module "bancho.js" {
|
|
|
794
794
|
/**
|
|
795
795
|
* osu! API key for API requests (see https://osu.ppy.sh/p/api). WARNING: Multiplayer lobbies won't work without an API key!
|
|
796
796
|
*/
|
|
797
|
-
apiKey?: string
|
|
797
|
+
apiKey?: string,
|
|
798
|
+
/**
|
|
799
|
+
* Gamemode id to fetch users with. Defaults to null
|
|
800
|
+
*/
|
|
801
|
+
gamemode?: number
|
|
798
802
|
}
|
|
799
803
|
|
|
800
804
|
interface BanchoClientOptionsWithoutRateLimiter extends BanchoClientBaseOptions {
|
package/lib/BanchoClient.js
CHANGED
|
@@ -58,6 +58,7 @@ class BanchoClient extends EventEmitter {
|
|
|
58
58
|
* @prop {string} [apiKey] osu! API key for API requests (see https://osu.ppy.sh/p/api). WARNING: Multiplayer lobbies won't work without an API key!
|
|
59
59
|
* @prop {RateLimiter} [rateLimiter] Instance of RateLimiter from the `limiter` npm module for outgoing Bancho messages. Default is safe for normal users in private messages (PM and #multiplayer channels), bots are not supposed to send public messages. Can be disabled by setting to `null`.
|
|
60
60
|
* @prop {boolean} [botAccount=false] Apply bot account rate-limits to the default RateLimiter instance if true (see https://osu.ppy.sh/wiki/en/Bot_account).
|
|
61
|
+
* @prop {number} [gamemode=null] Gamemode id to fetch users with. Defaults to null
|
|
61
62
|
*/
|
|
62
63
|
const options = {
|
|
63
64
|
host: "irc.ppy.sh",
|
|
@@ -66,6 +67,7 @@ class BanchoClient extends EventEmitter {
|
|
|
66
67
|
limiterPrivate: 9,
|
|
67
68
|
limiterPublic: undefined,
|
|
68
69
|
botAccount: false,
|
|
70
|
+
gamemode: null,
|
|
69
71
|
};
|
|
70
72
|
Object.assign(options, optionsOrUsername);
|
|
71
73
|
if(options.rateLimiter && options.botAccount)
|
|
@@ -90,10 +92,12 @@ class BanchoClient extends EventEmitter {
|
|
|
90
92
|
this.password = options.password;
|
|
91
93
|
this.host = options.host;
|
|
92
94
|
this.port = options.port;
|
|
93
|
-
if(options.apiKey)
|
|
95
|
+
if(options.apiKey) {
|
|
94
96
|
this.osuApi = new Nodesu.Client(options.apiKey, {
|
|
95
97
|
parseData: true
|
|
96
98
|
});
|
|
99
|
+
this.gamemode = options.gamemode;
|
|
100
|
+
}
|
|
97
101
|
this.rateLimiter = options.rateLimiter;
|
|
98
102
|
}
|
|
99
103
|
this.setMaxListeners(50);
|
|
@@ -341,7 +345,7 @@ class BanchoClient extends EventEmitter {
|
|
|
341
345
|
if(user)
|
|
342
346
|
resolve(user);
|
|
343
347
|
else
|
|
344
|
-
this.osuApi.user.get(userid, Nodesu.LookupType.id).then((apiUser) => {
|
|
348
|
+
this.osuApi.user.get(userid, this.gamemode, null, Nodesu.LookupType.id).then((apiUser) => {
|
|
345
349
|
user = this.getUser(apiUser.username);
|
|
346
350
|
user.updateFromAPI(apiUser);
|
|
347
351
|
resolve(user);
|
package/lib/BanchoUser.js
CHANGED
|
@@ -78,7 +78,7 @@ class BanchoUser extends EventEmitter {
|
|
|
78
78
|
fetchFromAPI() {
|
|
79
79
|
if(this.banchojs.osuApi) {
|
|
80
80
|
return new Promise((resolve, reject) => {
|
|
81
|
-
this.banchojs.osuApi.user.get(this.ircUsername,
|
|
81
|
+
this.banchojs.osuApi.user.get(this.ircUsername, this.banchojs.gamemode, null, Nodesu.LookupType.string).then((user) => {
|
|
82
82
|
this.updateFromAPI(user);
|
|
83
83
|
resolve(user);
|
|
84
84
|
}, reject);
|
|
@@ -7,6 +7,7 @@ const BanchoLobbyPlayerStates = require("./Enums/BanchoLobbyPlayerStates");
|
|
|
7
7
|
const BanchoLobbyTeams = require("./Enums/BanchoLobbyTeams");
|
|
8
8
|
const Regexes = require("./BanchoLobbyRegexes");
|
|
9
9
|
const Teams = require("./Enums/BanchoLobbyTeams");
|
|
10
|
+
const BanchoLobbyTeamModes = require("./Enums/BanchoLobbyTeamModes");
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Represents a Bancho multiplayer lobby
|
|
@@ -1081,6 +1082,15 @@ class BanchoLobby extends EventEmitter {
|
|
|
1081
1082
|
* @see BanchoLobbyTeamModes
|
|
1082
1083
|
*/
|
|
1083
1084
|
set teamMode(val) {
|
|
1085
|
+
const teamModes = [BanchoLobbyTeamModes.TeamVs, BanchoLobbyTeamModes.TagTeamVs];
|
|
1086
|
+
if(!teamModes.includes(this.teamMode) && teamModes.includes(val)) {
|
|
1087
|
+
for(let i = 0; i < this.slots.length; i++) {
|
|
1088
|
+
const slot = this.slots[i];
|
|
1089
|
+
if (slot !== null) {
|
|
1090
|
+
slot.team = i % 2 === 0 ? BanchoLobbyTeams.Blue : BanchoLobbyTeams.Red;
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1084
1094
|
this._setter("teamMode", val);
|
|
1085
1095
|
}
|
|
1086
1096
|
|