Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into mlss
  • Loading branch information
jamesbrq committed Feb 9, 2024
2 parents 5f2a75b + d97e66d commit cd1e634
Show file tree
Hide file tree
Showing 34 changed files with 1,076 additions and 1,031 deletions.
10 changes: 5 additions & 5 deletions BaseClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,8 +823,8 @@ def __repr__(self):
return self.__str__()

def __str__(self):
world = self.parent_region.multiworld if self.parent_region else None
return world.get_name_string_for_object(self) if world else f'{self.name} (Player {self.player})'
multiworld = self.parent_region.multiworld if self.parent_region else None
return multiworld.get_name_string_for_object(self) if multiworld else f'{self.name} (Player {self.player})'


class Region:
Expand Down Expand Up @@ -1040,8 +1040,8 @@ def __repr__(self):
return self.__str__()

def __str__(self):
world = self.parent_region.multiworld if self.parent_region and self.parent_region.multiworld else None
return world.get_name_string_for_object(self) if world else f'{self.name} (Player {self.player})'
multiworld = self.parent_region.multiworld if self.parent_region and self.parent_region.multiworld else None
return multiworld.get_name_string_for_object(self) if multiworld else f'{self.name} (Player {self.player})'

def __hash__(self):
return hash((self.name, self.player))
Expand Down Expand Up @@ -1175,7 +1175,7 @@ def set_entrance(self, entrance: str, exit_: str, direction: str, player: int) -
{"player": player, "entrance": entrance, "exit": exit_, "direction": direction}

def create_playthrough(self, create_paths: bool = True) -> None:
"""Destructive to the world while it is run, damage gets repaired afterwards."""
"""Destructive to the multiworld while it is run, damage gets repaired afterwards."""
from itertools import chain
# get locations containing progress items
multiworld = self.multiworld
Expand Down
186 changes: 93 additions & 93 deletions Fill.py

Large diffs are not rendered by default.

286 changes: 143 additions & 143 deletions Main.py

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions OoTAdjuster.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ def set_icon(window):
window.tk.call('wm', 'iconphoto', window._w, logo)

def adjust(args):
# Create a fake world and OOTWorld to use as a base
world = MultiWorld(1)
world.per_slot_randoms = {1: random}
ootworld = OOTWorld(world, 1)
# Create a fake multiworld and OOTWorld to use as a base
multiworld = MultiWorld(1)
multiworld.per_slot_randoms = {1: random}
ootworld = OOTWorld(multiworld, 1)
# Set options in the fake OOTWorld
for name, option in chain(cosmetic_options.items(), sfx_options.items()):
result = getattr(args, name, None)
Expand Down
4 changes: 2 additions & 2 deletions Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,8 +871,8 @@ def visualize_regions(root_region: Region, file_name: str, *,
Example usage in Main code:
from Utils import visualize_regions
for player in world.player_ids:
visualize_regions(world.get_region("Menu", player), f"{world.get_out_file_name_base(player)}.puml")
for player in multiworld.player_ids:
visualize_regions(multiworld.get_region("Menu", player), f"{multiworld.get_out_file_name_base(player)}.puml")
"""
assert root_region.multiworld, "The multiworld attribute of root_region has to be filled"
from BaseClasses import Entrance, Item, Location, LocationProgressType, MultiWorld, Region
Expand Down
2 changes: 1 addition & 1 deletion WebHostLib/templates/macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{% for patch in room.seed.slots|list|sort(attribute="player_id") %}
<tr>
<td>{{ patch.player_id }}</td>
<td data-tooltip="Connect via TextClient"><a href="archipelago://{{ patch.player_name | e}}:@{{ config['HOST_ADDRESS'] }}:{{ room.last_port }}">{{ patch.player_name }}</a></td>
<td data-tooltip="Connect via TextClient"><a href="archipelago://{{ patch.player_name | e}}:None@{{ config['HOST_ADDRESS'] }}:{{ room.last_port }}">{{ patch.player_name }}</a></td>
<td>{{ patch.game }}</td>
<td>
{% if patch.data %}
Expand Down
2 changes: 2 additions & 0 deletions docs/network protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ There are also a number of community-supported libraries available that implemen
| Haxe | [hxArchipelago](https://lib.haxe.org/p/hxArchipelago) | |
| Rust | [ArchipelagoRS](https://github.com/ryanisaacg/archipelago_rs) | |
| Lua | [lua-apclientpp](https://github.com/black-sliver/lua-apclientpp) | |
| Game Maker + Studio 1.x | [gm-apclientpp](https://github.com/black-sliver/gm-apclientpp) | For GM7, GM8 and GMS1.x, maybe older |
| GameMaker: Studio 2.x+ | [see Discord](https://discord.com/channels/731205301247803413/1166418532519653396) | |

## Synchronizing Items
When the client receives a [ReceivedItems](#ReceivedItems) packet, if the `index` argument does not match the next index that the client expects then it is expected that the client will re-sync items with the server. This can be accomplished by sending the server a [Sync](#Sync) packet and then a [LocationChecks](#LocationChecks) packet.
Expand Down
31 changes: 26 additions & 5 deletions docs/options api.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,49 @@ Choice, and defining `alias_true = option_full`.
- All options support `random` as a generic option. `random` chooses from any of the available values for that option,
and is reserved by AP. You can set this as your default value, but you cannot define your own `option_random`.

As an example, suppose we want an option that lets the user start their game with a sword in their inventory. Let's
create our option class (with a docstring), give it a `display_name`, and add it to our game's options dataclass:
As an example, suppose we want an option that lets the user start their game with a sword in their inventory, an option
to let the player choose the difficulty, and an option to choose how much health the final boss has. Let's create our
option classes (with a docstring), give them a `display_name`, and add them to our game's options dataclass:

```python
# options.py
from dataclasses import dataclass

from Options import Toggle, PerGameCommonOptions
from Options import Toggle, Range, Choice, PerGameCommonOptions


class StartingSword(Toggle):
"""Adds a sword to your starting inventory."""
display_name = "Start With Sword"


class Difficulty(Choice):
"""Sets overall game difficulty."""
display_name = "Difficulty"
option_easy = 0
option_normal = 1
option_hard = 2
alias_beginner = 0 # same as easy but allows the player to use beginner as an alternative for easy in the result in their options
alias_expert = 2 # same as hard
default = 1 # default to normal


class FinalBossHP(Range):
"""Sets the HP of the final boss"""
display_name = "Final Boss HP"
range_start = 100
range_end = 10000
default = 2000


@dataclass
class ExampleGameOptions(PerGameCommonOptions):
starting_sword: StartingSword
difficulty: Difficulty
final_boss_health: FinalBossHP
```

This will create a `Toggle` option, internally called `starting_sword`. To then submit this to the multiworld, we add it
to our world's `__init__.py`:
To then submit this to the multiworld, we add it to our world's `__init__.py`:

```python
from worlds.AutoWorld import World
Expand Down
7 changes: 2 additions & 5 deletions docs/style.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* 120 character per line for all source files.
* Avoid white space errors like trailing spaces.


## Python Code

* We mostly follow [PEP8](https://peps.python.org/pep-0008/). Read below to see the differences.
Expand All @@ -18,9 +17,10 @@
* Use type annotations where possible for function signatures and class members.
* Use type annotations where appropriate for local variables (e.g. `var: List[int] = []`, or when the
type is hard or impossible to deduce.) Clear annotations help developers look up and validate API calls.
* New classes, attributes, and methods in core code should have docstrings that follow
[reST style](https://peps.python.org/pep-0287/).
* Worlds that do not follow PEP8 should still have a consistent style across its files to make reading easier.


## Markdown

* We almost follow [Google's styleguide](https://google.github.io/styleguide/docguide/style.html).
Expand All @@ -30,20 +30,17 @@
* One space between bullet/number and text.
* No lazy numbering.


## HTML

* Indent with 2 spaces for new code.
* kebab-case for ids and classes.


## CSS

* Indent with 2 spaces for new code.
* `{` on the same line as the selector.
* No space between selector and `{`.


## JS

* Indent with 2 spaces.
Expand Down
Loading

0 comments on commit cd1e634

Please sign in to comment.