-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
148 lines (116 loc) · 3.58 KB
/
main.py
File metadata and controls
148 lines (116 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import time, sys, random, json
from datetime import datetime
def sprint(text, wait=0.05):
for i in text:
print(i,end="",flush = True)
time.sleep(wait)
print("")
class weapon:
def __init__(self, damage, hitChance, durability):
self.damage = damage
self.hitChance = hitChance
self.durability = durability
class enemy:
def __init__(self, damage, health, level):
self.damage = damage
self.health = health
self.level = level
class food:
def __init__(self, regen, level):
self.regen = regen
self.level = level
class armor:
def __init__(self, defense, level):
self.defense = defense
self.level = level
class player:
def __init__(self, level):
self.level = level
xpCount = 0
foodCount = 0
levelCount = 3
playerGold = 0
combat = True
stick = weapon(5, 75, 100)
sword = weapon(10, 70, 300)
devstick = weapon(1000, 100, 100)
skeleton = enemy(10, 30, 5)
zombie = enemy(10, 50, 6)
theif = enemy(15, 100, 10)
burger = food(100, 1)
Player = player(levelCount)
weaponChoice = input(sprint("What weapon do you want to use?"))
if weaponChoice == "stick":
activeWeapon = stick
if weaponChoice == "sword":
activeWeapon = sword
if weaponChoice == "devstick":
activeWeapon = devstick
def combatStart():
global tempXpCount
global newPlayerGold
tempXpCount = xpCount
newPlayerGold = playerGold
if combat:
enemy_type_number = random.randint(1,levelCount)
if enemy_type_number == 1:
enemy_type = skeleton
if enemy_type_number == 2:
enemy_type = zombie
if enemy_type_number == 3:
enemy_type = theif
enemy_health = enemy_type.health
enemy_damage = enemy_type.damage
enemy_level = enemy_type.level
weapon_damage = activeWeapon.damage
player_health = (100 + (Player.level * 25))
playerMaxHealth = player_health
sprint("An" + str(enemy_type) + "has engaged")
combatStarted = True
while combatStarted:
action = input("What would you like to do?")
if action == "attack":
enemy_health = enemy_health - weapon_damage
player_health -= enemy_damage
if action == "eat":
food_choice = input("What do you want to eat?")
if food_choice == "burger":
player_health += burger.regen
if player_health > playerMaxHealth:
player_health = playerMaxHealth
if action == "devtest1":
sprint(str(player_health))
if action == "devtest2":
sprint(str(enemy_health))
if action == "":
player_health -= enemy_damage
if player_health <= 0:
sprint("You have fallen")
break
if enemy_health <= 0:
sprint("You won!")
newPlayerGold += (enemy_type.level * random.randint(20,40))
sprint("+ " + str(newPlayerGold) + " Gold!")
tempXpCount += (enemy_level * random.randint(5,10))
mainScreen()
def mainScreen():
global newPlayerGold2
newPlayerGold2 = playerGold
print("Welcome to the village!")
home_tf = True
while home_tf == True:
home_action = input("What would you like to do?")
if home_action == "Fight" or "fight":
combatStart()
break
if home_action == "Shop" or "shop":
sprint("Welcome to the shop!")
shop_action = input("1. Food, 2. Weapons")
if shop_action == "Food" or "food":
sprint("What type of food would you like to buy?")
food_buy_type = input(": ")
if food_buy_type == "burger" or "Burger":
newPlayerGold2 -= 30
combatStart()
playerGold += newPlayerGold
xpCount += tempXpCount