You are on page 1of 28

mport random as rand

from sty import fg, RgbFg


import replit
from numpy import log
from hashlib import sha512
import time as t
import requests
import ast
#import os

url = 'https://api.jsonbin.io/b/5ef8eb787f16b71d48a78f34'
headers = {'secret-key':
"$2b$10$IEhBij6BDatS1tTMYFvl7uF3menuGp0f5qU8QVg/zeYAc/3qtkDn2", "content-type":
"application/json", "versioning": "false"}
a=680
b=18
vowels=["a","e","i","o","u"]
alphabet=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","
s","t","u","v","w","x","y","z"]
prompt=(" ")

red=RgbFg(248,11,45)
yellow=RgbFg(246,196,66)
green=RgbFg(0,130,0)
cyan=RgbFg(6,150,190)
blue=RgbFg(0,51,250)
magenta=RgbFg(255,20,147)
lightgreen=RgbFg(50,255,5)
midblue=RgbFg(0,122,236)
purple=RgbFg(198,73,248)
orange=RgbFg(255,128,0)
lightgold=RgbFg(249,215,147)
blizzardblue=RgbFg(0,204,255)
lilac=RgbFg(242,190,230)
white=RgbFg(255,255,255)
iceblue=RgbFg(195,255,255)
seagreen=RgbFg(102,80,0)
crimson=RgbFg(150,0,0)
sandyellow=RgbFg(253,214,140)
pastelpink=RgbFg(254,194,246)
grey=RgbFg(190,190,190)
flameorange=RgbFg(255,154,87)

colours={"red":red,"yellow":yellow,"green":green,"cyan":cyan,"blue":blue,"magenta":
magenta,"light green":lightgreen,"mid
blue":midblue,"purple":purple,"orange":orange,"light gold":lightgold,"blizzard
blue":blizzardblue,"lilac":lilac,"white":white,"ice blue":iceblue,"sea
green":seagreen,"crimson":crimson,"sand yellow":sandyellow,"pastel
pink":pastelpink,"grey":grey,"flame orange":flameorange}

def cprint(string,icolour,iend="\n"):
global colours
fg.set_style("x", colours[icolour])
print(fg.x+string+fg.rs,end=iend)

def retrieve(key):
req = requests.get(url, json=None, headers=headers)
return ast.literal_eval(req.text)[key]
def update(data):
req = requests.put(url, json=data, headers=headers)
print(req.text)

class Account:

accountlist = []

def __init__(self, name, pw, xps, gold, dayno, bait, rod, rarestfish,
inventorycontents, myths, pokedex, treasures, treasuredex, biome, items, weather):
global a,b
self.name = name
self.pw = pw
self.xps = [int(xp) for xp in xps]
self.levels=[]
self.levels.append(100)
for i,xp in enumerate(xps):

self.levels.append(int((a/(b*Biome.biomelist[i].lnvar))*log(((int(xp)*Biome.biomeli
st[i].lnvar)/a)+1)+1))
self.levels.append(1)
self.levels.append(1)
self.gold = gold
self.dayno = dayno
self.bait = bait
for eachrod in Rod.rodlist:
if eachrod.name == rod:
self.rod = eachrod
for eachfish in Fish.fishlist:
if eachfish.name == rarestfish:
self.rarestfish = eachfish
self.inventory = Inventory(inventorycontents, Fish.fishlist[:])
self.myths = Inventory(myths, Fish.fishlist[:])
self.pokedex = Inventory(pokedex, Fish.fishlist[:])
self.treasures = Inventory(treasures, Treasure.treasurelist[:])
self.treasuredex = Inventory(treasuredex, Treasure.treasurelist[:])
self.biome = biome
self.secondmessage="no message"
self.items = Inventory(items, Item.itemlist[:])
self.weather=weather

Account.accountlist.append(self)

def accinfo(self):
if self.myths.print_inv(False) == "empty":
mythprint = "none"
else:
mythprint = self.myths.print_inv(False,True)
if int(self.levels[Biome.biomelist.index(self.biome)+1])>=100:
return "gold - {0}\nbait - {1}\nrod - {2}\nlevel - {3}\nrarest fish
caught - {5}\ninventory - {4}\ntreasures - {7}\nitems - {8}\nmythical creatures
encountered - {6}".format(self.gold, self.bait,
self.rod.name,int(self.levels[Biome.biomelist.index(self.biome)
+1]),self.inventory.print_inv(False), self.rarestfish.name,
mythprint,self.treasures.print_inv(False,True),self.items.print_inv(False,True))
else:
return "gold - {0}\nbait - {1}\nrod - {2}\nlevel - {3}\nrarest fish
caught - {5}\ninventory - {4}\ntreasures - {6}\nitems - {7}".format(self.gold,
self.bait, self.rod.name,int(self.levels[Biome.biomelist.index(self.biome)
+1]),self.inventory.print_inv(False),
self.rarestfish.name,self.treasures.print_inv(False,True),self.items.print_inv(Fals
e,True))

def create_account():
global red, yellow, green, cyan, blue, magenta
global prompt
usernamedone = False
while not usernamedone:
flag = False
cprint("enter username", "red")
username = input(prompt)
tflag=False
while not tflag:
try:
req = requests.get(url, json=None, headers=headers)
saved = ast.literal_eval(req.text)
tflag=True
except:
pass
#accountsfile = open("accounts.txt", "r")
#accounts = accountsfile.readlines()
#accountsfile.close()
#for char in username:
# if char=="-":
# cprint("don't use a - character; please try again","red")
# flag = True
# break
accounts = saved["accounts"]
if username=="":
cprint("please enter a username","red")
for account in accounts:
#account = account.strip()
if account == username:
cprint("username taken; please try again", "red")
flag = True
if not flag:
usernamedone = True
cprint("enter password", "red")
pw = input(prompt)
#accountsfile = open("accounts.txt", "a")
#accountsfile.write(username + "-" + pw + "-0-0-1-10-none-wooden-empty-empty
\n")
#accountsfile.close()
weather=rand.choice(Biome.biomelist[0].distweathers)
salt = "3d987fbc3c8146c1a4903e5d198512c9"
hashed_pw = sha512(pw.encode() + salt.encode()).hexdigest()
player = Account(username, hashed_pw, [0,0,0,0], 0, 1, 10, "wooden", "none",
"empty", "empty", "empty", "empty", "empty", Biome.biomelist[0], "empty", weather)
accounts[username] = [hashed_pw, [0,0,0,0], 0, 1, 10, "wooden", "none",
"empty", "empty", "empty", "empty", "empty", "the riverlands", "empty", weather]
saved["accounts"] = accounts
tflag=False
while not tflag:
try:
requests.put(url, json=saved, headers=headers)
tflag=True
except:
pass
game_info(player)
input()
return player

def log_in():
global red, yellow, green, cyan, blue, magenta
global prompt
cprint("would you like to log in or sign up?", "red")
aec=False
flag=False
while not aec:
if not flag:
ans = input(prompt).lower()
if ans == "sign up":
player = create_account()
aec=True
elif ans == "log in":
loggedin = False
while not loggedin:
cprint("enter username", "red")
username = input(prompt)
cprint("enter password", "red")
pw = input(prompt)
salt = "3d987fbc3c8146c1a4903e5d198512c9"
hashed_pw = sha512(pw.encode() + salt.encode()).hexdigest()
tflag=False
while not tflag:
try:
req = requests.get(url, json=None, headers=headers)
saved = ast.literal_eval(req.text)
tflag=True
except:
pass
#print(saved)
accounts = saved["accounts"]
#print(accounts)
for account in accounts:
if username == account and hashed_pw == accounts[account][0]:
loggedin = True
cprint("succesfully logged in. press enter to continue",
"red", iend="")
bdone=False
for biomex in Biome.biomelist:
if accounts[account][12]==biomex.name:
biome=biomex
bdone = True
if not bdone:
biome = Biome.biomelist[0]
player=Account(username, hashed_pw, accounts[account][1],
accounts[account][2], int(accounts[account][3]), int(accounts[account][4]),
accounts[account][5], accounts[account][6], accounts[account][7], accounts[account]
[8], accounts[account][9], accounts[account][10], accounts[account][11], biome,
accounts[account][13], accounts[account][14])
aec=True
if not loggedin:
cprint("username and password do not match; please try again.
if you have forgotten your password, comment and tell me on the game jam fishing
game post on repl.it. if you meant to type sign up, type it now. if you didn't,
just press enter.", "red")
ans2=input(prompt).lower()
if ans2=="sign up":
loggedin=True
ans="sign up"
flag=True
else:
cprint("please enter log in or sign up", "red")
try:
replit.clear()
except:
print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
return player

def game_info(player):
print("\n\nwelcome, ",end="")
cprint("{}".format(player.name),"red",iend="")
print(", to my fishing game!\n")
t.sleep(2)
print("the aim of the game is to reach level 100 as quickly as possible. catch
the rarest fish you can and level up!\n")
t.sleep(3)
print("you can sell your fish in the shop. rarer fish bring in more gold. you
can use this gold to purchase bait, which is needed to catch fish, and rods, which
make catching rarer fish easier. careful, bait gets more expensive as you level
up.\n")
t.sleep(5)
print("new types of fish are unlocked as you level up, and at higher levels,
it's easier to catch fish.\n")
t.sleep(3)
print("you can also see information about all the fish you've come across in
the \'fishedex\' in the shop. catch them all!\n")
t.sleep(3)
print("you might also find some treasure when you're fishing!\n")
t.sleep(3)
print("to save, go to settings, or just log out. this means you can just log
back in and pick up where you left off. good luck!\n")
t.sleep(3)
print("press enter to continue.")

class Fish:

fishlist = []

def __init__(self, name, level, cost, rarityno, biome, weathers):


self.name = name
self.level = level
self.cost = cost
self.rarityno = rarityno
if name == "none":
self.rarity = "none"
self.xpgain=0
self.colour="white"
elif rarityno >=30:
self.rarity = "common"
self.xpgain = 5
self.colour= "grey"
elif rarityno >= 20 and rarityno < 30:
self.rarity = "uncommon"
self.xpgain = 10
self.colour = "light green"
elif rarityno >= 10 and rarityno < 20:
self.rarity = "rare"
self.xpgain = 15
self.colour = "mid blue"
elif rarityno >= 6 and rarityno < 10:
self.rarity = "super rare"
self.xpgain = 20
self.colour = "purple"
elif rarityno >= 3 and rarityno < 6:
self.rarity = "epic"
self.xpgain = 25
self.colour = "light gold"
elif rarityno >=1 and rarityno < 3:
self.rarity = "legendary"
self.xpgain = 30
self.colour = "blizzard blue"
elif rarityno == 0:
self.rarity = "mythical"
self.xpgain = 1000
self.colour = "lilac"
self.biome=biome
if weathers=="any":
self.weathers=Weather.weatherlist[:]
else:
self.weathers=[]
for weather in weathers.split("-"):
self.weathers.append(weather)
self.weathers.sort()

Fish.fishlist.append(self)

def returnweathers(fish, boo=True):


if fish.weathers==sorted(Weather.weatherlist):
return "all"
else:
wstring = ""
for w in fish.weathers:
if boo:
wstring += "{0}{1}".format(w, ", " if
fish.weathers.index(w)<len(fish.weathers)-2 else " and " if
fish.weathers.index(w)<len(fish.weathers)-1 else "")
else:
wstring += "{0}, ".format(w)
return wstring

class Treasure:

treasurelist=[]

def __init__(self,name,cost,rarityno,biome):
self.name=name
self.cost=cost
self.rarityno=rarityno
if rarityno==1:
self.rarity="legendary"
self.colour="blizzard blue"
elif rarityno==2:
self.rarity="epic"
self.colour="light gold"
elif rarityno==3 or rarityno==4:
self.rarity="super rare"
self.colour="purple"
elif rarityno==5 or rarityno==6:
self.rarity="rare"
self.colour="mid blue"
elif rarityno==7 or rarityno==8:
self.rarity="uncommon"
self.colour="light green"
elif rarityno>=9:
self.rarity="common"
self.colour="grey"
self.biome=biome

Treasure.treasurelist.append(self)

class Rod:

rodlist = []

def __init__(self, name, uncommonhelp, rarehelp, highrarehelp, mythhelp, cost,


biome):
self.name = name
self.uncommonhelp = int(uncommonhelp)
self.rarehelp = int(rarehelp)
self.highrarehelp = int(highrarehelp)
self.mythhelp = int(mythhelp)
self.cost = int(cost)
self.biome = biome

Rod.rodlist.append(self)

rodsfile = open("rods.txt","r")
rods = [x.strip() for x in rodsfile.readlines()]
rodsfile.close()
for rod in rods:
rod = rod.split(", ")
Rod(rod[0],rod[1],rod[2],rod[3],rod[4],rod[5],rod[6])

class Inventory:

def __init__(self, oldcontents, typelist):


self.contents = []
self.contentslist=[]
if oldcontents != "empty":
contents = oldcontents.split("/")
for element in contents:
element = element.split(",")
for fish in typelist:
if fish.name == element[0]:
fishtoappend = fish

self.contents.append([fishtoappend,int(element[1]),int(element[2])])
self.contentslist.append(fishtoappend)
def add(self, obj, expirydate=0):
flag = False
for fish in self.contents:
if fish[0].name == obj.name:
fish[1] += 1
flag = True
self.contentslist.append(obj)
if not flag:
self.contents.append([obj, 1, expirydate])
self.contentslist.append(obj)

def takeout(self, obj, no):


flag = False
for fish in self.contents:
if fish[0].name == obj.name:
flag = True
if fish[1] == no:
self.contents.remove(fish)
return True
elif fish[1] > no:
fish[1] = fish[1] - no
return True
else:
print("you do not have enough {} in your
inventory".format(obj.name))
return False
if not flag:
print("object not in inventory")
return False

def print_inv(self,start,pl=False):
if not self.contents:
if start:
return "your inventory is empty"
else:
return "empty"
else:
if start:
if pl:
return ("in your inventory you have {0}".format(", ".join(["{0}
{1}{2}".format(fish[1], fish[0].name,"s" if fish[1]>1 else "") for fish in
self.contents])))
else:
return ("in your inventory you have {0}".format(", ".join(["{0}
{1}".format(fish[1], fish[0].name) for fish in self.contents])))
else:
if pl:
return ("{0}".format(", ".join(["{0} {1}{2}".format(fish[1],
fish[0].name,"s" if fish[1]>1 else "") for fish in self.contents])))
else:
return ("{0}".format(", ".join(["{0} {1}".format(fish[1],
fish[0].name) for fish in self.contents])))

def write_inv(self):
if self.contents == []:
return "empty"
else:
return("/".join(["{0},{1},{2}".format(x[0].name,x[1],x[2]) for x in
self.contents]))

class Biome:

biomelist=[]

def __init__(self, name, colour, lnvar, percchance, shipcost, dangerlist,


iweathers, climate):
self.name=name
self.colour=colour
self.lnvar=lnvar
self.percchance=percchance
self.shipcost=shipcost
self.dangerlist=dangerlist
self.fishes=[]
self.treasures=[]
self.weathers=[]
self.distweathers=[]
for x in iweathers.split("/"):
x=x.split("-")
self.weathers.append(x[0])
for y in range(int(x[1])):
self.distweathers.append(x[0])
self.climate=climate
Biome.biomelist.append(self)

class Danger:

dangerlist=[]

def __init__(self, name, message, secondmessage, daysout, endattempt,


losestuff, keepplaying, goldlost):
self.name=name
self.message=message
self.secondmessage=secondmessage
self.daysout=daysout
if losestuff=="lose stuff":
self.losestuff=True
elif losestuff=="not lose stuff":
self.losestuff=False
if endattempt=="last attempt":
self.endattempt=True
elif endattempt=="not last attempt":
self.endattempt=True
if keepplaying=="keep playing":
self.keepplaying=True
elif keepplaying=="not keep playing":
self.keepplaying=False
self.goldlost=goldlost
Danger.dangerlist.append(self)

class Item:

itemlist=[]
distitemlist=[]

def
__init__(self,name,info,fishhelp,days,rarityno,treasurehelp,uncommonhelp,rarehelp,h
ighrarehelp,mythhelp,safetyhelp):
self.name=name
self.info=info
self.days=int(days)
self.rarityno=int(rarityno)
self.fishhelp=int(fishhelp)
self.treasurehelp=int(treasurehelp)
self.uncommonhelp=int(uncommonhelp)
self.rarehelp=int(rarehelp)
self.highrarehelp=int(highrarehelp)
self.mythhelp=int(mythhelp)
self.safetyhelp=int(safetyhelp)
self.expirydate=0
Item.itemlist.append(self)
for x in range(self.rarityno):
Item.distitemlist.append(self)

class Weather:

weatherlist=[]

def __init__(self,name):
self.name=name
Weather.weatherlist.append(name)

weathersfile=open("weathers.txt","r")
weathers=[x.strip() for x in weathersfile.readlines()]
weathersfile.close()
for weather in weathers:
Weather(weather)

fishfile = open("fish.txt", "r")


fishes = [x.strip() for x in fishfile.readlines()]
fishfile.close()
for fish in fishes:
fish = fish.split(", ")
#print(fish[0])
Fish(fish[0], int(fish[1]), int(fish[2]), int(fish[3]), fish[4], fish[5])

treasurefile = open("treasures.txt","r")
treasures=[x.strip() for x in treasurefile.readlines()]
treasurefile.close()
for treasure in treasures:
treasure=treasure.split(", ")
Treasure(treasure[0],int(treasure[1]),int(treasure[2]), treasure[3])

dangersfile=open("dangers.txt","r")
dangers=[x.strip() for x in dangersfile.readlines()]
dangersfile.close()
for danger in dangers:
danger=danger.split("-")
Danger(danger[0], danger[1], danger[2], int(danger[3]),danger[4], danger[5],
danger[6], int(danger[7]))

biomesfile=open("biomes.txt","r")
biomes = [x.strip() for x in biomesfile.readlines()]
biomesfile.close()
for biome in biomes:
biome=biome.split(", ")
dangerlist=[]
if biome[5]=="none":
dangerlist=[]
else:
for danger in biome[5].split("-"):
for dangery in Danger.dangerlist:
if danger==dangery.name:
dangerlist.append(dangery)
Biome(biome[0],biome[1],float(biome[2]),int(biome[3]),int(biome[4]),dangerlist,
biome[6], biome[7])

for biom in Biome.biomelist[:]:


for fish in Fish.fishlist:
if fish.biome == biom.name:
biom.fishes.append(fish)
for treas in Treasure.treasurelist:
if treas.biome == biom.name:
biom.treasures.append(treas)

itemsfile=open("items.txt","r")
items=[x.strip() for x in itemsfile.readlines()]
itemsfile.close()
for item in items[:]:
item=item.split("-")

Item(item[0],item[1],item[2],item[3],item[4],item[5],item[6],item[7],item[8],item[9
],item[10])

def go_fishing():
global vowels, a, b
if player.bait == 0:
cprint("you have no bait! go to the shop to buy some",player.biome.colour)
go_shopping()
else:
cprint("press enter to see how many attempts to catch fish you can make
today",player.biome.colour,iend="")
input()
if player.bait < 6:
max = player.bait
else:
max = 6
dice = rand.randint(1,max)

if dice>1:
attemptstr = "attempts"
else:
attemptstr = "attempt"

cprint("you can make ",player.biome.colour,iend="")


cprint(str(dice),"yellow",iend=" ")
cprint(attemptstr,player.biome.colour)

newfish=[]
newtreas=[]
newitems=[]

for x in range(int(dice)):

dvar = rand.randint(1,40)
if dvar<=(Biome.biomelist.index(player.biome)+1):
highesthelp=0
for item in player.items.contents:
if item[0].safetyhelp>highesthelp:
highesthelp=item[0].safetyhelp
if highesthelp!=1000 and
rand.randint(0,highesthelp+1)<=highesthelp:
dt=False
while not dt:
danger=rand.choice(player.biome.dangerlist)
if not (x+1==dice and danger.endattempt==False):
dt=True
cprint(danger.message,"crimson",iend="")
input("")
if not danger.losestuff:
for fish in newfish:
player.inventory.add(fish)
for treas in newtreas:
player.treasures.add(treas)
for item in newitems:
player.items.add(item[0],item[1])
if player.gold<=danger.goldlost:
player.gold=0
else:
player.gold-=danger.goldlost
player.dayno+=danger.daysout
player.secondmessage=danger.secondmessage
if danger.losestuff:
newfish, newtreas = [], []
if not danger.keepplaying:
return

cprint("attempt {}...".format(x+1),"yellow",iend="")
input()

player.bait -= 1

distfishlist = []
for fish in player.biome.fishes:
if fish.level <=
int(player.levels[Biome.biomelist.index(player.biome)+1]) and (player.weather in
fish.weathers):
timestoappend = fish.rarityno
if fish.rarity == "uncommon":
highestuchelp=0
for item in player.items.contents:
if item[0].uncommonhelp>highestuchelp:
highestuchelp=item[0].uncommonhelp
timestoappend = timestoappend + player.rod.uncommonhelp +
highestuchelp
elif fish.rarity == "rare":
highestrhelp=0
for item in player.items.contents:
if item[0].rarehelp>highestrhelp:
highestrhelp=item[0].rarehelp
timestoappend = timestoappend + player.rod.rarehelp +
highestrhelp
elif fish.rarity == "super rare" or fish.rarity == "epic" or
fish.rarity == "legendary":
highesthrhelp=0
for item in player.items.contents:
if item[0].highrarehelp>highesthrhelp:
highesthrhelp=item[0].highrarehelp
timestoappend = timestoappend + player.rod.highrarehelp
elif fish.rarity == "mythical":
highestmythhelp=0
for item in player.items.contents:
if item[0].mythhelp>highestmythhelp:
highestmythhelp=item[0].mythhelp
timestoappend = timestoappend + player.rod.mythhelp +
highestmythhelp
for x in range(timestoappend):
distfishlist.append(fish)

highestfishhelp=0
for item in player.items.contents:
if item[0].fishhelp>highestfishhelp:
highestfishhelp=item[0].fishhelp

percchance = player.levels[Biome.biomelist.index(player.biome)+1] +
player.biome.percchance + highestfishhelp
resultchance = rand.randint(1,200)
if resultchance < percchance:

oldflag=True
for fishx in Fish.fishlist[1:]:
flaga=False
for fishy in player.pokedex.contents:
if fishy[0].name == fishx.name:
flaga = True
if not flaga:
oldflag=False

fish = rand.choice(distfishlist)

if fish.name[0] in vowels:
aoran="an"
else:
aoran="a"

newfishflag=True
for fishy in player.pokedex.contents:
if fish.name==fishy[0].name:
newfishflag=False

player.pokedex.add(fish)

newflag=True
for fishx in Fish.fishlist[1:]:
flagb=False
for fishy in player.pokedex.contents:
if fishy[0].name == fishx.name:
flagb = True
if not flagb:
newflag=False

if fish.rarity == "mythical":
if newfishflag:
cprint("wow, you encountered
{}".format(aoran),player.biome.colour,iend="")
cprint(fish.name,fish.colour,iend="! ")
cprint("{2} {0} is a {1} creature that can't be sold. they
can be caught in {4} in {3} weather. {0}s have been added to your
fishedex.".format(fish.name, fish.rarity, aoran, fish.returnweathers(),
fish.biome),player.biome.colour)
else:
cprint("wow, you encountered
{}".format(aoran),player.biome.colour,iend="")
cprint(fish.name,fish.colour,iend="!\n")
player.myths.add(fish)
else:
if newfishflag:
cprint("you caught {}
".format(aoran),player.biome.colour,iend="")
cprint(fish.name, fish.colour, iend="! ")
cprint("{3} {0} is a {1} fish that can be sold for {2}
gold. they can be caught in {5} in {4} weather. {0} have been added to your
fishedex.".format(fish.name, fish.rarity, fish.cost,aoran, fish.returnweathers(),
fish.biome),player.biome.colour)
else:
cprint("you caught {}
".format(aoran),player.biome.colour,iend="")
cprint(fish.name,fish.colour,iend="!\n")
newfish.append(fish)
oldlevel = int(player.levels[Biome.biomelist.index(player.biome)
+1])
player.xps[Biome.biomelist.index(player.biome)] =
player.xps[Biome.biomelist.index(player.biome)] + fish.xpgain
player.levels[Biome.biomelist.index(player.biome)+1] =
int((a/(b*player.biome.lnvar)*log((int(player.xps[Biome.biomelist.index(player.biom
e)])*player.biome.lnvar)/a + 1))+1)
if ((fish.rarityno<=player.rarestfish.rarityno and fish.name !=
player.rarestfish.name) or player.rarestfish.rarityno==0) and fish.rarity !=
"mythical":
if fish.rarityno==player.rarestfish.rarityno:
if fish.level>player.rarestfish.level:
cprint("this is the rarest fish you've ever caught!",
"blizzard blue")
player.rarestfish = fish
else:
cprint("this is the rarest fish you've ever caught!",
"blizzard blue")
player.rarestfish = fish

toldflag,tnewflag=False,False

highesttreashelp=0
for item in player.items.contents:
if item[0].treasurehelp>highestfishhelp:
highesttreashelp=item[0].treasurehelp

if rand.randint(1,20) + highesttreashelp>=20:
disttreaslist=[]
for treas in player.biome.treasures:
for x in range(treas.rarityno):
disttreaslist.append(treas)

toldflag=True
for treasurex in Treasure.treasurelist:
flaga=False
for treasurey in player.treasuredex.contents:
if treasurey[0].name == treasurex.name:
flaga = True
if not flaga:
toldflag=False

treasure=rand.choice(disttreaslist)

if treasure.name[0] in vowels:
aoran="an"
else:
aoran="a"

newtreasureflag=True
for treasurey in player.treasuredex.contents:
if treasure.name==treasurey[0].name:
newtreasureflag=False

player.treasuredex.add(treasure)
newtreas.append(treasure)

tnewflag=True
for treasurex in Treasure.treasurelist:
flagb=False
for treasurey in player.treasuredex.contents:
if treasurey[0].name == treasurex.name:
flagb = True
if not flagb:
tnewflag=False

if newtreasureflag:
cprint("wow, you found {}
".format(aoran),player.biome.colour,iend="")
cprint(treasure.name,treasure.colour,iend="! ")
cprint("{0} {3} is a {1} treasure that can be sold for {2}
gold. {3}s have been added to your
treasuredex".format(aoran,treasure.rarity,treasure.cost,treasure.name),player.biome
.colour)
else:
cprint("wow, you found {}
".format(aoran),player.biome.colour,iend="")
cprint(treasure.name,treasure.colour,iend="!\n")

if rand.randint(1,40)==40:
bvar=False
while not bvar:
item=rand.choice(Item.distitemlist)
if item not in player.items.contentslist:
bvar=True
if item.name[0] in vowels:
aoran="an"
else:
aoran="a"
cprint("you found {}
".format(aoran),player.biome.colour,iend="")
cprint(item.name,"pastel pink",iend="! ")
cprint("{}".format(item.info),player.biome.colour)
newitems.append([item,player.dayno+item.days])

if not oldflag and newflag:


cprint("wow, congratulations, you've met all the different
types of fish in the world!! great job!", "magenta")
if not toldflag and tnewflag:
cprint("wow, congratulations, you've found all the different
types of treasure in the world!! great job!", "magenta")

if int(player.levels[Biome.biomelist.index(player.biome)+1]) >
oldlevel:

if int(player.levels[Biome.biomelist.index(player.biome)+1]) ==
100:
if player.biome.name=="the riverlands":
reached_lvl100()
if player.biome.name!="old valyria":
if player.biome.name!="the riverlands":
newlvl()
if shipapproaches():
return
else:
reached_lvl400()
cprint("CREDITS","magenta")
t.sleep(1)
cprint("written by Amelia Blackwell in 2018-
2019","magenta")
t.sleep(1)
cprint("idea finder: Henry Blackwell","magenta")
cprint("with special thanks to the following repl.it
users:","magenta")
t.sleep(1)
cprint("Cats_ur_cool77","magenta")
t.sleep(1)
cprint("ebest","magenta")
t.sleep(1)
cprint("Mavrick","magenta")
t.sleep(1)
cprint("leon332157","magenta")
t.sleep(1)
cprint("and...","magenta")
t.sleep(1)
cprint("the repl.it team","magenta")

else:
newlvl()

else:
cprint("the fishing line came up empty.",player.biome.colour)

for fish in newfish:


player.inventory.add(fish)
for treas in newtreas:
player.treasures.add(treas)
for item in newitems:
player.items.add(item[0],item[1])

def newlvl(var=True):
if var:
cprint("congratulations, you reached level
{0}".format(int(player.levels[Biome.biomelist.index(player.biome)+1])),"magenta")
for fish in player.biome.fishes:
if fish.level == int(player.levels[Biome.biomelist.index(player.biome)+1]):
if fish.name[0] in vowels:
aoran="an"
else:
aoran="a"
if fish.rarity == "mythical":
cprint("you can now encounter {0}s. {2} {0} is a {1} creature that
can't be sold. they can be caught in {3} in {4} weather.".format(fish.name,
fish.rarity,aoran,fish.biome,fish.returnweathers()),player.biome.colour)
else:
cprint("you can now catch {0}. {3} {0} is a {1} fish that can be
sold for {2} gold. they can be caught in {4} in {5} weather.".format(fish.name,
fish.rarity, fish.cost,aoran,fish.biome,fish.returnweathers()),player.biome.colour)

def reached_lvl100():
cprint("CONGRATULATIONS! YOU REACHED LEVEL 100!","magenta")
cprint("you reached level 100 in {0} days".format(player.dayno),"magenta")
cprint("these are the high score rankings for how many days other players have
reached level 100 in","magenta")
seehiscores(True,"hiscorers")
cprint("now that you've reached level 100, you have the ability to encounter
mythical creatures. these are extremely rare and can only be found with the
moonstone rod, which is now unlocked in the shop. rods from other regions work too.
they can't be sold, but encountering them gives you a lot of
experience!","magenta")
newlvl(False)
t.sleep(8)

def reached_lvl400():
cprint("CONGRATULATIONS! YOU REACHED THE ENDGAME!","magenta")
cprint("you reached the last level 100 in {}
days".format(player.dayno),"magenta")
cprint("these are the high score rankings for how many days other players have
reached the endgame in","magenta")
newlvl(False)
seehiscores(True, "endgame")

def shipapproaches():
cprint("a ship approaches on the horizon...","magenta")
t.sleep(1)
cprint("\"ahoy there, matey! board our ship to {0} for {1}
gold!\"".format(Biome.biomelist[Biome.biomelist.index(player.biome)
+1].name,Biome.biomelist[Biome.biomelist.index(player.biome)
+1].shipcost),"magenta")
t.sleep(1)
if player.gold<Biome.biomelist[Biome.biomelist.index(player.biome)+1].shipcost:
cprint("\"oh, you don't have enough gold? don't fear, we're staying in the
dock. come find us once you have enough.\"","magenta")
else:
cprint("enter yes or no.",player.biome.colour)
aec=False
while not aec:
ans=input(prompt).lower()
if ans=="yes":
cprint("\"well, come aboard then!\"","magenta")
player.gold-=Biome.biomelist[Biome.biomelist.index(player.biome)
+1].shipcost
player.biome=Biome.biomelist[Biome.biomelist.index(player.biome)+1]
for x in range(15):
t.sleep(0.1)
cprint(" ~ ", "sea green", iend="")
t.sleep(1)
print("")
cprint("\"welcome to {}. beware the {}! i think there's a cool rod
you can buy here. if you want to go back, there are plenty of ships in the docks to
take you. I believe they charge
{}.\"".format(player.biome.name,player.biome.dangerlist[0].name,Biome.biomelist[Bio
me.biomelist.index(player.biome)-1].shipcost), "magenta")
return True
elif ans=="no":
cprint("\huh, alright then. you're missing out on some cool fish,
believe me! and rods! though I guess you might be scared of the {}... come to the
docks if you change your
mind.\"".format(Biome.biomelist[Biome.biomelist.index(player.biome)
+1].dangerlist[0].name), "magenta")
return False
else:
cprint("please enter yes or no.",player.biome.colour)

def seehiscores(pvar, key):


Hiscorer.hiscorers=[]

tflag=False
while not tflag:
try:
req = requests.get(url, json=None, headers=headers)
saved = ast.literal_eval(req.text)
tflag=True
except:
pass

hiscorers = saved[key]

if not hiscorers and not pvar:


cprint("no one has reached this level yet.","magenta")
else:

for hiscorer in hiscorers:


Hiscorer(hiscorer,hiscorers[hiscorer])
if pvar:
Hiscorer(player.name,player.dayno)

for hiscorer in Hiscorer.hiscorers:


hiscorer.days=int(hiscorer.days)
orderedlist=[]
orderedlist.append([1,Hiscorer.hiscorers[0]])
for highscorer in Hiscorer.hiscorers[1:]:
inlist=False
for orderedhighscorer in orderedlist:
if highscorer.days<orderedhighscorer[1].days:
orderedlist.insert(orderedlist.index(orderedhighscorer),
[orderedhighscorer[0],highscorer])
for neworderedhighscorer in
orderedlist[orderedlist.index(orderedhighscorer):]:
neworderedhighscorer[0]+=1
inlist=True
elif highscorer.days==orderedhighscorer[1].days:
orderedlist.insert(orderedlist.index(orderedhighscorer),
[orderedhighscorer[0],highscorer])
for neworderedhighscorer in
orderedlist[(orderedlist.index(orderedhighscorer)+1):]:
neworderedhighscorer[0]+=1
inlist=True
if inlist:
break
if not inlist:
orderedlist.append([len(orderedlist)+1,highscorer])

for printinghi in orderedlist:


cprint("{0}. {1} - {2} days".format(printinghi[0], printinghi[1].name,
printinghi[1].days), "magenta")

printinghis=[]
for printinghi in Hiscorer.hiscorers:
printinghis.append("{0}-{1}".format(printinghi.name,printinghi.days))

if pvar:
hiscorers[player.name] = player.dayno

saved[key] = hiscorers

tflag=False
while not tflag:
try:
requests.put(url, json=saved, headers=headers)
tflag=True
except:
pass

class Hiscorer:

hiscorers = []

def __init__(self, name, days):


self.name = name
self.days = days

Hiscorer.hiscorers.append(self)

def go_shopping():
global prompt
stay = True
while stay:
cprint("press a. to buy, b. to sell fish, c. to sell treasure, d. to see
fishedex, e. to see treasuredex or f. leave?",player.biome.colour)
aec=False
while not aec:
ans = input(prompt).lower()
if ans == "a":
aec=True
buy()
elif ans == "b":
aec=True
sell_stuff(player.inventory,"fish",Fish.fishlist[:])
elif ans == "c":
aec=True
sell_stuff(player.treasures,"treasure",Treasure.treasurelist[:])
elif ans == "d":
aec=True
seepokedex("fish",Fish.fishlist[1:],player.pokedex.contents[:])
elif ans == "e":
aec=True

seepokedex("treasure",Treasure.treasurelist[:],player.treasuredex.contents[:])
elif ans == "f":
aec=True
stay = False
if not aec:
cprint("please enter a, b, c, d, e, or f",player.biome.colour)

def buy():
global prompt
cprint("enter a. to buy bait, b. to buy rods and c. to go
back",player.biome.colour)
aec=False
while not aec:
ans = input(prompt).lower()
if ans == "a":
aec=True
baitprice = int(player.levels[Biome.biomelist.index(player.biome)
+1]/2+1)*(Biome.biomelist.index(player.biome)+1)
cprint("bait costs {} gold each. how much would you like to buy? (max =
{}) press a. to leave".format(str(baitprice),
str(int(player.gold/baitprice))),player.biome.colour)
aec=False
while not aec:
try:
ans=input(prompt).lower()
if ans=="a":
aec=True
else:
ans = int(ans)
if player.gold >= ans*baitprice:
player.gold = player.gold - ans*baitprice
player.bait = player.bait + ans
cprint("bought successfully. you now have {0} bait and
{1} gold".format(player.bait,player.gold),player.biome.colour)
else:
cprint("you do not have enough
gold",player.biome.colour)
aec=True
except:
cprint("please enter a number or a",player.biome.colour)

elif ans == "b":


aec=True
for rod in Rod.rodlist:
if rod.biome==player.biome.name:
if not (rod.name=="moonstone" and
player.levels[Biome.biomelist.index(player.biome)+1]<100 and
player.biome.name=="the riverlands"):
cprint("the {} rod costs {}
gold".format(rod.name,rod.cost),player.biome.colour)
else:
cprint("the {} rod is currently
unavailable".format(rod.name),player.biome.colour)

cprint("which rod would you like to buy? enter none if you do not want
to buy one",player.biome.colour)
ans = input(prompt).lower()
if ans != "none":
rodbought = False
for rod in Rod.rodlist:
if rod.name in ans:
if rod.biome==player.biome.name:
if not (rod.name=="moonstone" and
player.levels[Biome.biomelist.index(player.biome)+1]<100):
if player.gold - rod.cost >=0:
rodbought = True
player.rod = rod
player.gold = player.gold - rod.cost
cprint("bought succesfully. you now have the {}
rod and {} gold".format(player.rod.name, player.gold),player.biome.colour)
else:
rodbought=True
cprint("you don't have enough gold for that
rod",player.biome.colour)
if not rodbought:
cprint("that rod is not available",player.biome.colour)

elif ans == "c":


aec=True

if not aec:
cprint("please enter a, b, or c",player.biome.colour)

def sell_stuff(inv,typ,lis):
global prompt
if inv.print_inv(False) == "empty":
cprint("you have no {}".format(typ),player.biome.colour)
else:
cprint("enter a. to sell all your {}, b. to sell some or c. to
leave.".format(typ),player.biome.colour)
aec=False
while not aec:
ans = input(prompt).lower()
if ans == "a":
sell_all_stuff(inv,typ)
aec=True
elif ans == "b":
sell_ind_stuff(inv,typ,lis)
aec=True
elif ans == "c":
aec=True
if not aec:
cprint("please enter a, b or c",player.biome.colour)

def sell_all_stuff(inv,typ):
pastcontents = inv.print_inv(False)
oldinv = inv.contents[:]
oldgold = player.gold
for fish in oldinv:
inv.takeout(fish[0],fish[1])
player.gold = player.gold + (fish[0].cost * fish[1])
cprint("the {0} were succesfully sold for {1} gold. you now have {2}
gold".format(pastcontents, player.gold-oldgold, player.gold),player.biome.colour)

def sell_ind_stuff(inv,typ,lis):
global prompt
cprint("enter the quantity and name of the {0} you would like to sell. separate
the number and name with a \"-\". seperate multiple {0} with a \", \" enter a. to
leave.".format(typ),player.biome.colour)
aec=False
while not aec:
oldgold=player.gold
try:
ans = input(prompt).lower()
if ans=="a":
aec=True
else:
fishestosell=[]
for fis in ans.split(", "):
minilist=fis.split("-")
fishestosell.append(minilist)
for fishy in fishestosell:
for fish in lis:
if fishy[1] == fish.name:
fishtosell = fish
flag=inv.takeout(fishtosell,int(fishy[0]))
if flag:
player.gold = player.gold + (fishtosell.cost *
int(fishy[0]))
cprint("you sold the {2} for {0} gold. you now have {1}
gold".format(player.gold-oldgold, player.gold,typ),player.biome.colour)
aec=True
except:
cprint("make sure to enter the {}
correctly".format(typ),player.biome.colour)

def seepokedex(typ,lis1,lis2):
c=1
for fish in lis1:
flag=False
for fishx in lis2:
if fishx[0].name == fish.name:
no=fishx[1]
flag=True
for biome in Biome.biomelist[:]:
if fish.biome==biome.name:
colour=biome.colour
habitat=biome.climate
if flag:
if typ=="fish":
cprint("#{} - ".format(str(c).zfill(3)),colour,iend="")
cprint(fish.name.ljust(33),fish.colour,iend="")
cprint("rarity - {} ".format(fish.rarity).ljust(22),colour,iend="")
cprint("habitat - {} ".format(habitat).ljust(22),colour,iend="")
cprint("weather - {}".format(fish.returnweathers()).ljust(40),
colour,iend="")
cprint("price - {} ".format(fish.cost).ljust(15),colour,iend="")
cprint("level - {} ".format(fish.level).ljust(13),colour,iend="")
cprint("no. caught - {} ".format(no).ljust(12),colour)
else:
cprint("#{} - ".format(str(c).zfill(3)),colour,iend="")
cprint(fish.name.ljust(25),fish.colour,iend="")
cprint("rarity - {} ".format(fish.rarity).ljust(25),colour,iend="")
cprint("found in - {} ".format(habitat).ljust(30),colour,iend="")
cprint("price - {} ".format(fish.cost).ljust(20),colour,iend="")
cprint("no. found - {} ".format(no).ljust(20),colour,iend="\n")
else:
if typ=="fish":
cprint("#{}
- ???".format(str(c).zfill(3)).ljust(40),colour,iend="")
cprint("rarity - ??? ".ljust(22),colour,iend="")
cprint("habitat - ???".ljust(22),colour,iend="")
cprint("weather - ???".ljust(40),colour,iend="")
cprint("price - ??? ".ljust(15),colour,iend="")
cprint("level - ??? ".ljust(13),colour,iend="")
cprint("no. caught - 0 ".ljust(12),colour,iend="\n")
else:
cprint("#{}
- ???".format(str(c).zfill(3)).ljust(32),colour,iend="")
cprint("rarity - ??? ".ljust(25),colour,iend="")
cprint("found in - ???".ljust(30),colour,iend="")
cprint("price - ??? ".ljust(20),colour,iend="")
cprint("no. found - 0 ".ljust(20),colour,iend="\n")
c+=1

def go_docks():
global alphabet, prompt
cprint("press ",player.biome.colour,iend="")
#[cprint("{0}. to board the ship to the {1} biome [costs {2}]
{3}".format(alphabet[Biome.biomelist.index(biome)] if
player.levels[Biome.biomelist.index(biome)]>=100 and player.biome!=biome else
alphabet[Biome.biomelist.index(biome)-1], biome.name, biome.shipcost, ", " if
player.levels[Biome.biomelist.index(biome)+2]>=100 and
player.levels[Biome.biomelist.index(biome)+3]>=100 else " and {}. to
leave.\n".format(alphabet[Biome.biomelist.index(biome)
+1])),player.biome.colour,iend="") for biome in Biome.biomelist if
player.levels[Biome.biomelist.index(biome)]>=100 and player.biome!=biome]
truebiomes=[]
a=0
for i, biome in enumerate(Biome.biomelist):
if player.levels[i]>=100 and biome!=player.biome:
truebiomes.append([alphabet[a],biome])
a+=1
[cprint("{0}. to board the ship to {1} [costs {2}]{3}".format(truebiome[0],
truebiome[1].name, truebiome[1].shipcost, ", " if truebiomes.index(truebiome)!
=len(truebiomes)-1 else " or {}. to leave\n".format(alphabet[len(truebiomes)])),
player.biome.colour, iend="") for truebiome in truebiomes]
aec=False
while not aec:
ans=input(prompt).lower()
if ans in alphabet:
for truebiome in truebiomes:
if ans == truebiome[0]:
if player.gold>truebiome[1].shipcost:
cprint("you boarded the ship to {} for {}
gold.".format(truebiome[1].name,truebiome[1].shipcost),player.biome.colour)
for x in range(15):
t.sleep(0.1)
cprint(" ~ ", "sea green", iend="")
t.sleep(1)
print("")
player.gold-=truebiome[1].shipcost
oldbiome=player.biome
player.biome=truebiome[1]
cprint("welcome to {0}. {1}if you want to go back to
{2}, there are ships in the docks to take you. they charge
{3}.".format(player.biome.name,"beware the {}!
".format(player.biome.dangerlist[0].name) if player.biome.dangerlist else
"",oldbiome.name, oldbiome.shipcost), player.biome.colour)
aec=True
return
else:
cprint("you don't have enough
gold.",player.biome.colour)
aec=True
return
if ans == alphabet[len(truebiomes)]:
aec=True
return
cprint("please enter ",player.biome.colour,iend="")
#[cprint("{0}{1}".format(alphabet[Biome.biomelist.index(biome)], ", " if
player.levels[Biome.biomelist.index(biome)+1]>=100 and
player.levels[Biome.biomelist.index(biome)+2] else " or " if
player.levels[Biome.biomelist.index(biome)+1]>=100 else
".\n"),player.biome.colour,iend="") for biome in Biome.biomelist if
(player.levels[Biome.biomelist.index(biome)]>=100 and player.biome!=biome)]
[cprint("{0}{1}".format(truebiome[0], ", " if truebiomes.index(truebiome)!
=len(truebiomes)-1 else " or {}.\n".format(alphabet[len(truebiomes)])),
player.biome.colour, iend="") for truebiome in truebiomes]

def go_settings():
global player
aec=False
leave=False
while not leave:
cprint("press a. to save, b. to reset your account, c. to see current level
100 highscores board, d. to see current endgame highscores board, e. to see current
number of accounts, f. to see game information, g. for game help, h. to see repl.it
user cats_ur_cool77's fishing game tribute and i. to leave.",player.biome.colour)
aec=False
while not aec:
ans=input(prompt).lower()
if ans=="a":
save()
print("your progress was saved.")
aec=True
if ans=="b":
aec=True
cprint("are you sure? enter yes or no:", "magenta")
ans2=input(prompt)
if ans2=="yes":
username=player.name
pw=player.pw
player = Account(username, pw, [0,0,0,0], 0, 1, 10, "wooden",
"none", "empty", "empty","empty","empty", "empty", Biome.biomelist[0], "empty",
"fair")
cprint("account successfully restarted.","magenta")
save()
elif ans=="c":
aec=True
seehiscores(False,"hiscorers")
elif ans=="d":
aec=True
seehiscores(False,"endgame")
elif ans=="e":
aec=True
tflag=False
while not tflag:
try:
req = requests.get(url, json=None, headers=headers)
saved = ast.literal_eval(req.text)
tflag=True
except:
pass
accounts = saved["accounts"]
cprint("there are currently {} accounts signed up to the fishing
game! thank you to all the players!".format(len(accounts)),"magenta")
elif ans =="f":
aec=True
cprint("the fishing game was developed by Amelia Blackwell in 2018-
2019. it's inspired by runescape and stardew valley. it's written in python, using
the repl.it website. one of the reasons i choose fishing in particular was because
most plural fish names are the same as the singular haha. the data storage is done
using jsonclient.io and the json-store-client module written by repl.it user
leon332157. the password encryption is done using the hashlib module which was
shown to me by repl.it user ebest. the coloured text is done using the sys module.
the code is very object orientated. why game of thrones place names? because i'm
uncreative. if want to write something similar and need help, please email me at
ameliaxblackwell@gmail.com. thanks for playing the game!", "magenta")
elif ans == "g":
aec=True
cprint("the aim of the game is to reach level 100 as quickly as
possible. catch the rarest fish you can and level up!\nyou can sell your fish in
the shop. rarer fish bring in more gold. you can use this gold to purchase bait,
which is needed to catch fish, and rods, which make catching rarer fish easier.
careful, bait gets more expensive as you level up.\nnew types of fish are unlocked
as you level up, and at higher levels, it's easier to catch fish.\nyou can also see
information about all the fish you've come across in the \'fishedex\' in the shop.
catch them all!\nyou might also find some treasure when you're fishing!\nthe game
saves your progress at the end of each day, so you can just log in again and pick
up where you left off. good luck!","magenta")
elif ans == "h":
aec=True
cprint("this artwork was created by repl.it cats_ur_cool77. thanks
to your much-appreciated support and life-saving bug-finding!","magenta")
###CODE BY CATS_UR_COOL77 ON REPL.IT
cprint(' ___________\n| \ /| ','orange')
cprint('| . . \/ |','blizzard blue')
cprint('| __ |','orange')
cprint('| /\ |','blizzard blue')
cprint('|___________/ \|','orange')
###
elif ans == "i":
aec=True
leave=True
else:
cprint("please enter a, b, c, d, f, g, h or
i.",player.biome.colour)

def do_stuff(dayno):
global prompt
play = True
cprint("location - {}".format(player.biome.name),player.biome.colour)
cprint("day {}".format(dayno), "green")
player.weather=rand.choice(player.biome.distweathers)
cprint("weather - {}".format(player.weather),"green")
for item in player.items.contents[:]:
if item[2]<dayno:
player.items.takeout(item[0],1)
cprint(player.accinfo(),player.biome.colour)
if player.secondmessage!="no message":
cprint(player.secondmessage, "crimson")
player.secondmessage="no message"
if player.levels[1]<100:
cprint("press a. to go fishing, b. to go to the shop, c. to go to settings
or d. to log out.",player.biome.colour)
else:
cprint("press a. to go fishing, b. to go to the shop, c. to go to the
docks, d. to go to settings or e. to log out.",player.biome.colour)
aec = False
while not aec:
ans = input(prompt).lower()
if ans == "b":
go_shopping()
aec=True
cprint("it's the end of the day. press enter to
continue",player.biome.colour)
input(prompt)
elif ans == "a":
go_fishing()
aec=True
cprint("it's the end of the day. press enter to
continue",player.biome.colour)
input(prompt)
elif (ans == "c" and player.levels[1]>=100):
go_docks()
aec=True
cprint("it's the end of the day. press enter to
continue",player.biome.colour)
input(prompt)
elif (ans == "c" and player.levels[1]<100) or (ans=="d" and
player.levels[1]>=100):
go_settings() #NO AEC=TRUE TO ALLOW LOOP TO CONTINUE
if player.levels[1]<100:
cprint("press a. to go fishing, b. to go to the shop, c. to go to
settings or d. to log out.",player.biome.colour)
else:
cprint("press a. to go fishing, b. to go to the shop, c. to go to
the docks, d. to go to settings or e. to log out.",player.biome.colour)
elif (ans == "d" and player.levels[1]<100) or (ans=="e"and
player.levels[1]>=100):
play = False
aec=True
else:
if player.levels[1]<100:
cprint("please enter a, b, c or d",player.biome.colour)
else:
cprint("please enter a, b, c, d or e",player.biome.colour)
return play

def save():
#accountsfile = open("accounts.txt", "r")
#accounts = [x.strip() for x in accountsfile.readlines()]
#accountsfile.close()
#for account in accounts:
# if account.split("-")[0] == player.name:
# accounts.remove(account)
#accountsfile = open("accounts.txt", "w")
#for account in accounts:
# account = account.split("-")
#print(account[0])
# accountsfile.write("{0}-{1}-{2}-{3}-{4}-{5}-{6}-{7}-{8}-{9}-
{10}\n".format(account[0],account[1],account[2],account[3],
account[4],account[5],account[6],account[7],account[8],account[9],account[10]))
#accountsfile.write("{0}-{1}-{2}-{3}-{4}-{5}-{6}-{7}-{8}-{9}-
{10}\n".format(player.name,player.pw,player.xp,player.gold,player.dayno,player.bait
,player.rarestfish.name,player.rod.name,player.inventory.write_inv(),player.myths.w
rite_inv(),player.pokedex.write_inv()))
#accountsfile.close()
print("saving...")
tflag=False
while not tflag:
try:
req = requests.get(url, json=None, headers=headers)
saved = ast.literal_eval(req.text)
accounts=saved["accounts"]
for account in accounts:
pass##iterablecheck??
tflag=True
except:
pass
if player.name in accounts:
accounts.pop(player.name)
accounts[player.name] =
[player.pw,player.xps,player.gold,player.dayno,player.bait,player.rod.name,player.r
arestfish.name,player.inventory.write_inv(),player.myths.write_inv(),player.pokedex
.write_inv(),player.treasures.write_inv(),player.treasuredex.write_inv(),player.bio
me.name,player.items.write_inv(),player.weather]

#("{0}-{1}-{2}-{3}-{4}-{5}-{6}-{7}-{8}-{9}-{10}-{11}-{12}-{13}-{14}-
{15}".format(player.name,player.pw,",".join(map(str,player.xps)),player.gold,player
.dayno,player.bait,player.rarestfish.name,player.rod.name,player.inventory.write_in
v(),player.myths.write_inv(),player.pokedex.write_inv(),player.treasures.write_inv(
),player.treasuredex.write_inv(),player.biome.name,player.items.write_inv(),player.
weather))

saved["accounts"] = accounts
tflag=False
while not tflag:
try:
req = requests.put(url, json=saved, headers=headers)
#print(req.text)
tflag=True
except:
pass

#replit.clear()
player = log_in()

play = True

player.dayno

while play:
play = do_stuff(player.dayno)
#save()
try:
replit.clear()
except:
print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
player.dayno += 1

save()
print("your progress was saved")
print("thanks for playing!")

You might also like