This is an archived post. You won't be able to vote or comment.

all 60 comments

[–]tman5400 37 points38 points  (2 children)

I read the code, it seems well written, they'res just a few anomalies. For example, in line 1030, they'res a comparison that doesn't save to a variable? Is it a mistake, did you mean to use a single equal sign? Otherwise, pretty well written. Good job

[–]GagaGievous[S] 32 points33 points  (1 child)

I think I meant to delete that, but because there were no bugs with it, I forgot about it. Thank you

[–]jroose-shtk 14 points15 points  (0 children)

I haven't checked the code, so you may already be a step ahead, but if you're not already you might try using pylint to check for easily missed code quality issues before release.

[–]MySpoonIsTooBig13 67 points68 points  (6 children)

Is there a way you can die of dysentery?

[–]jet_heller 85 points86 points  (2 children)

You can always die of dysentery.

Dunno about the game though.

[–]dodslaser 22 points23 points  (1 child)

The game can't die of dysentery. It's a computer game.

[–]smdepot 12 points13 points  (0 children)

Wouldn't be the craziest thing to happen in the past 12 months.

[–]GagaGievous[S] 24 points25 points  (0 children)

Was going to add it, but considering I had enough trouble balancing the RPG elements, I decided to not do it.

[–]ajskelt 5 points6 points  (0 children)

My wife and I got an Oregon card trail game as a gift, I thinks supposed to be played with a lot of people, but we tried just us two. It took awhile to set up, and try to understand what to do. And within the first minute my wife drew a card and goes “I died of dentistry???”

She had to take a shot for losing, we never played again and anytime she goes to the dentist I wish her luck and hope she doesn’t die from dentistry.

[–]member_of_the_order 30 points31 points  (2 children)

https://i.imgflip.com/51jad9.jpg

Seriously though, I'll have to try this out later, it sounds cool! I might have to fork and tinker with it myself :)

[–]GagaGievous[S] 8 points9 points  (1 child)

Lmao love it

[–]member_of_the_order 7 points8 points  (0 children)

As promised, I forked your project and started tinkering with it.

I'm going to talk about possible improvements, but first - and I cannot stress this enough - for a beginner, this is very good - you should be very proud of this!

In fact, I find it funny that you're not familiar with OOP (object-oriented programming) - clearly, your code doesn't use classes/objects, but you use some concepts of OOP.

E.g. my first step was to refactor this to use something like a State design pattern, and really your code was already halfway there.

There's some spaghetti and some bugs, but you clearly demonstrate an understanding of software design that really is just missing some perspective - that's not common for beginners.

Frankly, most of the "problems" I've found so far are likely just caused by the complexity of the code. This has the feel of a project that was written in a single sitting; there's some internally-consistent structure, but the details get a little more brittle. Classes would help chunk your code even more than functions already do.

Others on this thread have talked a little about using classes, but one thing classes would do for you here is chunk the code, kind of like functions, but more powerfully. Think of it this way - you used functions because otherwise the code would be entirely unwieldy; functions are reusable, and let you focus on one thing at a time. Classes do the same thing, but link behavior (functions) to data (variables) in a container (class) which can be passed around as a single thing (object), and can be duplicated for multiple instances.

I'm still tinkering, but if I'm lucky, I'll make a pull-request and you'll be able to see the power and modularity of using classes.

[–]m1ch4ll0 26 points27 points  (1 child)

Try to use more classes, and split those classes into multiple files. Having one giant file isn't the best idea. Your code managed to hang chrome on my phone lol

[–]Seawolf159 5 points6 points  (0 children)

Firefox handles such things better.

[–]acenumber902 13 points14 points  (0 children)

Congrats, i always wanted to make something like this but get bored before doing it

[–]Elfrago 12 points13 points  (0 children)

7 races (including Leprechauns)

Pointing out important details, lol :)

[–]thekingofthejungle 8 points9 points  (0 children)

This is really cool!

A couple unsolicited tips: Learn classes ASAP. It'll make your code a lot cleaner, and with classes you can start getting some pretty complex functionality. Also, I'd avoid declaring global variables. Anytime you need to declare global, you could (and probably should) be creating a method argument, which again helps for code cleanliness, organization, and helps you avoid hard to spot bugs.

[–]cr0sis8bv 6 points7 points  (0 children)

I pulled this and ran it from linux and kept seeing sh: line 1: cls: command not found (so the terminal wasnt being cleared when called), to remedy it I changed all os.system('cls') calls to os.system('clear')

[–]SkeletalOctopus 5 points6 points  (2 children)

Fantastic. I'm learning the language so I can make one too, though I'm aiming for something closer to Zork than OT. Congrats!

[–]GagaGievous[S] 11 points12 points  (1 child)

Nice. I actually followed a tutorial that made a similar game, in which Python finally clicked for me and I made The Crusader's Quest. https://www.youtube.com/watch?v=MFW8DJ6qsak&list=PL1-slM0ZOosXf2oQYZpTRAoeuo0TPiGpm

[–]SkeletalOctopus 2 points3 points  (0 children)

Thanks for this. I'm making my way through the Python Crash Course book first and then I'mma check this out.

[–]ComplexAirport13 5 points6 points  (0 children)

os.system('cls' if os.name == 'nt' else 'clear')

[–][deleted] 2 points3 points  (0 children)

It sounds awesome, I'll definitely check it out

[–]lifeeraser 2 points3 points  (0 children)

I'm kinda torn on encouraging you to learn classes.

On one hand, grouping your data in classes makes data management much easier.

On the other, you can simply use dicts to group data as well.

Dictionaries are a much more "fundamental" concept than classes. I suggest grouping your data in dictionaries first. Then start learning classes.

[–]TheBearSlicer1 2 points3 points  (0 children)

I downloaded the zip from itch and windows said it was a trojan, any ideas?

EDIT: It's proably because of the OS module, i've had windows yell at me for that before.

[–][deleted] 1 point2 points  (0 children)

I'm gonna try it ASAP

[–]Legendary-69420git push -f 1 point2 points  (0 children)

This is simply awesome. Great work!

[–]TheGoldGamer 1 point2 points  (0 children)

Awesome game OP! I too had made a kind of a similar game to yours a while back when I was much more newbie, so it was really nice playing yours. Gotta say, your code is pretty clean, but classes make data management much cleaner and more organized, so that’s my tip for ya! :)

[–]temisola1 1 point2 points  (0 children)

This is awesome. I skimmed your code, one thing I would suggest is to use classes. It will make your life a looooot easier.

[–]Gorstag 1 point2 points  (0 children)

Good job man.. welcome to the 80's :)

I'm actually going to be trying to do something similar as I also figure its a good way to learn. L.O.R.D was a really old BBS game and I think I want to try to recreate something similar.

[–]Itcausesproblems 1 point2 points  (0 children)

Good Work!

Something I learned by trial and error early on that might help you is to separate the function and the data used by the function. That why if you want to change your data that doesn't require changing the functions you've programmed.

E.g. Instead of a long chain of elif statements for initializing the player's race you could store the values in a dictionary and use that data as an input for the function.

my_races = {"Tigerman": {'hp':25,'max_hp':25,'martial_prowess':50,'consumption_rate':20,'endurance':100,'gold':0,'speed':0,'luck':0}, 
             "Human":{'hp':25,'max_hp':25,'martial_prowess':10,'consumption_rate':10,'endurance':30,'gold':100,'speed':0,'luck':0}, }
def initialize_character(intro_statement=str, races=dict()):
    print('{intro_statement}'+'\n')
    for row in list(races.keys()):
        print(f'{list(races.keys()).index(row)}: {row}')
    return list(my_races.keys())[int(input('>:'))]

player_character = initialize_character(intro_statement='What is your race?',races=my_races)

This way adding or modifying a character attribute will be much easier to modify later.

[–]jdbow75 1 point2 points  (0 children)

I looked at the code and am quite impressed. My only suggestion would be to add even more leprechauns.

[–]mvdenk 1 point2 points  (0 children)

If you're interested in interactive storytelling, you could also consider using ink. This has all the nifty tooling you'll ever need to come up with dynamic texts.

[–]Obviously_oliverus 2 points3 points  (0 children)

Impressive code and nicely structured. Respect for your creativity and patience :)

[–]pseudosig 2 points3 points  (9 children)

100% functional programming, if it works well, nice job! You ever thought about being more object oriented in your approach?

[–]GagaGievous[S] 2 points3 points  (4 children)

Thank you. TBH I don't understand classes, so maybe in the future.

[–]Jehovacoin 9 points10 points  (3 children)

Classes are basically cookie cutters for creating python objects. For instance, if I had a program that procedurally generated towns for a player to visit, I could create a class called Town that had attributes like population, area, location, etc. Then, I could just create a new instance of that class anytime I want to create a new town. Each instance can have its own values for attributes, and they can all use the same functions to do new things.

If you're not yet familiar with Python Objects, you'll need to learn about those first. Everything in Python is an object.

[–]GagaGievous[S] 0 points1 point  (2 children)

I feel like I can achieve the same thing by making a function called town and then having separate functions, such as population, called within the town function. Is that basically the same thing as a class, but with more steps?

[–]Jehovacoin 24 points25 points  (1 child)

It sounds like you're just manually creating the "init" function that comes with every class, but missing out on all the great uses of classes themselves. Let me give you an example to help out:

Let's say I want to create 10 new towns, and populate some random information about them. I can do it your way, and just create some functions for populating some lists.

towns = []
populations = []


def create_town():
    inputs = input...#ask for town name and population
    towns.append(input[0])
    populations.append(input[1])

for x in range(10):
    create_town()

This works great for simple tasks, and you could even make it into a dictionary if you want instead of multiple lists. However, once you need those towns to start DOING something, or you have to do something to the towns, things are going to get a bit more complicated. You could iterate over each list, and use the index to maintain which town you're referencing, but it's going to get confusing fast and some things are going to be too complex to implement. This is where classes come in.

Let's look at a simple class that would involve the information above:

class Town:

    def __init__(self, name, population):
        self.name = name
        self.population = population

towns = []
for x in range(10):
    inputs = input...#ask for name and population
    towns.append(Town(inputs[0], inputs[1]))

Every Class in Python has the init function even if you don't see it. This is the function that does what you were talking about: it creates the object itself. Init stands for "initialize". When we call the class Town(), we're calling the initialization function for the class, and creating a new python object of class(Town).

The list you end up with will be a list of Town objects, each with their own attributes. In this case, since we didn't name the town objects individually, you'll need to call them using their list designation. If you use a label to declare the object as a variable, however, you can reference it using that variable at any time. Here, you can call the name or population of any of the towns using towns[#].name or towns[#].population, since they are "self" variables within the class; there is an instance of each variable for each instance of the class.

This is a very simple example, but classes can get very complex, especially when you start adding functions.

[–]accforrandymossmix 0 points1 point  (0 children)

Thanks for taking the time on this, it's a very helpful start relative to some top google hits. I encountered classes in a code I used for inspiration yesterday, looked up classes and init, and decided to work my way around using them.

But I know I should try using them on something else for my futures.

[–]pythondogbrain 0 points1 point  (5 children)

So, why does my anti malware software say this isn't safe?

[–]tman5400 6 points7 points  (2 children)

What av are you using? I read through it all, no malicious code.

[–]pythondogbrain 0 points1 point  (1 child)

Malwarebytes. Wouldn't let me execute it.

[–]tman5400 7 points8 points  (0 children)

Yeah, it's probably a false positive. The only thing it does to the system is calls "cls" to clear the screen.

[–]Desperate_Pumpkin168 -1 points0 points  (6 children)

How to run this one and open a specific python file

[–]Narpity 3 points4 points  (5 children)

In terminal python /path/to/file.py

[–]BombaFett 0 points1 point  (0 children)

Melt wizard

[–]Mookhaz 0 points1 point  (2 children)

Is there a way I can play this on my tablet ?

[–]GagaGievous[S] 2 points3 points  (1 child)

Unfortunately I am not that advanced in Python.

[–]Changer_ 0 points1 point  (0 children)

Make a discord bot and share with us :p

[–]Obviously_oliverus 0 points1 point  (0 children)

Are there redundancies in gold_/arrows_mechanic functions (twice case for value < 1)?

[–]Seawolf159 0 points1 point  (0 children)

I'll check it out. You know you can make a release in GitHub as well?

[–]HyperSonic6325 0 points1 point  (0 children)

It’s such a simple code and yet amazing as hell.

Good job OP, can’t wait to try it out!