Skip to content
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

Message Bus Engine v1 #60

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
"python.analysis.lintingEnabled": true,
"python.analysis.linter": "pylint",
"python.analysis.linting.pylintArgs": ["--rcfile", "/path/to/your/.pylintrc"]
"python.analysis.linting.pylintArgs": ["--rcfile", "/workspaces/Slay-The-Spire-in-Python/.pylintrc"]
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-python.pylint"
"ms-python.pylint",
"charliermarsh.ruff"
],

// Use 'postCreateCommand' to run commands after the container is created.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ jobs:
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml
if: github.ref != 'refs/heads/main'
if: github.ref != 'refs/heads/main' && github.event_name == 'pull_request' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == 'false'
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"editor.lineHeight": 23,
"editor.cursorBlinking": "solid",
"editor.cursorSmoothCaretAnimation": "on",
"editor.fontFamily": "Consolas, 'Courier New', monospace"
"editor.fontFamily": "Consolas, 'Courier New', monospace",
"audioCues.lineHasInlineSuggestion": "off"
}
19 changes: 18 additions & 1 deletion definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class EncounterType(StrEnum):
ELITE = auto()
REST_SITE = auto()
BOSS = auto()
SHOP = auto()
UNKNOWN = auto()

class Rarity(StrEnum):
Expand All @@ -37,4 +38,20 @@ class PlayerClass(StrEnum):
IRONCLAD = 'Ironclad'
SILENT = 'Silent'
DEFECT = 'Defect'
WATCHER = 'Watcher'
WATCHER = 'Watcher'
COLORLESS = 'Colorless'
ANY = 'Any'

class TargetType(StrEnum):
ANY = 'Any'
AREA = 'Area'
ENEMY = 'Enemy'
NOTHING = 'Nothing'
RANDOM = 'Random'
SINGLE = 'Single'
YOURSELF = 'Yourself'

class CardCategory(StrEnum):
CARD = 'Card'
POTION = 'Potion'
RELIC = 'Relic'
2 changes: 1 addition & 1 deletion enemy_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def __init__(self):
super().__init__([13, 17], 0, "Fat Gremlin")

def set_intent(self):
self.next_move, self.intent = [("Smash", "Attack", (4,)), ("Debuff", ("Weak", 1))], "<aggresive>Attack<aggresive> Σ4 / <debuff>Debuff</debuff>"
self.next_move, self.intent = [("Smash", "Attack", (4,)), ("Debuff", ("Weak", 1))], "<aggresive>Attack</aggresive> Σ4 / <debuff>Debuff</debuff>"

class MadGremlin(Enemy):
def __init__(self):
Expand Down
174 changes: 55 additions & 119 deletions entities.py

Large diffs are not rendered by default.

20 changes: 13 additions & 7 deletions game.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
from functools import partial
from time import sleep
import math
import random
from time import sleep
from copy import copy, deepcopy
from ansi_tags import ansiprint
from events import choose_event
from items import relics, potions, cards, activate_sacred_bark
from helper import active_enemies, view, gen, ei
from enemy_catalog import create_act1_normal_encounters, create_act1_elites, create_act1_boss
from entities import player, Player, Enemy
from definitions import CombatTier, EncounterType
from message_bus_tools import Message, bus
from dataclasses import dataclass
import game_map
from ansi_tags import ansiprint
from enemy_catalog import (
create_act1_boss,
create_act1_elites,
create_act1_normal_encounters,
)
from helper import active_enemies, combat_turn, ei, gen, potion_dropchance, view
from shop import Shop


@dataclass
Expand All @@ -24,12 +29,11 @@ class Combat:

def combat(self, current_map) -> None:
"""There's too much to say here."""
global combat_turn
boss_name = self.start_combat(self.tier)
# Combat automatically ends when all enemies are dead.
while len(active_enemies) > 0:
# Draws cards, removes block, ticks debuffs, and activates start-of-turn buffs, debuffs, and relics.
bus.publish(Message.START_OF_TURN, (self.player, self.active_enemies, self.tier))
bus.publish(Message.START_OF_TURN, (self.turn, ))
while True:
if len(active_enemies) == 0:
self.end_combat(self.tier, killed_enemies=True)
Expand Down Expand Up @@ -234,7 +238,7 @@ def unknown() -> None:
normal_combat = 0.1
treasure_room += 0.02
merchant += 0.03
Combat.combat(CombatTier.NORMAL)
Combat(player, CombatTier.NORMAL).combat()
else:
ansiprint(player)
chosen_event = choose_event()
Expand Down Expand Up @@ -292,6 +296,8 @@ def play(encounter: EncounterType, gm: game_map.GameMap):
return Combat(player, CombatTier.ELITE).combat(gm)
elif encounter.type == EncounterType.NORMAL:
return Combat(player, CombatTier.NORMAL).combat(gm)
elif encounter.type == EncounterType.SHOP:
return Shop(player).loop()
else:
raise game_map.MapError(f"Encounter type {encounter} is not valid.")

Expand Down
2 changes: 1 addition & 1 deletion game_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def create_first_map():
start = Encounter(ET.START)

F1a = Encounter(ET.NORMAL, parents=[start])
F1b = Encounter(ET.NORMAL, parents=[start])
F1b = Encounter(ET.SHOP, parents=[start])
F1c = Encounter(ET.NORMAL, parents=[start])
F1d = Encounter(ET.NORMAL, parents=[start])

Expand Down
Loading