mirror of
https://github.com/ArchipelagoMW/Archipelago.git
synced 2026-03-26 18:33:23 -07:00
* APQuest * Add confetti cannon * ID change on enemy drop * nevermind * Write the apworld * Actually implement hard mode * split everything into multiple files * Push out webworld into a file * Comment * Enemy health graphics * more ruff rules * graphics :) * heal player when receiving health upgrade * the dumbest client of all time * Fix typo * You can kinda play it now! Now we just need to render the game... :))) * fix kvui imports again * It's playable. Kind of * oops * Sounds and stuff * exceptions for audio * player sprite stuff * Not attack without sword * Make sure it plays correctly * Collect behavior * ruff * don't need to clear checked_locations, but do need to still clear finished_game * Connect calls disconnect, so this is not necessary * more seemless reconnection * Ok now I think it's correct * Bgm * Bgm * minor adjustment * More refactoring of graphics and sound * add graphics * Item column * Fix enemies not regaining their health * oops * oops * oops * 6 health final boss on hard mode * boss_6.png * Display APQuest items correctly * auto switch tabs * some mypy stuff * Intro song * Confetti Cannon * a bit more confetti work * launcher component * Graphics change * graphics and cleanup * fix apworld * comment out horse and cat for now * add docs * copypasta * ruff made my comment look unhinged * Move that comment * Fix typing and don't import kvui in nogui * lmao that already exists I don't need to do it myself * Must've just copied this from somewhere * order change * Add unit tests * Notes about the client * oops * another intro song case * Write WebWorld and setup guides * Yes description provided * thing * how to play * Music and Volume * Add cat and horse player sprites * updates * Add hammer and breakable wall * TODO * replace wav with ogg * Codeowners and readme * finish unit tests * lint * Todid * Update worlds/apquest/client/ap_quest_client.py Co-authored-by: Duck <31627079+duckboycool@users.noreply.github.com> * Update worlds/apquest/client/custom_views.py Co-authored-by: Duck <31627079+duckboycool@users.noreply.github.com> * Filler pattern * __future__ annotations * twebhost * Allow wasd and arrow keys * correct wording * oops * just say the website * append instead of += * qwint is onto my favoritism * kitty alias * Add a comment about preplaced items for assertAccessDependency * Use classvar_matrix instead of MultiworldTestBase * actually remove multiworld stuff from those tests * missed one more * Refactor a bit more * Fix getting of the user path * Actually explain components * Meh * Be a bit clearer about what's what * oops * More comments in the regions.py file * Nevermind * clarify regions further * I use too many brackets * Ok I'm done fr * simplify wording * missing . * Add precollected example * add note about precollected advancements * missing s * APQuest sound rework * Volume slider * I forgot I made this * a * fix volume of jingles * Add math trap to game (only works in play_in_console mode so far) * Math trap in apworld and client side * Fix background during math trap * fix leading 0 * Sound and further ui improvements for Math Trap * fix music bug * rename apquest subfolder to game * Move comment to where it belongs * Clear up language around components (hopefully) * Clear up what CommonClient is * Reword some more * Mention Archipelago (the program) explicitly * Update worlds/apquest/docs/en_APQuest.md Co-authored-by: Ixrec <ericrhitchcock@gmail.com> * Explain a bit more why you would use classvar matrix * reword the assert raises stuff * the volume slider thing is no longer true * german game page * Be more clear about why we're overriding Item and Location * default item classification * logically considered -> relevant to logic () * Update worlds/apquest/items.py Co-authored-by: Ixrec <ericrhitchcock@gmail.com> * a word on the ambiguity of the word 'filler' * more rewording * amount -> number * stress the necessity of appending to the multiworld itempool * Update worlds/apquest/locations.py Co-authored-by: Ixrec <ericrhitchcock@gmail.com> * get_location_names_with_ids * slight rewording of the new helper method * add some words about creating known location+item pairs * Add some more words to worlds/apqeust/options.py * more words in options.py * 120 chars (thanks Ixrec >:((( LOL) * Less confusing wording about rules, hopefully? * victory -> completion * remove the immediate creation of the hammer rule on the option region entrance * access rule performance * Make all imports module-level in world.py * formatting * get rid of noqa RUF012 (and also disable the rule in my local ruff.toml * move comment for docstring closer to docstring in another place * advancement???? * Missing function type annotations * pass mypy again (I don't love this one but all the alternatives are equally bad) * subclass instead of override * I forgor to remove these * Get rid of classvar_matrix and instead talk about some other stuff * protect people a bit from the assertAccessDependency nonsense * reword a bit more * word * More accessdependency text * More accessdependency text * More accessdependency text * More accessdependency text * oops * this is supposed to be absolute * Add some links to docs * that's called game now * Add an archipelago.json and explain what it means * new line who dis * reorganize a bit * ignore instead of skip * Update archipelago.json * She new on my line till I * Update archipelago.json * add controls tab * new ruff rule? idk * WHOOPS * Pack graphics into fewer files * annoying ruff format thing * Cleanup + mypy * relative import * Update worlds/apquest/client/custom_views.py Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com> * Update generate_math_problem.py * Update worlds/apquest/game/player.py Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com> --------- Co-authored-by: Duck <31627079+duckboycool@users.noreply.github.com> Co-authored-by: Ixrec <ericrhitchcock@gmail.com> Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com>
313 lines
6.9 KiB
Python
313 lines
6.9 KiB
Python
from __future__ import annotations
|
|
|
|
from abc import abstractmethod
|
|
from typing import TYPE_CHECKING, ClassVar
|
|
|
|
from .graphics import Graphic
|
|
from .items import ITEM_TO_GRAPHIC, Item
|
|
from .locations import Location
|
|
|
|
if TYPE_CHECKING:
|
|
from .player import Player
|
|
|
|
|
|
class Entity:
|
|
solid: bool
|
|
graphic: Graphic
|
|
|
|
|
|
class InteractableMixin:
|
|
@abstractmethod
|
|
def interact(self, player: Player) -> None:
|
|
pass
|
|
|
|
|
|
class ActivatableMixin:
|
|
@abstractmethod
|
|
def activate(self, player: Player) -> None:
|
|
pass
|
|
|
|
|
|
class LocationMixin:
|
|
location: Location
|
|
content: Item | None = None
|
|
remote: bool = False
|
|
has_given_content: bool = False
|
|
|
|
def force_clear(self) -> None:
|
|
if self.has_given_content:
|
|
return
|
|
|
|
self.has_given_content = True
|
|
self.content_success()
|
|
|
|
def give_content(self, player: Player) -> None:
|
|
if self.has_given_content:
|
|
return
|
|
|
|
if self.content is None:
|
|
self.content_failure()
|
|
return
|
|
|
|
if self.remote:
|
|
player.location_cleared(self.location.value)
|
|
else:
|
|
player.receive_item(self.content)
|
|
|
|
self.has_given_content = True
|
|
self.content_success()
|
|
|
|
def content_success(self) -> None:
|
|
pass
|
|
|
|
def content_failure(self) -> None:
|
|
pass
|
|
|
|
|
|
class Empty(Entity):
|
|
solid = False
|
|
graphic = Graphic.EMPTY
|
|
|
|
|
|
class Wall(Entity):
|
|
solid = True
|
|
graphic = Graphic.WALL
|
|
|
|
|
|
class Chest(Entity, InteractableMixin, LocationMixin):
|
|
solid = True
|
|
|
|
is_open: bool = False
|
|
|
|
def __init__(self, location: Location) -> None:
|
|
self.location = location
|
|
|
|
def update_solidity(self) -> None:
|
|
self.solid = not self.has_given_content
|
|
|
|
def open(self) -> None:
|
|
self.is_open = True
|
|
self.update_solidity()
|
|
|
|
def interact(self, player: Player) -> None:
|
|
if self.has_given_content:
|
|
return
|
|
|
|
if self.is_open:
|
|
self.give_content(player)
|
|
return
|
|
|
|
self.open()
|
|
|
|
def content_success(self) -> None:
|
|
self.update_solidity()
|
|
|
|
def content_failure(self) -> None:
|
|
self.update_solidity()
|
|
|
|
@property
|
|
def graphic(self) -> Graphic:
|
|
if self.has_given_content:
|
|
return Graphic.EMPTY
|
|
if self.is_open:
|
|
if self.content is None:
|
|
return Graphic.EMPTY
|
|
return ITEM_TO_GRAPHIC[self.content]
|
|
return Graphic.CHEST
|
|
|
|
|
|
class Door(Entity):
|
|
solid = True
|
|
|
|
is_open: bool = False
|
|
|
|
closed_graphic: ClassVar[Graphic]
|
|
|
|
def open(self) -> None:
|
|
self.is_open = True
|
|
self.solid = False
|
|
|
|
@property
|
|
def graphic(self) -> Graphic:
|
|
if self.is_open:
|
|
return Graphic.EMPTY
|
|
return self.closed_graphic
|
|
|
|
|
|
class KeyDoor(Door, InteractableMixin):
|
|
closed_graphic = Graphic.KEY_DOOR
|
|
|
|
def interact(self, player: Player) -> None:
|
|
if self.is_open:
|
|
return
|
|
|
|
if not player.has_item(Item.KEY):
|
|
return
|
|
|
|
player.remove_item(Item.KEY)
|
|
|
|
self.open()
|
|
|
|
|
|
class BreakableBlock(Door, InteractableMixin):
|
|
closed_graphic = Graphic.BREAKABLE_BLOCK
|
|
|
|
def interact(self, player: Player) -> None:
|
|
if self.is_open:
|
|
return
|
|
|
|
if not player.has_item(Item.HAMMER):
|
|
return
|
|
|
|
player.remove_item(Item.HAMMER)
|
|
|
|
self.open()
|
|
|
|
|
|
class Bush(Door, InteractableMixin):
|
|
closed_graphic = Graphic.BUSH
|
|
|
|
def interact(self, player: Player) -> None:
|
|
if self.is_open:
|
|
return
|
|
|
|
if not player.has_item(Item.SWORD):
|
|
return
|
|
|
|
self.open()
|
|
|
|
|
|
class Button(Entity, InteractableMixin):
|
|
solid = True
|
|
|
|
activates: ActivatableMixin
|
|
activated = False
|
|
|
|
def __init__(self, activates: ActivatableMixin) -> None:
|
|
self.activates = activates
|
|
|
|
def interact(self, player: Player) -> None:
|
|
if self.activated:
|
|
return
|
|
|
|
self.activated = True
|
|
self.activates.activate(player)
|
|
|
|
@property
|
|
def graphic(self) -> Graphic:
|
|
if self.activated:
|
|
return Graphic.BUTTON_ACTIVATED
|
|
return Graphic.BUTTON_NOT_ACTIVATED
|
|
|
|
|
|
class ButtonDoor(Door, ActivatableMixin):
|
|
closed_graphic = Graphic.BUTTON_DOOR
|
|
|
|
def activate(self, player: Player) -> None:
|
|
self.is_open = True
|
|
self.solid = False
|
|
|
|
|
|
class Enemy(Entity, InteractableMixin):
|
|
solid = True
|
|
|
|
current_health: int
|
|
max_health: int
|
|
|
|
dead: bool = False
|
|
|
|
enemy_graphic_by_health: ClassVar[dict[int, Graphic]] = {
|
|
2: Graphic.NORMAL_ENEMY_2_HEALTH,
|
|
1: Graphic.NORMAL_ENEMY_1_HEALTH,
|
|
}
|
|
enemy_default_graphic = Graphic.NORMAL_ENEMY_1_HEALTH
|
|
|
|
def __init__(self, max_health: int) -> None:
|
|
self.max_health = max_health
|
|
self.respawn()
|
|
|
|
def die(self) -> None:
|
|
self.dead = True
|
|
self.solid = False
|
|
|
|
def respawn(self) -> None:
|
|
self.dead = False
|
|
self.solid = True
|
|
self.heal_if_not_dead()
|
|
|
|
def heal_if_not_dead(self) -> None:
|
|
if self.dead:
|
|
return
|
|
self.current_health = self.max_health
|
|
|
|
def interact(self, player: Player) -> None:
|
|
if self.dead:
|
|
return
|
|
|
|
if player.has_item(Item.SWORD):
|
|
self.current_health = max(0, self.current_health - 1)
|
|
|
|
if self.current_health == 0:
|
|
if not self.dead:
|
|
self.die()
|
|
return
|
|
|
|
player.damage(2)
|
|
|
|
@property
|
|
def graphic(self) -> Graphic:
|
|
if self.dead:
|
|
return Graphic.EMPTY
|
|
return self.enemy_graphic_by_health.get(self.current_health, self.enemy_default_graphic)
|
|
|
|
|
|
class EnemyWithLoot(Enemy, LocationMixin):
|
|
def __init__(self, max_health: int, location: Location) -> None:
|
|
super().__init__(max_health)
|
|
self.location = location
|
|
|
|
def die(self) -> None:
|
|
self.dead = True
|
|
self.solid = not self.has_given_content
|
|
|
|
def interact(self, player: Player) -> None:
|
|
if self.dead:
|
|
if not self.has_given_content:
|
|
self.give_content(player)
|
|
return
|
|
|
|
super().interact(player)
|
|
|
|
@property
|
|
def graphic(self) -> Graphic:
|
|
if self.dead and not self.has_given_content:
|
|
if self.content is None:
|
|
return Graphic.EMPTY
|
|
return ITEM_TO_GRAPHIC[self.content]
|
|
return super().graphic
|
|
|
|
def content_success(self) -> None:
|
|
self.die()
|
|
|
|
def content_failure(self) -> None:
|
|
self.die()
|
|
|
|
|
|
class FinalBoss(Enemy):
|
|
enemy_graphic_by_health: ClassVar[dict[int, Graphic]] = {
|
|
5: Graphic.BOSS_5_HEALTH,
|
|
4: Graphic.BOSS_4_HEALTH,
|
|
3: Graphic.BOSS_3_HEALTH,
|
|
2: Graphic.BOSS_2_HEALTH,
|
|
1: Graphic.BOSS_1_HEALTH,
|
|
}
|
|
enemy_default_graphic = Graphic.BOSS_1_HEALTH
|
|
|
|
def interact(self, player: Player) -> None:
|
|
dead_before = self.dead
|
|
|
|
super().interact(player)
|
|
|
|
if not dead_before and self.dead:
|
|
player.victory()
|