package steam

import (
    "fmt"

    "zlh-agent/internal/state"
)

func InstallTerraria(cfg state.Config) error {
    dir, err := EnsureGameDir(cfg)
    if err != nil {
        return err
    }

    login := SteamLoginArgs(cfg)
    appID := "105600" // Terraria Dedicated

    args := []string{
        "+login", login,
        "+force_install_dir", dir,
        "+app_update", appID, "validate",
        "+quit",
    }

    if err := RunSteamCMD(args...); err != nil {
        return fmt.Errorf("terraria install failed: %w", err)
    }

    return nil
}
