Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

See through a Gm's eyes!
#18

Canaris Wrote:I tested your program and not sure if it's the way you want but when I type: "buy" when it says "I have a 'sword' and a 'shield' for sale! Which would you like to 'buy' some sir?" it prints "Care to buy anything else?". Shouldn't that be only after the purchase?

Nice start for only having learned for 6 hours. Keep it up Smile

I'm not expert programmer or anything just used to try out some stuff for fun like you are doing now. Anyway, If you are still improving it to learn here's some food for the thought.

1) Remove some of the unneeded variables. Your while loops use boolean variables to break out of them. You can clean it up a bit by just making it endless loop and breaking out using break statement whenever needed. No change in functionality. Just easier for the reader of your code.
Code:
while 1:
    if selection == 1:
        # do stuff here
        break
    elif selection == 2:
        # do some other stuff here
        break

2) Error checking for user input. What if user decides to type for example "plaa" to a question that accepts integer variables (for example the first question)? Program goes nuts. Exceptions are easy way to handle those situations more gracefully and have your program deal with the situation:
Code:
try:
        selection = int(raw_input("Please choose a reward 1 or 2.\n"))
    except:
        print "Only numerical values accepted!"
Never trust users of your program to do the intended thing Big Grin

More on topic: Nasir said code like this would take max 15mins to write. I'm sure any of the devs that are working/worked on INX can do that. Can't really compare between what more experienced devs like Maka, Nasir or Rob do and code that galens wrote. Difference in amount of experience is huge.

Ya know, I was reading on try and except later in the morning, then I passed out from lack of sleep. I didn't quite grasp it. Now I get it, instead of it printing any error and exiting the program, its more or less another if statement, except, if raw_input = null, non int or non str, it prints a repetative message. I could squeeze you till your eyeballs poop out. ^_^

I'm going to try and fix, plus add a ton more features with narration.

I appreciate it.


Messages In This Thread
See through a Gm's eyes! - by Galens - 01-10-2008, 12:32 PM
See through a Gm's eyes! - by imported_Kitiara - 01-10-2008, 01:27 PM
See through a Gm's eyes! - by imported_KYO1 - 01-10-2008, 01:38 PM
See through a Gm's eyes! - by Galens - 01-10-2008, 02:09 PM
See through a Gm's eyes! - by imported_Nasir - 01-10-2008, 04:55 PM
See through a Gm's eyes! - by imported_Lederoil - 01-10-2008, 05:23 PM
See through a Gm's eyes! - by imported_Aghast - 01-10-2008, 05:37 PM
See through a Gm's eyes! - by imported_Hate - 01-10-2008, 06:40 PM
See through a Gm's eyes! - by imported_ShadarWar - 01-10-2008, 07:37 PM
See through a Gm's eyes! - by imported_ScareCrow - 01-10-2008, 08:29 PM
See through a Gm's eyes! - by imported_Vulcan - 01-10-2008, 09:09 PM
See through a Gm's eyes! - by Galens - 01-10-2008, 10:34 PM
See through a Gm's eyes! - by imported_Kitiara - 01-10-2008, 11:03 PM
See through a Gm's eyes! - by Galens - 01-10-2008, 11:16 PM
See through a Gm's eyes! - by imported_KYO1 - 01-11-2008, 01:50 AM
See through a Gm's eyes! - by Galens - 01-11-2008, 02:13 AM
See through a Gm's eyes! - by imported_Kamos - 01-11-2008, 05:59 AM
See through a Gm's eyes! - by Galens - 01-11-2008, 07:22 AM
See through a Gm's eyes! - by imported_Odium - 01-11-2008, 07:39 AM
See through a Gm's eyes! - by Eighty Swords - 01-11-2008, 07:54 AM
See through a Gm's eyes! - by imported_ScareCrow - 01-11-2008, 08:29 AM
See through a Gm's eyes! - by Galens - 01-11-2008, 10:48 AM
See through a Gm's eyes! - by imported_Kamos - 01-11-2008, 03:53 PM
See through a Gm's eyes! - by imported_Kamos - 01-11-2008, 04:15 PM
See through a Gm's eyes! - by Galens - 01-11-2008, 04:58 PM
See through a Gm's eyes! - by imported_Aghast - 01-11-2008, 05:25 PM
See through a Gm's eyes! - by Eighty Swords - 01-11-2008, 08:39 PM
See through a Gm's eyes! - by imported_LudaKrishna - 01-16-2008, 01:12 AM

Forum Jump:


Users browsing this thread: 6 Guest(s)