repl.it
Python

A text-based RPG

fork
loading
Files
  • main.py
  • disps.py
  • enemies.py
  • locations.py
main.py
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
from disps import *
from locations import *
from numpy.random import choice

strt = start(5, 5, "START", True)

class Player:
	def __init__(self, x, y):
		scr("What is your name, adventurer?")
		self.name = str(input(">"))
		
		self.hp = 100
		self.maxhp = 100
		self.mp = 100
		self.maxmp = 100
		self.sp = 100
		self.maxsp = 100

		self.exp = 0
		self.lvl = 1

		self.x = x
		self.y = y

player = Player(5, 5)

def inputs():
	global player
	print("(N)orth, (n)orth, (U)p, or (u)p")
	print("(S)outh, (s)outh, (D)own, or (d)own")
	print("(E)ast, (e)ast, (R)ight, or (r)ight")
	print("(W)est, (w)est, (L)eft, or (l)eft")
	print("Show (S)tats or (s)tats")
	print("Show (P)osition or (p)osition")
	i = str(input(">"))
	if i=='N' or i=="n" or i=="U" or i=="u":
		player.y += 1
	if i=='S' or i=="s" or i=="D" or i=="d":
		player.y -= 1
	if i=='E' or i=="e" or i=="R" or i=="r":
		player.x += 1
	if i=='W' or i=="w" or i=="L" or i=="l":
		player.x -= 1
	if i=="S" or i=="s":
		printStats()
	if i=="P" or i=="p":
		showPos()


def testLocs():
	for i in locs:
		if player.x == i.x and player.y == i.y and not i.done:
			i.enter()
			i.event()

			if i.oneTime:
				i.done = True

def printStats():
	print("HP: " + str(player.hp))
	print("Max HP: " + str(player.maxhp))
	print("Mana: " + str(player.mp))
	print("Max Mana: " + str(player.maxmp))
	print("Stamina: " + str(player.sp))
	print("Max Stamina: " + str(player.maxsp))
	print("Experience Points: " + str(player.exp))
	print("Level: " + str(player.lvl))
	input("Press enter to continue ")
	
def showPos():
	print("X: " + str(player.x))
	print("Y: " + str(player.y))

def testBattle():
	u = choice([0,1], 1, p=[.9, .1])
	if u:
		print("BATTLE!!")



strt.enter()
strt.done = True

while 1:

	inputs()
	testLocs()
	testBattle()
	
	

Fetching token
?