nba


today i added a draft a draft clock free agency standings and trades

import random
import math

class Player:
    def __init__(self, name, overall, age, position):
        self.name = name
        self.overall = overall
        self.age = age
        self.position = position
        self.team = None
        # Logic: Minimum $1.1M, increases by $1.5M for every point over 60 Overall
        self.asking_salary = max(1100000, (overall - 60) * 1500000)

class Team:
    def __init__(self, name, budget):
        self.name = name
        self.budget = budget
        self.roster = []

    def can_afford(self, salary):
        return self.budget >= salary

    def sign_player(self, player):
        if self.can_afford(player.asking_salary):
            self.budget -= player.asking_salary
            player.team = self.name
            self.roster.append(player)
            return True
        return False

# 1. Setup Sample Data
players = [
    Player("Luka Magic", 97, 25, "PG"),
    Player("Big Ticket", 90, 28, "C"),
    Player("3-Point King", 88, 32, "SG"),
    Player("Rookie Star", 78, 20, "SF"),
    Player("Vet Min", 72, 35, "PF")
]

teams = [
    Team("Lakers", 50_000_000),
    Team("Knicks", 45_000_000),
    Team("Spurs", 65_000_000)
]

# 2. Simulation Logic
def simulate_free_agency(player_list, team_list):
    # Sort by overall so stars sign first
    player_list.sort(key=lambda x: x.overall, reverse=True)
    
    for player in player_list:
        # Find teams that can afford the player
        suitors = [t for t in team_list if t.can_afford(player.asking_salary)]
        
        if suitors:
            # Player chooses the team with the most cap space (simplified interest)
            best_offer_team = max(suitors, key=lambda t: t.budget)
            if best_offer_team.sign_player(player):
                print(f"✅ {player.name} ({player.overall} OVR) signed with {best_offer_team.name} for ${player.asking_salary:,}")
        else:
            print(f"❌ {player.name} remains a Free Agent (Asking price: ${player.asking_salary:,})")

# Run the sim
simulate_free_agency(players, teams)

this will commed after the draft and if a team signs a big player like say if  LeBron James signs with the cavs it will say the detalls for example:

as u can see this is after 1 year simulation and how Luka signed with spuers for 55,500,000 (witch is a lot of money) (in my option) but it will show u the big offseason moves

it shows the actual games


Leave a Reply

Your email address will not be published. Required fields are marked *