Page 1 of 1

Made a simple text based game

PostPosted: Mon Aug 25, 2014 9:05 pm
by Fl0urite
Oh and I'm back btw, haven't been on for a few months.
heres the rundown of what I made
made to be good fun or a good time waster
game features:
simple townsperson goes an a quest to kill goblins and orcs, and recieves a bounter for each orc/goblin killed to get better weapons
and health boosts/potions
the game is rather pointless, but the combat is realistic considering there is armor classes and different weapon types have different bonuses/nerfs
melee has a bonus against ranged (1.25x) but a nerf against magic (0.75x)
ranged has a bonus against magic (1.25x) but a nerf against magic (0.75x)
magic has a bonus against melee (1.25x) but a nerf against ranged attacks (0.75x)
also made to be harder to hack then other rpg games, although it includes another version that is much easier to hack
ofcourse if you do manage to hack it and give yourself a bunch of money there is 1 weapon in paticular that 1 hits everything in the game so far. (adamantium sword).
with the unencoded source you can create your own enemies/weapons/savesfiles
basically just mess around.
here is the encoded source:
Code: Select all
http://pastebin.com/i6jsmGkJ

and the unencoded source
Code: Select all
http://pastebin.com/mA8rEXfC

Re: Made a simple text based game

PostPosted: Tue Aug 26, 2014 11:13 am
by cyberdrain
Wow, don't take this the wrong way, but it's almost unreadable (and that's hard for Python sources). Too many globals, no dictionaries, almost no functions. And that's a pity, because it seems like a fun game to test things out on. Decoding the source wasn't that hard, just change exec to print and remove the parentheses. Next time you might want to only distribute the pyc file, though I don't think that will help much. Some things I noticed:
- You don't seem to use any lists or dictionaries, which might help quite a lot with this project (though you might still be learning about them);
- You're not using classes or functions to their full potential;
- At the risk of sounding like centip3de: what's with all the globals? Pass them in or move them into classes;
- There's no empty lines at all, not even between functions or if statements (this would improve readability quite a bit);
- You do use your own implementation of a list into a string, which is interesting (why though?).

So yeah, lists:
Code: Select all
weaponType=playerWeapon.split(':')
playerWeapon="magic:air strike:5:50"
would become
Code: Select all
weaponType = playerWeapon[0]
playerWeapon = ["magic", "air strike", 5, 50]

Dictionaries:
Code: Select all
if weaponType=='melee':
    action='swung'

elif weaponType=='ranged':
    action='shot'

elif weaponType=='magic':
    action='cast'
would become
Code: Select all
action = weaponTypeActions['melee']
weaponTypeActions = {'melee': 'swung', 'ranged': 'shot', 'magic': 'cast'}


Still, I have to admit it is a whole lot better than my first attempt.

Re: Made a simple text based game

PostPosted: Tue Mar 10, 2015 4:27 pm
by Fl0urite
cyberdrain wrote:Wow, don't take this the wrong way, but it's almost unreadable (and that's hard for Python sources). Too many globals, no dictionaries, almost no functions. And that's a pity, because it seems like a fun game to test things out on. Decoding the source wasn't that hard, just change exec to print and remove the parentheses. Next time you might want to only distribute the pyc file, though I don't think that will help much. Some things I noticed:
- You don't seem to use any lists or dictionaries, which might help quite a lot with this project (though you might still be learning about them);
- You're not using classes or functions to their full potential;
- At the risk of sounding like centip3de: what's with all the globals? Pass them in or move them into classes;
- There's no empty lines at all, not even between functions or if statements (this would improve readability quite a bit);
- You do use your own implementation of a list into a string, which is interesting (why though?).

So yeah, lists:
Code: Select all
weaponType=playerWeapon.split(':')
playerWeapon="magic:air strike:5:50"
would become
Code: Select all
weaponType = playerWeapon[0]
playerWeapon = ["magic", "air strike", 5, 50]

Dictionaries:
Code: Select all
if weaponType=='melee':
    action='swung'

elif weaponType=='ranged':
    action='shot'

elif weaponType=='magic':
    action='cast'
would become
Code: Select all
action = weaponTypeActions['melee']
weaponTypeActions = {'melee': 'swung', 'ranged': 'shot', 'magic': 'cast'}


Still, I have to admit it is a whole lot better than my first attempt.


I am not using lists for a good reason: the game is being saved to a file, and that file simply loads the variables into the game.

Re: Made a simple text based game

PostPosted: Tue Mar 10, 2015 5:03 pm
by cyberdrain
Fl0urite wrote:I am not using lists for a good reason: the game is being saved to a file, and that file simply loads the variables into the game.

A list is nothing but a list of variables, so you could modify it a bit to make that work. Dictionaries is a bit harder, but could work similarly. So you haven't moved on to other projects by now?

Re: Made a simple text based game

PostPosted: Thu Mar 12, 2015 8:41 pm
by Fl0urite
cyberdrain wrote:
Fl0urite wrote:I am not using lists for a good reason: the game is being saved to a file, and that file simply loads the variables into the game.

A list is nothing but a list of variables, so you could modify it a bit to make that work. Dictionaries is a bit harder, but could work similarly. So you haven't moved on to other projects by now?

Yes ofcourse, I simply wanted to clear that up :)

Re: Made a simple text based game

PostPosted: Fri Mar 13, 2015 7:46 am
by cyberdrain
Ah, thanks for that :D

Re: Made a simple text based game

PostPosted: Sat Jun 13, 2015 11:00 pm
by Ayr3s
you could try using json to save dictionaries to the save file. :)