babalae/better-genshin-impact · error · PartySetupFailedException

切换角色:未找到 {rebuildStartSlot} 号位的换下按钮

Error message

切换角色:未找到 {rebuildStartSlot} 号位的换下按钮

What it means

Thrown during the suffix-rebuild clearing phase: after clicking the rebuildStartSlot team slot and waiting 500ms, TryClickText(page, "换下", Rect1080(382,994,87,51)) cannot find the localized '换下' (remove) button, so the role cannot be removed to make room.

Source

Thrown at BetterGenshinImpact/GameTask/Common/Job/SwitchCharacterStateMachineTask.cs:620

            if (firstMismatchSlot == null)
            {
                throw new PartySetupFailedException("切换角色:换下错位角色后无法确定需要补回的槽位");
            }

            StartSuffixRebuild(firstMismatchSlot.Value);
            _prepareSuffixRebuildAfterRemoval = false;
        }

        if (_rebuildStartSlot is int rebuildStartSlot)
        {
            var minimumRetainedCount = Math.Max(1, rebuildStartSlot - 1);
            if (_isRebuildClearing && _currentTeamSlots.Count > minimumRetainedCount)
            {
                ClickFixedTeamSlot(rebuildStartSlot);
                await Delay(500, _ct);
                if (!TryClickText(page, "换下", Rect1080(382, 994, 87, 51)))
                {
                    throw new PartySetupFailedException($"切换角色:未找到 {rebuildStartSlot} 号位的换下按钮");
                }

                await WaitForRoleRemoved(rebuildStartSlot, _ct);
                _expectedTeamCount--;
                _teamSnapshotDirty = true;
                return StateHandlerResult.Wait;
            }

            _isRebuildClearing = false;

            if (_rebuildRoles.Count > 0)
            {
                var refillRole = _rebuildRoles.Peek();
                if (_roleSwitchAttempts.GetValueOrDefault(refillRole.Slot) >= MaxRoleSwitchAttempts)
                {
                    throw new PartySetupFailedException(
                        $"切换角色:{refillRole.Slot} 号位连续 {MaxRoleSwitchAttempts} 次未能补回 {refillRole.Name}");
                }

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Re-click the slot and re-search '换下' once more after a longer delay before failing.
  2. Confirm the '换下' string and the Rect1080(382,994,87,51) region match the current game locale/scale.
  3. Verify ClickFixedTeamSlot actually selects a populated slot before searching for the remove button.
  4. If the slot is already empty (count already at minimum), skip clearing instead of searching for the button.

Example fix

// before
ClickFixedTeamSlot(rebuildStartSlot);
await Delay(500, _ct);
if (!TryClickText(page, "换下", Rect1080(382, 994, 87, 51)))
{
    throw new PartySetupFailedException($"切换角色:未找到 {rebuildStartSlot} 号位的换下按钮");
}

// after: one retry with a longer wait
ClickFixedTeamSlot(rebuildStartSlot);
await Delay(500, _ct);
if (!TryClickText(page, "换下", Rect1080(382, 994, 87, 51)))
{
    await Delay(500, _ct);
    ClickFixedTeamSlot(rebuildStartSlot);
    await Delay(500, _ct);
}
if (!TryClickText(page, "换下", Rect1080(382, 994, 87, 51)))
    throw new PartySetupFailedException($"切换角色:未找到 {rebuildStartSlot} 号位的换下按钮");
Defensive patterns

Strategy: retry

Validate before calling

null

Type guard

null

Try / catch

try { await sm.Start(s1, s2, s3, s4, usePhysicalSlots, ct); }
catch (PartySetupFailedException e) when (e.Message.Contains("换下按钮"))
{ /* re-click the slot after a longer delay, verify locale, then retry */ }

Prevention

When it happens

Trigger: _isRebuildClearing is true, _currentTeamSlots.Count > minimumRetainedCount, ClickFixedTeamSlot(rebuildStartSlot) is issued, but the subsequent '换下' text search inside Rect1080(382,994,87,51) fails. The slot click did not open the expected detail panel, or the button text/position differs.

Common situations: The slot click missed or opened the wrong panel (no '换下' button rendered); localization mismatch on '换下'; the 500ms wait was too short for the detail panel; resolution drift moved the button off Rect1080(382,994,87,51); the slot was already empty.

Related errors


AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13). Data as JSON: /api/errors/bf5158b40f6a251f. Report an issue: GitHub.