Python Forum
If statements - Shell Word-based RPG
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If statements - Shell Word-based RPG
#1
def start_game():
  import sys
  import time
  import random
  import math
  print('''Welcome to Python World.
This is a word based RPG adventure game.
I am Dev_unknown and I will be your guide through this exhillirating adventure
1) Start your adventure
2) Continue
3) Read help journals
4) Exit''')
  first_input = input()
  input_list= ["1", "2", "3", "4"]
  while first_input not in input_list:
    start_game()
  if first_input == "1":
    def play():
      money=100
      print ("Vendor: Hello! What would be your name?")
      name = input("")
      print(name,'''? What a lovely name, for such a lovely fella.
Now, tell me, what weapon shall I get for you? A sword? Dagger? Perhaps a bow? Or... an axe?''')
      w_1=input("")
      print("Indeed? That'll be fifty.")
      print("Money:", money)
      print ("That'll be nuff.")
      money=money-50
      inventory = list ("")
      if w_1 == "Sword" or "sword":
        inventory.append("Stone Sword")
      if w_1 == "Axe" or "axe":
        inventory.append ("Stone Axe")
      if w_1 == "Bow" or "bow":
        inventory.append ("Wood Bow")
      if w_1 == "dagger" or "Dagger":
        inventory.append("Rusty Dagger")
      else:
        print("Vendor: Well... what do you want?")
        w_1 = input()
        if w_1 == "Sword" or "sword":
          print("You have received Stone Sword.")
        inventory.append("Stone Sword")
        if w_1 == "Axe" or "axe":
          print("You have received Stone Axe")
        inventory.append ("Stone Axe")
        if w_1 == "Bow" or "bow":
          print("You have received Wood Bow.")
        inventory.append ("Wood Bow")
        if w_1 == "dagger" or "Dagger":
          print("You have received Rusty Dagger")
        inventory.append("Rusty Dagger")
      def add(item):
        print ("You have received:", item)
      time.sleep(1)
      if w_1 == "Sword" or "sword":
        add("Stone Sword")
      if w_1 == "Axe" or "axe":
        add("Stone Axe")
      if w_1 == "Bow" or "bow":
        add("Wood Bow")
      if w_1 == "Dagger" or "dagger":
        add("Rusty Dagger")
      print("Money:", money)
      print("Dev_unknown: And so... your adventure starts.")
      time.sleep(3)
      print ("")
      print ("The Barktree Forest")
    play()
  if first_input == "4":
    sys.exit()
  if first_input == "3":
      print ('''Python World tutorial and guide:
Python World is an adventure RPG. It uses simple commands like [input] to find out what the player wants to do. It cannot allow too much freedom, so many lines in the code state to: Input [x,y,z].
It uses dictionaries and lists to contain data on weapons and enemies. These functions hopefully make it more fun to play the game.
It uses a peculiar system where each weapon is in a class of it's own.
Input [more] to learn about weapon classes or [exit] to back out to the menu.''')        
  input_help_a= input()
  if input_help_a == "more" or "More":
    print('''The Combat System:
Python World uses a variety of mathematical functions to make sure the combat is exciting.
Python World uses the random value to replicate a percentage. There is a chance for attacks to miss, hit, or hit and do 'critical' damage.

Stone Sword:
40 ATK
Speed=50
Crit chance = 20%
Miss chance = 10%

Warrior's Sword:
100 ATK
Speed=75
Crit chance = 45%
Miss chance = 15%

Rusty Dagger:
20 ATK
Speed=60
Crit chance = 40%
Miss chance = 15%

Assassain's Dagger:
80 ATK
Speed = 100
Crit chance = 50%
Miss chance = 25%

Wood Bow:
40 ATK
Speed = 45
Crit chance = 30%
Miss chance = 20%

Archer's Bow:
100 ATK
Speed = 90
Crit chance = 40%
Miss chance = 10%

Stone Axe:
80 ATK
Speed = 20
Crit chance = 5%
Miss chance = 30%

Guard's Axe:
120 ATK
Speed = 15
Crit chance = 0%
Miss chance = 30%
Input [more] to learn about enemy types or [exit] to return to the menu.''')
    input_help_b = input()
    if input_help_b == "more":
      print ('''Enemies:
There are four types of common monsters.
Slime:
These monsters are slow, but they almost never miss.
Zombie:
Not very accurate, but hit very hard.
Arcane Skeleton:
Undead wizard that doesn't hit for much, but a crit will do a lot of damage.
Ghost:
Speedy souls, chip damage.
Input [exit] to return to the menu.''')
      input_help_c = input()
      if input_help_c == "exit":
        start_game()
      else:
        print("Input [exit].")
        input_help_c = input()
        if input_help_c == "exit":
          start_game()
        else:
          start_game()
    else:
      start_game()    
  if input_help_a == "exit" or "Exit":
    start_game()
  else:
      first_input=input("")  
start_game()
The problem is with lines 30-39
Reply
#2
Quote:
if w_1 == "Sword" or "sword":

We actually have a whole article to help out :)
https://python-forum.io/Thread-Multiple-...or-keyword
Reply
#3
Shoot. I just realized my mistake just now. Sorry for the noobie mistake. I am actually very disappointed in myself. Again, sorry.

Errr.
def start_game():
  import sys
  import time
  import random
  import math
  print('''Welcome to Python World.
This is a word based RPG adventure game.
I am Dev_unknown and I will be your guide through this exhillirating adventure
1) Start your adventure
2) Continue
3) Read help journals
4) Exit''')
  first_input = input()
  input_list= ["1", "2", "3", "4"]
  while first_input not in input_list:
    start_game()
  if first_input == "1":
    def play():
      money=100
      print ("Vendor: Hello! What would be your name?")
      name = input("")
      print(name,'''? What a lovely name, for such a lovely fella.
Now, tell me, what weapon shall I get for you? A sword? Dagger? Perhaps a bow? Or... an axe?''')
      inventory = list ("")
      w_1=input("")
      if w_1 != "Stone Sword" or "Stone Axe" or "Wood Bow" or "Rusty Dagger":
        print ("Vendor: I'll just give you this sword, k?")
        inventory.append("Stone Sword")
        print ("You have received: Stone Sword.")
      if w_1 == "Stone Sword" or "Stone Axe" or "Wood Bow" or "Rusty Dagger":
        print("Indeed? That'll be fifty.")
        print("Money:", money)
        print ("That'll be nuff.")
        money=money-50
        inventory = list ("")
      def add(item):
        print ("You have received:", item)
      if w_1 == "Sword" or "sword":
        inventory.append("Stone Sword")
        add("Stone Sword")
      elif w_1 == "Axe" or "axe":
        inventory.append ("Stone Axe")
        add("Stone Axe")
      elif w_1 == "Bow" or "bow":
        inventory.append ("Wood Bow")
        add("Wood Bow")
      elif w_1 == "dagger" or "Dagger":
        inventory.append("Rusty Dagger")
        add("Rusty Dagger")
      else:
        pass
      time.sleep(1)
      print("Money:", money)
      print("Dev_unknown: And so... your adventure starts.")
      time.sleep(3)
      print ("")
      print ("The Barktree Forest")
    play()
  elif first_input == "4":
    sys.exit()
  elif first_input == "3":
      print ('''Python World tutorial and guide:
Python World is an adventure RPG. It uses simple commands like [input] to find out what the player wants to do. It cannot allow too much freedom, so many lines in the code state to: Input [x,y,z].
It uses dictionaries and lists to contain data on weapons and enemies. These functions hopefully make it more fun to play the game.
It uses a peculiar system where each weapon is in a class of it's own.
Input [more] to learn about weapon classes or [exit] to back out to the menu.''')        
  input_help_a= input()
  if input_help_a == "more" or "More":
    print('''The Combat System:
Python World uses a variety of mathematical functions to make sure the combat is exciting.
Python World uses the random value to replicate a percentage. There is a chance for attacks to miss, hit, or hit and do 'critical' damage.

Stone Sword:
40 ATK
Speed=50
Crit chance = 20%
Miss chance = 10%

Warrior's Sword:
100 ATK
Speed=75
Crit chance = 45%
Miss chance = 15%

Rusty Dagger:
20 ATK
Speed=60
Crit chance = 40%
Miss chance = 15%

Assassain's Dagger:
80 ATK
Speed = 100
Crit chance = 50%
Miss chance = 25%

Wood Bow:
40 ATK
Speed = 45
Crit chance = 30%
Miss chance = 20%

Archer's Bow:
100 ATK
Speed = 90
Crit chance = 40%
Miss chance = 10%

Stone Axe:
80 ATK
Speed = 20
Crit chance = 5%
Miss chance = 30%

Guard's Axe:
120 ATK
Speed = 15
Crit chance = 0%
Miss chance = 30%
Input [more] to learn about enemy types or [exit] to return to the menu.''')
    input_help_b = input()
    if input_help_b == "more":
      print ('''Enemies:
There are four types of common monsters.
Slime:
These monsters are slow, but they almost never miss.
Zombie:
Not very accurate, but hit very hard.
Arcane Skeleton:
Undead wizard that doesn't hit for much, but a crit will do a lot of damage.
Ghost:
Speedy souls, chip damage.
Input [exit] to return to the menu.''')
      input_help_c = input()
      if input_help_c == "exit":
        start_game()
      else:
        print("Input [exit].")
        input_help_c = input()
        if input_help_c == "exit":
          start_game()
        else:
          start_game()
    else:
      start_game()    
  if input_help_a == "exit" or "Exit":
    start_game()
  else:
      first_input=input("")  
start_game()
Is there something I'm missing?
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020