import random
from dataclasses import dataclass, field
from typing import Self


@dataclass
class _Base:
    id: int
    level: int = 1


@dataclass
class Hero(_Base):
    soliders: list["Solider"] = field(default_factory=list)

    def level_up(self: Self) -> Self:
        self.level += 1
        return self


@dataclass
class Solider(_Base):
    def follow(self: Self, hero: Hero) -> None:
        print(f"Иду за героем {hero.id}")


def main() -> None:
    amount_of_players = 2
    heroes = [Hero(i) for i in range(2)]
    for i in range(amount_of_players, amount_of_players * 3 + 1):
        solider = Solider(i)
        random.choice(heroes).soliders.append(solider)

    amount_of_soliders = [len(hero.soliders) for hero in heroes]
    winner_id = amount_of_soliders.index(max(amount_of_soliders))
    winner = heroes[winner_id]
    loser_id = amount_of_soliders.index(max(amount_of_soliders))
    loser = heroes[loser_id]
    winner.level_up()
    print(winner)
    random.choice(loser.soliders).follow(winner)


if __name__ == "__main__":
    main()
