-
Notifications
You must be signed in to change notification settings - Fork 909
Clique: Refactors and Additional Features supported by v1.5 #1989
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from typing import Callable, Dict, NamedTuple, Optional | ||
|
||
from BaseClasses import Item, ItemClassification, MultiWorld | ||
|
||
|
||
class CliqueItem(Item): | ||
game = "Clique" | ||
|
||
|
||
class CliqueItemData(NamedTuple): | ||
code: Optional[int] = None | ||
type: ItemClassification = ItemClassification.filler | ||
can_create: Callable[[MultiWorld, int], bool] = lambda multiworld, player: True | ||
|
||
|
||
item_data_table: Dict[str, CliqueItemData] = { | ||
"Feeling of Satisfaction": CliqueItemData( | ||
code=69696969, | ||
type=ItemClassification.progression, | ||
), | ||
"Button Activation": CliqueItemData( | ||
code=69696968, | ||
type=ItemClassification.progression, | ||
can_create=lambda multiworld, player: bool(getattr(multiworld, "hard_mode")[player]), | ||
), | ||
"A Cool Filler Item (No Satisfaction Guaranteed)": CliqueItemData( | ||
code=69696967, | ||
can_create=lambda multiworld, player: False # Only created from `get_filler_item_name`. | ||
), | ||
"The Urge to Push": CliqueItemData( | ||
type=ItemClassification.progression, | ||
), | ||
} | ||
|
||
item_table = {name: data.code for name, data in item_data_table.items() if data.code is not None} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from typing import Callable, Dict, NamedTuple, Optional | ||
|
||
from BaseClasses import Location, MultiWorld | ||
|
||
|
||
class CliqueLocation(Location): | ||
game = "Clique" | ||
|
||
|
||
class CliqueLocationData(NamedTuple): | ||
region: str | ||
address: Optional[int] = None | ||
can_create: Callable[[MultiWorld, int], bool] = lambda multiworld, player: True | ||
locked_item: Optional[str] = None | ||
|
||
|
||
location_data_table: Dict[str, CliqueLocationData] = { | ||
"The Big Red Button": CliqueLocationData( | ||
region="The Button Realm", | ||
address=69696969, | ||
), | ||
"The Item on the Desk": CliqueLocationData( | ||
region="The Button Realm", | ||
address=69696968, | ||
can_create=lambda multiworld, player: bool(getattr(multiworld, "hard_mode")[player]), | ||
), | ||
"In the Player's Mind": CliqueLocationData( | ||
region="The Button Realm", | ||
locked_item="The Urge to Push", | ||
), | ||
} | ||
|
||
location_table = {name: data.address for name, data in location_data_table.items() if data.address is not None} | ||
locked_locations = {name: data for name, data in location_data_table.items() if data.locked_item} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,34 @@ | ||
from typing import Dict | ||
|
||
from Options import Option, Toggle | ||
from Options import Choice, Option, Toggle | ||
|
||
|
||
class HardMode(Toggle): | ||
"""Only for the most masochistically inclined... Requires button activation!""" | ||
display_name = "Hard Mode" | ||
|
||
|
||
class ButtonColor(Choice): | ||
"""Customize your button! Now available in 12 unique colors.""" | ||
display_name = "Button Color" | ||
option_red = 0 | ||
option_orange = 1 | ||
option_yellow = 2 | ||
option_green = 3 | ||
option_cyan = 4 | ||
option_blue = 5 | ||
option_magenta = 6 | ||
option_purple = 7 | ||
option_pink = 8 | ||
option_brown = 9 | ||
option_white = 10 | ||
option_black = 11 | ||
|
||
|
||
clique_options: Dict[str, type(Option)] = { | ||
"hard_mode": HardMode | ||
"color": ButtonColor, | ||
"hard_mode": HardMode, | ||
|
||
# DeathLink is always on. Always. | ||
# "death_link": DeathLink, | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from typing import Dict, List, NamedTuple | ||
|
||
|
||
class CliqueRegionData(NamedTuple): | ||
connecting_regions: List[str] = [] | ||
|
||
|
||
region_data_table: Dict[str, CliqueRegionData] = { | ||
"Menu": CliqueRegionData(["The Button Realm"]), | ||
"The Button Realm": CliqueRegionData(), | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from typing import Callable | ||
|
||
from BaseClasses import CollectionState, MultiWorld | ||
|
||
|
||
def get_button_rule(multiworld: MultiWorld, player: int) -> Callable[[CollectionState], bool]: | ||
if getattr(multiworld, "hard_mode")[player]: | ||
return lambda state: state.has("Button Activation", player) | ||
|
||
return lambda state: True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
from BaseClasses import Entrance, Item, ItemClassification, Location, MultiWorld, Region, Tutorial | ||
from typing import List | ||
|
||
from BaseClasses import Region, Tutorial | ||
from worlds.AutoWorld import WebWorld, World | ||
from worlds.generic.Rules import set_rule | ||
from .Items import CliqueItem, item_data_table, item_table | ||
from .Locations import CliqueLocation, location_data_table, location_table, locked_locations | ||
from .Options import clique_options | ||
|
||
|
||
class CliqueItem(Item): | ||
game = "Clique" | ||
|
||
|
||
class CliqueLocation(Location): | ||
game = "Clique" | ||
from .Regions import region_data_table | ||
from .Rules import get_button_rule | ||
|
||
|
||
class CliqueWebWorld(WebWorld): | ||
|
@@ -27,71 +24,69 @@ class CliqueWebWorld(WebWorld): | |
|
||
|
||
class CliqueWorld(World): | ||
"""The greatest game ever designed. Full of exciting gameplay!""" | ||
"""The greatest game of all time.""" | ||
|
||
game = "Clique" | ||
data_version = 2 | ||
data_version = 3 | ||
web = CliqueWebWorld() | ||
option_definitions = clique_options | ||
|
||
# Yes, I'm like 12 for this. | ||
location_name_to_id = { | ||
"The Big Red Button": 69696969, | ||
"The Item on the Desk": 69696968, | ||
} | ||
|
||
item_name_to_id = { | ||
"Feeling of Satisfaction": 69696969, | ||
"Button Activation": 69696968, | ||
} | ||
location_name_to_id = location_table | ||
item_name_to_id = item_table | ||
|
||
def create_item(self, name: str) -> CliqueItem: | ||
return CliqueItem(name, ItemClassification.progression, self.item_name_to_id[name], self.player) | ||
return CliqueItem(name, item_data_table[name].type, item_data_table[name].code, self.player) | ||
|
||
def create_items(self) -> None: | ||
self.multiworld.itempool.append(self.create_item("Feeling of Satisfaction")) | ||
self.multiworld.priority_locations[self.player].value.add("The Big Red Button") | ||
item_pool: List[CliqueItem] = [] | ||
for name, item in item_data_table.items(): | ||
if item.code and item.can_create(self.multiworld, self.player): | ||
item_pool.append(self.create_item(name)) | ||
|
||
if self.multiworld.hard_mode[self.player]: | ||
self.multiworld.itempool.append(self.create_item("Button Activation")) | ||
self.multiworld.itempool += item_pool | ||
|
||
def create_regions(self) -> None: | ||
if self.multiworld.hard_mode[self.player]: | ||
self.multiworld.regions += [ | ||
create_region(self.multiworld, self.player, "Menu", None, ["The entrance to the button."]), | ||
create_region(self.multiworld, self.player, "The realm of the button.", self.location_name_to_id) | ||
] | ||
else: | ||
self.multiworld.regions += [ | ||
create_region(self.multiworld, self.player, "Menu", None, ["The entrance to the button."]), | ||
create_region(self.multiworld, self.player, "The realm of the button.", { | ||
"The Big Red Button": 69696969 | ||
})] | ||
|
||
self.multiworld.get_entrance("The entrance to the button.", self.player) \ | ||
.connect(self.multiworld.get_region("The realm of the button.", self.player)) | ||
# Create regions. | ||
for region_name in region_data_table.keys(): | ||
region = Region(region_name, self.player, self.multiworld) | ||
self.multiworld.regions.append(region) | ||
|
||
# Create locations. | ||
for region_name, region_data in region_data_table.items(): | ||
region = self.multiworld.get_region(region_name, self.player) | ||
region.add_locations({ | ||
location_name: location_data.address for location_name, location_data in location_data_table.items() | ||
if location_data.region == region_name and location_data.can_create(self.multiworld, self.player) | ||
}, CliqueLocation) | ||
region.add_exits(region_data_table[region_name].connecting_regions) | ||
|
||
# Place locked locations. | ||
for location_name, location_data in locked_locations.items(): | ||
# Ignore locations we never created. | ||
if not location_data.can_create(self.multiworld, self.player): | ||
continue | ||
|
||
locked_item = self.create_item(location_data_table[location_name].locked_item) | ||
self.multiworld.get_location(location_name, self.player).place_locked_item(locked_item) | ||
|
||
# Set priority location for the Big Red Button! | ||
self.multiworld.priority_locations[self.player].value.add("The Big Red Button") | ||
|
||
def get_filler_item_name(self) -> str: | ||
return self.multiworld.random.choice(self.item_name_to_id) | ||
return "A Cool Filler Item (No Satisfaction Guaranteed)" | ||
|
||
def set_rules(self) -> None: | ||
if self.multiworld.hard_mode[self.player]: | ||
set_rule( | ||
self.multiworld.get_location("The Big Red Button", self.player), | ||
lambda state: state.has("Button Activation", self.player)) | ||
|
||
self.multiworld.completion_condition[self.player] = lambda state: \ | ||
state.has("Feeling of Satisfaction", self.player) | ||
|
||
button_rule = get_button_rule(self.multiworld, self.player) | ||
self.multiworld.get_location("The Big Red Button", self.player).access_rule = button_rule | ||
self.multiworld.get_location("In the Player's Mind", self.player).access_rule = button_rule | ||
|
||
def create_region(world: MultiWorld, player: int, name: str, locations=None, exits=None): | ||
region = Region(name, player, world) | ||
if locations: | ||
for location_name in locations.keys(): | ||
region.locations.append(CliqueLocation(player, location_name, locations[location_name], region)) | ||
# Do not allow button activations on buttons. | ||
self.multiworld.get_location("The Big Red Button", self.player).item_rule =\ | ||
lambda item: item.name != "Button Activation" | ||
|
||
if exits: | ||
for _exit in exits: | ||
region.exits.append(Entrance(player, _exit, region)) | ||
# Completion condition. | ||
self.multiworld.completion_condition[self.player] = lambda state: state.has("The Urge to Push", self.player) | ||
|
||
return region | ||
def fill_slot_data(self): | ||
return { | ||
"color": getattr(self.multiworld, "color")[self.player].current_key | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could make this a lot nicer and get rid of all the getattr with #993 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah well... it ain't merged yet. :P |
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this raise if someone plandoes "Button Activation" with "hard_mode" disabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you asking if it should raise or it does if that happens? If someone plandos Button Activation it would just create a useless item.
Worst case, it will cause a generation failure (or ignore for
force: false
andforce: null
if it's not possible like in a single player game.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that was a play on the attribute name
can_create
. ifcan_create
returns false, it should crash, no?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope,
can_create
is only referenced increate_items
for normal items.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i know. i would expect it to throw an exception or divide by 0 when being called from plando
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I disagree.