Skip to content

DLCQuest: progression coin bundle update #2785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 62 additions & 33 deletions worlds/dlcquest/Items.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class Group(enum.Enum):
Item = enum.auto()
Coin = enum.auto()
Trap = enum.auto()
Twice = enum.auto()
Piece = enum.auto()



@dataclass(frozen=True)
Expand Down Expand Up @@ -85,7 +88,7 @@ def initialize_groups():
initialize_groups()


def create_trap_items(world, World_Options: Options.DLCQuestOptions, trap_needed: int, random: Random) -> List[Item]:
def create_trap_items(world, world_options: Options.DLCQuestOptions, trap_needed: int, random: Random) -> List[Item]:
traps = []
for i in range(trap_needed):
trap = random.choice(items_by_group[Group.Trap])
Expand All @@ -94,40 +97,66 @@ def create_trap_items(world, World_Options: Options.DLCQuestOptions, trap_needed
return traps


def create_items(world, World_Options: Options.DLCQuestOptions, locations_count: int, random: Random):
def create_items(world, world_options: Options.DLCQuestOptions, locations_count: int, random: Random):
created_items = []
if World_Options.campaign == Options.Campaign.option_basic or World_Options.campaign == Options.Campaign.option_both:
for item in items_by_group[Group.DLCQuest]:
if item.has_any_group(Group.DLC):
created_items.append(world.create_item(item))
if item.has_any_group(Group.Item) and World_Options.item_shuffle == Options.ItemShuffle.option_shuffled:
if world_options.campaign == Options.Campaign.option_basic or world_options.campaign == Options.Campaign.option_both:
create_items_basic(world_options, created_items, world)

if (world_options.campaign == Options.Campaign.option_live_freemium_or_die or
world_options.campaign == Options.Campaign.option_both):
create_items_lfod(world_options, created_items, world)

trap_items = create_trap_items(world, world_options, locations_count - len(created_items), random)
created_items += trap_items

return created_items


def create_items_lfod(world_options, created_items, world):
for item in items_by_group[Group.Freemium]:
if item.has_any_group(Group.DLC):
created_items.append(world.create_item(item))
if item.has_any_group(Group.Item) and world_options.item_shuffle == Options.ItemShuffle.option_shuffled:
created_items.append(world.create_item(item))
if item.has_any_group(Group.Twice):
created_items.append(world.create_item(item))
if World_Options.coinsanity == Options.CoinSanity.option_coin:
coin_bundle_needed = math.floor(825 / World_Options.coinbundlequantity)
for item in items_by_group[Group.DLCQuest]:
if item.has_any_group(Group.Coin):
for i in range(coin_bundle_needed):
created_items.append(world.create_item(item))
if 825 % World_Options.coinbundlequantity != 0:
created_items.append(world.create_item(item))

if (World_Options.campaign == Options.Campaign.option_live_freemium_or_die or
World_Options.campaign == Options.Campaign.option_both):
for item in items_by_group[Group.Freemium]:
if item.has_any_group(Group.DLC):
if world_options.coinsanity == Options.CoinSanity.option_coin:
if world_options.coinbundlequantity == -1:
create_coin_piece(created_items, world, 889, 200, Group.Freemium)
return
create_coin(world_options, created_items, world, 889, 200, Group.Freemium)


def create_items_basic(world_options, created_items, world):
for item in items_by_group[Group.DLCQuest]:
if item.has_any_group(Group.DLC):
created_items.append(world.create_item(item))
if item.has_any_group(Group.Item) and world_options.item_shuffle == Options.ItemShuffle.option_shuffled:
created_items.append(world.create_item(item))
if item.has_any_group(Group.Twice):
created_items.append(world.create_item(item))
if item.has_any_group(Group.Item) and World_Options.item_shuffle == Options.ItemShuffle.option_shuffled:
if world_options.coinsanity == Options.CoinSanity.option_coin:
if world_options.coinbundlequantity == -1:
create_coin_piece(created_items, world, 825, 250, Group.DLCQuest)
return
create_coin(world_options, created_items, world, 825, 250, Group.DLCQuest)


def create_coin(world_options, created_items, world, total_coins, required_coins, group):
coin_bundle_required = math.ceil(required_coins / world_options.coinbundlequantity)
coin_bundle_useful = math.ceil((total_coins - coin_bundle_required * world_options.coinbundlequantity) / world_options.coinbundlequantity)
for item in items_by_group[group]:
if item.has_any_group(Group.Coin):
for i in range(coin_bundle_required):
created_items.append(world.create_item(item))
if World_Options.coinsanity == Options.CoinSanity.option_coin:
coin_bundle_needed = math.floor(889 / World_Options.coinbundlequantity)
for item in items_by_group[Group.Freemium]:
if item.has_any_group(Group.Coin):
for i in range(coin_bundle_needed):
created_items.append(world.create_item(item))
if 889 % World_Options.coinbundlequantity != 0:
created_items.append(world.create_item(item))

trap_items = create_trap_items(world, World_Options, locations_count - len(created_items), random)
created_items += trap_items
for i in range(coin_bundle_useful):
created_items.append(DLCQuestItem(item.name, ItemClassification.useful, item.code, world.player))

return created_items

def create_coin_piece(created_items, world, total_coins, required_coins, group):
for item in items_by_group[group]:
if item.has_any_group(Group.Piece):
for i in range(required_coins*10):
created_items.append(world.create_item(item))
for i in range((total_coins - required_coins) * 10):
created_items.append(DLCQuestItem(item.name, ItemClassification.useful, item.code, world.player))
11 changes: 11 additions & 0 deletions worlds/dlcquest/Locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,14 @@ class DLCQuestLocation(Location):
for i in range(1, 890):
item_coin_freemium = f"Live Freemium or Die: {i} Coin"
location_table[item_coin_freemium] = offset + 825 + 58 + i


offset_special = 3829200000

for i in range(1, 8251):
item_coin_piece = f"DLC Quest: {i / 10} Coin Piece"
location_table[item_coin_piece] = offset_special + i

for i in range(1, 8891):
item_coin_piece_freemium = f"Live Freemium or Die: {i / 10} Coin Piece"
location_table[item_coin_piece_freemium] = offset_special + 8250 + i
9 changes: 9 additions & 0 deletions worlds/dlcquest/Options.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from dataclasses import dataclass
import datetime

from Options import Choice, DeathLink, NamedRange, PerGameCommonOptions

Expand Down Expand Up @@ -48,6 +49,14 @@ class CoinSanityRange(NamedRange):
"normal": 20,
"high": 50,
}
if datetime.datetime.today().month == 4:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work if someone starts a website on march 30th, and then goes to the settings page again in april without restarting the server?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will test this tonight

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did test I don't think it is but I am not sure if I can do anything

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So more test and the one for factorio doesn't change so I don't know what happen but maybe berzerker reset the server for Aprils

if datetime.datetime.today().day == 1:
special_range_names["surprise"] =-1
else:
special_range_names["coin piece"] =-1





class EndingChoice(Choice):
Expand Down
13 changes: 13 additions & 0 deletions worlds/dlcquest/Regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,22 @@ def create_coinsanity_locations_lfod(has_coinsanity: bool, coin_bundle_size: int
def create_coinsanity_locations(has_coinsanity: bool, coin_bundle_size: int, player: int, region: Region, last_coin_number: int, campaign_prefix: str):
if not has_coinsanity:
return
if coin_bundle_size == -1:
create_coinsanity_piece_locations(player, region, last_coin_number, campaign_prefix)
return


coin_bundle_needed = math.ceil(last_coin_number / coin_bundle_size)
for i in range(1, coin_bundle_needed + 1):
number_coins = min(last_coin_number, coin_bundle_size * i)
item_coin = f"{campaign_prefix}: {number_coins} Coin"
region.locations += [DLCQuestLocation(player, item_coin, location_table[item_coin], region)]


def create_coinsanity_piece_locations(player: int, region: Region, total_coin: int, campaign_prefix:str):

pieces_needed = total_coin * 10
for i in range(1, pieces_needed + 1):
number_piece = i / 10
item_piece = f"{campaign_prefix}: {number_piece} Coin Piece"
region.locations += [DLCQuestLocation(player, item_piece, location_table[item_piece], region)]
Loading