Nightshade Anime & Manga RPG Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.


A fun filled anime/manga reading, watching and RPG community.
 
HomePortalLatest imagesRegisterLog in

 

 Code (Python 2.7.5)

Go down 
AuthorMessage
Lenka
Moderate
Moderate
Lenka


Posts : 244
Reputation : 0
Join date : 2013-09-09
Age : 26

Character Sheet
Current Active Characters:
Game Related Information:
Nom de Guerre:

Code (Python 2.7.5)  Empty
PostSubject: Code (Python 2.7.5)    Code (Python 2.7.5)  EmptyMon Dec 16, 2013 9:20 pm

This is a text-based game I am writing for a friend. So... Here's what I have so far.

global STR
global INT
global DEX
global Vitality
global Mana
global Endurance
global Name
global Race
global Pro
global motive

def RaceSelection ():
global Selection
global Race
Selection = raw_input("What people doth thou hail from? ")
if Selection == "Human":
  Race = "Human"
  return
elif Selection == "Hill Dwarf":
  Race = "Hill Dwarf"
  return
elif Selection == "Mountain Dwarf":
  Race = "Mountain Dwarf"
  return
elif Selection == "Halfling":
  Race = "Halfling"
  return
elif Selection == "Gnome":
  Race = "Gnome"
  return
elif Selection == "Faun":
  Race = "Faun"
  return
elif Selection == "Half-Etten":
  Race = "Half-Etten"
  return
else:
 print "Invalid Answer"
 RaceSelection()
return

def ProSelection ():
global Selection
global Pro
Selection = raw_input("What ist thyne proffession? ")

if Selection == "Lark":
  Pro = Selection

elif Selection == "Beserker":
  Pro = Selection

elif Selection == "Crusader":
  Pro = Selection
  return
elif Selection == "Cleric":
  Pro = Selection
  return
elif Selection == "Magician":
  Pro = Selection
  return
elif Selection == "Ranger":
  Pro = Selection
  return
else:
 print "Invalid Answer"
 ProSelection()
return

def C ():
Continue = raw_input ("Invalid Answer, Continue? [Y/N]")
if Continue == "Y":
  RunGame ()
elif Continue == "N":
 
  print "Game Over"
  print "----------------"
  print "%s, a noble %s %s, Was slain in the %s %s, trying %s" %(Name, Race, Pro, dunpre, dunsuf, motive)
  print "STR - %s" % STR
  print "INT - %s" % INT
  print "DEX - %s" % DEX
  print "~~~~~~~~~~~~~~~~"
  print "Vitality - 0"
  print "Mana - %s" % Mana
  print "Endurance - %s" % Endurance
  print "---------------"
 
elif Continue <> "N":
 C()  
return

def Attack ():
   import random
   from random import randint
   global phealth
   global shield
   global armor
   global fire
   global ice
   global magic
   global melee
   global projectile
   global mhealth
   global attack
   global mattack
   phealth = raw_input ("Player's Health: ")
   shield = raw_input ("Player's Sheild Type: ")
   armor = raw_input ("Player's Armor Type: ")
   fire = raw_input ("Fire Resistance? [Y/N]: ")
   ice = raw_input ("Ice Resistance? [Y/N]: ")
   magic = raw_input ("Magic Resistance? [Y/N]: ")
   melee = raw_input ("Melee Resistance? [Y/N]: ")
   projectile = raw_input ("Projectile Resistance? [Y/N]: ")
   mhealth = raw_input("Enter NPC health. ")
   mhealth = float(mhealth)
   attack = raw_input("Enter player attack. ")
   attack = float(attack)
   mattack = raw_input("Enter NPC attack. ")
   mattack = float(mattack)
   print "Which attack is the NPC using?"
   typ = raw_input("fire, ice, magic, melee, projectile: ")
   loop = 0
   
   if armor == "none":
       fluff = 0
   elif armor == "light":
       mattack = mattack / 10
       mattack = mattack * 9
   elif armor == "medium":
       mattack = mattack / 100
       mattack = mattakck * 75
   elif armor == "heavy":
       mattack = mattack / 10
       mattack = mattack * 6
   elif armor == "mega":
       mattack = 0

   elif typ == "fire" and fire == "resistance":
       mattack = mattack / 2
   elif typ == "fire" and fire == "weakness":
       mattack = mattack * 2
   elif typ == "ice" and ice == "resistance":
       mattack = mattack / 2
   elif typ == "ice" and ice == "weakness":
       mattack = mattack * 2
   elif typ == "melee" and melee == "resistance":
       mattack = mattack / 2
   elif typ == "melee" and melee == "weakness":
       mattack = mattack * 2
   elif typ == "magic" and magic == "resistance":
       mattack = mattack / 2
   elif typ == "magic" and magic == "weakness":
       mattack = mattack * 2
   elif typ == "projectile" and projectile == "resistance":
       mattack = mattack / 2
   elif typ == "projectile" and projectile == "weakness":
       mattack = mattack * 2
   elif magic == "none" or melee == "none" or fire == "none" or ice == "none" or projectile == "none":
       fluff = 0    

   while loop < 1:
       mhealth = mhealth - attack
       print "Player has dealt %d damage to NPC." % attack
       print "NPC has", mhealth, "health left."
       if mhealth < 1:
           print "NPC has been slain."
       rand = random.randint(1, 100)
       if shield == "wood":
           if rand < 11:
               print "NPC misses."
               if rand > 10:
                   print "NPC hits player(-%d hp)" % mattack
                   health = health - mattack
                   if health < 1:
                       print "Player has died."
                       return health
       if shield == "steel":
           if rand < 16:
               print "NPC misses."
               if rand > 15:
                   print "NPC hits player.(-%d hp)" % mattack
                   health = health - mattack
                   if health < 1:
                       print "Player has died."
                       return health
       if shield == "tower":
           if rand < 31:
               print "NPC misses."
               if rand > 30:
                   print "NPC hits player(-%d hp)" % mattack
                   health = health - mattack
                   if health < 1:
                       print "Player has died."
                       return health
       if shield == "none":
           health = health - mattack
           print "NPC hits player.(-%d hp)" % mattack
           if health < 1:
               print "NPC slays player."
               return health
       loop = loop + 1    

def RunGame ():
import random
from random import randint
from random import choice

gs = 1




STR = random.randint(5,12)
INT = random.randint(3,10)
DEX = random.randint(5,10)

Vitality = STR * 7 - DEX * 2
Mana = INT * 4
Endurance = STR * 4 - INT * 2

races = [ 'Human','Human','Human','Human','Human','Human', 'Hill Dwarf','Hill Dwarf','Hill Dwarf','Hill Dwarf', 'Mountain Dwarf','Mountain Dwarf', 'Halfling','Halfling','Halfling','Halfling','Halfling','Halfling',
         'Gnome','Gnome','Gnome', 'Faun', 'Half-Etten','Faun', 'Half-Etten', ]

pro = [ 'Beserker','Crusader','Hunter','Lark','Cleric','Magician',]


Dungeon_Pre = [ 'Twisted', 'Forgotten', 'Sacred', 'Ancient', 'Malagant',]
global dunpre
dunpre = choice(Dungeon_Pre)

Dungeon_Suf = [ 'Hollow', 'Cavern', 'Cave', 'Delve', 'Castle', 'Fortress', 'Dungeon', 'Ruin', 'Barrow', 'Crypt', 'Keep', 'Ruined City', 'Temple', 'Portal', 'Lair', 'Enclave',]
global dunsuf
dunsuf = choice(Dungeon_Suf)

motives = [ 'to find a missing villager', 'to find the truth about the return of the dragons', 'to discover why their is no mana left in the Kingdom of Alandor', 'to kill the Red Dragon', 'to kill the White Dragon',
          'to find a lost treasure', 'to escape from the Royal Gaurd', 'while tracking an Orc Warband', 'while serching for evidence that the Barron of Kinternoth is a vampire', 'seeking a cure to his illness',
          'to prove that Fairies do not exist', 'to look for an anchient tome of knowledge',]
global motive
motive = choice(motives)
global Name
Name = raw_input("What is thyne name, valient warrior? ")

print """

-- Races --

+ Human
+ Hill Dwarf
+ Mountain Dwarf
+ Halfling
+ Gnome
+ Faun
+ Half-Etten

"""


RaceSelection ()

print """

-- Proffessions --

+ Beserker
+ Crusader
+ Hunter
+ Lark
+ Cleric
+ Magician

"""

ProSelection ()

print "%s, a noble %s %s, entered the %s %s %s" %(Name, Race, Pro, dunpre, dunsuf, motive)

print "----------------"
print "STR - %s" % STR
print "INT - %s" % INT
print "DEX - %s" % DEX
print "~~~~~~~~~~~~~~~~"
print "Vitality - %s" % Vitality
print "Mana - %s" % Mana
print "Endurance - %s" % Endurance
print "---------------"

rooms = [ 'You enter a dark hallway, lit only by an occational torch', 'You walk into a strange corridor, filled with statues of pagan gods', 'You stumble into a dimly lit chamber made of stone bricks',
         'Walking through a grand archway, you enter a room lit by magical torches', 'Magical Runes line the floor in this room', 'By the looks of this room, a battle between to opposing goblin tribes took place here',
         'Writings of an Old Dwarfish Alphabet line the walls here', 'The room here is flooded with murky water', 'Part of this room has collapsed into a large cave system', 'You enter a small chamber lit by a single torch',]
events = ['You find a Red Colored Potion, and quickly drink it', 'You take a rusty sword leaning against the wall', 'You stumble and are about to hit your head against the wall...', 'You find a lotus flower, which is said to bring good luck',
         'You are ambushed by an Orc Warloard. You fight him off, but he escapes into another part of the dungeon', 'You attack a wandering Hobgoblin', 'You are haunted by Wraiths, but scare them off when you make the sign of a cross',
         'You hear footsteps behind you, and dash ahead to try and loose your pursuer', 'You are hit by a swinging ball trap', 'You attack a wandering cave bear', 'You hear the movements of rats from the other side of the wall',
         'From the other side of the wall, voices can be heard', 'You catch a glimsp of a small wisp before it fades into a wall']

gs = 0
cont = 0

while gs == 0:
  cont = raw_input('Action? [Enter for nothing]')
  if cont == 'Attack':
   Attack()
  else:
   print choice(rooms)

   CE = choice(events)
   print CE
   if CE == 'You are hit by a swinging ball trap':
    Vitality = Vitality-5
    if Vitality <= 0:
     print "Vitality = 0"
     print "You Die..."
     break
    else:
     print "Vitality = %s" % Vitality
   elif CE == 'You stumble and are about to hit your head against the wall...':
    if Vitality >= 0:
     Chance = random.randint(1,10)
     if Chance == 9:
      Dmg = random.randint(1,50)
      Vitality = Vitality-Dmg
      if Vitality <= 0:
       print "...And you snap your neck..."
       print "You Die..."
       break
      else:
        print "You have a deep gash in your head, but you survive."
        print "Vitality = %s" %Vitality
     else:
      print "You catch yourself."
    else:
     print "Vitality = %s" % Vitality
   elif CE == 'You are ambushed by an Orc Warlord. You fight him off, but he escapes into another part of the dungeon':
    Vitality = Vitality-15
    if Vitality <= 0:
     print "Vitality = 0"
     print "You Die..."
     break
   elif CE == 'You attack a wandering cave bear':
    if Vitality <= 0:
     print "It swipes at you..."
     print "And Slashes deep into your chest."
     print "Vitality = 0"
     print "You Die..."
     break
    else:
     print "It swipes at you..."
     Chance = random.randint(1,5)
     if Chance == 4:
      Dmg = random.randint(1,30)
      Vitality = Vitality-Dmg
      print "And Slashes deep into your chest."
      if Vitality <= 0:
       print "Vitality = 0"
       print "You Die..."
       break
      else:
       print "Vitality = %s" % Vitality
     else:
      print "...And misses completely"
      print "You escape."  
      print "Vitality = %s" % Vitality
   else:
    print 'No Stat Change'

Continue = raw_input ("Continue? [Y/N]")
if Continue == "Y":
  RunGame ()

elif Continue == "N":
  print "Game Over"
  print "----------------"
  print "%s, a noble %s %s, Was slain in the %s %s, trying %s" %(Name, Race, Pro, dunpre, dunsuf, motive)
  print "STR - %s" % STR
  print "INT - %s" % INT
  print "DEX - %s" % DEX
  print "~~~~~~~~~~~~~~~~"
  print "Vitality - 0"
  print "Mana - %s" % Mana
  print "Endurance - %s" % Endurance
  print "---------------"
 
 
elif Continue <> "N":
 C()  
return

RunGame ()

--Fuck Spoilers
Back to top Go down
Guest
Guest




Code (Python 2.7.5)  Empty
PostSubject: Re: Code (Python 2.7.5)    Code (Python 2.7.5)  EmptyTue Dec 17, 2013 7:44 am

It's pretty good. It seems like even more code than ChoiceScript but you covered all your bases. You may have a problem with some of the loops that you have though simply because of the way Python code works. I myself haven't used it too much but I hear it can be a pain.
Back to top Go down
 
Code (Python 2.7.5)
Back to top 
Page 1 of 1
 Similar topics
-
» Code of Conduct

Permissions in this forum:You cannot reply to topics in this forum
Nightshade Anime & Manga RPG Forum :: Limbo and Practice RP :: OOC & Chat :: Discussion Board-
Jump to: