mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-15 00:32:40 +00:00
N3 widened the combat *roster* from 1 to N but never widened the action model,
the scaling model, or the test net to match. Building the hireable companion
walked into all three. Only one of the four defects found was the companion's;
the rest have been live in prod for every human party since N3.
The party golden did not exist (§5)
Solo combat is pinned exhaustively (7468 lines); the entire N-body layer had
nothing. That is why a healer class that cannot heal shipped without a test
going red. Adds party_characterization.golden (9 scenarios x 5 seeds, incl.
weak and dying seats) and TestPartyCharacterization_OneSeatIsStillSolo, so the
N-body path can never quietly stop being a superset of the balance corpus.
Regenerate only on purpose: -update-party.
No action could target another seat (§1)
Every heal in the engine was self-scoped. A party cleric could not put one hit
point on a friend. Adds turnActionEffect.AllyHeal/AllySeat, `!cast <spell>
@user` and `--target @user` -- the latter has been advertised in !help and
silently swallowed by parseCombatCast since SP2 ("reserved for SP3"). The auto
picker uses it too (simPickAllyHeal), so away-players and engine-driven healers
behave like competent ones. It will not raise the dead.
Corpses kept buffing the boss (§2b)
enemyActionsThisRound counted len(st.actors), dead included -- so a party that
lost a member kept paying for them, and the survivor faced a boss still swinging
at two-player cadence, alone. A death spiral with the arrow pointing the wrong
way. Now counts livingActors(). Party golden moved deliberately for this.
An engine-driven seat was a bool any command could clear (§3)
autoDriveCombat drives a party by dispatching each seat's turn AS that seat, so
a companion's own auto-played move arrived at beginCombatTurn looking like a
player returning to the keyboard and cleared the latch that was moving him. He
then stood in the fight doing nothing while the boss he had inflated killed
everyone. ActorStatuses.EngineDriven is now a persisted seat property that no
command clears, and the driver calls driveEngineSeat instead of impersonating.
"The party" could be empty (§4)
A solo expedition has no expedition_party rows, so asking the roster who was in
the party answered "nobody" -- and every caller fell back to something plausible.
That is how the companion got hired at level 1 for exactly the player the feature
exists for. expeditionParty()/partyHumans() always include the owner.
The companion himself (!expedition hire [class] / !expedition dismiss)
Day 1, leader only, costs coins, role-fills the gap, globally exclusive. He is an
NPC seat and must never become a player: no player_meta, no dnd_character, no
inventory, no DM room -- mint him a player_meta row and
ensureDnDCharacterForCombat will auto-build the news bot a real character, and
he starts appearing in the graveyard and filing death notices about himself.
Mail and seats are different sets: he fights, he does not get written to.
Measured on millenia, n=750/arm. Before these fixes he was -28pp -- worse than no
companion at all. After: solo 48.5% -> 63.9% clear (+15.3pp), with +28.0pp for
trailing players and +2.0pp for leaders. Help, never a carry.
The solo golden is byte-identical throughout: solo combat provably did not move,
and the balance corpus is intact.
Known gap: the companion cannot cast (castActionForSeat loads a sheet from the DB
and he has none by design), so a hired Cleric is still just a bad fighter.
Claude-Session: https://claude.ai/code/session_01J5SQZWoLmL3M3mw2XmHHdy
116 lines
4.2 KiB
Go
116 lines
4.2 KiB
Go
package plugin
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// The player-facing surface for hiring Pete.
|
|
//
|
|
// !expedition hire [class] (leader, Day 1 — auto-fills the missing role)
|
|
// !expedition dismiss (leader — sends him home, no refund)
|
|
//
|
|
// He is hired on Day 1 like any other companion, because a body that materializes
|
|
// three rooms in is not a party member, it is a cheat code. See
|
|
// adventure_companion.go for why he is an NPC seat and not a player.
|
|
|
|
// expeditionCmdHire brings the correspondent along.
|
|
func (p *AdventurePlugin) expeditionCmdHire(ctx MessageContext, rest string) error {
|
|
exp, isLeader, err := activeExpeditionFor(ctx.Sender)
|
|
if err != nil {
|
|
return p.SendDM(ctx.Sender, "Couldn't read expedition state: "+err.Error())
|
|
}
|
|
if exp == nil {
|
|
return p.SendDM(ctx.Sender, "No active expedition. `!expedition start <zone>` first.")
|
|
}
|
|
if !isLeader {
|
|
return p.SendDM(ctx.Sender, "Only the party leader hires. You're along for the ride.")
|
|
}
|
|
if !inviteWindowOpen(exp) {
|
|
return p.SendDM(ctx.Sender,
|
|
"This expedition has already set off — Pete joins on Day 1 or not at all.")
|
|
}
|
|
if companionSeated(exp.ID) {
|
|
return p.SendDM(ctx.Sender, "Pete's already with you. `!expedition party` to see the roster.")
|
|
}
|
|
if p.euro == nil {
|
|
return p.SendDM(ctx.Sender, "Coin system unavailable — try again later.")
|
|
}
|
|
|
|
zone := zoneOrFallback(exp.ZoneID)
|
|
level := companionPartyLevel(exp.ID)
|
|
|
|
class, explicit := parseCompanionClass(rest)
|
|
if !explicit {
|
|
if arg := strings.TrimSpace(rest); arg != "" && !strings.EqualFold(arg, "auto") {
|
|
return p.SendDM(ctx.Sender, fmt.Sprintf(
|
|
"Don't know the class %q. Name one, or just `!expedition hire` and he'll fill whatever you're missing.", arg))
|
|
}
|
|
class = companionRoleFill(companionPartyClasses(exp.ID))
|
|
}
|
|
|
|
cost := float64(companionHireCost(level, zone.Tier))
|
|
if balance := p.euro.GetBalance(ctx.Sender); balance < cost {
|
|
return p.SendDM(ctx.Sender, fmt.Sprintf(
|
|
"Pete doesn't work for free. His fee for **%s** is **%d** — you have **%.0f**.",
|
|
zone.Display, int(cost), balance))
|
|
}
|
|
if !p.euro.Debit(ctx.Sender, cost, "expedition: hired Pete") {
|
|
return p.SendDM(ctx.Sender, "Couldn't debit Pete's fee (try again).")
|
|
}
|
|
|
|
if err := hireCompanion(exp.ID, class, level); err != nil {
|
|
p.euro.Credit(ctx.Sender, cost, "expedition: Pete hire refund")
|
|
return p.SendDM(ctx.Sender, companionRefusalText(err))
|
|
}
|
|
|
|
emitCompanionHireFact(ctx.Sender, class, level, zone)
|
|
|
|
ci, _ := classInfo(class)
|
|
filled := "You asked for a " + ci.Display + "."
|
|
if !explicit {
|
|
filled = "He's filling the hole in your roster — **" + ci.Display + "**."
|
|
}
|
|
return p.SendDM(ctx.Sender, fmt.Sprintf(
|
|
"📝 **Pete's coming with you into %s.** %s He's **level %d**, and his fee was **%d**.\n\n"+
|
|
"He fights his own turns — you don't command him. He takes no loot and no XP; he's here for the story.\n"+
|
|
"`!expedition dismiss` sends him home (no refund — he's already packed).",
|
|
zone.Display, filled, level, int(cost)))
|
|
}
|
|
|
|
// expeditionCmdDismiss sends him home mid-run.
|
|
func (p *AdventurePlugin) expeditionCmdDismiss(ctx MessageContext) error {
|
|
exp, isLeader, err := activeExpeditionFor(ctx.Sender)
|
|
if err != nil {
|
|
return p.SendDM(ctx.Sender, "Couldn't read expedition state: "+err.Error())
|
|
}
|
|
if exp == nil {
|
|
return p.SendDM(ctx.Sender, "No active expedition.")
|
|
}
|
|
if !isLeader {
|
|
return p.SendDM(ctx.Sender, "Only the party leader can dismiss him.")
|
|
}
|
|
if err := dismissCompanion(exp.ID); err != nil {
|
|
return p.SendDM(ctx.Sender, companionRefusalText(err))
|
|
}
|
|
return p.SendDM(ctx.Sender,
|
|
"📝 **Pete heads back.** He got what he came for. The fee stays spent.")
|
|
}
|
|
|
|
// companionRefusalText turns the companion layer's sentinel errors into copy.
|
|
func companionRefusalText(err error) string {
|
|
switch {
|
|
case errors.Is(err, ErrCompanionAlreadyHired):
|
|
return "Pete's already with you."
|
|
case errors.Is(err, ErrCompanionOnAssignment):
|
|
return "Pete's out on assignment with another party. He'll be back."
|
|
case errors.Is(err, ErrCompanionNotHired):
|
|
return "Pete isn't with you."
|
|
case errors.Is(err, ErrPartyFull):
|
|
return "No room — your party's full. Someone has to `!expedition leave` first."
|
|
default:
|
|
return "Couldn't hire Pete: " + err.Error()
|
|
}
|
|
}
|