mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-15 16:42:41 +00:00
N3/P6c: a fight the whole party sits down for
`!fight` seats the expedition's roster instead of the one player who typed it. Seat 0 is the leader, always: the session row is theirs, the lock is theirs, and `!flee`, the fork, and `!extract` stay their call. A monster that wins initiative now swings before anyone speaks. The session layer used to park every new fight on a player_turn, which is true of the hardcoded solo order and a lie about a party's -- the enemy would forfeit round 1 and nobody would notice. `startPartyCombatSession` rolls the order and sets the phase from it; `handleFightCmd` settles the round before it announces, so the opening block narrates the hit rather than quietly showing its damage. Members were invisible to two commands that had no business ignoring them: `!cast` queued a spell for "next combat" while its caster was standing in one, and `!rest` healed a seated member to full mid boss fight. Both now resolve through the party. Nobody leaves without an answer. A downed member's `!fight` opens the party's fight and tells them why they are not in it. The leader's `!extract` reaches everyone it drags out of the dungeon, and everyone rolls for what moved into their house while they were gone. Supplies burn at 50% x N x 4/5 -- a party eats more than one and less than N. The ratio is exact: 0.8 as a float truncates a party of three to 119%, a permanent tax nobody would have found. Solo is untouched, byte for byte. One seat means one build, one INSERT, no participant rows, the same RNG draws in the same order -- the combat characterization golden does not move, and neither does the balance corpus.
This commit is contained in:
@@ -795,7 +795,7 @@ func (p *AdventurePlugin) autoDriveCombat(ctx MessageContext) (bool, error) {
|
||||
if err := p.handleFightCmd(ctx); err != nil {
|
||||
return false, fmt.Errorf("fight: %w", err)
|
||||
}
|
||||
sess, err := getActiveCombatSession(ctx.Sender)
|
||||
sess, err := activeCombatSessionFor(ctx.Sender)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("getActiveCombatSession: %w", err)
|
||||
}
|
||||
@@ -803,8 +803,12 @@ func (p *AdventurePlugin) autoDriveCombat(ctx MessageContext) (bool, error) {
|
||||
// No session opened (bestiary miss, doorway already cleared).
|
||||
return false, nil
|
||||
}
|
||||
// The cap counts dispatches, and a party spends one per seat per round. Scale
|
||||
// it by the roster so a three-player boss fight gets the same 200 rounds of
|
||||
// headroom a solo one does; solo multiplies by 1 and is unchanged.
|
||||
sessionID := sess.SessionID
|
||||
for i := 0; i < autoCombatRoundCap; i++ {
|
||||
dispatchCap := autoCombatRoundCap * sess.RosterSize()
|
||||
for i := 0; i < dispatchCap; i++ {
|
||||
// Re-fetch by id so we can read Won/Lost/Fled — the "active"
|
||||
// filter on getActiveCombatSession returns nil once status flips.
|
||||
cur, err := getCombatSession(sessionID)
|
||||
@@ -820,21 +824,55 @@ func (p *AdventurePlugin) autoDriveCombat(ctx MessageContext) (bool, error) {
|
||||
case CombatStatusLost, CombatStatusFled:
|
||||
return false, nil
|
||||
}
|
||||
kind, arg := p.pickAutoCombatAction(ctx.Sender, cur)
|
||||
|
||||
// Every combat command is refused to anyone but the seat on the clock, so
|
||||
// a party fight has to be driven as whoever that is. Solo skips the lookup
|
||||
// entirely: seat 0 is the only seat, and the sender is already sitting in
|
||||
// it — the bit-identical path the balance corpus rests on.
|
||||
turn := ctx
|
||||
seat := 0
|
||||
if cur.IsParty() {
|
||||
seat, err = p.actingSeatForAutopilot(cur)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("iter %d: %w", i, err)
|
||||
}
|
||||
turn.Sender = id.UserID(cur.seatUserID(seat))
|
||||
}
|
||||
|
||||
kind, arg := p.pickAutoCombatActionForSeat(turn.Sender, cur, seat)
|
||||
var dispatchErr error
|
||||
switch kind {
|
||||
case "consume":
|
||||
dispatchErr = p.handleConsumeCmd(ctx, arg)
|
||||
dispatchErr = p.handleConsumeCmd(turn, arg)
|
||||
case "cast":
|
||||
dispatchErr = p.handleCombatCastCmd(ctx, arg)
|
||||
dispatchErr = p.handleCombatCastCmd(turn, arg)
|
||||
default:
|
||||
dispatchErr = p.handleAttackCmd(ctx)
|
||||
dispatchErr = p.handleAttackCmd(turn)
|
||||
}
|
||||
if dispatchErr != nil {
|
||||
return false, fmt.Errorf("%s iter %d: %w", kind, i, dispatchErr)
|
||||
}
|
||||
}
|
||||
return false, fmt.Errorf("combat exceeded %d rounds", autoCombatRoundCap)
|
||||
return false, fmt.Errorf("combat exceeded %d dispatches (%d seats × %d rounds)",
|
||||
dispatchCap, sess.RosterSize(), autoCombatRoundCap)
|
||||
}
|
||||
|
||||
// actingSeatForAutopilot names the seat autoDriveCombat must act as next. The
|
||||
// session it reads has already been settled by the command that parked it here,
|
||||
// so it is sitting on a live player's turn; a session that is not is a bug in
|
||||
// the engine, not a state the autopilot should paper over by spinning to the
|
||||
// round cap.
|
||||
func (p *AdventurePlugin) actingSeatForAutopilot(sess *CombatSession) (int, error) {
|
||||
players, enemy, err := p.partyCombatantsForSession(sess)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("rebuild party fight: %w", err)
|
||||
}
|
||||
seat, waiting := actingSeat(sess, players, enemy)
|
||||
if !waiting {
|
||||
return 0, fmt.Errorf("combat session %s: active but waiting on nobody (phase %q)",
|
||||
sess.SessionID, sess.Phase)
|
||||
}
|
||||
return seat, nil
|
||||
}
|
||||
|
||||
// simShortRestHPPct is the HP-percentage threshold below which the sim
|
||||
|
||||
Reference in New Issue
Block a user