Skip to content

Commit

Permalink
Add bonus supply filler item
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziktofel committed Dec 12, 2024
1 parent 8805e88 commit a60cd0d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
9 changes: 7 additions & 2 deletions worlds/sc2/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ def __init__(self, *args, **kwargs) -> None:
self.minerals_per_item: int = 15 # For backwards compat with games generated pre-0.4.5
self.vespene_per_item: int = 15 # For backwards compat with games generated pre-0.4.5
self.starting_supply_per_item: int = 2 # For backwards compat with games generated pre-0.4.5
self.maximum_supply_per_item: int = 2
self.nova_covert_ops_only = False
self.kerrigan_levels_per_mission_completed = 0
self.trade_enabled: int = EnableVoidTrade.default
Expand Down Expand Up @@ -777,6 +778,7 @@ def on_package(self, cmd: str, args: dict) -> None:
self.minerals_per_item = args["slot_data"].get("minerals_per_item", 15)
self.vespene_per_item = args["slot_data"].get("vespene_per_item", 15)
self.starting_supply_per_item = args["slot_data"].get("starting_supply_per_item", 2)
self.maximum_supply_per_item = args["slot_data"].get("maximum_supply_per_item", 2)
self.nova_covert_ops_only = args["slot_data"].get("nova_covert_ops_only", False)
self.trade_enabled = args["slot_data"].get("enable_void_trade", EnableVoidTrade.option_false)

Expand Down Expand Up @@ -1272,6 +1274,8 @@ def calculate_items(ctx: SC2Context) -> typing.Dict[SC2Race, typing.List[int]]:
accumulators[item_data.race][item_data.type.flag_word] += ctx.vespene_per_item
elif name == item_names.STARTING_SUPPLY:
accumulators[item_data.race][item_data.type.flag_word] += ctx.starting_supply_per_item
elif name == item_names.MAX_SUPPLY:
accumulators[item_data.race][item_data.type.flag_word] += ctx.maximum_supply_per_item
else:
accumulators[item_data.race][item_data.type.flag_word] += item_data.number

Expand Down Expand Up @@ -1694,10 +1698,11 @@ async def update_colors(self):
self.ctx.pending_color_update = False

async def update_resources(self, current_items):
await self.chat_send("?GiveResources {} {} {}".format(
await self.chat_send("?GiveResources {} {} {} {}".format(
current_items[SC2Race.ANY][get_item_flag_word(item_names.STARTING_MINERALS)],
current_items[SC2Race.ANY][get_item_flag_word(item_names.STARTING_VESPENE)],
current_items[SC2Race.ANY][get_item_flag_word(item_names.STARTING_SUPPLY)]
current_items[SC2Race.ANY][get_item_flag_word(item_names.STARTING_SUPPLY)],
current_items[SC2Race.ANY][get_item_flag_word(item_names.MAX_SUPPLY)]
))

async def update_terran_tech(self, current_items):
Expand Down
1 change: 1 addition & 0 deletions worlds/sc2/item/item_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,7 @@
STARTING_MINERALS = "Additional Starting Minerals"
STARTING_VESPENE = "Additional Starting Vespene"
STARTING_SUPPLY = "Additional Starting Supply"
MAX_SUPPLY = "Additional Maximum Supply"
NOTHING = "Nothing"

# Deprecated
Expand Down
5 changes: 5 additions & 0 deletions worlds/sc2/item/item_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class FactionlessItemType(ItemTypeEnum):
Supply = "Supply", 2
Nothing = "Nothing Group", 4
Deprecated = "Deprecated", 5
MaxSupply = "Max Supply", 6
Keys = "Keys", -1


Expand Down Expand Up @@ -1071,6 +1072,9 @@ def get_full_item_list():
item_names.NOTHING:
ItemData(803 + SC2WOL_ITEM_ID_OFFSET, FactionlessItemType.Nothing, -1, SC2Race.ANY, quantity=0,
classification=ItemClassification.trap),
item_names.MAX_SUPPLY:
ItemData(804 + SC2WOL_ITEM_ID_OFFSET, FactionlessItemType.MaxSupply, -1, SC2Race.ANY, quantity=0,
classification=ItemClassification.filler),

# Nova gear
item_names.NOVA_GHOST_VISOR:
Expand Down Expand Up @@ -2128,6 +2132,7 @@ def get_item_table():
item_names.STARTING_MINERALS,
item_names.STARTING_VESPENE,
item_names.STARTING_SUPPLY,
item_names.MAX_SUPPLY,
)

# Defense rating table
Expand Down
12 changes: 12 additions & 0 deletions worlds/sc2/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,17 @@ class StartingSupplyPerItem(Range):
default = 2


class MaximumSupplyPerItem(Range):
"""
Configures how much maximum supply per is given per item.
"""
display_name = "Maximum Supply Per Item"
range_start = 0
range_end = 16
default = 2



@dataclass
class Starcraft2Options(PerGameCommonOptions):
start_inventory: Sc2StartInventory
Expand Down Expand Up @@ -1084,6 +1095,7 @@ class Starcraft2Options(PerGameCommonOptions):
minerals_per_item: MineralsPerItem
vespene_per_item: VespenePerItem
starting_supply_per_item: StartingSupplyPerItem
maximum_supply_per_item: MaximumSupplyPerItem

custom_mission_order: CustomMissionOrder

Expand Down

0 comments on commit a60cd0d

Please sign in to comment.