From 78c198b4ea2a2a546b110f73aa4dfd25e6f3d0f8 Mon Sep 17 00:00:00 2001 From: Spineraks Date: Fri, 7 Jun 2024 22:35:32 +0200 Subject: [PATCH 1/2] Update worlds/yachtdice/Items.py Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com> --- worlds/yachtdice/Items.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worlds/yachtdice/Items.py b/worlds/yachtdice/Items.py index 011aaed7fd..50ea7e1cff 100644 --- a/worlds/yachtdice/Items.py +++ b/worlds/yachtdice/Items.py @@ -111,4 +111,4 @@ item_groups = { "Category Five Distinct Dice", "Category 4&5 Full House" } -} \ No newline at end of file +} From f6fbf2221f31388d297790f729002bba5c826e3e Mon Sep 17 00:00:00 2001 From: Spineraks Date: Fri, 7 Jun 2024 22:43:19 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com> --- worlds/yachtdice/Locations.py | 4 ++-- worlds/yachtdice/Options.py | 25 +++++++++++++------------ worlds/yachtdice/Rules.py | 7 ++++--- worlds/yachtdice/__init__.py | 26 +++++++++++++------------- worlds/yachtdice/docs/en_Yacht Dice.md | 4 ++-- worlds/yachtdice/docs/setup_en.md | 6 +++--- 6 files changed, 37 insertions(+), 35 deletions(-) diff --git a/worlds/yachtdice/Locations.py b/worlds/yachtdice/Locations.py index 65612c6236..624a450294 100644 --- a/worlds/yachtdice/Locations.py +++ b/worlds/yachtdice/Locations.py @@ -42,8 +42,8 @@ def ini_locations(goal_score, max_score, num_locs, dif): hiscore = 0 for i in range(num_locs - 1): perc = (i/num_locs) - curscore = int( 1 + (perc ** scaling) * (max_score-2) ) - if(curscore <= hiscore): + curscore = int(1 + (perc ** scaling) * (max_score-2)) + if curscore <= hiscore: curscore = hiscore + 1 hiscore = curscore scores += [curscore] diff --git a/worlds/yachtdice/Options.py b/worlds/yachtdice/Options.py index d1ef8cd738..abd9cff2cd 100644 --- a/worlds/yachtdice/Options.py +++ b/worlds/yachtdice/Options.py @@ -1,9 +1,9 @@ from Options import Choice, Range, PerGameCommonOptions from dataclasses import dataclass -class gameDifficulty(Choice): +class GameDifficulty(Choice): """ - Difficulty. This setting determines how difficult the scores are to achieve. + Difficulty. This option determines how difficult the scores are to achieve. Easy: for beginners. No luck required, just roll the dice and have fun. Lower final goal. Medium: intended difficulty. If you play smart, you will finish the game without any trouble. Hard: you will need to play smart and be lucky. @@ -29,7 +29,7 @@ class scoreForLastCheck(Range): class scoreForGoal(Range): """ - This setting determines what score you need to reach to finish the game. + This option determines what score you need to reach to finish the game. It cannot be higher than the score for the last check (if it is, it is changed automatically). """ display_name = "Score for goal" @@ -56,7 +56,7 @@ class numberDiceFragmentsPerDice(Range): """ Dice can be split into fragments, gathering enough will give you an extra dice. You start with one dice, and there will always be one full dice in the pool. - The other dice are split into fragments, according to this setting. + The other dice are split into fragments, according to this option. Setting this to 1 fragment per dice just puts "Dice" objects in the pool. """ display_name = "Number of dice fragments per dice" @@ -68,7 +68,7 @@ class numberRollFragmentsPerRoll(Range): """ Rolls can be split into fragments, gathering enough will give you an extra roll. You start with one roll, and there will always be one full roll in the pool. - The other three rolls are split into fragments, according to this setting. + The other three rolls are split into fragments, according to this option. Setting this to 1 fragment per roll just puts "Roll" objects in the pool. """ display_name = "Number of roll fragments per roll" @@ -97,7 +97,7 @@ class alternativeCategories(Range): class chanceOfDice(Range): """ The item pool is always filled in such a way that you can reach a score of 1000. - Extra progressive items are added that will help you on your quest. + Extra progression items are added that will help you on your quest. You can set the weight for each extra progressive item in the following options. Of course, more dice = more points! @@ -128,7 +128,7 @@ class chanceOfFixedScoreMultiplier(Range): class chanceOfStepScoreMultiplier(Range): """ The Step Score Multiplier boosts your multiplier after every roll by 1%, and resets on sheet reset. - So, keep high scoring categories for later to get the most of them. + So, keep high scoring categories for later to get the most out of them. By default, this item is not included. It is fun however, you just need to know the above strategy. """ display_name = "Weight of adding Step Score Multiplier" @@ -158,7 +158,7 @@ class chanceOfPoints(Range): class pointsSize(Choice): """ If you choose to add points to the item pool, do you prefer many small points, - medium size, a few larger points, or a mix of them? + medium-size points, a few larger points, or a mix of them? """ display_name = "Size of points" option_small = 1 @@ -203,7 +203,7 @@ class addStoryChapters(Choice): all_of_it: fill all locations with story chapters sure: if there is space left, put in 10 story chapters. - never: do not put any story chapters, I do not like reading (but I am glad you are reading THIS!) + never: do not put any story chapters in, I do not like reading (but I am glad you are reading THIS!) """ display_name = "Extra story chapters in the pool" option_all_of_it = 1 @@ -232,8 +232,8 @@ class whichStory(Choice): class allowManual(Choice): """ Yacht Dice allows players to roll IRL dice. - By sending "manual" in the chat, a input field appears where you can type your dice rolls. - Of course we cannot check anymore if the player is playing fair. + By sending "manual" in the chat, an input field appears where you can type your dice rolls. + Of course, we cannot check anymore if the player is playing fair. Do you want to allow manual input of rolls? """ display_name = "Allow manual inputs" @@ -267,4 +267,5 @@ class YachtDiceOptions(PerGameCommonOptions): add_story_chapters: addStoryChapters which_story: whichStory - allow_manual_input: allowManual \ No newline at end of file + allow_manual_input: allowManual + \ No newline at end of file diff --git a/worlds/yachtdice/Rules.py b/worlds/yachtdice/Rules.py index e5e8e768b6..5b50c7b2ac 100644 --- a/worlds/yachtdice/Rules.py +++ b/worlds/yachtdice/Rules.py @@ -1,4 +1,4 @@ -from ..generic.Rules import set_rule +from worlds.generic.Rules import set_rule from BaseClasses import MultiWorld from .YachtWeights import yacht_weights import math @@ -129,7 +129,7 @@ def dice_simulation_strings(categories, num_dice, num_rolls, fixed_mult, step_mu categories.sort(key=lambda category: category.mean_score(num_dice, num_rolls)) #function to add two discrete distribution. - #defaultdict is a dict where you don't need to check if a id is present, you can just use += (lot faster) + #defaultdict is a dict where you don't need to check if an id is present, you can just use += (lot faster) def add_distributions(dist1, dist2): combined_dist = defaultdict(float) for val1, prob1 in dist1.items(): @@ -232,4 +232,5 @@ def set_yacht_rules(world: MultiWorld, player: int, options): # Sets rules on completion condition def set_yacht_completion_rules(world: MultiWorld, player: int): - world.completion_condition[player] = lambda state: state.has("Victory", player) \ No newline at end of file + world.completion_condition[player] = lambda state: state.has("Victory", player) + \ No newline at end of file diff --git a/worlds/yachtdice/__init__.py b/worlds/yachtdice/__init__.py index 9bcabd9dcf..dfae9033a4 100644 --- a/worlds/yachtdice/__init__.py +++ b/worlds/yachtdice/__init__.py @@ -1,12 +1,11 @@ import math -import logging from BaseClasses import Region, Entrance, Item, Tutorial, CollectionState from .Items import YachtDiceItem, item_table, item_groups from .Locations import YachtDiceLocation, all_locations, ini_locations from .Options import YachtDiceOptions from .Rules import set_yacht_rules, set_yacht_completion_rules, dice_simulation -from ..AutoWorld import World, WebWorld +from world.AutoWorld import World, WebWorld class YachtDiceWeb(WebWorld): @@ -20,6 +19,7 @@ class YachtDiceWeb(WebWorld): ["Spineraks"] )] + class YachtDiceWorld(World): """ Yacht Dice is a straightforward game, custom-made for Archipelago, @@ -51,7 +51,7 @@ class YachtDiceWorld(World): "race": self.multiworld.is_race, } - #In generate early, we fill the item-pool, then determine the number of locations, and add filler items. + # In generate early, we fill the item-pool, then determine the number of locations, and add filler items. def generate_early(self): self.itempool = [] self.precollected = [] @@ -120,7 +120,7 @@ class YachtDiceWorld(World): #if one fragment per dice, just add "Dice" objects if frags_per_dice == 1: - self.itempool += ["Dice"] * (num_of_dice-1) #minus one because one is in start inventory + self.itempool += ["Dice"] * (num_of_dice-1) # minus one because one is in start inventory else: self.itempool += ["Dice"] #always add a full dice to make generation easier (will be early) self.itempool += ["Dice Fragment"] * (frags_per_dice * (num_of_dice-2)) @@ -199,7 +199,7 @@ class YachtDiceWorld(World): weights[5] = 1 #Next, add the appropriate item. We'll slightly alter weights to avoid too many of the same item - which_item_to_add = self.multiworld.random.choices([0,1,2,3,4,5], weights = weights)[0] + which_item_to_add = self.multiworld.random.choices([0, 1, 2, 3, 4, 5], weights = weights)[0] if which_item_to_add == 0: if frags_per_dice == 1: self.itempool += ["Dice"] @@ -240,11 +240,11 @@ class YachtDiceWorld(World): self.itempool += ["1 Point"] extra_points_added += 1 weights[5] /= 1.01 - elif c==1: + elif c == 1: self.itempool += ["10 Points"] extra_points_added += 10 weights[5] /= 1.1 - elif c==2: + elif c == 2: self.itempool += ["100 Points"] extra_points_added += 100 weights[5] /= 2 @@ -256,11 +256,11 @@ class YachtDiceWorld(World): #count the number of locations in the game. already_items = len(self.itempool) + self.extra_plando_items + 1 #+1 because of Victory item - #We need to add more filler/useful items if there are many items in the pool to guarantee succesful generation + #We need to add more filler/useful items if there are many items in the pool to guarantee successful generation extra_locations_needed += (already_items - 45) // 15 self.number_of_locations = already_items + extra_locations_needed - # From here, we will count the number of items in the self.itempool, and add usuful/filler items to the pool, + # From here, we will count the number of items in the self.itempool, and add useful/filler items to the pool, # making sure not to exceed the number of locations. #first, we flood the entire pool with extra points (useful), if that setting is chosen. @@ -283,7 +283,7 @@ class YachtDiceWorld(World): #add some story chapters (filler) if self.options.add_story_chapters.value == 2: #add extra points if wanted already_items = len(self.itempool) + self.extra_plando_items + 1 - if(self.number_of_locations - already_items >= 10): + if self.number_of_locations - already_items >= 10: self.itempool += ["Story Chapter"] * 10 #add some more extra points if there is still room @@ -315,7 +315,7 @@ class YachtDiceWorld(World): already_items = len(self.itempool) + self.extra_plando_items + 1 if already_items != self.number_of_locations: raise Exception(f"[Yacht Dice] Number in self.itempool is not number of locations " - f"{already_items} {self.number_of_locations}.") + f"{already_items} {self.number_of_locations}.") #add precollected items using push_precollected. Items in self.itempool get created in create_items for item in self.precollected: @@ -331,7 +331,7 @@ class YachtDiceWorld(World): def create_regions(self): #call the ini_locations function, that generates locations based on the inputs. location_table, goal_index = ini_locations(self.goal_score, self.max_score, self.number_of_locations, - self.options.game_difficulty.value) + self.options.game_difficulty.value) #simple menu-board construction menu = Region("Menu", self.player, self.multiworld) @@ -339,7 +339,7 @@ class YachtDiceWorld(World): #add locations to board, one for every location in the location_table board.locations = [YachtDiceLocation(self.player, loc_name, loc_data.score, loc_data.id, board) - for loc_name, loc_data in location_table.items() if loc_data.region == board.name] + for loc_name, loc_data in location_table.items() if loc_data.region == board.name] #which index of all locations should have the Victory item. diff --git a/worlds/yachtdice/docs/en_Yacht Dice.md b/worlds/yachtdice/docs/en_Yacht Dice.md index f45c5bcb90..53eefe9e9c 100644 --- a/worlds/yachtdice/docs/en_Yacht Dice.md +++ b/worlds/yachtdice/docs/en_Yacht Dice.md @@ -11,5 +11,5 @@ When you receive an item, it could be extra dice, extra rolls, score multipliers ## Winning the Game Victory in Yacht Dice is all about reaching the target score. You can set your own target score, which is displayed on the website. Once you hit it, you've conquered the game! -## How to Access Settings -Need to tweak your game? Head over to the [player settings page](../player-settings) for all your configuration options and to export your config file. +## How to Access Options +Need to tweak your game? Head over to the [player options page](../player-options) for all your configuration options and to export your config file. diff --git a/worlds/yachtdice/docs/setup_en.md b/worlds/yachtdice/docs/setup_en.md index 671e5ea830..ae5f92d93e 100644 --- a/worlds/yachtdice/docs/setup_en.md +++ b/worlds/yachtdice/docs/setup_en.md @@ -14,8 +14,8 @@ Both options have an "offline" play option to try out the game without having to ## Play with Archipelago -- Create your yaml file via the [Yacht Dice Player Settings Page](/games/YachtDice/player-settings). -- After generating, open the Yacht Dice website. After the tutoroll, fill in the room-information. +- Create your yaml file via the [Yacht Dice Player Options Page](../player-options). +- After generating, open the Yacht Dice website. After the tutoroll, fill in the room information. - After logging in, you are good to go. The website has a built-in client, where you can chat and send commands. -For more information on yaml files, generating Archipelago games and connecting to servers, please see the [Basic Multiworld Setup Guide](/tutorial/Archipelago/setup/en). +For more information on yaml files, generating Archipelago games, and connecting to servers, please see the [Basic Multiworld Setup Guide](/tutorial/Archipelago/setup/en).