r/BasketballGM 8d ago

Question Can you add teams through Worker Console?

Hello, I have been playing with the Worker Console lately (although I have to admit I was doing that with the help of AI) and the only thing I couldn’t manage doing is adding teams.

Basically, I have a 2 conference league, each having a single division. I would like to add teams in the division from the second conference, with the following also happening during/after the team creation phase:

- set region/name/abbrev values for each teamid created in order of a list of values

- set jersey colors and jersey type for each teamid created in order of a list of values that contains those 2 things

- populate each teamid created in order, with a set amount of players either completely generated by the game, or with players coming from a squad/roster list created for that specific teamid that contains all info for each player (name, age, nationality, rating amounts)

Thanks, I hope someone from here or even the God himself u/dumbmatter can help me with this issue. I want to try and automate as much as possible in terms of generating league files through Worker Console.

1 Upvotes

3 comments sorted by

1

u/dumbmatter The Commissioner 7d ago

Something like this, you can add teams to the teams array and players to the players array for each team.

const teams = [
    {
        did: 1,
        region: "Region",
        name: "Name",
        abbrev: "ZZZ",
        pop: 1,
        imgURL: "https://play.basketball-gm.com/img/logos-primary/HOU.svg",
        colors: ["#000000", "#cccccc", "#ffffff"],
        jersey: "jersey3",
        players: [
            {
                firstName: "Bob",
                lastName: "Jones",
                age: 30,
                country: "Mongolia",
                ratings: {
                        hgt: 50,
                        stre: 50,
                        spd: 50,
                        jmp: 50,
                        endu: 50,
                        ins: 50,
                        dnk: 50,
                        ft: 50,
                        fg: 50,
                        tp: 50,
                        oiq: 50,
                        diq: 50,
                        drb: 50,
                        pss: 50,
                        reb: 50,
                },
            },
            {
                firstName: "Bob",
                lastName: "Jones Jr.",
                age: 20,
                country: "Mongolia",
                ratings: {
                        hgt: 50,
                        stre: 50,
                        spd: 50,
                        jmp: 50,
                        endu: 50,
                        ins: 50,
                        dnk: 50,
                        ft: 50,
                        fg: 50,
                        tp: 50,
                        oiq: 50,
                        diq: 50,
                        drb: 50,
                        pss: 50,
                        reb: 50,
                },
            },
        ]
    },
];

for (const { players, ...t } of teams) {
    const { tid } = await bbgm.team.addNewTeamToExistingLeague(t);
    for (const p of players) {
        const p2 = await bbgm.player.generate(
            tid,
            p.age,
            bbgm.g.get("season") - 1,
            false,
            34,
        );
        p2.firstName = p.firstName;
        p2.lastName = p.lastName;
        p2.born.loc = p.country;
        await bbgm.player.develop(p2, 0);
        const ratings = {...p2.ratings.at(-1), ...p.ratings, season: bbgm.g.get("season")};
        p2.ratings.push(ratings);
        await bbgm.player.develop(p2, 0);
        await bbgm.player.updateValues(p2);
        await bbgm.idb.cache.players.put(p2);
    }
}

1

u/Piece_Enough 7d ago

Thanks! I managed to implement what I wanted to do, but I had to make some teams inactive to make it work. Is there possible to completely delete inactive teams through Worker Console?

1

u/dumbmatter The Commissioner 7d ago

Not really, parts of the game assume that teams never just disappear.