Skip to content

Commit ab824c5

Browse files
author
Vesper-arch
committed
More formatting changes
1 parent 5ccd31d commit ab824c5

File tree

7 files changed

+27
-62
lines changed

7 files changed

+27
-62
lines changed

dagascii.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@
88
import pydoc
99
import sys
1010

11-
from grandalf.graphs import Edge
12-
from grandalf.graphs import Graph
13-
from grandalf.graphs import Vertex
11+
from grandalf.graphs import Edge, Graph, Vertex
1412
from grandalf.layouts import SugiyamaLayout
15-
from grandalf.routing import EdgeViewer
16-
from grandalf.routing import route_with_lines
13+
from grandalf.routing import EdgeViewer, route_with_lines
1714

1815
DVC_PAGER = "DVC_PAGER"
1916

definitions.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from enum import StrEnum, auto
22

3+
34
class CombatTier(StrEnum):
45
NORMAL = 'Normal'
56
ELITE = 'Elite'
@@ -60,4 +61,4 @@ class EnemyState(StrEnum):
6061
ALIVE = 'alive'
6162
DEAD = 'dead'
6263
ESCAPED = 'escaped'
63-
INTANGIBLE = 'intangible' # Enemies that revive have a period where they cannot be attacked and have no intent.
64+
INTANGIBLE = 'intangible' # Enemies that revive have a period where they cannot be attacked and have no intent.

entities.py

-1
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,6 @@ def move_spam_check(self, target_move, max_count):
753753
return True
754754

755755
def attack(self, dmg: int, times: int):
756-
dmg_affected_by = ''
757756
for _ in range(times):
758757
bus.publish(Message.BEFORE_ATTACK, (self, dmg, player.block))
759758
if dmg <= player.block:

events.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import random
21
import math
2+
import random
33
from time import sleep
44
from typing import Callable
5+
56
from ansi_tags import ansiprint
6-
from items import cards, potions, relics
7+
from definitions import CombatTier
78
from entities import player
89
from helper import gen, view
9-
from definitions import CombatTier
10+
from items import cards, potions, relics
1011

1112

1213
def event_Neow():

game.py

+2-34
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ def end_combat(self, killed_enemies=False, escaped=False, robbed=False):
7979
player.gain_gold(random.randint(10, 20) * 1 if relics['Golden Idol'] not in self.player.relics else 1.25)
8080
if potion_roll < self.player.potion_dropchance or relics['White Beast Statue'] in self.player.relics:
8181
gen.claim_potions(True, 1, player, potions)
82-
potion_dropchance -= 10
82+
player.potion_dropchance -= 10
8383
else:
84-
potion_dropchance += 10
84+
player.potion_dropchance += 10
8585
for _ in range(int(relics['Prayer Wheel'] in self.player.relics) + 1):
8686
gen.card_rewards(self.tier, True, self.player, cards)
8787
sleep(1.5)
@@ -296,38 +296,6 @@ def play_potion():
296296
view.view_potions(player.potions, player.max_potions)
297297
input('This is currently not implemented. Press enter to leave > ')
298298

299-
300-
301-
def play_card(card):
302-
while True:
303-
# Prevents the player from using a card that they don't have enough energy for.
304-
energy_cost = card.get("Energy", float('inf')) if card.get("Energy", float('inf')) != -1 else player.energy
305-
if energy_cost > player.energy:
306-
ansiprint("<red>You don't have enough energy to use this card.</red>")
307-
sleep(1)
308-
view.clear()
309-
return
310-
if player.choker_cards_played == 6:
311-
ansiprint("You have already played 6 cards this turn!")
312-
sleep(1)
313-
view.clear()
314-
return
315-
if card.get("Target") == 'Single' and len(active_enemies) > 1:
316-
try:
317-
target = int(input("Choose an enemy to target > ")) - 1
318-
_ = active_enemies[target]
319-
except (IndexError, ValueError):
320-
ansiprint(f"\u001b[1A\u001b[100D<red>You have to enter a number between 1 and {len(active_enemies)}</red>", end='')
321-
sleep(1)
322-
print("\u001b[2K\u001b[100D", end='')
323-
continue
324-
elif len(active_enemies) == 1:
325-
target = 0
326-
else:
327-
target = 0
328-
player.use_card(card, active_enemies[target], False, player.hand)
329-
break
330-
331299
def play(encounter: EncounterType, gm: game_map.GameMap):
332300
if encounter.type == EncounterType.START:
333301
pass

game_map.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# game_map.py
22
from __future__ import annotations
3-
from enum import StrEnum, auto
3+
44
import random
5+
from enum import StrEnum, auto
56
from typing import List
6-
from typing import List
7+
8+
from grandalf.graphs import Edge, Graph, Vertex
9+
710
from dagascii import draw
811
from definitions import EncounterType
9-
from grandalf.graphs import Vertex, Edge, Graph
12+
1013

1114
class MapError(Exception):
1215
pass
@@ -138,4 +141,4 @@ def create_first_map():
138141

139142
boss = Encounter(ET.BOSS, parents=[F4a, F4b, F4c, F4d])
140143

141-
return GameMap(start)
144+
return GameMap(start)

helper.py

+10-14
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import random
33
import re
44
from copy import deepcopy
5-
from os import system
5+
from os import name, system
66
from time import sleep
77
from typing import Callable
88

@@ -169,7 +169,7 @@ def display_actual_block(self, string: str, entity) -> tuple[str, str]:
169169
return string, affected_by
170170

171171
def clear(self):
172-
system('cls' if os.name == 'nt' else 'clear')
172+
system('cls' if name == 'nt' else 'clear')
173173

174174
class Generators():
175175
'''Generates relic_pool, potions, and cards'''
@@ -190,9 +190,9 @@ def generate_card_rewards(self, reward_tier: CombatTier, amount: int, entity: ob
190190
common_cards = [card() for card in card_pool if card.rarity == Rarity.COMMON and card.type not in (CardType.STATUS, CardType.CURSE) and card.player_class == entity.player_class]
191191
uncommon_cards = [card() for card in card_pool if card.rarity == Rarity.UNCOMMON and card.type not in (CardType.STATUS, CardType.CURSE) and card.player_class == entity.player_class]
192192
rare_cards = [card() for card in card_pool if card.rarity == Rarity.RARE and card.type not in (CardType.STATUS, CardType.CURSE) and card.player_class == entity.player_class]
193-
assert len(common_cards) > 0, f"Common pool is empty."
194-
assert len(uncommon_cards) > 0, f"Uncommon pool is empty."
195-
assert len(rare_cards) > 0, f"Rare pool is empty."
193+
assert len(common_cards) > 0, "Common pool is empty."
194+
assert len(uncommon_cards) > 0, "Uncommon pool is empty."
195+
assert len(rare_cards) > 0, "Rare pool is empty."
196196

197197
rarities = [common_cards, uncommon_cards, rare_cards]
198198
rewards = []
@@ -215,9 +215,9 @@ def generate_potion_rewards(self, amount: int, entity: object, potion_pool: dict
215215
common_potions: list[dict] = [potion() for potion in potion_pool if potion.rarity == Rarity.COMMON and (potion.player_class == PlayerClass.ANY or potion.player_class == entity.player_class)]
216216
uncommon_potions: list[dict] = [potion() for potion in potion_pool if potion.rarity == Rarity.UNCOMMON and (potion.player_class == PlayerClass.ANY or potion.player_class == entity.player_class)]
217217
rare_potions: list[dict] = [potion() for potion in potion_pool if potion.rarity == Rarity.RARE and (potion.player_class == PlayerClass.ANY or potion.player_class == entity.player_class)]
218-
assert len(common_potions) > 0, f"Common potions pool is empty."
219-
assert len(uncommon_potions) > 0, f"Uncommon potions pool is empty."
220-
assert len(rare_potions) > 0, f"Rare potions pool is empty."
218+
assert len(common_potions) > 0, "Common potions pool is empty."
219+
assert len(uncommon_potions) > 0, "Uncommon potions pool is empty."
220+
assert len(rare_potions) > 0, "Rare potions pool is empty."
221221

222222
all_potions = common_potions + uncommon_potions + rare_potions
223223
rarities = [common_potions, uncommon_potions, rare_potions]
@@ -257,7 +257,7 @@ def generate_relic_rewards(self, source: str, amount: int, entity, relic_pool: d
257257
return rewards
258258

259259
def claim_relics(self, choice: bool, entity: object, relic_amount: int, relic_pool: dict=None, rewards: list=None, chance_based=True):
260-
relic_pool = relic_pool if not relic_pool else relic_pool
260+
relic_pool = relic_pool if relic_pool else relic_pool
261261
if not rewards:
262262
rewards = self.generate_relic_rewards('Other', relic_amount, entity, relic_pool, chance_based)
263263
if not choice:
@@ -325,11 +325,7 @@ def card_rewards(self, tier: str, choice: bool, entity, card_pool: dict, rewards
325325
if choice:
326326
chosen_reward = view.list_input('What card do you want? > ', rewards, view.view_piles)
327327
# This could probably be condensed
328-
if entity.upgrade_attacks and rewards[chosen_reward].type == 'Attack':
329-
rewards[chosen_reward].upgrade()
330-
elif entity.upgrade_skills and rewards[chosen_reward].type == 'Skill':
331-
rewards[chosen_reward].upgrade()
332-
elif entity.upgrade_powers and rewards[chosen_reward].type == 'Power':
328+
if entity.upgrade_attacks and rewards[chosen_reward].type == 'Attack' or (entity.upgrade_skills and rewards[chosen_reward].type == 'Skill' or entity.upgrade_powers and rewards[chosen_reward].type == 'Power'):
333329
rewards[chosen_reward].upgrade()
334330
entity.deck.append(rewards[chosen_reward])
335331
ansiprint(f"{entity.name} obtained <bold>{rewards[chosen_reward].name}</bold>")

0 commit comments

Comments
 (0)