Skip to content

Commit

Permalink
final commit before pre-release v0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ManasKoti committed Jan 23, 2024
1 parent 00c950c commit fb8d09c
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 146 deletions.
3 changes: 3 additions & 0 deletions battle.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def battle(player, enemy):
return "dead"
elif enemy.health <= 0:
print(f"You defeated the {enemy.name}!\n")
print(f"You gained {enemy.level * 10} experience!")
print(f"You gained {enemy.money} gold!\n")
player.money += enemy.money
player.gain_experience(enemy.level * 10)


12 changes: 10 additions & 2 deletions entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def gain_experience(self, amount):
def level_up(self):
self.level += 1
self.strength += 10
print(f"{self.name} leveled up! Level: {self.level}, Strength: {self.strength}")
print(f"{self.name} leveled up! Level: {self.level}, Strength: {self.strength}\n")

def save_to_json(self, file_path="player_data.json"):
data = {
Expand All @@ -47,7 +47,9 @@ def save_to_json(self, file_path="player_data.json"):
"strength": self.strength,
"health": self.health,
"weapon_multiplier": self.weapon_multiplier,
"armour_multiplier": self.armour_multiplier
"armour_multiplier": self.armour_multiplier,
"level": self.level,
"experience": self.experience
}

with open(file_path, "w") as file:
Expand All @@ -64,6 +66,8 @@ def load_from_json(self, file_path="player_data.json"):
self.health = data["health"]
self.weapon_multiplier = data["weapon_multiplier"]
self.armour_multiplier = data["armour_multiplier"]
self.level = data["level"]
self.experience = data["experience"]
return "successfull"
except FileNotFoundError:
print("No saved data found.\n")
Expand All @@ -77,6 +81,7 @@ def __init__(self):
self.strength = 500
self.health = 500
self.level = 10
self.money = 1000

def attack(self, player):
if random.choice(HIT_CHANCE) == 1:
Expand All @@ -94,6 +99,7 @@ def __init__(self):
self.strength = 50
self.health = 50
self.level = 1
self.money = 5

def attack(self, player):
if random.choice(HIT_CHANCE) == 1:
Expand All @@ -111,6 +117,7 @@ def __init__(self):
self.strength = 100
self.health = 100
self.level = 3
self.money = 20

def attack(self, player):
if random.choice(HIT_CHANCE) == 1:
Expand All @@ -128,6 +135,7 @@ def __init__(self):
self.strength = 200
self.health = 200
self.level = 5
self.money = 50

def attack(self, player):
if random.choice(HIT_CHANCE) == 1:
Expand Down
Loading

0 comments on commit fb8d09c

Please sign in to comment.