Modules / Players & social

partyplugin

Who plays together, held in the hub and mirrored into every truth a member is in.

Putting it in a scene

List it before ui, which draws what party shows. The scene's sim hands the party kinds from #plugins/party/party.sim.ts a way to mail other truths and the truth's own name (see Rules). The scene has one { "is": "parties" } actor, and the hub has one too. The scene's security must list partyseat.account and partyseat.invite, so no seat is sent another's account or invite.

"plugins": ["loader", "scenemanager", "player", "party", "chat", "ui", "render2d"],
"security": { "partyseat": { "account": "me", "invite": "me" } },
"world": { "party": { "mods": { "whisper": "chat" } } },
"prefabs": {
  "player": { "seat": 0, "masks": [], "account": "", "name": "", "hp": 100, "hpMax": 100 },
  "parties": {
    "hub": "hub",
    "prefix": "party-",
    "max": 4,
    "invite": 600,
    "grain": 0.05,
    "rate": { "gap": 30, "burst": 3 },
    "who": { "kind": "player", "seat": "seat", "account": "account", "name": "name", "life": "hp", "most": "hpMax" },
    "page": {
      "stride": 48, "name": [8, 4], "zone": [8, 22], "bar": [8, 36],
      "kick": [140, 4], "promote": [180, 4], "leave": [8, 200],
      "prompt": { "name": [8, 240], "accept": [8, 260], "decline": [80, 260] }
    },
    "n": 0,
    "next": {},
    "invites": {}
  }
}

Rows

RowHolds
partiesOne per truth, the door: a seat sends every party act at it. Its prefab is the table below.
partyIn the hub, one per party: { key, leader, members }. members is keyed by account, each { name, zone, life, joined }: the member's name, the truth they were last in, their life as a fraction from 0 to 1, and the hub step they joined on. key is prefix followed by the row's id, and is the instance key of the party's dungeons.
partymirrorIn a member's truth, the same fields as the hub last mailed them, one per party with a member here. Rules read it and the page draws it. It is ended once no member of the party is here.
partyseatOne per account with a row here: { account, invite }. invite is { from, name } while an invite waits for the account, and null after. Its owner is the account's player row, so with the security above each seat is sent its own account and invite and every other seat's without them.

Properties

Read from the parties prefab.

FieldMeaning
hubThe name of the hub's truth, where parties are held.
prefixWhat a party's key starts with.
maxThe most members a party has.
inviteHub steps an invite waits for an answer before it expires.
grainThe step a member's life fraction is rounded to, so a small change in life is not mailed.
rate{ gap, burst }: a seat may ask burst times at once, then once every gap steps of the parties row.
who{ kind, seat, account, name, life, most }: the kind whose row stands for a seat, and the names of its fields. seat holds the truth's seat number, account and name identify the member, and life and most are its life and its greatest life, each a field name or a dotted path into the row's data.
pageWhere the page draws, in pixels (below).
n, nextThe row's own step count, and per seat the step it may next ask. Both start as shown.
invitesIn the hub, the waiting invites, keyed by the invited account: { from, name, zone, life, until }, where until is the hub step it expires on. One invite waits per account, and a newer one replaces it. Starts as {}.

.page

Each is an [x, y] in pixels except stride.

KeyMeaning
stridePixels between one member's frame and the next, going down.
name, zone, barIn a member's frame: their name, the truth they are in, and their life bar.
kick, promoteIn a member's frame, the buttons shown only while the seat leads.
leaveThe button that leaves the party.
prompt{ name, accept, decline }: the inviter's name and the two buttons of the prompt shown while an invite waits.

Panels and styles

The panels and styles are in ui's prefab. A panel the prefab makes modal has the input while it shows the prompt, as any ui modal does.

PanelContents and styles
party.framesA frame for each other member, in the order they joined, page.stride below the one before. The name is in the style party.name, or party.leader for the leader. The truth they are in is in party.zone, and their life is a ui bar of the style party.life filled in its fill. While the seat leads, each frame has buttons of the styles party.kick and party.promote. A button of the style party.leave leaves the party. Each button style is a button options object with its label.
party.inviteWhile an invite waits: the inviter's name in the style party.prompt, and buttons of the styles party.accept and party.decline.

Methods

Acts

Sent at the parties row by a seat. All are open and held to rate. The hub decides each.

invite( account )

Invites the account. Refused when the account is the sender, when the invited account is in a party, when the sender is in a party they do not lead, or when that party is full. Otherwise the invite is kept for invite steps and the invited account is told.

accept( )

Takes the waiting invite. The account joins the inviter's party, which is made then with the inviter as leader if they have none. Nothing happens if the party is full or the account joined another meanwhile.

decline( )

Drops the waiting invite.

leave( )

The member leaves. A leader who leaves hands the lead to the member who joined first, and a party left with one member is disbanded.

kick( account )

The leader removes that member, as for leave. Ignored from anyone else, or for the leader's own account.

promote( account )

The leader gives the lead to that member. Ignored from anyone else, or for the leader's own account.

Rules

From #plugins/party/party.sim.ts.

party( post, here ) : { parties, party, partymirror, partyseat }

Builds the four kinds for the game's sim. post(w, to, kind, act, ...args) calls an act on the first row of kind in the truth to names, which is a truth name, { account } or { scene }. here(w) returns the name of the truth it is called in. Every change to a party is mailed to each of its members, and to one who left or was kicked, so each member's truth keeps its partymirror. A member's name, truth or rounded life that differs from its mirror is mailed to the hub.

partyOf( w, account ) : Party | undefined

The party holding that account: the party row in the hub, the partymirror anywhere else.

members( w, account ) : string[]

Every account in that account's party, its own included, or an empty list.

mates( w, account ) : Row[]

The rows of who.kind in this truth that belong to the other members of that account's party.

instance( w, account ) : string

The key a dungeon of that account's is instanced by: its party's key, or the account alone.

On the page

Through plugins.party.

invite( account )

Sends an invite for that account, for another plugin's page half or an actor to call when the player picks someone. It does nothing before the first packet holds a parties row.

Mods

Name them in world.party.mods.

  • chat
    whisper: a tap on a member's name opens chat's whisper channel to them. With none named, a name is only a name and takes no tap. A scene that names it must list chat in its plugins.

Used by

  • chat
    Sends a party line to the members of the speaker's party, found with party's members.