From 7c1a68ad3b2238e8d16814932f3500494191f620 Mon Sep 17 00:00:00 2001 From: spinerak Date: Sat, 25 May 2024 00:32:35 +0200 Subject: [PATCH] changed options and added exceptions --- worlds/yachtdice/Options.py | 27 ++++++++++++++------------- worlds/yachtdice/Rules.py | 2 ++ worlds/yachtdice/__init__.py | 15 ++++++++++----- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/worlds/yachtdice/Options.py b/worlds/yachtdice/Options.py index aa9d8b8a97..48f8571bce 100644 --- a/worlds/yachtdice/Options.py +++ b/worlds/yachtdice/Options.py @@ -143,36 +143,37 @@ class gameMode(Choice): Standard. Get to 500 points on medium difficulty (and a bit lower/higher on other difficulties). - Extra points: a bunch of "10 Points" items are shuffled through the item pool. Get to 1000 points. + Points mode: a bunch of "10 Points" items are shuffled through the item pool. Get to 1000 points. The amount of "10 Points" items in the pool depends on your selected difficulty. - Extra categories: categories may appear multiple times. - Getting a category again gives a x2 multiplier for that category. Get to 1000 points. - The amount of "10 Points" items in the pool depends on your selected difficulty. + I'll add a new category soon™ """ + # Extra categories: categories may appear multiple times. + # Getting a category again gives a x2 multiplier for that category. Get to 1000 points. + # The amount of "10 Points" items in the pool depends on your selected difficulty. + display_name = "Game mode" option_standard = 1 - option_extra_points = 2 - option_extra_categories = 3 + option_points_mode = 2 + #option_extra_categories = 3 default = 1 class pointsGameMode(Choice): """ - This extra game mode shuffles many points items in the pool, - and your goal is to reach a score of 1000. + If points mode is selected, this option determines the value of the points items. yes_1_per_item: hundreds of "1 Point" items are shuffled into the pool. - NOT recommended in multiplayer, unless everyone is aware of the hundred of extra items + NOT recommended in multiplayer, unless everyone is aware of the hundred of points items yes_10_per_item: puts tens of "10 Points" (and a few 1 Points) into the item pool. yes_100_per_item: puts a few "100 Points" (and a few 1 and 10 Points) into the item pool. Warning: will unlock many checks if an 100 Points item is collected. """ - display_name = "Extra points game mode" - option_yes_1_per_item = 2 - option_yes_10_per_item = 3 - option_yes_100_per_item = 4 + display_name = "Value of points item" + option_1_per_item = 2 + option_10_per_item = 3 + option_100_per_item = 4 default = 3 diff --git a/worlds/yachtdice/Rules.py b/worlds/yachtdice/Rules.py index 44f7cf0f44..a1926141ea 100644 --- a/worlds/yachtdice/Rules.py +++ b/worlds/yachtdice/Rules.py @@ -186,6 +186,8 @@ def diceSimulation(state, player, options): categories, nbDice, nbRolls, multiplier, expoints = extractProgression(state, player, options) return diceSimulationStrings(categories, nbDice, nbRolls, multiplier, options.game_difficulty.value, options.score_multiplier_type.value) + expoints + + # Sets rules on entrances and advancements that are always applied def set_yacht_rules(world: MultiWorld, player: int, options): diff --git a/worlds/yachtdice/__init__.py b/worlds/yachtdice/__init__.py index dfbc57dc7f..9c36f17afd 100644 --- a/worlds/yachtdice/__init__.py +++ b/worlds/yachtdice/__init__.py @@ -1,8 +1,8 @@ from BaseClasses import Region, Entrance, Item, Tutorial -from .Items import ITEM_GROUPS, YachtDiceItem, item_table +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 +from .Rules import set_yacht_rules, set_yacht_completion_rules, diceSimulation from ..AutoWorld import World, WebWorld import math import logging @@ -154,8 +154,8 @@ class YachtDiceWorld(World): #the number of necessary items, should never exceed the number_of_locations #if it does, there is some weird error, perhaps with plando. This should raise an error... if already_items > self.number_of_locations: - logging.error(f"In Yacht Dice, there are more items \ - than locations ({already_items}, {self.number_of_locations})") + raise Exception(f"In Yacht Dice, there are more items than locations ({already_items}, {self.number_of_locations})") + #note that self.number_of_locations is the number of locations EXCLUDING the victory location. #and since the victory item is added later, we should have the number of items @@ -221,7 +221,7 @@ class YachtDiceWorld(World): #we're done adding items. Now because of the last step, number of items should be number of locations already_items = len(itempool) + self.extra_plando_items if len(itempool) != self.number_of_locations: - logging.error(f"Number in itempool is not number of locations {len(itempool)} {self.number_of_locations}.") + raise Exception(f"Number in itempool is not number of locations {len(itempool)} {self.number_of_locations}.") #convert strings to actual items itempool = [item for item in map(lambda name: self.create_item(name), itempool)] @@ -230,6 +230,7 @@ class YachtDiceWorld(World): for item in itempool: self.multiworld.itempool += [item] + def set_rules(self): @@ -237,6 +238,10 @@ class YachtDiceWorld(World): set_yacht_rules(self.multiworld, self.player, self.options) set_yacht_completion_rules(self.multiworld, self.player) + maxScoreWithItems = diceSimulation(self.multiworld.get_all_state(False), self.player, self.options) + if self.goal_score > maxScoreWithItems: + raise Exception("In Yacht Dice, with all items in the pool, it is impossible to get to the goal.") +