Get the next building upgrade in monopoly

Each street in Monopoly is comprised of 2 or 3 different properties.

When a user upgrades a street, it will build 1 of 3 buildings on the appropriate property.

House – least valuable, will build this by default, max 16 per property.

Hotel – costs 3 houses to build. Max 8 per property.

Sky scraper – most valuable, costs 2 hotels to build, max 1 per property.

Each type of building needs to be spread evenly. For example if there’s 2 properties, the order of upgrades would be:

House on property 1

House on property 2

House on property 1

House on property 2

House on property 1

House on property 2

Hotel on property 1 (also delete 3 houses)

Hotel on property 2 (also delete 3 houses)

House on property 1

The only time there would be more than 3 houses on a property is after the skyscrapers and hotels are both maxed out, then the houses would stack up until 16 on each property.

I need a function that will calculate this. The parameters of this function are numOfProperties, numOfSkyScrapers, numOfHotels, numOfHouses and it needs to output which building should be next.

This function cannot use looping. I think the mod operator would be useful.

My code below works when there is 1 property. But with 2 properties, upgrade 8 is a house when it should be a hotel. It’s because after the first hotel upgrade, it deletes that properties 3 houses, so the total number is 3 again and builds another house.

I’m not sure how I can make this dynamic and work for all amount of properties

def next_building(num_properties, num_houses, num_hotels, num_skyscrapers):

# Maximum limits per property

max_houses_per_property = 16

max_hotels_per_property = 8

max_skyscrapers_per_property = 1



# Conversion ratios

houses_per_hotel = 3

hotels_per_skyscraper = 2



# Calculate the number of buildings per property

houses_per_property = num_houses // num_properties

hotels_per_property = num_hotels // num_properties

skyscrapers_per_property = num_skyscrapers // num_properties



# Calculate remainders to help balance the properties

houses_remainder = num_houses % num_properties

hotels_remainder = num_hotels % num_properties

skyscrapers_remainder = num_skyscrapers % num_properties



# Determine the next building to construct

if num_hotels >= hotels_per_skyscraper and (skyscrapers_per_property < max_skyscrapers_per_property):

    # Check if there are enough hotels for the next skyscraper

    return "skyscraper"

if num_houses >= houses_per_hotel and (hotels_per_property < max_hotels_per_property):

    # Check if there are enough houses for the next hotel

    return "hotel"

if houses_per_property < max_houses_per_property:

    return "house"



return "No building needed"

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật