loading
open in
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
import random as rand
from sty import fg, RgbFg
import replit
from numpy import log
import json_store_client
from hashlib import sha512
import time as t
jsonstoretoken="c92f7b55a824b49872dfc697bdfca668409dd1a1ce6fa51e12ac15cc0c448e10"
client=json_store_client.Client(jsonstoretoken)
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)


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.biomelist[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(False,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:
                accounts=list(client.retrieve("accounts"))
                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
        if username=="":
            cprint("please enter a username","red")
        for account in accounts:
            #account = account.strip()
            if account.split("-")[0] == 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.append(username + "-" + hashed_pw + "-0,0,0,0-0-1-10-none-wooden-empty-empty-empty-empty-empty-normal-empty-" + weather)
    tflag=False
    while not tflag:
        try:
            client.delete("accounts")
            client.store("accounts",accounts)
            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:
                        accounts=client.retrieve("accounts")
                        tflag=True
                    except:
                        pass
                for account in accounts:
                    if username == account.split("-")[0] and hashed_pw == account.split("-")[1]:
                        loggedin = True
                        cprint("succesfully logged in. press enter to continue", "red", iend="")
                        for biomex in Biome.biomelist:
                            if account.split("-")[13]==biomex.name:
                                biome=biomex
                        player=Account(username, hashed_pw, account.split("-")[2].split(","), int(account.split("-")[3]), int(account.split("-")[4]), int(account.split("-")[5]), account.split("-")[7], account.split("-")[6], account.split("-")[8], account.split("-")[9], account.split("-")[10], account.split("-")[11], account.split("-")[12], biome, account.split("-")[14], account.split("-")[15])
                        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):
    cprint("welcome, {}, to my fishing game!\nthe 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!\npress enter to continue.".format(player.name),"red")

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,highrarehelp,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.biome)])*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[Biome.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:
            hiscorers=client.retrieve(key)
            tflag=True
        except:
            pass

    if hiscorers == [] and not pvar:
        cprint("no one has reached this level yet.","magenta")
    else:

        for hiscorer in hiscorers:
            Hiscorer(hiscorer.split("-")[0],int(hiscorer.split("-")[1]))
        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))

        tflag=False
        while not tflag:
            try:
                client.delete(key)
                client.store(key,printinghis)
                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
            cprint("bait costs {} gold each. how much would you like to buy? press a. to leave".format(str(int(player.levels[Biome.biomelist.index(player.biome)+1]/2+1)*(Biome.biomelist.index(player.biome)+1))),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*(int(player.levels[Biome.biomelist.index(player.biome)+1]/2+1)*(Biome.biomelist.index(player.biome)+1)):
                            player.gold = player.gold - ans*(int(player.levels[Biome.biomelist.index(player.biome)+1]/2+1)*(Biome.biomelist.index(player.biome)+1))
                            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 ans == rod.name:
                        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 reset your account, b. to see current level 100 highscores board, c. to see current endgame highscores board, d. to see current number of accounts, e. to see game information, f. for game help, g. to see repl.it user cats_ur_cool77's fishing game tribute and h. to leave.",player.biome.colour)
        aec=False
        while not aec:
            ans=input(prompt).lower()
            if ans=="a":
                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=="b":
                aec=True
                seehiscores(False,"hiscorers")
            elif ans=="c":
                aec=True
                seehiscores(False,"endgame")
            elif ans=="d":
                tflag=False
                while not tflag:
                    try:
                        accounts=client.retrieve("accounts")
                        tflag=True
                    except:
                        pass
                cprint("there are currently {} accounts signed up to the fishing game! thank you to all the players!".format(len(accounts)),"magenta")
            elif ans =="e":
                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 [email protected] thanks for playing the game!", "magenta")
            elif ans == "f":
                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 == "g":
                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 == "h":
                aec=True
                leave=True
            else:
                cprint("please enter a, b, c, d, or f.",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 save and continue",player.biome.colour)
            input(prompt)
        elif ans == "a":
            go_fishing()
            aec=True
            cprint("it's the end of the day. press enter to save and 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 save and 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.write_inv(),player.pokedex.write_inv()))
    #accountsfile.close()
    print("saving...")
    tflag=False
    while not tflag:
        try:
            accounts=client.retrieve("accounts")
            for account in list(accounts):
                pass##iterablecheck??
            tflag=True
        except:
            pass
    tflag=False
    for account in accounts:
        if account.split("-")[0]==player.name:
            accounts.remove(account)
            accounts.append("{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_inv(),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))
    while not tflag:
        try:
            client.delete("accounts")
            client.store("accounts",accounts)
            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

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