@modlock/modlock 0.1.70 → 0.1.72
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/bystander.d.ts +9 -0
- package/hook.d.ts +3 -2
- package/host.gen.d.ts +89 -0
- package/index.d.ts +17 -1
- package/index.js +735 -39
- package/package.json +6 -6
- package/rotation.d.ts +76 -0
- package/strays.d.ts +17 -0
package/package.json
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"name": "@modlock/modlock",
|
|
9
9
|
"optionalDependencies": {
|
|
10
|
-
"@modlock/darwin-arm64": "0.1.
|
|
11
|
-
"@modlock/darwin-x64": "0.1.
|
|
12
|
-
"@modlock/linux-arm64": "0.1.
|
|
13
|
-
"@modlock/linux-x64": "0.1.
|
|
14
|
-
"@modlock/win32-x64": "0.1.
|
|
10
|
+
"@modlock/darwin-arm64": "0.1.72",
|
|
11
|
+
"@modlock/darwin-x64": "0.1.72",
|
|
12
|
+
"@modlock/linux-arm64": "0.1.72",
|
|
13
|
+
"@modlock/linux-x64": "0.1.72",
|
|
14
|
+
"@modlock/win32-x64": "0.1.72"
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"type": "module",
|
|
22
22
|
"types": "index.d.ts",
|
|
23
|
-
"version": "0.1.
|
|
23
|
+
"version": "0.1.72"
|
|
24
24
|
}
|
package/rotation.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** startingRating is the rating a player starts the session at. */
|
|
2
|
+
export declare const startingRating = 1000;
|
|
3
|
+
/** ratingStep is how far one even match moves each side's rating, by default. */
|
|
4
|
+
export declare const ratingStep = 32;
|
|
5
|
+
/** Standing is one player's record for the session. */
|
|
6
|
+
export interface Standing {
|
|
7
|
+
/** played counts the matches the player was seated for. */
|
|
8
|
+
played: number;
|
|
9
|
+
rating: number;
|
|
10
|
+
wins: number;
|
|
11
|
+
losses: number;
|
|
12
|
+
/** streak counts the matches won in a row, zero after a loss. */
|
|
13
|
+
streak: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Standings keeps a Standing for each Steam ID that joined this session. A
|
|
17
|
+
* mod that keeps more per player, such as matches played as each hero,
|
|
18
|
+
* passes extra to add those fields to each new standing.
|
|
19
|
+
*/
|
|
20
|
+
export declare class Standings<Extra extends object = object> {
|
|
21
|
+
private readonly extra;
|
|
22
|
+
private readonly bySteamId;
|
|
23
|
+
constructor(extra?: () => Extra);
|
|
24
|
+
/**
|
|
25
|
+
* join is steamId's standing, made at the starting rating on their first
|
|
26
|
+
* join. Its matches played rise to the fewest anyone present has played,
|
|
27
|
+
* so joining late or rejoining never puts a player ahead of the line.
|
|
28
|
+
*/
|
|
29
|
+
join(steamId: bigint, present: readonly Standing[]): Standing & Extra;
|
|
30
|
+
/** get is steamId's standing, or undefined before they join. */
|
|
31
|
+
get(steamId: bigint): (Standing & Extra) | undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* fewestPlayed is the fewest matches any of standings has played, zero with
|
|
35
|
+
* none.
|
|
36
|
+
*/
|
|
37
|
+
export declare function fewestPlayed(standings: readonly Standing[]): number;
|
|
38
|
+
/**
|
|
39
|
+
* nextMatch picks two sides of size players from the line: the 2 * size who
|
|
40
|
+
* have played the fewest matches, the earlier in line first among equals,
|
|
41
|
+
* dealt by rating in a snake (first, second, second, first, ...) so the sum
|
|
42
|
+
* of ratings stays close. One a side is the two in rating order; two a side
|
|
43
|
+
* is the best with the worst against the middle two. It returns undefined
|
|
44
|
+
* while too few wait.
|
|
45
|
+
*/
|
|
46
|
+
export declare function nextMatch<T>(line: readonly T[], size: number, standing: (player: T) => Standing): [T[], T[]] | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* afterMatch is the line once a match ends: everyone who did not fight
|
|
49
|
+
* first, then the fighters, each part in line order.
|
|
50
|
+
*/
|
|
51
|
+
export declare function afterMatch<T>(line: readonly T[], fought: readonly T[]): T[];
|
|
52
|
+
/**
|
|
53
|
+
* ratingChange is how far each winner's rating rises, and each loser's
|
|
54
|
+
* falls, when a side rated winners beats a side rated losers: the Elo step,
|
|
55
|
+
* larger for an upset.
|
|
56
|
+
*/
|
|
57
|
+
export declare function ratingChange(winners: number, losers: number, step?: number): number;
|
|
58
|
+
/**
|
|
59
|
+
* settle records a finished match: each side's ratings move by the change
|
|
60
|
+
* between the sides' average ratings, and the wins, losses and streaks
|
|
61
|
+
* count it. It returns the rating change, zero with an empty side.
|
|
62
|
+
*/
|
|
63
|
+
export declare function settle(winners: readonly Standing[], losers: readonly Standing[], step?: number): number;
|
|
64
|
+
/**
|
|
65
|
+
* leastUsed is the option to give a player next so each gets an even share:
|
|
66
|
+
* the index of the smallest of counts, or prefer when it ties for smallest.
|
|
67
|
+
* Counting each player's matches as each hero and seating leastUsed gives
|
|
68
|
+
* everyone every hero about equally.
|
|
69
|
+
*/
|
|
70
|
+
export declare function leastUsed(counts: readonly number[], prefer?: number): number;
|
|
71
|
+
/**
|
|
72
|
+
* leaderboard is the rows a viewer sees: players by wins and then rating,
|
|
73
|
+
* the first rows of them, with viewer kept on the last row when they would
|
|
74
|
+
* fall off the end.
|
|
75
|
+
*/
|
|
76
|
+
export declare function leaderboard<T>(players: readonly T[], standing: (player: T) => Standing, rows: number, viewer?: T): T[];
|
package/strays.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** strayGraceSeconds is how long a hero pawn belongs to no player before it is laid down. */
|
|
2
|
+
export declare const strayGraceSeconds = 3;
|
|
3
|
+
/**
|
|
4
|
+
* Strays finds and lays down stray hero pawns. A mod that swaps heroes keeps
|
|
5
|
+
* one and calls sweep each frame with the game time; it looks once a second.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Strays {
|
|
8
|
+
/** since maps each stray pawn to when it was first seen with no player. */
|
|
9
|
+
private since;
|
|
10
|
+
private sweptAt;
|
|
11
|
+
/**
|
|
12
|
+
* sweep lays down each hero pawn that has belonged to no player for
|
|
13
|
+
* strayGraceSeconds, at most once a second. The game sets a dead pawn's
|
|
14
|
+
* respawn when it dies, so the hold repeats on each sweep.
|
|
15
|
+
*/
|
|
16
|
+
sweep(now: number): void;
|
|
17
|
+
}
|