1
0

Better import usage, adds game_config.py, adds a debug mode (sets all spell chances to 100%)

This commit is contained in:
Kwarde 2024-01-18 16:43:20 +01:00
parent 1485f171be
commit 7cb65f5895
4 changed files with 30 additions and 10 deletions

View File

@ -1,8 +1,10 @@
#import random
from player import *
from wands import *
import random
from player import Player
from wands import wands
from spells import SPELL_TYPE_COMMON, SPELL_TYPE_POWERFUL, _INVALID_SPELL
from spells import random_combat_spell, print_spells, find_spell_by_name
from spells import spells
from game_config import MAX_PLAYER_HEALTH
##
## Definitions

16
game_config.py Normal file
View File

@ -0,0 +1,16 @@
##
## Player config
##
MAX_PLAYER_HEALTH = 1000 # Maximum health
MAX_STUNNED_ROUNDS = 10 # Max amount of rounds a player can be stunned
##
## Spells config
##
CHANCE_HEAL_PARTLY = 25 # Percentage chance a player is healed with 5% of max health when using a defensive spell
CHANCE_HEAL_FULLY = 5 # Percentage chance a player is fully healed when using a defensive spell
##
## Misc
##
DEBUG_MODE = False # Enable or disable debug mode. Sets all spell chances to 100% when enabled

View File

@ -2,9 +2,7 @@ import random
from wands import Wand
from spells import SPELL_TYPE_NONE, SPELL_TYPE_USELESS, SPELL_TYPE_DEFENSE, SPELL_TYPE_UNFORGIVABLE#, SPELL_TYPE_COMMON, SPELL_TYPE_POWERFUL
from spells import Spell, spells, _INVALID_SPELL
MAX_PLAYER_HEALTH = 1000
MAX_STUNNED_ROUNDS = 10
from game_config import MAX_PLAYER_HEALTH, MAX_STUNNED_ROUNDS
class Player:
def __init__(self, name: str, wand: Wand):

View File

@ -1,4 +1,5 @@
import random
from game_config import CHANCE_HEAL_PARTLY, CHANCE_HEAL_FULLY, DEBUG_MODE
SPELL_TYPE_NONE = -1
SPELL_TYPE_USELESS = 0
@ -7,9 +8,7 @@ SPELL_TYPE_COMMON = 2
SPELL_TYPE_POWERFUL = 3
SPELL_TYPE_UNFORGIVABLE = 4
# If SPELL_TYPE_DEFENSE is casted, always these chances to heal partly (restore 5% of max hp) or completely
CHANCE_HEAL_PARTLY = 25
CHANCE_HEAL_FULLY = 5
#Maximum Levenshtein distance. Eg if a user casts 'Pritrgo' instead of 'Protego', distance would be 2 and Protego would still be cast if MAX_LEVENSHTEIN_DISTANCE is at least 2
#Set to 0 to disable
@ -94,6 +93,11 @@ spells = {
_INVALID_SPELL: Spell(0, 0, 0, "(internal) invalid spell", SPELL_TYPE_NONE)
}
# Set succes rates to 100% if debug mode is enabled
if DEBUG_MODE:
for i in spells.items():
i[1].succes_rate = 100
##
## Standalone spell functions
##
@ -145,4 +149,4 @@ def print_spells():
.strip('(')
.strip(')')
.replace(',', ':', 1)
)
)