@modlock/modlock 0.1.72 → 0.1.74

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/cast.d.ts CHANGED
@@ -56,12 +56,23 @@ export declare class Cast<M> {
56
56
  * not show yet. seconds is the game clock.
57
57
  */
58
58
  frame(seconds: number): void;
59
- /** settle ends the members whose connection left and makes the new ones. */
59
+ /**
60
+ * settle ends the members whose connection left and makes the new ones,
61
+ * joined at now.
62
+ */
60
63
  private settle;
61
64
  /** kick asks the server to remove a bot, once per connection. */
62
65
  private kick;
63
66
  /** reconcile reads a member's hero and asks for the part of the want it lacks. */
64
67
  private reconcile;
68
+ /**
69
+ * stranded returns 'any' for a human whose hero is free when the game has
70
+ * left them on a team without one for changeSeconds since they joined, and
71
+ * otherwise leaves the hero free. Such a pawn never gets a hero on its own,
72
+ * while a player still choosing one has no pawn and a spectator stands on
73
+ * team 1. A bot is left to the game, which seats it.
74
+ */
75
+ private stranded;
65
76
  /** wantOf is what the member in seat wants now. */
66
77
  private wantOf;
67
78
  /** seated reports whether the member's hero shows the hero and team they want. */
package/host.gen.d.ts CHANGED
@@ -874,11 +874,20 @@ export interface Connection {
874
874
  */
875
875
  readonly roles: ModRole[];
876
876
  }
877
- /** Pawn is one player's hero this frame. */
877
+ /**
878
+ * Pawn is one player's pawn this frame: their hero, or the game's placeholder
879
+ * before a hero is selected.
880
+ */
878
881
  export interface Pawn {
879
- /** entity is the hero's entity handle, which ReadField reads. */
882
+ /**
883
+ * entity is the pawn's entity handle, which ReadField reads. It changes
884
+ * whenever the game replaces the pawn.
885
+ */
880
886
  readonly entity: number;
881
- /** hero identifies the hero, as SelectHero returns it. */
887
+ /**
888
+ * hero identifies the hero, as SelectHero returns it, or is 0 for a
889
+ * placeholder pawn that has none yet.
890
+ */
882
891
  readonly hero: number;
883
892
  /** team is the hero's team number. */
884
893
  readonly team: number;
@@ -929,6 +938,10 @@ export interface Pawn {
929
938
  * from items included. Absent when the game's own reading is unavailable.
930
939
  */
931
940
  readonly effectiveMaxHealth?: number;
941
+ /** abilityPoints is the ability points the player holds unspent. */
942
+ readonly abilityPoints: number;
943
+ /** abilityUnlocks is the ability unlocks the player holds unspent. */
944
+ readonly abilityUnlocks: number;
932
945
  }
933
946
  /**
934
947
  * Score is one player's scoreboard counters since the match began, as the
@@ -1261,7 +1274,10 @@ export interface FrameEvent {
1261
1274
  export interface CommandEvent {
1262
1275
  /** player is the player who typed the command. */
1263
1276
  readonly player: Player;
1264
- /** line is the complete command line, starting with the command name. */
1277
+ /**
1278
+ * line is the complete command line, starting with the command name in
1279
+ * lower case, whatever case the player typed; the arguments keep theirs.
1280
+ */
1265
1281
  readonly line: string;
1266
1282
  }
1267
1283
  /**
@@ -1346,7 +1362,12 @@ export declare class Player {
1346
1362
  centerText(text: string): boolean;
1347
1363
  /** announce shows a game announcement with a title to the player. */
1348
1364
  announce(title: string, text: string): boolean;
1349
- /** pawn returns the player's hero this frame, or nothing without one. */
1365
+ /**
1366
+ * pawn returns the player's pawn this frame: the hero, or the game's
1367
+ * placeholder with hero 0 that a player joining on a team holds until a hero
1368
+ * is selected. It returns nothing for a spectator and before the game has
1369
+ * made a pawn. The pawn's entity changes whenever the game replaces it.
1370
+ */
1350
1371
  pawn(): Pawn | undefined;
1351
1372
  /**
1352
1373
  * setting returns the player's value of a setting the manifest
@@ -1417,7 +1438,10 @@ export declare class Player {
1417
1438
  * hero back to it. Stopping the mod returns every such player.
1418
1439
  */
1419
1440
  unwatch(): boolean;
1420
- /** respawn revives the player's dead hero. */
1441
+ /**
1442
+ * respawn revives the player's dead hero. A pawn with hero 0 has no hero to
1443
+ * revive; the call fails until SelectHero gives it one.
1444
+ */
1421
1445
  respawn(): boolean;
1422
1446
  /**
1423
1447
  * changeTeam moves the player's hero, living or dead, to team 2 or 3 where
@@ -1466,14 +1490,19 @@ export declare class Player {
1466
1490
  */
1467
1491
  giveItem(item: string, imbue?: number): boolean;
1468
1492
  /**
1469
- * replaceAbility puts the ability named ability, untrained, in the hero's
1470
- * ability slot index, as Ability.slot, removing the ability there. An
1471
- * ability from another hero loads its models and particles only if
1472
- * Precache named that hero and those resources before the world loaded;
1473
- * otherwise its first effect stalls the game on a blocking load and the
1474
- * game reports an assertion.
1493
+ * replaceAbility puts the ability named ability, untrained unless keep
1494
+ * carries the old one's progress, in the hero's ability slot index, as
1495
+ * Ability.slot, removing the ability there. The game trains and upgrades an
1496
+ * ability in slots 0 to 3 by its slot, so a player holds the upgrade key and
1497
+ * presses the slot's ability key to spend ability points on it, and training
1498
+ * an untrained one costs an ability unlock. A hero change or ResetHero gives
1499
+ * the hero its own abilities again, so a mod that keeps a swap replaces
1500
+ * again then. An ability from another hero loads its models and particles
1501
+ * only if Precache named that hero and those resources before the world
1502
+ * loaded; otherwise its first effect stalls the game on a blocking load and
1503
+ * the game reports an assertion.
1475
1504
  */
1476
- replaceAbility(index: number, ability: string): boolean;
1505
+ replaceAbility(index: number, ability: string, keep?: boolean): boolean;
1477
1506
  /**
1478
1507
  * holdModifier keeps a modifier, named as GiveModifier names it, on the
1479
1508
  * hero with no expiry, giving it back whenever the game removes it or the
@@ -1537,6 +1566,13 @@ export declare class Player {
1537
1566
  * nothing. Silent skips the pickup's sound and number.
1538
1567
  */
1539
1568
  adjustSouls(delta: number, silent?: boolean): boolean;
1569
+ /**
1570
+ * adjustAbilityPoints gives the player ability points and ability unlocks,
1571
+ * or takes them when negative, as Pawn.ability_points and
1572
+ * Pawn.ability_unlocks read them. A spend larger than the player holds
1573
+ * fails and spends nothing.
1574
+ */
1575
+ adjustAbilityPoints(points: number, unlocks: number): boolean;
1540
1576
  /** startingSouls sets the souls the player's hero spawns with. */
1541
1577
  startingSouls(souls: number): boolean;
1542
1578
  /**
@@ -1556,7 +1592,8 @@ export declare class Player {
1556
1592
  * seconds: the build first, then health, stamina and pose once it settles,
1557
1593
  * then charges and cooldowns. A Restored event reports when the result has
1558
1594
  * held for a second, or why it could not. A new call replaces the running
1559
- * one.
1595
+ * one. A pawn with hero 0 has no hero to restore; the call fails until
1596
+ * SelectHero gives it one.
1560
1597
  */
1561
1598
  restoreHero(target: HeroTarget): boolean;
1562
1599
  /**
package/index.d.ts CHANGED
@@ -25,6 +25,7 @@ export { poseAt, type Pose, Puppet, type PuppetOptions, type PuppetState, ghostS
25
25
  export { type HeroSnapshot, restoreHero } from './restore.js';
26
26
  export { type ReplayedHit, replayDamage } from './replayed-damage.js';
27
27
  export { type CatalogEntry, Dropper, dropperButtons } from './dropper.js';
28
+ export { type BoardPage, type BoardRead, type BoardRow, type BoardWindow, type MatchPlace, readBoard, reportMatch, reportScore, type ScoreOptions, } from './scores.js';
28
29
  export { decodeSpot, encodeSpot, LoadedSpot, loadSpot, type Placed, type Spot, type SpotObject, triggers, } from './spot.js';
29
30
  export { type ButtonProps, type Child, type Component, type Edges, type ElementProps, Fragment, type Gradient, type HeroLookName, type HeroProps, hide, hideHud, cursorFree, freeCursor, type HudPart, type ImageProps, type JSX, jsx, jsxs, type LabelProps, type LayoutProps, type Length, type Overflow, type PanelProps, route, type Scaling, type Shadow, sheet, show, type Style, toast, type Transition, type UiElement, } from './ui.js';
30
31
  /** LogPart is a value log writes as text. */
@@ -46,8 +47,9 @@ export declare function serve(service: string, handler: Service): void;
46
47
  * command calls handler when a player types /name in chat or their client
47
48
  * sends the console command name to the server. The handler runs with the
48
49
  * next server frame, before the frame handlers, and receives the text after
49
- * the name, trimmed of surrounding spaces. Registering a name again replaces
50
- * its handler.
50
+ * the name, trimmed of surrounding spaces. Names are lower case and match
51
+ * whatever case the player types. Registering a name again replaces its
52
+ * handler.
51
53
  */
52
54
  export declare function command(name: string, handler: (player: Player, args: string) => void): void;
53
55
  /**
package/index.js CHANGED
@@ -3648,7 +3648,8 @@ var ReplaceAbilityRequest = /* @__PURE__ */ createMessageType(
3648
3648
  () => [
3649
3649
  [1, "player", 5],
3650
3650
  [2, "index", 13],
3651
- [3, "ability", 9]
3651
+ [3, "ability", 9],
3652
+ [4, "keep", 8, 4]
3652
3653
  ],
3653
3654
  {
3654
3655
  decode: (r, end, m) => {
@@ -3665,6 +3666,9 @@ var ReplaceAbilityRequest = /* @__PURE__ */ createMessageType(
3665
3666
  case 3:
3666
3667
  m.ability = r.string();
3667
3668
  break;
3669
+ case 4:
3670
+ m.keep = r.bool();
3671
+ break;
3668
3672
  default:
3669
3673
  r.skip(t);
3670
3674
  }
@@ -3684,6 +3688,10 @@ var ReplaceAbilityRequest = /* @__PURE__ */ createMessageType(
3684
3688
  const v = m.ability;
3685
3689
  if (v) w.uint32(26).string(v);
3686
3690
  }
3691
+ {
3692
+ const v = m.keep;
3693
+ if (v != null) w.uint32(32).bool(v);
3694
+ }
3687
3695
  }
3688
3696
  }
3689
3697
  );
@@ -6272,9 +6280,9 @@ var CountResponse = /* @__PURE__ */ createMessageType(
6272
6280
  }
6273
6281
  );
6274
6282
 
6275
- // src/wasm/files/files.pb.ts
6283
+ // src/wasm/files.pb.ts
6276
6284
  var ReadFileRequest = /* @__PURE__ */ createMessageType(
6277
- "modlock.wasm.files.ReadFileRequest",
6285
+ "modlock.wasm.ReadFileRequest",
6278
6286
  () => [[1, "path", 9]],
6279
6287
  {
6280
6288
  decode: (r, end, m) => {
@@ -6300,7 +6308,7 @@ var ReadFileRequest = /* @__PURE__ */ createMessageType(
6300
6308
  }
6301
6309
  );
6302
6310
  var ReadFileResponse = /* @__PURE__ */ createMessageType(
6303
- "modlock.wasm.files.ReadFileResponse",
6311
+ "modlock.wasm.ReadFileResponse",
6304
6312
  () => [[1, "text", 9, 4]],
6305
6313
  {
6306
6314
  decode: (r, end, m) => {
@@ -6326,7 +6334,7 @@ var ReadFileResponse = /* @__PURE__ */ createMessageType(
6326
6334
  }
6327
6335
  );
6328
6336
  var WriteFileRequest = /* @__PURE__ */ createMessageType(
6329
- "modlock.wasm.files.WriteFileRequest",
6337
+ "modlock.wasm.WriteFileRequest",
6330
6338
  () => [
6331
6339
  [1, "path", 9],
6332
6340
  [2, "text", 9]
@@ -6362,9 +6370,9 @@ var WriteFileRequest = /* @__PURE__ */ createMessageType(
6362
6370
  }
6363
6371
  );
6364
6372
 
6365
- // src/wasm/handoff/handoff.pb.ts
6373
+ // src/wasm/handoff.pb.ts
6366
6374
  var HandoffRequest = /* @__PURE__ */ createMessageType(
6367
- "modlock.wasm.handoff.HandoffRequest",
6375
+ "modlock.wasm.HandoffRequest",
6368
6376
  () => [[1, "text", 9]],
6369
6377
  {
6370
6378
  decode: (r, end, m) => {
@@ -6390,7 +6398,7 @@ var HandoffRequest = /* @__PURE__ */ createMessageType(
6390
6398
  }
6391
6399
  );
6392
6400
  var HandoffPlayerRequest = /* @__PURE__ */ createMessageType(
6393
- "modlock.wasm.handoff.HandoffPlayerRequest",
6401
+ "modlock.wasm.HandoffPlayerRequest",
6394
6402
  () => [
6395
6403
  [1, "player", 5],
6396
6404
  [2, "text", 9]
@@ -6426,7 +6434,7 @@ var HandoffPlayerRequest = /* @__PURE__ */ createMessageType(
6426
6434
  }
6427
6435
  );
6428
6436
  var HandedOffResponse = /* @__PURE__ */ createMessageType(
6429
- "modlock.wasm.handoff.HandedOffResponse",
6437
+ "modlock.wasm.HandedOffResponse",
6430
6438
  () => [[1, "text", 9]],
6431
6439
  {
6432
6440
  decode: (r, end, m) => {
@@ -6452,9 +6460,9 @@ var HandedOffResponse = /* @__PURE__ */ createMessageType(
6452
6460
  }
6453
6461
  );
6454
6462
 
6455
- // src/wasm/input/input.pb.ts
6463
+ // src/wasm/input.pb.ts
6456
6464
  var InputEvent = /* @__PURE__ */ createMessageType(
6457
- "modlock.wasm.input.InputEvent",
6465
+ "modlock.wasm.InputEvent",
6458
6466
  () => [
6459
6467
  [1, "player", 5],
6460
6468
  [2, "pressed", 4],
@@ -6498,7 +6506,7 @@ var InputEvent = /* @__PURE__ */ createMessageType(
6498
6506
  }
6499
6507
  );
6500
6508
  var ButtonsResponse = /* @__PURE__ */ createMessageType(
6501
- "modlock.wasm.input.ButtonsResponse",
6509
+ "modlock.wasm.ButtonsResponse",
6502
6510
  () => [[1, "buttons", 4]],
6503
6511
  {
6504
6512
  decode: (r, end, m) => {
@@ -6524,7 +6532,7 @@ var ButtonsResponse = /* @__PURE__ */ createMessageType(
6524
6532
  }
6525
6533
  );
6526
6534
  var InputRequest = /* @__PURE__ */ createMessageType(
6527
- "modlock.wasm.input.InputRequest",
6535
+ "modlock.wasm.InputRequest",
6528
6536
  () => [[1, "buttons", 4]],
6529
6537
  {
6530
6538
  decode: (r, end, m) => {
@@ -6550,7 +6558,7 @@ var InputRequest = /* @__PURE__ */ createMessageType(
6550
6558
  }
6551
6559
  );
6552
6560
  var PlayerInputRequest = /* @__PURE__ */ createMessageType(
6553
- "modlock.wasm.input.PlayerInputRequest",
6561
+ "modlock.wasm.PlayerInputRequest",
6554
6562
  () => [
6555
6563
  [1, "player", 5],
6556
6564
  [2, "buttons", 4]
@@ -6586,7 +6594,7 @@ var PlayerInputRequest = /* @__PURE__ */ createMessageType(
6586
6594
  }
6587
6595
  );
6588
6596
  var RemapInputRequest = /* @__PURE__ */ createMessageType(
6589
- "modlock.wasm.input.RemapInputRequest",
6597
+ "modlock.wasm.RemapInputRequest",
6590
6598
  () => [
6591
6599
  [1, "from", 4],
6592
6600
  [2, "to", 4],
@@ -6630,9 +6638,9 @@ var RemapInputRequest = /* @__PURE__ */ createMessageType(
6630
6638
  }
6631
6639
  );
6632
6640
 
6633
- // src/wasm/match/match.pb.ts
6641
+ // src/wasm/match.pb.ts
6634
6642
  var SetFreeForAllRequest = /* @__PURE__ */ createMessageType(
6635
- "modlock.wasm.match.SetFreeForAllRequest",
6643
+ "modlock.wasm.SetFreeForAllRequest",
6636
6644
  () => [[1, "enabled", 8]],
6637
6645
  {
6638
6646
  decode: (r, end, m) => {
@@ -6658,7 +6666,7 @@ var SetFreeForAllRequest = /* @__PURE__ */ createMessageType(
6658
6666
  }
6659
6667
  );
6660
6668
  var SetTeamSeatingRequest = /* @__PURE__ */ createMessageType(
6661
- "modlock.wasm.match.SetTeamSeatingRequest",
6669
+ "modlock.wasm.SetTeamSeatingRequest",
6662
6670
  () => [[1, "enabled", 8]],
6663
6671
  {
6664
6672
  decode: (r, end, m) => {
@@ -6684,7 +6692,7 @@ var SetTeamSeatingRequest = /* @__PURE__ */ createMessageType(
6684
6692
  }
6685
6693
  );
6686
6694
  var PauseRequest = /* @__PURE__ */ createMessageType(
6687
- "modlock.wasm.match.PauseRequest",
6695
+ "modlock.wasm.PauseRequest",
6688
6696
  () => [[1, "paused", 8]],
6689
6697
  {
6690
6698
  decode: (r, end, m) => {
@@ -6710,7 +6718,7 @@ var PauseRequest = /* @__PURE__ */ createMessageType(
6710
6718
  }
6711
6719
  );
6712
6720
  var MatchClockResponse = /* @__PURE__ */ createMessageType(
6713
- "modlock.wasm.match.MatchClockResponse",
6721
+ "modlock.wasm.MatchClockResponse",
6714
6722
  () => [[1, "seconds", 2]],
6715
6723
  {
6716
6724
  decode: (r, end, m) => {
@@ -6736,7 +6744,7 @@ var MatchClockResponse = /* @__PURE__ */ createMessageType(
6736
6744
  }
6737
6745
  );
6738
6746
  var HoldMatchClockRequest = /* @__PURE__ */ createMessageType(
6739
- "modlock.wasm.match.HoldMatchClockRequest",
6747
+ "modlock.wasm.HoldMatchClockRequest",
6740
6748
  () => [[1, "seconds", 2, 4]],
6741
6749
  {
6742
6750
  decode: (r, end, m) => {
@@ -6762,7 +6770,7 @@ var HoldMatchClockRequest = /* @__PURE__ */ createMessageType(
6762
6770
  }
6763
6771
  );
6764
6772
  var RiftResponse = /* @__PURE__ */ createMessageType(
6765
- "modlock.wasm.match.RiftResponse",
6773
+ "modlock.wasm.RiftResponse",
6766
6774
  () => [[1, "state", 11, 0, RiftState.codec]],
6767
6775
  {
6768
6776
  decode: (r, end, m) => {
@@ -6788,7 +6796,7 @@ var RiftResponse = /* @__PURE__ */ createMessageType(
6788
6796
  }
6789
6797
  );
6790
6798
  var RiftState = /* @__PURE__ */ createMessageType(
6791
- "modlock.wasm.match.RiftState",
6799
+ "modlock.wasm.RiftState",
6792
6800
  () => [
6793
6801
  [1, "scoring_team", 5],
6794
6802
  [2, "scoring_time", 2],
@@ -6856,7 +6864,7 @@ var RiftState = /* @__PURE__ */ createMessageType(
6856
6864
  }
6857
6865
  );
6858
6866
  var StartRiftRequest = /* @__PURE__ */ createMessageType(
6859
- "modlock.wasm.match.StartRiftRequest",
6867
+ "modlock.wasm.StartRiftRequest",
6860
6868
  () => [[1, "position", 11, 0, Vec3.codec]],
6861
6869
  {
6862
6870
  decode: (r, end, m) => {
@@ -8514,7 +8522,9 @@ var Pawn = /* @__PURE__ */ createMessageType(
8514
8522
  [15, "carrying_urn", 8, 4],
8515
8523
  [16, "score", 11, 0, Score.codec],
8516
8524
  [17, "camera_position", 11, 0, Vec3.codec],
8517
- [18, "effective_max_health", 5, 4]
8525
+ [18, "effective_max_health", 5, 4],
8526
+ [19, "ability_points", 5],
8527
+ [20, "ability_unlocks", 5]
8518
8528
  ],
8519
8529
  {
8520
8530
  decode: (r, end, m) => {
@@ -8588,6 +8598,12 @@ var Pawn = /* @__PURE__ */ createMessageType(
8588
8598
  case 18:
8589
8599
  m.effectiveMaxHealth = r.int32();
8590
8600
  break;
8601
+ case 19:
8602
+ m.abilityPoints = r.int32();
8603
+ break;
8604
+ case 20:
8605
+ m.abilityUnlocks = r.int32();
8606
+ break;
8591
8607
  default:
8592
8608
  r.skip(t);
8593
8609
  }
@@ -8667,6 +8683,14 @@ var Pawn = /* @__PURE__ */ createMessageType(
8667
8683
  const v = m.effectiveMaxHealth;
8668
8684
  if (v != null) w.uint32(144).int32(v);
8669
8685
  }
8686
+ {
8687
+ const v = m.abilityPoints;
8688
+ if (v) w.uint32(152).int32(v);
8689
+ }
8690
+ {
8691
+ const v = m.abilityUnlocks;
8692
+ if (v) w.uint32(160).int32(v);
8693
+ }
8670
8694
  }
8671
8695
  }
8672
8696
  );
@@ -9577,6 +9601,50 @@ var AdjustSoulsRequest = /* @__PURE__ */ createMessageType(
9577
9601
  }
9578
9602
  }
9579
9603
  );
9604
+ var AdjustAbilityPointsRequest = /* @__PURE__ */ createMessageType(
9605
+ "modlock.wasm.players.AdjustAbilityPointsRequest",
9606
+ () => [
9607
+ [1, "player", 5],
9608
+ [2, "points", 5],
9609
+ [3, "unlocks", 5]
9610
+ ],
9611
+ {
9612
+ decode: (r, end, m) => {
9613
+ while (r.pos < end) {
9614
+ const t = r.tag();
9615
+ if ((t & 7) === 4) return m;
9616
+ switch (t >>> 3) {
9617
+ case 1:
9618
+ m.player = r.int32();
9619
+ break;
9620
+ case 2:
9621
+ m.points = r.int32();
9622
+ break;
9623
+ case 3:
9624
+ m.unlocks = r.int32();
9625
+ break;
9626
+ default:
9627
+ r.skip(t);
9628
+ }
9629
+ }
9630
+ return m;
9631
+ },
9632
+ encode: (m, w) => {
9633
+ {
9634
+ const v = m.player;
9635
+ if (v) w.uint32(8).int32(v);
9636
+ }
9637
+ {
9638
+ const v = m.points;
9639
+ if (v) w.uint32(16).int32(v);
9640
+ }
9641
+ {
9642
+ const v = m.unlocks;
9643
+ if (v) w.uint32(24).int32(v);
9644
+ }
9645
+ }
9646
+ }
9647
+ );
9580
9648
  var StartingSoulsRequest = /* @__PURE__ */ createMessageType(
9581
9649
  "modlock.wasm.players.StartingSoulsRequest",
9582
9650
  () => [
@@ -12518,7 +12586,9 @@ function fromPawn(message) {
12518
12586
  carryingUrn: message.carryingUrn,
12519
12587
  score: message.score === void 0 ? void 0 : fromScore(message.score),
12520
12588
  cameraPosition: message.cameraPosition === void 0 ? void 0 : vector(message.cameraPosition),
12521
- effectiveMaxHealth: message.effectiveMaxHealth
12589
+ effectiveMaxHealth: message.effectiveMaxHealth,
12590
+ abilityPoints: message.abilityPoints ?? 0,
12591
+ abilityUnlocks: message.abilityUnlocks ?? 0
12522
12592
  };
12523
12593
  }
12524
12594
  function fromScore(message) {
@@ -12735,7 +12805,12 @@ var Player = class _Player {
12735
12805
  announce(title, text2) {
12736
12806
  return call("Announce", AnnounceRequest.toBinary({ player: this.slot, title, text: text2 })) !== void 0;
12737
12807
  }
12738
- /** pawn returns the player's hero this frame, or nothing without one. */
12808
+ /**
12809
+ * pawn returns the player's pawn this frame: the hero, or the game's
12810
+ * placeholder with hero 0 that a player joining on a team holds until a hero
12811
+ * is selected. It returns nothing for a spectator and before the game has
12812
+ * made a pawn. The pawn's entity changes whenever the game replaces it.
12813
+ */
12739
12814
  pawn() {
12740
12815
  const reply2 = call("Pawn", PlayerRequest.toBinary({ player: this.slot }));
12741
12816
  if (reply2 === void 0) return void 0;
@@ -12844,7 +12919,10 @@ var Player = class _Player {
12844
12919
  unwatch() {
12845
12920
  return call("Unwatch", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
12846
12921
  }
12847
- /** respawn revives the player's dead hero. */
12922
+ /**
12923
+ * respawn revives the player's dead hero. A pawn with hero 0 has no hero to
12924
+ * revive; the call fails until SelectHero gives it one.
12925
+ */
12848
12926
  respawn() {
12849
12927
  return call("Respawn", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
12850
12928
  }
@@ -12916,15 +12994,20 @@ var Player = class _Player {
12916
12994
  return call("GiveItem", GiveItemRequest.toBinary({ player: this.slot, item: item2, imbue })) !== void 0;
12917
12995
  }
12918
12996
  /**
12919
- * replaceAbility puts the ability named ability, untrained, in the hero's
12920
- * ability slot index, as Ability.slot, removing the ability there. An
12921
- * ability from another hero loads its models and particles only if
12922
- * Precache named that hero and those resources before the world loaded;
12923
- * otherwise its first effect stalls the game on a blocking load and the
12924
- * game reports an assertion.
12997
+ * replaceAbility puts the ability named ability, untrained unless keep
12998
+ * carries the old one's progress, in the hero's ability slot index, as
12999
+ * Ability.slot, removing the ability there. The game trains and upgrades an
13000
+ * ability in slots 0 to 3 by its slot, so a player holds the upgrade key and
13001
+ * presses the slot's ability key to spend ability points on it, and training
13002
+ * an untrained one costs an ability unlock. A hero change or ResetHero gives
13003
+ * the hero its own abilities again, so a mod that keeps a swap replaces
13004
+ * again then. An ability from another hero loads its models and particles
13005
+ * only if Precache named that hero and those resources before the world
13006
+ * loaded; otherwise its first effect stalls the game on a blocking load and
13007
+ * the game reports an assertion.
12925
13008
  */
12926
- replaceAbility(index, ability) {
12927
- return call("ReplaceAbility", ReplaceAbilityRequest.toBinary({ player: this.slot, index, ability })) !== void 0;
13009
+ replaceAbility(index, ability, keep) {
13010
+ return call("ReplaceAbility", ReplaceAbilityRequest.toBinary({ player: this.slot, index, ability, keep })) !== void 0;
12928
13011
  }
12929
13012
  /**
12930
13013
  * holdModifier keeps a modifier, named as GiveModifier names it, on the
@@ -13005,6 +13088,15 @@ var Player = class _Player {
13005
13088
  adjustSouls(delta, silent) {
13006
13089
  return call("AdjustSouls", AdjustSoulsRequest.toBinary({ player: this.slot, delta: int32(delta), silent })) !== void 0;
13007
13090
  }
13091
+ /**
13092
+ * adjustAbilityPoints gives the player ability points and ability unlocks,
13093
+ * or takes them when negative, as Pawn.ability_points and
13094
+ * Pawn.ability_unlocks read them. A spend larger than the player holds
13095
+ * fails and spends nothing.
13096
+ */
13097
+ adjustAbilityPoints(points, unlocks) {
13098
+ return call("AdjustAbilityPoints", AdjustAbilityPointsRequest.toBinary({ player: this.slot, points: int32(points), unlocks: int32(unlocks) })) !== void 0;
13099
+ }
13008
13100
  /** startingSouls sets the souls the player's hero spawns with. */
13009
13101
  startingSouls(souls) {
13010
13102
  return call("StartingSouls", StartingSoulsRequest.toBinary({ player: this.slot, souls: int32(souls) })) !== void 0;
@@ -13032,7 +13124,8 @@ var Player = class _Player {
13032
13124
  * seconds: the build first, then health, stamina and pose once it settles,
13033
13125
  * then charges and cooldowns. A Restored event reports when the result has
13034
13126
  * held for a second, or why it could not. A new call replaces the running
13035
- * one.
13127
+ * one. A pawn with hero 0 has no hero to restore; the call fails until
13128
+ * SelectHero gives it one.
13036
13129
  */
13037
13130
  restoreHero(target) {
13038
13131
  return call("RestoreHero", RestoreHeroRequest.toBinary({ player: this.slot, target: toHeroTarget(target) })) !== void 0;
@@ -13361,8 +13454,8 @@ function watchInput(buttons) {
13361
13454
  function remapInput(from, to, repeat2) {
13362
13455
  return call("RemapInput", RemapInputRequest.toBinary({ from, to, repeat: repeat2 })) !== void 0;
13363
13456
  }
13364
- function callService(service, method, payload) {
13365
- const reply2 = call("CallService", ServiceCall.toBinary({ service, method, payload }));
13457
+ function callService(service2, method, payload) {
13458
+ const reply2 = call("CallService", ServiceCall.toBinary({ service: service2, method, payload }));
13366
13459
  if (reply2 === void 0) return void 0;
13367
13460
  const response = ServiceReply.fromBinary(reply2);
13368
13461
  return response.payload ?? new Uint8Array();
@@ -15912,7 +16005,7 @@ var badgeSize = 18;
15912
16005
  var portraits = new Map(heroes.map((hero) => [hero.id, hero.portrait]));
15913
16006
  function rosterKey(rows) {
15914
16007
  return rows.slice(0, rosterRows).map(
15915
- (row) => `${row.self ? "*" : ""}${row.selected ? "+" : ""}${row.onPress ? ">" : ""}${row.name} ${row.hero} ${row.activity} ${row.steamId ?? ""}`
16008
+ (row2) => `${row2.self ? "*" : ""}${row2.selected ? "+" : ""}${row2.onPress ? ">" : ""}${row2.name} ${row2.hero} ${row2.activity} ${row2.steamId ?? ""}`
15916
16009
  ).join("\n");
15917
16010
  }
15918
16011
  function Roster(props) {
@@ -15930,7 +16023,7 @@ function Roster(props) {
15930
16023
  props.rows.slice(0, rosterRows).map(rosterRow)
15931
16024
  );
15932
16025
  }
15933
- function rosterRow(row, index) {
16026
+ function rosterRow(row2, index) {
15934
16027
  const right = { horizontalAlign: "right", textAlign: "right" };
15935
16028
  const text2 = element(
15936
16029
  "panel",
@@ -15940,18 +16033,18 @@ function rosterRow(row, index) {
15940
16033
  role: "label",
15941
16034
  tone: "text",
15942
16035
  style: right,
15943
- children: clip(row.name.toUpperCase(), rosterName)
16036
+ children: clip(row2.name.toUpperCase(), rosterName)
15944
16037
  }),
15945
16038
  Text({
15946
16039
  role: "caption",
15947
16040
  tone: "muted",
15948
16041
  style: { ...right, margin: [1, 0, 0, 0] },
15949
- children: row.activity
16042
+ children: row2.activity
15950
16043
  })
15951
16044
  ]
15952
16045
  );
15953
- const src = portraits.get(row.hero);
15954
- const badge = row.steamId === void 0 ? false : avatarBadge(row.steamId);
16046
+ const src = portraits.get(row2.hero);
16047
+ const badge = row2.steamId === void 0 ? false : avatarBadge(row2.steamId);
15955
16048
  const image = src === void 0 ? false : portraitImage(src);
15956
16049
  const portrait = element(
15957
16050
  "panel",
@@ -15960,7 +16053,7 @@ function rosterRow(row, index) {
15960
16053
  height: portraitSize,
15961
16054
  padding: 1,
15962
16055
  verticalAlign: "center",
15963
- background: row.self || row.selected ? tones.accent : shades.dim
16056
+ background: row2.self || row2.selected ? tones.accent : shades.dim
15964
16057
  },
15965
16058
  element(
15966
16059
  "panel",
@@ -15973,7 +16066,7 @@ function rosterRow(row, index) {
15973
16066
  horizontalAlign: "right",
15974
16067
  margin: [0, 0, 8, 0]
15975
16068
  };
15976
- const line2 = row.onPress ? {
16069
+ const line2 = row2.onPress ? {
15977
16070
  type: "button",
15978
16071
  props: {
15979
16072
  style: {
@@ -15984,7 +16077,7 @@ function rosterRow(row, index) {
15984
16077
  hover: { background: shades.raised },
15985
16078
  hoverSound: sounds.hover,
15986
16079
  sound: sounds.press,
15987
- onPress: row.onPress,
16080
+ onPress: row2.onPress,
15988
16081
  children: [text2, portrait]
15989
16082
  },
15990
16083
  key: `row-${index}`
@@ -16136,15 +16229,18 @@ var Cast = class {
16136
16229
  */
16137
16230
  frame(seconds) {
16138
16231
  if (this.reported !== void 0) {
16139
- this.settle(this.reported);
16232
+ this.settle(this.reported, seconds);
16140
16233
  this.reported = void 0;
16141
16234
  }
16142
16235
  for (const seat of this.seats.values()) {
16143
16236
  this.reconcile(seat, seconds);
16144
16237
  }
16145
16238
  }
16146
- /** settle ends the members whose connection left and makes the new ones. */
16147
- settle(players2) {
16239
+ /**
16240
+ * settle ends the members whose connection left and makes the new ones,
16241
+ * joined at now.
16242
+ */
16243
+ settle(players2, now4) {
16148
16244
  const present = new Map(players2.map((c) => [c.player.slot, c]));
16149
16245
  for (const [slot, seat] of this.seats) {
16150
16246
  if (present.get(slot)?.generation !== seat.connection.generation) {
@@ -16168,6 +16264,7 @@ var Cast = class {
16168
16264
  fellAt: -Infinity,
16169
16265
  hero: 0,
16170
16266
  heroLostAt: -Infinity,
16267
+ joinedAt: now4,
16171
16268
  askedAt: -Infinity
16172
16269
  });
16173
16270
  }
@@ -16192,7 +16289,8 @@ var Cast = class {
16192
16289
  const changing = had === 0 && now4 - seat.heroLostAt < changeSeconds;
16193
16290
  if (now4 - seat.askedAt < 1 || changing) return;
16194
16291
  const want = this.wantOf(seat);
16195
- const { hero, respawn } = want;
16292
+ const { respawn } = want;
16293
+ const hero = want.hero ?? this.stranded(seat, now4);
16196
16294
  if (hero !== void 0 && !this.seated(seat, want, hero)) {
16197
16295
  seat.askedAt = now4;
16198
16296
  this.seat(seat, want, hero);
@@ -16201,6 +16299,19 @@ var Cast = class {
16201
16299
  seat.connection.player.respawn();
16202
16300
  }
16203
16301
  }
16302
+ /**
16303
+ * stranded returns 'any' for a human whose hero is free when the game has
16304
+ * left them on a team without one for changeSeconds since they joined, and
16305
+ * otherwise leaves the hero free. Such a pawn never gets a hero on its own,
16306
+ * while a player still choosing one has no pawn and a spectator stands on
16307
+ * team 1. A bot is left to the game, which seats it.
16308
+ */
16309
+ stranded(seat, now4) {
16310
+ const { pawn } = seat;
16311
+ const team = pawn?.team;
16312
+ const heroless = pawn?.hero === 0 && (team === 2 || team === 3);
16313
+ return heroless && !seat.connection.bot && now4 - seat.joinedAt >= changeSeconds ? "any" : void 0;
16314
+ }
16204
16315
  /** wantOf is what the member in seat wants now. */
16205
16316
  wantOf(seat) {
16206
16317
  const { want = noWant } = this.options;
@@ -16574,13 +16685,13 @@ var ProbeRun = class {
16574
16685
  * tick runs check for the frame at now until the run ends. step names what
16575
16686
  * the probe waits on, and describe adds the probe's state to a timeout.
16576
16687
  */
16577
- tick(now4, step, check, describe) {
16688
+ tick(now4, step, check, describe2) {
16578
16689
  if (this.finished) {
16579
16690
  return;
16580
16691
  }
16581
16692
  let result;
16582
16693
  if (this.elapsed(now4) > this.timeout) {
16583
- const state = describe ? `: ${describe()}` : "";
16694
+ const state = describe2 ? `: ${describe2()}` : "";
16584
16695
  result = `timed out waiting for ${step}${state}`;
16585
16696
  } else {
16586
16697
  result = check();
@@ -17293,12 +17404,529 @@ function snap(value) {
17293
17404
  return Math.round(value / grid) * grid;
17294
17405
  }
17295
17406
 
17407
+ // src/wasm/scores/scores.pb.ts
17408
+ var Window_Enum = /* @__PURE__ */ createEnumType(
17409
+ "modlock.wasm.scores.Window",
17410
+ [
17411
+ [0, "WINDOW_UNKNOWN"],
17412
+ [1, "WINDOW_ALL_TIME"],
17413
+ [2, "WINDOW_DAY"],
17414
+ [3, "WINDOW_WEEK"]
17415
+ ]
17416
+ );
17417
+ var ScoreReport = /* @__PURE__ */ createMessageType(
17418
+ "modlock.wasm.scores.ScoreReport",
17419
+ () => [
17420
+ [1, "board", 9],
17421
+ [2, "player", 5],
17422
+ [3, "value", 3],
17423
+ [4, "tiebreak", 3],
17424
+ [5, "partition", 9, 584],
17425
+ [6, "key", 9],
17426
+ [7, "earned_at_unix_millis", 3],
17427
+ [8, "evidence", 9]
17428
+ ],
17429
+ {
17430
+ decode: (r, end, m) => {
17431
+ while (r.pos < end) {
17432
+ const t = r.tag();
17433
+ if ((t & 7) === 4) return m;
17434
+ switch (t >>> 3) {
17435
+ case 1:
17436
+ m.board = r.string();
17437
+ break;
17438
+ case 2:
17439
+ m.player = r.int32();
17440
+ break;
17441
+ case 3:
17442
+ m.value = r.int64();
17443
+ break;
17444
+ case 4:
17445
+ m.tiebreak = r.int64();
17446
+ break;
17447
+ case 5: {
17448
+ const [k, v] = r.entry(
17449
+ (r2) => r2.string(),
17450
+ (r2) => r2.string(),
17451
+ "",
17452
+ ""
17453
+ );
17454
+ m.partition ??= newMap();
17455
+ m.partition[k] = v;
17456
+ break;
17457
+ }
17458
+ case 6:
17459
+ m.key = r.string();
17460
+ break;
17461
+ case 7:
17462
+ m.earnedAtUnixMillis = r.int64();
17463
+ break;
17464
+ case 8:
17465
+ m.evidence = r.string();
17466
+ break;
17467
+ default:
17468
+ r.skip(t);
17469
+ }
17470
+ }
17471
+ return m;
17472
+ },
17473
+ encode: (m, w) => {
17474
+ {
17475
+ const v = m.board;
17476
+ if (v) w.uint32(10).string(v);
17477
+ }
17478
+ {
17479
+ const v = m.player;
17480
+ if (v) w.uint32(16).int32(v);
17481
+ }
17482
+ {
17483
+ const v = m.value;
17484
+ if (v) w.uint32(24).int64(v);
17485
+ }
17486
+ {
17487
+ const v = m.tiebreak;
17488
+ if (v) w.uint32(32).int64(v);
17489
+ }
17490
+ {
17491
+ const o = m.partition;
17492
+ if (o != null)
17493
+ for (const [k, v] of Object.entries(o)) {
17494
+ const s = w.uint32(42).fork();
17495
+ w.uint32(10).string(k);
17496
+ w.uint32(18).string(v);
17497
+ w.join(s);
17498
+ }
17499
+ }
17500
+ {
17501
+ const v = m.key;
17502
+ if (v) w.uint32(50).string(v);
17503
+ }
17504
+ {
17505
+ const v = m.earnedAtUnixMillis;
17506
+ if (v) w.uint32(56).int64(v);
17507
+ }
17508
+ {
17509
+ const v = m.evidence;
17510
+ if (v) w.uint32(66).string(v);
17511
+ }
17512
+ }
17513
+ }
17514
+ );
17515
+ var MatchReport = /* @__PURE__ */ createMessageType(
17516
+ "modlock.wasm.scores.MatchReport",
17517
+ () => [
17518
+ [1, "board", 9],
17519
+ [2, "places", 11, 1, Place.codec],
17520
+ [3, "partition", 9, 584],
17521
+ [4, "key", 9],
17522
+ [5, "earned_at_unix_millis", 3],
17523
+ [6, "evidence", 9]
17524
+ ],
17525
+ {
17526
+ decode: (r, end, m) => {
17527
+ while (r.pos < end) {
17528
+ const t = r.tag();
17529
+ if ((t & 7) === 4) return m;
17530
+ switch (t >>> 3) {
17531
+ case 1:
17532
+ m.board = r.string();
17533
+ break;
17534
+ case 2:
17535
+ ;
17536
+ (m.places ??= []).push(Place.decode(r, r.delimited(), {}));
17537
+ break;
17538
+ case 3: {
17539
+ const [k, v] = r.entry(
17540
+ (r2) => r2.string(),
17541
+ (r2) => r2.string(),
17542
+ "",
17543
+ ""
17544
+ );
17545
+ m.partition ??= newMap();
17546
+ m.partition[k] = v;
17547
+ break;
17548
+ }
17549
+ case 4:
17550
+ m.key = r.string();
17551
+ break;
17552
+ case 5:
17553
+ m.earnedAtUnixMillis = r.int64();
17554
+ break;
17555
+ case 6:
17556
+ m.evidence = r.string();
17557
+ break;
17558
+ default:
17559
+ r.skip(t);
17560
+ }
17561
+ }
17562
+ return m;
17563
+ },
17564
+ encode: (m, w) => {
17565
+ {
17566
+ const v = m.board;
17567
+ if (v) w.uint32(10).string(v);
17568
+ }
17569
+ {
17570
+ const a = m.places;
17571
+ if (a != null) for (const e of a) Place.writeField(w, 2, e);
17572
+ }
17573
+ {
17574
+ const o = m.partition;
17575
+ if (o != null)
17576
+ for (const [k, v] of Object.entries(o)) {
17577
+ const s = w.uint32(26).fork();
17578
+ w.uint32(10).string(k);
17579
+ w.uint32(18).string(v);
17580
+ w.join(s);
17581
+ }
17582
+ }
17583
+ {
17584
+ const v = m.key;
17585
+ if (v) w.uint32(34).string(v);
17586
+ }
17587
+ {
17588
+ const v = m.earnedAtUnixMillis;
17589
+ if (v) w.uint32(40).int64(v);
17590
+ }
17591
+ {
17592
+ const v = m.evidence;
17593
+ if (v) w.uint32(50).string(v);
17594
+ }
17595
+ }
17596
+ }
17597
+ );
17598
+ var Place = /* @__PURE__ */ createMessageType(
17599
+ "modlock.wasm.scores.Place",
17600
+ () => [
17601
+ [1, "player", 5],
17602
+ [2, "place", 13],
17603
+ [3, "value", 3]
17604
+ ],
17605
+ {
17606
+ decode: (r, end, m) => {
17607
+ while (r.pos < end) {
17608
+ const t = r.tag();
17609
+ if ((t & 7) === 4) return m;
17610
+ switch (t >>> 3) {
17611
+ case 1:
17612
+ m.player = r.int32();
17613
+ break;
17614
+ case 2:
17615
+ m.place = r.uint32();
17616
+ break;
17617
+ case 3:
17618
+ m.value = r.int64();
17619
+ break;
17620
+ default:
17621
+ r.skip(t);
17622
+ }
17623
+ }
17624
+ return m;
17625
+ },
17626
+ encode: (m, w) => {
17627
+ {
17628
+ const v = m.player;
17629
+ if (v) w.uint32(8).int32(v);
17630
+ }
17631
+ {
17632
+ const v = m.place;
17633
+ if (v) w.uint32(16).uint32(v);
17634
+ }
17635
+ {
17636
+ const v = m.value;
17637
+ if (v) w.uint32(24).int64(v);
17638
+ }
17639
+ }
17640
+ }
17641
+ );
17642
+ var BoardQuery = /* @__PURE__ */ createMessageType(
17643
+ "modlock.wasm.scores.BoardQuery",
17644
+ () => [
17645
+ [1, "board", 9],
17646
+ [2, "partition", 9, 584],
17647
+ [3, "window", 14, 0, Window_Enum],
17648
+ [4, "offset", 13],
17649
+ [5, "limit", 13],
17650
+ [6, "player", 5, 4]
17651
+ ],
17652
+ {
17653
+ decode: (r, end, m) => {
17654
+ while (r.pos < end) {
17655
+ const t = r.tag();
17656
+ if ((t & 7) === 4) return m;
17657
+ switch (t >>> 3) {
17658
+ case 1:
17659
+ m.board = r.string();
17660
+ break;
17661
+ case 2: {
17662
+ const [k, v] = r.entry(
17663
+ (r2) => r2.string(),
17664
+ (r2) => r2.string(),
17665
+ "",
17666
+ ""
17667
+ );
17668
+ m.partition ??= newMap();
17669
+ m.partition[k] = v;
17670
+ break;
17671
+ }
17672
+ case 3:
17673
+ m.window = r.int32();
17674
+ break;
17675
+ case 4:
17676
+ m.offset = r.uint32();
17677
+ break;
17678
+ case 5:
17679
+ m.limit = r.uint32();
17680
+ break;
17681
+ case 6:
17682
+ m.player = r.int32();
17683
+ break;
17684
+ default:
17685
+ r.skip(t);
17686
+ }
17687
+ }
17688
+ return m;
17689
+ },
17690
+ encode: (m, w) => {
17691
+ {
17692
+ const v = m.board;
17693
+ if (v) w.uint32(10).string(v);
17694
+ }
17695
+ {
17696
+ const o = m.partition;
17697
+ if (o != null)
17698
+ for (const [k, v] of Object.entries(o)) {
17699
+ const s = w.uint32(18).fork();
17700
+ w.uint32(10).string(k);
17701
+ w.uint32(18).string(v);
17702
+ w.join(s);
17703
+ }
17704
+ }
17705
+ {
17706
+ const v = m.window;
17707
+ if (v) w.uint32(24).int32(v);
17708
+ }
17709
+ {
17710
+ const v = m.offset;
17711
+ if (v) w.uint32(32).uint32(v);
17712
+ }
17713
+ {
17714
+ const v = m.limit;
17715
+ if (v) w.uint32(40).uint32(v);
17716
+ }
17717
+ {
17718
+ const v = m.player;
17719
+ if (v != null) w.uint32(48).int32(v);
17720
+ }
17721
+ }
17722
+ }
17723
+ );
17724
+ var BoardPage = /* @__PURE__ */ createMessageType(
17725
+ "modlock.wasm.scores.BoardPage",
17726
+ () => [
17727
+ [1, "rows", 11, 1, Standing.codec],
17728
+ [2, "player", 11, 0, Standing.codec],
17729
+ [3, "loading", 8]
17730
+ ],
17731
+ {
17732
+ decode: (r, end, m) => {
17733
+ while (r.pos < end) {
17734
+ const t = r.tag();
17735
+ if ((t & 7) === 4) return m;
17736
+ switch (t >>> 3) {
17737
+ case 1:
17738
+ ;
17739
+ (m.rows ??= []).push(Standing.decode(r, r.delimited(), {}));
17740
+ break;
17741
+ case 2:
17742
+ m.player = Standing.decode(r, r.delimited(), m.player ?? {});
17743
+ break;
17744
+ case 3:
17745
+ m.loading = r.bool();
17746
+ break;
17747
+ default:
17748
+ r.skip(t);
17749
+ }
17750
+ }
17751
+ return m;
17752
+ },
17753
+ encode: (m, w) => {
17754
+ {
17755
+ const a = m.rows;
17756
+ if (a != null) for (const e of a) Standing.writeField(w, 1, e);
17757
+ }
17758
+ {
17759
+ const v = m.player;
17760
+ if (v != null) Standing.writeField(w, 2, v);
17761
+ }
17762
+ {
17763
+ const v = m.loading;
17764
+ if (v) w.uint32(24).bool(v);
17765
+ }
17766
+ }
17767
+ }
17768
+ );
17769
+ var Standing = /* @__PURE__ */ createMessageType(
17770
+ "modlock.wasm.scores.Standing",
17771
+ () => [
17772
+ [1, "rank", 13],
17773
+ [2, "steam_id", 4],
17774
+ [3, "name", 9],
17775
+ [4, "value", 3],
17776
+ [5, "tiebreak", 3],
17777
+ [6, "count", 13]
17778
+ ],
17779
+ {
17780
+ decode: (r, end, m) => {
17781
+ while (r.pos < end) {
17782
+ const t = r.tag();
17783
+ if ((t & 7) === 4) return m;
17784
+ switch (t >>> 3) {
17785
+ case 1:
17786
+ m.rank = r.uint32();
17787
+ break;
17788
+ case 2:
17789
+ m.steamId = r.uint64();
17790
+ break;
17791
+ case 3:
17792
+ m.name = r.string();
17793
+ break;
17794
+ case 4:
17795
+ m.value = r.int64();
17796
+ break;
17797
+ case 5:
17798
+ m.tiebreak = r.int64();
17799
+ break;
17800
+ case 6:
17801
+ m.count = r.uint32();
17802
+ break;
17803
+ default:
17804
+ r.skip(t);
17805
+ }
17806
+ }
17807
+ return m;
17808
+ },
17809
+ encode: (m, w) => {
17810
+ {
17811
+ const v = m.rank;
17812
+ if (v) w.uint32(8).uint32(v);
17813
+ }
17814
+ {
17815
+ const v = m.steamId;
17816
+ if (v) w.uint32(16).uint64(v);
17817
+ }
17818
+ {
17819
+ const v = m.name;
17820
+ if (v) w.uint32(26).string(v);
17821
+ }
17822
+ {
17823
+ const v = m.value;
17824
+ if (v) w.uint32(32).int64(v);
17825
+ }
17826
+ {
17827
+ const v = m.tiebreak;
17828
+ if (v) w.uint32(40).int64(v);
17829
+ }
17830
+ {
17831
+ const v = m.count;
17832
+ if (v) w.uint32(48).uint32(v);
17833
+ }
17834
+ }
17835
+ }
17836
+ );
17837
+
17838
+ // js/src/scores.ts
17839
+ var service = "scores";
17840
+ var windowValues = {
17841
+ allTime: 1 /* ALL_TIME */,
17842
+ day: 2 /* DAY */,
17843
+ week: 3 /* WEEK */
17844
+ };
17845
+ function reportScore(player, board, value, options = {}) {
17846
+ const report = ScoreReport.toBinary({
17847
+ board,
17848
+ player: player.slot,
17849
+ value: int64(value),
17850
+ tiebreak: int64(options.tiebreak ?? 0),
17851
+ partition: options.partition,
17852
+ key: options.key,
17853
+ earnedAtUnixMillis: int64(options.earnedAt ?? 0),
17854
+ evidence: options.evidence
17855
+ });
17856
+ return taken(
17857
+ "Report",
17858
+ report,
17859
+ `${board}${describe(options.partition)}: player ${player.slot} ${value}`
17860
+ );
17861
+ }
17862
+ function reportMatch(board, places, options = {}) {
17863
+ const report = MatchReport.toBinary({
17864
+ board,
17865
+ places: places.map((p) => ({
17866
+ player: p.player.slot,
17867
+ place: p.place,
17868
+ value: int64(p.value ?? 0)
17869
+ })),
17870
+ partition: options.partition,
17871
+ key: options.key,
17872
+ earnedAtUnixMillis: int64(options.earnedAt ?? 0),
17873
+ evidence: options.evidence
17874
+ });
17875
+ const line2 = places.map((p) => `player ${p.player.slot} #${p.place}`).join(", ");
17876
+ return taken(
17877
+ "Match",
17878
+ report,
17879
+ `${board}${describe(options.partition)}: ${line2}`
17880
+ );
17881
+ }
17882
+ function readBoard(board, read = {}) {
17883
+ const query = BoardQuery.toBinary({
17884
+ board,
17885
+ partition: read.partition,
17886
+ window: read.window === void 0 ? void 0 : windowValues[read.window],
17887
+ offset: read.offset,
17888
+ limit: read.limit,
17889
+ player: read.player?.slot
17890
+ });
17891
+ const reply2 = callService(service, "Read", query);
17892
+ if (reply2 === void 0) return void 0;
17893
+ const page = BoardPage.fromBinary(reply2);
17894
+ return {
17895
+ rows: (page.rows ?? []).map(row),
17896
+ player: page.player ? row(page.player) : void 0,
17897
+ loading: page.loading ?? false
17898
+ };
17899
+ }
17900
+ function taken(method, report, line2) {
17901
+ if (callService(service, method, report) !== void 0) return true;
17902
+ log(`score ${line2} (not reported: the host keeps no scores)`);
17903
+ return false;
17904
+ }
17905
+ function row(standing) {
17906
+ return {
17907
+ rank: standing.rank ?? 0,
17908
+ steamId: standing.steamId ?? 0n,
17909
+ name: standing.name ?? "",
17910
+ value: Number(standing.value ?? 0n),
17911
+ tiebreak: Number(standing.tiebreak ?? 0n),
17912
+ count: standing.count ?? 0
17913
+ };
17914
+ }
17915
+ function int64(value) {
17916
+ return BigInt(Math.round(value));
17917
+ }
17918
+ function describe(partition) {
17919
+ const names = Object.keys(partition ?? {}).sort();
17920
+ if (!names.length) return "";
17921
+ return `[${names.map((name) => `${name}=${partition[name]}`).join(" ")}]`;
17922
+ }
17923
+
17296
17924
  // js/src/index.ts
17297
17925
  function log2(...parts) {
17298
17926
  log(parts.map((part) => String(part)).join(" "));
17299
17927
  }
17300
- function serve(service, handler) {
17301
- services.set(service, { handler });
17928
+ function serve(service2, handler) {
17929
+ services.set(service2, { handler });
17302
17930
  }
17303
17931
  function command(name, handler) {
17304
17932
  commands.set(name, { handler });
@@ -17503,8 +18131,12 @@ serveEvents((call2) => serveMod(handlers, call2));
17503
18131
 
17504
18132
  // js/src/quickjs.ts
17505
18133
  var bridge = globalThis.__modlock;
17506
- bind((call2) => bridge.hostCall(call2));
17507
- bridge.event = deliver;
18134
+ var host = (call2) => bridge.hostCall(call2);
18135
+ bind(host);
18136
+ bridge.event = (call2) => {
18137
+ bind(host);
18138
+ return deliver(call2);
18139
+ };
17508
18140
  export {
17509
18141
  Action,
17510
18142
  Banner,
@@ -17619,6 +18251,7 @@ export {
17619
18251
  pushEntity,
17620
18252
  ratingChange,
17621
18253
  ratingStep,
18254
+ readBoard,
17622
18255
  readField,
17623
18256
  readFieldList,
17624
18257
  readFile,
@@ -17627,6 +18260,8 @@ export {
17627
18260
  removeEntities,
17628
18261
  removeEntity,
17629
18262
  replayDamage,
18263
+ reportMatch,
18264
+ reportScore,
17630
18265
  restoreHero,
17631
18266
  restoreNpcs,
17632
18267
  rift,
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.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"
10
+ "@modlock/darwin-arm64": "0.1.74",
11
+ "@modlock/darwin-x64": "0.1.74",
12
+ "@modlock/linux-arm64": "0.1.74",
13
+ "@modlock/linux-x64": "0.1.74",
14
+ "@modlock/win32-x64": "0.1.74"
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.72"
23
+ "version": "0.1.74"
24
24
  }
package/scores.d.ts ADDED
@@ -0,0 +1,72 @@
1
+ import { type Player } from './host.gen.js';
2
+ /** BoardWindow is a span of time a board keeps standings for, in UTC; a week starts Monday. */
3
+ export type BoardWindow = 'allTime' | 'day' | 'week';
4
+ /** ScoreOptions describe where a score ranks and the run it came from. */
5
+ export interface ScoreOptions {
6
+ /** partition names a value for each of the board's partitions. */
7
+ partition?: Record<string, string>;
8
+ /** tiebreak ranks equal values, lower first, such as fewer deaths. */
9
+ tiebreak?: number;
10
+ /** key identifies the run, so a resent score counts once. */
11
+ key?: string;
12
+ /** earnedAt is when the score was earned, in Unix milliseconds; the host's clock by default. */
13
+ earnedAt?: number;
14
+ /** evidence names what shows the run, such as a recording. */
15
+ evidence?: string;
16
+ }
17
+ /** MatchPlace is one player's finishing place in a match, 1 for the winner. */
18
+ export interface MatchPlace {
19
+ player: Player;
20
+ place: number;
21
+ /** value is the player's score in the match, for a board that keeps one. */
22
+ value?: number;
23
+ }
24
+ /** BoardRead selects a page of a board. */
25
+ export interface BoardRead {
26
+ /** partition names a value for each of the board's partitions. */
27
+ partition?: Record<string, string>;
28
+ /** window is one of the board's windows; all time by default. */
29
+ window?: BoardWindow;
30
+ /** offset skips that many rows from the top. */
31
+ offset?: number;
32
+ /** limit bounds the rows; ten by default. */
33
+ limit?: number;
34
+ /** player asks for this player's own row too. */
35
+ player?: Player;
36
+ }
37
+ /** BoardRow is one player's place on a board. */
38
+ export interface BoardRow {
39
+ rank: number;
40
+ steamId: bigint;
41
+ name: string;
42
+ value: number;
43
+ tiebreak: number;
44
+ count: number;
45
+ }
46
+ /** BoardPage is a page of a board. */
47
+ export interface BoardPage {
48
+ /** rows are the standings in rank order. */
49
+ rows: BoardRow[];
50
+ /** player is the asked player's row, when they hold a standing. */
51
+ player?: BoardRow;
52
+ /** loading is set until the host has read the board; read again on a later frame. */
53
+ loading: boolean;
54
+ }
55
+ /**
56
+ * reportScore reports one score for player to a board the manifest declares.
57
+ * It reports whether the host took it; a host without the scores service
58
+ * takes none, and the mod logs the score instead.
59
+ */
60
+ export declare function reportScore(player: Player, board: string, value: number, options?: ScoreOptions): boolean;
61
+ /**
62
+ * reportMatch reports one match's places to a rating or match board the
63
+ * manifest declares. Players who tie, such as one team's members, share a
64
+ * place. It reports whether the host took it, as reportScore does.
65
+ */
66
+ export declare function reportMatch(board: string, places: readonly MatchPlace[], options?: Omit<ScoreOptions, 'tiebreak'>): boolean;
67
+ /**
68
+ * readBoard reads a page of a board the manifest declares, as the host last
69
+ * read it, or undefined when the host serves no scores. A page the host has
70
+ * not read yet comes back loading.
71
+ */
72
+ export declare function readBoard(board: string, read?: BoardRead): BoardPage | undefined;
package/scriptc.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import './index.js';
2
2
  /**
3
- * event answers the Call the host holds, size bytes long. call hands the
4
- * host an encoded Call and returns the size of its Reply; read copies the
5
- * bytes the host holds, the Call first and then each Reply, into its
6
- * argument.
3
+ * event answers the Call the host holds, size bytes long. Each Call binds the
4
+ * host again, as the QuickJS entry does, so a transport bound during one
5
+ * event lasts only until the next.
7
6
  */
8
- export declare function event(size: number, call: (data: Uint8Array) => number, read: (data: Uint8Array) => void): Uint8Array;
7
+ export declare function event(size: number): Uint8Array;