Share your repls and programming experiences

← Back to all posts
TextRPG: [TRADER UPDATE]
bryancrisso (104)

NEW UPDATE: Traders are here! (full changelog at the bottom)

I've created a game called TextRPG. It's a roguelike, turn-based dungeon crawler, with infinite randomly generated floors. This game is still in the early stages (this is the first "playable" update), so the interface is a bit unpolished. It would be great if people could report bugs, and stay tuned for the next updates! (btw if u wanna report an error/crash please include the error message it makes it so much easier for me to track down said error with the output)

DISCLAIMER: The save system doesn't seem to work here. If you want to save your games, please fork this code into your own repl and run from there.

If you want to report any problems, ask any questions, or simply just wanna chat about the future of the game, feel free to join my discord server: https://discord.gg/aeN2wgs It would be greatly appreciated!

Important Info

Terms of use: You are allowed to use this code for personal use only, that means that you can modify the code all you want, but you are not allowed to distribute it either commercially or non-commercially. This is because I want to release this as a fully fledged game in the future.


GUIDE

It seems that the interface of the game is more complicated than I thought!
I guess I'll describe how it works.
The dungeon is made of a series of floors, which are generated with rooms every time you descend down the steps.
There are 5 different types of rooms:

  • U: This is a staircase going up. Use the "Continue" option while in this room to go up the stairs (you can't go up if you're on floor one!)
  • D: This is a staircase, you guessed it, going down! Works similarly to the "U" stairs. You can still go down the stairs even if you haven't explored the entire floor.
  • F: This is a "fight" room. Here you will find an enemy to fight, and enemy difficulty is based on your current floor.
  • L: This is a loot chest! You will always get one food item from the chest and a 1/3 chance of getting a weapon. The loot of lowest quality has the highest chance of dropping, while high quality loot is quite rare!
  • T: This is the "trader" room. Traders will either be a grocer or blacksmith. You can buy food from the grocer or buy weapons and repair your weapons at the blacksmith!
  • Traversing through the rooms is quite easy! When you have the chance, choose the "Continue" option, and you will be shown a map of your floor. Choose the options to move in the four directions. On the map, each letter represents a room. A room of colour orange/yellow means it is unexplored. Green is explored, and red is where you are currently at.
    Every 10 floors, the size of the floors increases and the quality of loot improves!
    Have fun grinding infinitely!

Early Access Update 1 Changelog:

  • Traders have been added! A trader will be either a grocer or a blacksmith. You can buy food from the grocer. You can buy weapons and repair your weapons at the blacksmith. Each trader will have a range of stock to sell!
  • A bunch more content has been added! Grind for more weapons, eat a wider range of food, and face more enemies! Check the code for all the additions! Thanks to @EdmundNewman for helping me out with this.
  • A bug has been fixed where the game could crash while moving floors beyond floor 9
  • Fixed a bug where the options list would disappear after eating while fighting an enemy
  • Fixed a bug where player position would not reset after death
  • Some QoL additions: Health now shows on top of eat screen, Current floor is now shown in stats, Current enemy info is shown at the top of the fight options screen
  • Your gold count is now halved upon death (still slightly buggy :/)
  • Escape chance is now 25% instead of 50%, and when you escape from an enemy, you will have to fight it again if you re-enter the room
    I can confirm that the next update will be centred around the introduction of armour, inventory management, and bosses. Hopefully a new save system as well, so it will work on this post!
Commentshotnewtop
JonahElias (149)

just a suggestion, you should make a new data save for each player because I just logged into someone else's game and had all of their stuff

bryancrisso (104)

@JonahElias yeah this is made to be a game installed on your local machine... it doesnt quite like it when j put it on repl. I'll see what i can do in the next update!!

JonahElias (149)

@bryancrisso It's a really good game btw

ManuelLL (1)

@bryancrisso Perhaps you should consider using the repl.it database for these SaveGame purposes. And I'm sure it goes without saying that prior to play, users should fork it into their own repl.it.
Otherwise, good job!

conkon300 (3)

@JonahElias I keep on going into someone's named "asd" game.

epicman702 (217)

This is sadly better than my ad infinitum...

Its rly good!

novelboy (0)

@hello4691 Tried it out! Very, very cool. Traveled the full 1000 miles. I liked the mage/magician appearing, and the options were good. I thought the bottle showed up too many times - but maybe that was just for me? I also thought the protagonist is kinda a bad dude lol, making trouble everywhere he goes (as those were the options). Good game!~

hello4691 (32)

@novelboy Thanks :). The reason the bottle scenario came up so many times was because I used multiple of the same scenario. The potions gave different effects. I got kinda lazy after that and didn't add anymore scenarios.

Aarush001 (0)

@hello4691 I have tried your game, it is nice
I have a suggestion: you could've allowed increasing the stamina more than 100
you could've added 'save' option
I have even travelled 1000 steps also


that's it,
waiting for your game to be download...

bowmand117 (3)

i love your text rpg series! plz post more updates asap!

lucky77 (0)

my name is now SAVED DO NOT WORK HERE (lol)

FloCal35 (158)

Noice, glad to see trader's here

AtharvGoel (3)

Mysql might be a potential way for you to get save files to work.

AtharvGoel (3)

Can you add a way to sell stuff to the trader?

FloCal35 (158)

Good Job, one thing tho. When I pressed continue a game it gave me a random persons game

Aarush001 (0)

This game is AWESOME!!
I love this game and I hope you create more games like this and you publish it soon so that I can access it from my device.
waiting to download Text RPG...

MegaEmailman (0)

When trying to go from floor 12 to 13, I got the following error.

Traceback (most recent call last):
File "main.py", line 661, in <module>
game = Game()
File "main.py", line 581, in init
self.mainMenu()
File "main.py", line 382, in mainMenu
self.intro(player)
File "main.py", line 398, in intro
self.pause(player)
File "main.py", line 428, in pause
self.floorMovement(player)
File "main.py", line 481, in floorMovement
player.floorList.append(dungeon.createFloor(player.currentFloor))
File "main.py", line 599, in createFloor
floorArray = self.populateFloor(floorArray, floor)
File "main.py", line 646, in populateFloor
j.loot = [random.choice(eligibleFood), random.choice(eligibleWeapon)]
File "/usr/lib/python3.8/random.py", line 290, in choice
raise IndexError('Cannot choose from an empty sequence') from None
IndexError: Cannot choose from an empty sequence

I also never got a weapon from a chest. Could there be an issue with the weapons list? Perhaps especially for floor 13?

bryancrisso (104)

@MegaEmailman the error you got should be fixed now. as for the weapons, it's a 1/3 chance to get a weapon from a chest, so you're probably getting really unlucky

AtharvGoel (3)

For your bat stew, you can use the random module's randint to choose a random number in some range. Use an if else conditional, so that if the random number is like 5 or something, the health you gain is negative, hence you take damage. Else, you gain 20 health.

bryancrisso (104)

@AtharvGoel it's a bit more complicated than that, but good idea nevertheless! the comment that says "dk how to implement" is from my friend, who does most of the content creation!

LukeShomper (50)

Im not too good at coding but would you be cool if I tried to make it online? and like gave friends the script so we could play together, ill credit you of course.

bryancrisso (104)

@LukeShomper go ahead! I'd love to see what you can come up with. I'm thinking about including multiplayer myself later on, but now i want to focus on fleshing out the singleplayer experience. Personally I want to give the game a visual experience before adding multiplayer.

LukeShomper (50)

@bryancrisso Yeah, I realized how work in progress it is, I might wait a while.

JBYT27 (427)

@bryancrisso So what does the self thing do?

bryancrisso (104)

@JBYT27 when you are working with classes, self attributes the variable to the current class

DragonQuester (0)

Small problem, the game doesn’t save my name after taking a break. It changed to “asd.”

DragonQuester (0)

Just realized that it signed into someone else’s game like @JonahElias said.

pleasestop (0)

i made a game like this but in pygame. probably won't ever upload it because it's probably trash. a quick question: how did you get things to save? that's one of my limitations right now, it has to be played in one session.

bryancrisso (104)

@pleasestop u can use the python "pickle" module to save data

DobbyK (0)

Really Cool, but I have a bug to report

When you choose to eat, and after you eat an item the entire interface, ends and only says: What is you choice.

bryancrisso (104)

@DobbyK yeah that's a weird bug. It will still just take options from the battle options while not showing the menu.

DobbyK (0)

@bryancrisso I think I found the problem but it might be wrong (Under the function 'eat'):

 for i in foodDictionary:
            if choice.name == i.name:
                print('The item you chose exists as a food item!')
                print('Your choice exists in your inventory!')
                print('Eating ' + choice.name + '\n')
                self.currentHealth += choice.healthRegen
                if self.currentHealth > self.maxHealth:
                    self.currentHealth = self.maxHealth
                self.inventoryRemove(choiceNum)
                #self.saveInventory(self.inventory)
                #self.saveStats()
                selected = True
                break

After it actually gets the eating done, and improves your health it breaks and returns to here: (Under the Function "Encounter"):

while not hasAttacked:
            choice = ""
            while choice not in choices:
                choice = input("Choice: ")
                if choice in choices:
                    os.system('cls||clear')
                    if choice == '1':
                        player.attack(enemy)
                        hasAttacked = True
                    elif choice == '2':
                        return random.randint(1, 2)
                        hasAttacked = True
                    elif choice == '3':
                        player.eat()
                    elif choice == '4':
                        player.selectWeapon()
                    elif choice == '5':
                        player.displayStats()
                else:
                    print("Invalid number!")

I'm not sure where it goes after finishing "player.eat" but I think this may be the problem.

bryancrisso (104)

@DobbyK theres nothing wrong with the eat function, it just doesn't show the options screen after eating (because it clears screen after eating). It's a really easy fix...

DobbyK (0)

@bryancrisso Oh, I just think too much hard on everything lol.

TurtleAndrew (74)

Wow this is really cool.

Muffinlavania (1390)

The save system is sad... I have the same problem with the .dat files to..... (This is in this )
Also you could even make this like a full game you can move around, i made a maze game here:
https://repl.it/@Muffinlavania/Maze-thing#main.py
Using these physics you could maybe make events, like a Q is an event, and if you move into it it triggers something

Also if you want to do anything with this i can help

bryancrisso (104)

@Muffinlavania i mean, the save system was never made for repl, it works perfectly fine on a local installation. I'm prototyping ways of using the repl database for saving data, for this post.
Your maze prototype is a good idea, but I definitely have different priorities for this. Anyways, as the saying goes, don't fix what ain't broke.
I'm totally fine on this project, I have like 4 friends already working with me on it, although I do most of the programming, and a couple of them create all the content.

bryancrisso (104)

@ZDev1 it's just a file type used to store data

ZDev1 (694)

@bryancrisso oh amazing
Is there a tutorial about how to use it?

bryancrisso (104)

@ZDev1 search up "python pickle module"

ZDev1 (694)

@bryancrisso oh gud
Can I use it with Nodejs?

WilliamRV (0)

for me, the game crashes when I try to go down to floor 7 or 8

bryancrisso (104)

@WilliamRV could you share the error message? would help a lot when trying to fix the error!

elizurfk (12)

It is pretty good, but I have one little suggestion. When you go downstairs, you gain a floor. When you go upstairs, you lose a floor. Why is that? I think it should be flipped.

bryancrisso (104)

@elizurfk Well, if you think about a classic dungeon, you would start at the top, and explore downwards, right? So this is what happens. We start at the top and you go downwards, and since the floors are technically infinitely generated, it's just a lot easier to get bigger floor numbers the more you go down (it helps with the generation algorithm, it's just a lot simpler)

elizurfk (12)

@bryancrisso Yeah, but why would the floors get bigger if you are going down?

elizurfk (12)

Ummm dude I played for 20 minutes straight and on floor 10 I was going to floor 11 and this happened: It had errors from multiple lines and my thing just crashed

bryancrisso (104)

@elizurfk uhoh, tysm for reporting the bug! I haven't tested beyond floor 10 because, well, I though it would work just fine! I'll try to replicate the bug and attempt to fix it within the next few hours.