import time
import random
inventory = [""]
gold = 0
rawfish = ["Mackarel", "Cod", "Salmon", "Herring", "Tuna"]
trash = ["Old Shoe", "Plastic Bag", "Rusted Empty Box", "Plank Fragment"]
special = ["Copper Ring"]
mackarel_range = range(1,3)
cod_range = range(3,5)
salmon_range = range(5,7)
herring_range = range(7,9)
tuna_range = range(9,11)
oldshoe_range = range(11,16)
plasticbag_range = range(16,21)
rustedemptybox_range = range(21,26)
plankfragment_range = range(26,31)
copperring_range = range(31,32)
print "~~~~WELCOME TO FISHING~~~~"
time.sleep(2)
print "Loading Version 0.4 ..."
time.sleep(2)
print "In this current version the last item in your inventory is sold."
def sell_function():
if inventory[0] in rawfish:
sold = inventory.pop(0)
gold += 5
print "You have sold a", sold, "for 5 gold coins!"
action_function()
if inventory[0] in trash:
sold = inventory.pop(0)
gold += 1
print "You have recycled a", sold, "for 1 gold coins!"
action_function()
if inventory[0] in special:
sold = inventory.pop(0)
gold += 10
print "You have sold a", sold, "for 10 gold coins!"
action_function()
def fish_function():
if random.randrange == mackarel_range:
inventory.append("Mackarel")
print "You have reeled in a Mackarel!"
action_function()
if random.randrange == cod_range:
inventory.append("Cod")
print "You have reeled in a Cod!"
action_function()
if random.randrange == salmon_range:
inventory.append("Salmon")
print "You have reeled in a Salmon!"
action_function()
if random.randrange == herring_range:
inventory.append("Herring")
print "You have reeled in a Herring!"
action_function()
if random.randrange == tuna_range:
inventory.append("Tuna")
print "You have reeled in a Tuna!"
action_function()
if random.randrange == oldshoe_range:
inventory.append("Old Shoe")
print "You have reeled in an Old Shoe..."
action_function()
if random.randrange == plasticbag_range:
inventory.append("Plastic Bag")
print "You have reeled in a Plastic Bag..."
action_function()
if random.randrange == rustedemptybox_range:
inventory.append("Rusted Empty Box")
print "You have reeled in a Rusted Empty Box..."
action_function()
if random.randrange == plankfragment_range:
inventory.append("Plank Fragment")
print "You have reeled in a Plank Fragment..."
action_function()
if random.randrange == copperring_range:
inventory.append("special1")
print "You find a slightly dirty Copper Ring, after clearing the dirt it appears quite nice."
action_function()
def action_function():
chance = random.randrange(1,31)
action = raw_input("Do you want to .sell or .fish?")
if action == "sell":
sell_function()
if action == "fish":
fish_function()
if action == "inventory":
print inventory
action_function()
action_function()
我已经在这个游戏上寻求过帮助,我仍在尝试一点一点地制作。因此,当我运行程序时,它似乎到达了action = raw_input("Do you want to .sell or .fish?")
打印提示的部分,但是当我键入 fish 或 sell 时,它再次打印提示。:s 在我看来,它只是回到函数的开头并重新启动它。请帮忙。