def sell_player(ourteam,firstroundthisyear,secondroundthisyear,thirdoroundthisyear,draft1,season): draftfound=0 #global playersavliable playersavliable=[] randomnum1=random.randint(0,1) ffc=random.randint(1,2) while True: #pdb.set_trace() global playersavliable #firstroundthisyear=1 #secondroundthisyear=1 #thirdoroundthisyear=1 #firstroundnextyear=1 #secondroundnextyear=1 #thirdoroundnextyear=1 draftfound=draftfound+1 os.system('clear') print ("In this Section you will have offers for your more highley rated players") print ("##################") avaliablepicks(firstroundthisyear,secondroundthisyear,thirdoroundthisyear) ######################## set variables #print ("We have intrest in exchanging for these players\n") incrmentalnum=-1 teamchar=0 teamexp=0 teamage=0 playerstoswap=[] numofplayertoswap=[] # playersavliable=[] playerstobuy=[] ######### print ("Your Scout as mentioned these players are avaliable to swap for:\n") # pdb.set_trace() if draftfound==1: #playersavliable=func_create_players.rn3(gk =5, defe =5, mid =5, ata =5, exp =4, maxskill =23, skill =23, skillpeak =0, char =10, maxage=34, minskill=15,weighted=0,minage=23,minrchar=5) randomgk=random.randint(6,8) randomdef=random.randint(6,10) randommid=random.randint(6,10) randomata=random.randint(6,8) if season < 4: playersavliable=func_create_players.rn3(gk=randomgk, defe=randomdef, mid=randommid, ata=randomata, exp =4, maxskill =24, skill =24, skillpeak =0, char =10, maxage=34, minskill=15,weighted=0,minage=20,minrchar=5) elif season <8: playersavliable=func_create_players.rn3(gk=randomgk, defe=randomdef, mid=randommid, ata=randomata, exp =4, maxskill =24, skill =24, skillpeak =0, char =10, maxage=33, minskill=16,weighted=0,minage=20,minrchar=6) elif season <12: playersavliable=func_create_players.rn3(gk=randomgk, defe=randomdef, mid=randommid, ata=randomata, exp =4, maxskill =24, skill =24, skillpeak =0, char =10, maxage=33, minskill=17,weighted=0,minage=20,minrchar=7) else: playersavliable=func_create_players.rn3(gk=randomgk, defe=randomdef, mid=randommid, ata=randomata, exp =4, maxskill =24, skill =24, skillpeak =0, char =10, maxage=33, minskill=17,weighted=0,minage=19,minrchar=8) mylog.fmlog(detail=str(("Who is avaliable to buy ", playersavliable)), verbosity=11) for i in range(len(playersavliable)): playerfound=0 playerfoundscore=0 # masterplayersfound=0 # if incrmentalnum==0: # incrmentalnum=1 incrmentalnum=1+incrmentalnum incrementalnumwp="{:<2}".format(incrmentalnum) singlerecord = playersavliable[incrmentalnum] position1=singlerecord[0] name1=singlerecord[1] name2=singlerecord[2] gfield4skill=int(singlerecord[3]) maxskill=int(singlerecord[4]) char=int(singlerecord[5]) charformated="{:<2}".format(char) experience=int(singlerecord[6]) experienceformated="{:<2}".format(experience) age=int(singlerecord[7]) ageformated="{:<3}".format(age) if (age < 24): if char > 6: if 17 <= gfield4skill < 20: playerfound=1 playerfoundscore=4 offer2=offervalue(4) masterplayersfound=1 elif 20 <= gfield4skill < 23: playerfound=1 playerfoundscore=6 offer2=offervalue(6) masterplayersfound=1 elif 23 <= gfield4skill < 25: playerfound=1 playerfoundscore=16 offer2=offervalue(16) masterplayersfound=1 elif gfield4skill >= 25: playerfound=1 playerfoundscore=16 offer2=offervalue(16) masterplayersfound=1 else: playerfound=1 playerfoundscore=11 offer2=offervalue(11) masterplayersfound=1 else: # ffc=random.randint(1,2) playerfound=1 playerfoundscore=2 offer2=offervalue(2) masterplayersfound=1 elif age < 27: if char > 6: if 17 <= gfield4skill < 20: playerfound=1 playerfoundscore=3 offer2=offervalue(3) masterplayersfound=1 elif 20 <= gfield4skill < 23: playerfound=1 playerfoundscore=4 offer2=offervalue(4) masterplayersfound=1 elif 23 <= gfield4skill < 25: playerfound=1 playerfoundscore=15 offer2=offervalue(15) masterplayersfound=1 elif gfield4skill >= 25: playerfound=1 playerfoundscore=15 offer2=offervalue(15) masterplayersfound=1 else: playerfound=1 playerfoundscore=1 offer2=offervalue(1) masterplayersfound=1 else: playerfound=1 playerfoundscore=14 offer2=offervalue(14) masterplayersfound=1 elif age < 30: if char >6: if 17 <= gfield4skill < 20: playerfound=1 playerfoundscore=13 offer2=offervalue(13) masterplayersfound=1 elif 20 <= gfield4skill < 23: playerfound=1 playerfoundscore=3 offer2=offervalue(3) masterplayersfound=1 elif 23 <= gfield4skill < 25: playerfound=1 playerfoundscore=4 offer2=offervalue(4) masterplayersfound=1 elif gfield4skill >= 25: playerfound=1 playerfoundscore=5 offer2=offervalue(5) masterplayersfound=1 else: playerfound=1 playerfoundscore=11 offer2=offervalue(11) masterplayersfound=1 else: playerfound=1 playerfoundscore=14 offer2=offervalue(14) masterplayersfound=1 elif age < 32: if char >6: if 17 <= gfield4skill < 20: playerfound=1 playerfoundscore=11 offer2=offervalue(11) masterplayersfound=1 elif 20 <= gfield4skill < 23: playerfound=1 playerfoundscore=12 offer2=offervalue(12) masterplayersfound=1 elif 23 <= gfield4skill < 25: playerfound=1 playerfoundscore=12 offer2=offervalue(12) masterplayersfound=1 elif gfield4skill >= 25: playerfound=1 playerfoundscore=13 offer2=offervalue(13) masterplayersfound=1 else: playerfound=1 playerfoundscore=11 offer2=offervalue(11) masterplayersfound=1 else: playerfound=1 playerfoundscore=14 offer2=offervalue(14) masterplayersfound=1 elif age < 34: if char >6: if 17 <= gfield4skill < 20: playerfound=1 playerfoundscore=1 offer2=offervalue(1) masterplayersfound=1 if 20 <= gfield4skill < 23: playerfound=1 playerfoundscore=14 offer2=offervalue(14) masterplayersfound=1 if 23 <= gfield4skill < 25: playerfound=1 playerfoundscore=14 offer2=offervalue(14) masterplayersfound=1 if gfield4skill >= 25: playerfound=1 playerfoundscore=2 offer2=offervalue(2) masterplayersfound=1 else: playerfound=1 playerfoundscore=1 offer2=offervalue(1) masterplayersfound=1 else: playerfound=1 playerfoundscore=1 offer2=offervalue(1) masterplayersfound=1 else: #randomnum1=random.randint(0,1) if randomnum1==0: ffchance=14 else: ffchance=11 playerfound=1 playerfoundscore=int(ffchance) offer2=offervalue(int(ffchance)) masterplayersfound=1 if playerfound == 1: playerstobuy.append ([incrementalnumwp,position1,name1,name2,gfield4skill,maxskill,charformated,experienceformated,ageformated,offer2]) numofplayertoswap.append (int(incrementalnumwp)) playerfound = 0 playerfoundscore=0 print ("B P Name S MS C E A Offer") for i in range(len(playerstobuy)): for j in range(len(playerstobuy[i])): print(playerstobuy[i][j], end=' ') print() incrmentalnum=-1 teamchar=0 teamexp=0 teamage=0 playerstoswap=[] numofplayertoswap=[] # playersavliable=[] # playerstobuy=[] print ("\nOpposition teams have intrest in exchanging for these players in your squad:\n") #playerfound=0 # looping through each player and valuing each player to determine draft value # based on following table # 24 27 30 34 Age #17 3 2 1 1 #20 4 3 2 1 #23 5 4 3 2 #25 7 5 4 3 #Skill # and value of those picks = # Round Value # 1 3 # 2 1 # 3 0.5 # so a 24 year old with skill of 25 would get a value of 7 # which would mean an offer of 2 1st Rounders and a second Round masterplayersfound=0 for i in range(len(ourteam)): playerfound=0 playerfoundscore=0 # masterplayersfound=0 incrmentalnum=1+incrmentalnum incrementalnumwp="{:<2}".format(incrmentalnum) singlerecord = ourteam[incrmentalnum] position1=singlerecord[0] name1=singlerecord[1] name2=singlerecord[2] gfield4skill=int(singlerecord[3]) maxskill=int(singlerecord[4]) char=int(singlerecord[5]) charformated="{:<2}".format(char) experience=int(singlerecord[6]) experienceformated="{:<2}".format(experience) age=int(singlerecord[7]) ageformated="{:<3}".format(age) if (char > 6) and (age < 24): if 17 <= gfield4skill < 20: playerfound=1 playerfoundscore=3 offer2=offervalue(3) masterplayersfound=1 if 20 <= gfield4skill < 23: playerfound=1 playerfoundscore=4 offer2=offervalue(4) masterplayersfound=1 if 23 <= gfield4skill < 25: playerfound=1 playerfoundscore=5 offer2=offervalue(5) masterplayersfound=1 if gfield4skill >= 25: playerfound=1 playerfoundscore=7 offer2=offervalue(7) masterplayersfound=1 elif (char > 6) and (age < 27): if 17 <= gfield4skill < 20: playerfound=1 playerfoundscore=2 offer2=offervalue(2) masterplayersfound=1 if 20 <= gfield4skill < 23: playerfound=1 playerfoundscore=3 offer2=offervalue(3) masterplayersfound=1 if 23 <= gfield4skill < 25: playerfound=1 playerfoundscore=4 offer2=offervalue(4) masterplayersfound=1 if gfield4skill >= 25: playerfound=1 playerfoundscore=5 offer2=offervalue(5) masterplayersfound=1 elif (char > 6) and (age < 30): if 17 <= gfield4skill < 20: playerfound=1 playerfoundscore=1 offer2=offervalue(11) masterplayersfound=1 if 20 <= gfield4skill < 23: playerfound=1 playerfoundscore=2 offer2=offervalue(2) masterplayersfound=1 if 23 <= gfield4skill < 25: playerfound=1 playerfoundscore=3 offer2=offervalue(3) masterplayersfound=1 if gfield4skill >= 25: playerfound=1 playerfoundscore=4 offer2=offervalue(4) masterplayersfound=1 elif (char > 6) and (age < 34): if 17 <= gfield4skill < 20: playerfound=1 playerfoundscore=1 offer2=offervalue(1) masterplayersfound=1 if 20 <= gfield4skill < 23: playerfound=1 playerfoundscore=1 offer2=offervalue(1) masterplayersfound=1 if 23 <= gfield4skill < 25: playerfound=1 playerfoundscore=11 offer2=offervalue(11) masterplayersfound=1 if gfield4skill >= 25: playerfound=1 playerfoundscore=3 offer2=offervalue(3) masterplayersfound=1 if playerfound == 1: # print (name1) playerstoswap.append ([incrementalnumwp,position1,name1,name2,gfield4skill,maxskill,charformated,experienceformated,ageformated,offer2]) numofplayertoswap.append (int(incrementalnumwp)) playerfound = 0 playerfoundscore=0 print ("B=Player to buy, P=Position,S=Skill,MS=Max Skill,C=Character,E=Experience,A=Age") print ("") offernumber=0 efound=0 bfound=0 sfound=0 mfound=0 dfound=0 ffound=0 timespressed=0 # pdb.set_trace() if masterplayersfound == 0: print("No players good enough :( ") #return else: print ("B P Name S MS C E A Offer") for i in range(len(playerstoswap)): offernumber=offernumber+1 for j in range(len(playerstoswap[i])): print(playerstoswap[i][j], end=' ') print() ### Error check users input is a number while True: select1=input("\nWhat do you want to do? ... \n\ne to Exit this section and start with the first avaliable round of the draft(presuming you have picks-if not the new season will start)\nr for a team/player report\nb for buy a player your Scout has found \ns for sell one of your players for extra draft picks\nm Move up draft \nd Move down draft\nf Feedback of your team (from the end of the previous season)\n1 Scout first round\n" ) if select1 =="": break if select1=="1": scoutthedraft(draft1) break if select1 =="e": efound=1 break if select1 =="f": mylog.fmlog(detail=str(("f hit on menu")), verbosity=30) ffound=1 timespressed=timespressed+1 # immport here as to high and log.txt hasn't been created #if timespressed==1: #import func_analsyispicks #func_analsyispicks() # os.system(./func_analsyispicks.py) subprocess.call("python3 func_analsyispicks.py", shell=True) break if select1 =="d": dfound=1 firstroundthisyear,secondroundthisyear,thirdoroundthisyear=movedowndraft(firstroundthisyear,secondroundthisyear,thirdoroundthisyear) break if select1 =="r": teamreport1(createteam=ourteam,printto="yp") break if select1 =="b": mylog.fmlog(detail=str(("playerstobuy_before_Work ", playerstobuy)), verbosity=11) firstroundthisyear,secondroundthisyear,thirdoroundthisyear,playerstobuy,ourteam,playertodelete,enoughcapital=buypplayer (firstroundthisyear,secondroundthisyear,thirdoroundthisyear,playerstobuy,ourteam) # getting messy and painful trying to delete the picked player so he doesn't show up again #pdb.set_trace() # playertodelete=int(playertodelete-1) try: #del playerstobuy[playertodelete] if enoughcapital ==1: del playersavliable[playertodelete] except: print ("\ni errored dropping into debug more...\n") print ("playertodeletenumber",playertodelete) print ( "playertodelete-list",playertodelete) print ( "playersavaliable-list",playersavliable) pdb.set_trace() # del playersavliable[playertodelete] mylog.fmlog(detail=str(("playerstobuy_after_Work ", playerstobuy)), verbosity=11) bfound=1 #pdb.set_trace() break if select1 =="m": mfound=1 firstroundthisyear,secondroundthisyear,thirdoroundthisyear=moveupdraft(firstroundthisyear,secondroundthisyear,thirdoroundthisyear) break if select1 =="s": if masterplayersfound == 0: input ("No players good enough to swap, press enter to get back to the main menu") break else: os.system('clear') print ("O P Name S MS C E A Offer") for i in range(len(playerstoswap)): offernumber=offernumber+1 for j in range(len(playerstoswap[i])): print(playerstoswap[i][j], end=' ') print() sfound=1 #print ("S found") ourteam,firstroundthisyear,secondroundthisyear,thirdoroundthisyear=sellplayer(ourteam=ourteam,numofplayertoswap=numofplayertoswap,firstroundthisyear=firstroundthisyear,secondroundthisyear=secondroundthisyear,thirdoroundthisyear=thirdoroundthisyear,playerstoswap=playerstoswap,season=season) break if efound==1: break else: continue # if bfound==1: # continue return ourteam,firstroundthisyear,secondroundthisyear,thirdoroundthisyear
def bat(ourgk, oppgk, ourdef, oppdef, ourmid, oppmid, ourata, oppata, ourchar, oppchar, ourexp, oppexp): # create scores ourdefscore = 0 ourattackscore = 0 oppdefscore = 0 ourattackscore = 0 oppattackscore = 0 randomnumber = random.randint(1, 10) randomnumber50 = random.randint(1, 10) randomnumber501 = random.randint(1, 10) randomnumber1 = random.randint(1, 10) mylog.fmlog(detail=str(("rn ", randomnumber)), verbosity=1) mylog.fmlog(detail=str(("rn50 ", randomnumber50)), verbosity=1) mylog.fmlog(detail=str(("rn501 ", randomnumber501)), verbosity=1) mylog.fmlog(detail=str(("rn1 ", randomnumber1)), verbosity=1) # print ("rn=",randomnumber) # print ("rn50=",randomnumber50) # print ("rn501=",randomnumber501) ourattackscore = int(((ourdef * 4) + (ourmid * 8) + (ourata * 6) + (ourexp / 7) + (ourchar / 4)) / 4.5) oppattackscore = int(((oppdef * 4) + (oppmid * 8) + (oppata * 6) + (oppexp / 7) + (oppchar / 4)) / 4.5) ourdefscore = int(((ourgk * 4) + (ourdef * 8) + (ourmid * 4) + (ourata * 2) + (ourexp / 7) + (ourchar / 4)) / 4.5) oppdefscore = int(((oppgk * 4) + (oppdef * 8) + (oppmid * 4) + (oppata * 2) + (oppexp / 7) + (oppchar / 4)) / 4.5) print("Our Def Team score", ourdefscore) print("Our Ata Team score", ourattackscore) print("The Def Opposition Team score", oppdefscore) print("The Ata Opposition Team score", oppattackscore) print("\n") #print ("\nLets go play a game") # our goals tally ourcomaprescore = 0 ourgoals = 0 ourcomparescore = int(ourattackscore - oppdefscore) if ourcomparescore > 50: if randomnumber1 < 2: ourgoals = ("5") elif randomnumber1 < 4: ourgoals = ("4") elif randomnumber1 <= 7: ourgoals = ("3") elif randomnumber1 <= 8: ourgoals = ("2") else: if randomnumber > 5: ourgoals = ("1") else: ourgoals = ("0") elif ourcomparescore > 25: if randomnumber1 <= 4: ourgoals = ("4") elif randomnumber1 <= 7: ourgoals = ("3") elif randomnumber1 < 10: ourgoals = ("2") else: if randomnumber > 3: ourgoals = ("1") else: ourgoals = ("0") elif ourcomparescore > 10: if randomnumber1 <= 6: ourgoals = ("3") elif randomnumber1 < 9: ourgoals = ("2") else: if randomnumber > 6: ourgoals = ("1") else: ourgoals = ("0") else: if randomnumber50 <= 1: ourgoals = ("3") elif randomnumber50 <= 4: ourgoals = ("2") elif randomnumber50 <= 7: ourgoals = ("1") else: ourgoals = ("0") # opposition goals tally oppcomaprescore = 0 oppgoals = 0 oppcomparescore = int(oppattackscore - ourdefscore) if oppcomparescore > 50: if randomnumber < 2: oppgoals = ("5") elif randomnumber < 4: oppgoals = ("4") elif randomnumber <= 6: oppgoals = ("3") elif randomnumber <= 8: oppgoals = ("2") else: if randomnumber50 > 5: ourgoals = ("1") else: ourgoals = ("0") elif oppcomparescore > 25: if randomnumber <= 7: oppgoals = ("3") elif randomnumber < 10: oppgoals = ("2") else: if randomnumber50 > 5: ourgoals = ("1") else: ourgoals = ("0") elif oppcomparescore > 10: if randomnumber <= 4: oppgoals = ("3") elif randomnumber < 8: oppgoals = ("2") else: if randomnumber50 > 5: ourgoals = ("1") else: ourgoals = ("0") else: if randomnumber501 <= 1: oppgoals = ("3") elif randomnumber501 <= 4: oppgoals = ("2") elif randomnumber501 <= 7: oppgoals = ("1") else: oppgoals = ("0") return ourgoals, oppgoals
def buypplayer (firstroundthisyear,secondroundthisyear,thirdoroundthisyear,playerstobuy,ourteam): enoughcapital=0 maxoption=len(playerstobuy)+1 #pdb.set_trace() while True: select3=input("\nWho do you want to Buy (or press e to exit?)...") mylog.fmlog(detail=str(("Who do you want to Buy (press e to exit)...", select3)), verbosity=9) if select3=="e": enoughcapital=0 intselect3="99" break if select3.isnumeric(): if 0<=int(select3) <=maxoption: intselect3=int(select3) # a2test= ourteam[intselect3] # hacking data to make is usable, stripping out fields and commas , try: a2 = playerstobuy[intselect3] except: pdb.set_trace() mylog.fmlog(detail=str(("Who am i going to buy ", a2)), verbosity=9) a2p = a2[1:2] a2p= (''.join(a2p)) mylog.fmlog(detail=str(("Players Position ", a2p)), verbosity=9) valueofplayer=a2[9:10] valueofplayer=(''.join(valueofplayer)) mylog.fmlog(detail=str(("Value of player ", valueofplayer)), verbosity=9) #strip a few bits out of player to make is usable for our team a2.pop(0) a2.pop(8) firstroundthisyear,secondroundthisyear,thirdoroundthisyear,enoughcapital=sellplayerbuy(firstroundthisyear,secondroundthisyear,thirdoroundthisyear,valueofplayer,a2) break else: print ("Invalid number please try again") pdb.set_trace() print ("Invalid option try again...\n") incrementalnumber=0 playinposition=0 minposition=0 maxposition=0 z=0 rangeofpaval=[] print () os.system('clear') if enoughcapital==1: print ("These are the people you can replace") print ("P Name S MS C E A N") for i1 in range(len(ourteam)): incrementalnumber=incrementalnumber+1 for j1 in range(len(ourteam[i1])): playerposinteam=ourteam[i1][0] if playerposinteam in a2p: # incrementalnumber=incrementalnumber+1 playinposition=playinposition+1 if playinposition ==1: playinposition=incrementalnumber maxposition=incrementalnumber print(ourteam[i1][j1], end=' ') z=1 else: z=0 if z == 1: # incrementalnumber=incrementalnumber+1 print (incrementalnumber, end=' ') print () rangeofpaval.append (incrementalnumber) print ("") print ( "Key") print ("========") print ("N=Players number in the draft (this is not sorted)") print ("P=Position") print ("S=Skill") print ("MS=Max Skill") print ("C=Character") print ("E=Experience") print ("A=Age") print ("") #input ("Who do you choose?") mylog.fmlog(detail=str(("minposition= ", minposition)), verbosity=9) mylog.fmlog(detail=str(("maxposition= ", maxposition)), verbosity=9) while True: select2=input("\nWho do you want to Sell? " ) if select2.isnumeric(): if minposition<= int(select2) <= maxposition : whotoreplace=int(select2)-1 break else: pass print ("Invalid option try again...\n") #pdb.set_trace() # if enoughcapital==1: del ourteam[whotoreplace] # del playerstobuy[intselect3] del playerstobuy[intselect3] ourteam.insert(whotoreplace, (a2)) os.system('clear') print ("here is your current team") print ("P Name S MS C E A") for i in range(len(ourteam)): for j in range(len(ourteam[i])): print(ourteam[i][j], end=' ') print() input("Press a button to continue") #playertodelete=intselect3 #enoughcapital=0 return (firstroundthisyear,secondroundthisyear,thirdoroundthisyear,playerstobuy,ourteam,intselect3,enoughcapital)
def wherearewe(round,ourgk,ourdef,ourmid,ourata,ourchar,ourexp,season): oppgk=0 oppdef=0 oppmid=0 oppata=0 oppexp=0 oppchar=0 # increase chance of playoff skill every 2 years season=int(season) season=(season/2) season=int(season) #expe char increased seasonex=(season) seasonex=int(seasonex) if round=="w": print ("###Wildcard Weekend### > Divisonal > Conference > Superbowl") print ("=============================================================\n") print ("Team ratings") print ("============") oppgk=random.randint (15,(20+season)) oppdef=random.randint (10,(15+season)) oppmid=random.randint (10,(13+season)) oppata=random.randint (10,(13+season)) oppexp=random.randint (100,(200+seasonex)) oppchar=random.randint (125,(200+seasonex)) forscore,against=func_gameday.bat(ourgk=ourgk,oppgk=oppgk,ourdef=ourdef,oppdef=oppmid,ourmid=ourmid,oppmid=oppmid,ourata=ourata,oppata=oppata,ourchar=ourchar,oppchar=oppchar,ourexp=ourexp,oppexp=oppexp) print ("Normal game time") print ("================") time.sleep(st) print ("The Score was",forscore,against) if (str(forscore)==str(against)): print ("\nGoing to Overtime") print ("=================") time.sleep(st) forscore,against=func_gameday_overtime.bat(ourgk=ourgk,oppgk=oppgk,ourdef=ourdef,oppdef=oppmid,ourmid=ourmid,oppmid=oppmid,ourata=ourata,oppata=oppata,ourchar=ourchar,oppchar=oppchar,ourexp=ourexp,oppexp=oppexp,ourprevgoals=int(forscore),oppprevgoals=int(against)) print ("The Score was",forscore,against) print () if round=="d": print ("Wildcard Weekend > ###Divisonal### > Conference > Superbowl") print ("=============================================================\n") print ("Team ratings") print ("============") oppgk=random.randint (15,(20+season)) oppdef=random.randint (13,(15+season)) oppmid=random.randint (13,(15+season)) oppata=random.randint (13,(15+season)) oppexp=random.randint (130,(200+seasonex)) oppchar=random.randint (130,(200+seasonex)) forscore,against=func_gameday.bat(ourgk=ourgk,oppgk=oppgk,ourdef=ourdef,oppdef=oppmid,ourmid=ourmid,oppmid=oppmid,ourata=ourata,oppata=oppata,ourchar=ourchar,oppchar=oppchar,ourexp=ourexp,oppexp=oppexp) print ("Normal game time") print ("================") time.sleep(st) print ("The Score was",forscore,against) if (str(forscore)==str(against)): print ("\nGoing to Overtime") print ("=================") time.sleep(st) forscore,against=func_gameday_overtime.bat(ourgk=ourgk,oppgk=oppgk,ourdef=ourdef,oppdef=oppmid,ourmid=ourmid,oppmid=oppmid,ourata=ourata,oppata=oppata,ourchar=ourchar,oppchar=oppchar,ourexp=ourexp,oppexp=oppexp,ourprevgoals=int(forscore),oppprevgoals=int(against)) print ("The Score was",forscore,against) print () if round=="c": mylog.fmlog(detail=str(("Wildcard Weekend -start ")), verbosity=1) print ("Wildcard Weekend > Divisonal > ###Conference### > Superbowl") print ("=============================================================\n") print ("Team ratings") print ("============") oppgk=random.randint (14,(20+season)) oppdef=random.randint (14,(18+season)) oppmid=random.randint (14,(18+season)) oppata=random.randint (14,(18+season)) oppexp=random.randint (140,(200+seasonex)) oppchar=random.randint (140,(200+seasonex)) forscore,against=func_gameday.bat(ourgk=ourgk,oppgk=oppgk,ourdef=ourdef,oppdef=oppmid,ourmid=ourmid,oppmid=oppmid,ourata=ourata,oppata=oppata,ourchar=ourchar,oppchar=oppchar,ourexp=ourexp,oppexp=oppexp) print ("Normal game time") print ("================") time.sleep(st) print ("The Score was",forscore,against) if (str(forscore)==str(against)): print ("\nGoing to Overtime") print ("==================") time.sleep(st) forscore,against=func_gameday_overtime.bat(ourgk=ourgk,oppgk=oppgk,ourdef=ourdef,oppdef=oppmid,ourmid=ourmid,oppmid=oppmid,ourata=ourata,oppata=oppata,ourchar=ourchar,oppchar=oppchar,ourexp=ourexp,oppexp=oppexp,ourprevgoals=int(forscore),oppprevgoals=int(against)) print ("The Score was",forscore,against) print () if round=="s": print ("Wildcard Weekend > Divisonal > Conference > ###Superbowl###") print ("=============================================================\n") print ("Team ratings") print ("============") oppgk=random.randint (15,(20+season)) oppdef=random.randint (16,(20+season)) oppmid=random.randint (16,(20+season)) oppata=random.randint (16,(20+season)) oppexp=random.randint (150,(200+seasonex)) oppchar=random.randint (150,(200+seasonex)) forscore,against=func_gameday.bat(ourgk=ourgk,oppgk=oppgk,ourdef=ourdef,oppdef=oppmid,ourmid=ourmid,oppmid=oppmid,ourata=ourata,oppata=oppata,ourchar=ourchar,oppchar=oppchar,ourexp=ourexp,oppexp=oppexp) print ("Normal game time") print ("================") time.sleep(st) print ("The Score was",forscore,against) if (str(forscore)==str(against)): print ("\nGoing to Overtime") print ("==================") time.sleep(st) forscore,against=func_gameday_overtime.bat(ourgk=ourgk,oppgk=oppgk,ourdef=ourdef,oppdef=oppmid,ourmid=ourmid,oppmid=oppmid,ourata=ourata,oppata=oppata,ourchar=ourchar,oppchar=oppchar,ourexp=ourexp,oppexp=oppexp,ourprevgoals=int(forscore),oppprevgoals=int(against)) print ("The Score was",forscore,against) print () return forscore,against
def teams(gk, defe, mid, ata, createteam, printo): import mylog incrmentalnum = -1 checkp = "nty" gskillnum = 0 dskillnum = 0 mskillnum = 0 sskillnum = 0 teamchar = 0 teamexp = 0 teamage = 0 gkfinalscore = 0 deffinalscore = 0 midfinalscore = 0 atafinalscore = 0 expfinalscore = 0 charfinalscore = 0 gplayerrange = [] dplayerrange = [] mplayerrange = [] splayerrange = [] for i in range(len(createteam)): incrmentalnum = 1 + incrmentalnum singlerecord = createteam[incrmentalnum] field1pos = singlerecord[0] if field1pos == "GK ": gfield4skill = int(singlerecord[3]) gplayerrange.append(gfield4skill) gskillnum = gskillnum + gfield4skill teamchar = teamchar + int(singlerecord[5]) teamexp = teamexp + int(singlerecord[6]) teamage = teamage + int(singlerecord[7]) if field1pos == "DEF ": dfield4skill = int(singlerecord[3]) dplayerrange.append(dfield4skill) dskillnum = dskillnum + dfield4skill teamchar = teamchar + int(singlerecord[5]) teamexp = teamexp + int(singlerecord[6]) teamage = teamage + int(singlerecord[7]) if field1pos == "MID ": mfield4skill = int(singlerecord[3]) mplayerrange.append(mfield4skill) mskillnum = mskillnum + mfield4skill teamchar = teamchar + int(singlerecord[5]) teamexp = teamexp + int(singlerecord[6]) teamage = teamage + int(singlerecord[7]) if field1pos == "ATA ": sfield4skill = int(singlerecord[3]) splayerrange.append(sfield4skill) sskillnum = sskillnum + sfield4skill teamchar = teamchar + int(singlerecord[5]) teamexp = teamexp + int(singlerecord[6]) teamage = teamage + int(singlerecord[7]) gplayerrange.sort(reverse=True) dplayerrange.sort(reverse=True) mplayerrange.sort(reverse=True) splayerrange.sort(reverse=True) if printo != checkp: print("First 11 Scout Report") print("##########\n") playerpositionts = -1 rating = "" sr = "" for i in gplayerrange: playerpositionts = playerpositionts + 1 if gk > playerpositionts: gkfinalscore = gkfinalscore + i rating = gkfinalscore quality = "" sr = scores(rating) if printo != checkp: print("GoalKeeper Score (out of 20)", gkfinalscore, sr) playerpositionts = -1 dkfinalscore = 0 rating = "" sr = "" for i in dplayerrange: playerpositionts = playerpositionts + 1 if d > playerpositionts: dkfinalscore = dkfinalscore + i rating = int(dkfinalscore / 4) deffinalscore = rating sr = scores(rating) if printo != checkp: print("Defence Score (out of 20)", rating, sr) playerpositionts = -1 mkfinalscore = 0 rating = "" sr = "" for i in mplayerrange: playerpositionts = playerpositionts + 1 if m > playerpositionts: mkfinalscore = mkfinalscore + i rating = int(mkfinalscore / m) midfinalscore = rating sr = scores(rating) if printo != checkp: print("Midfield Score (out of 20)", rating, sr) playerpositionts = -1 skfinalscore = 0 rating = "" sr = "" for i in splayerrange: playerpositionts = playerpositionts + 1 if s > playerpositionts: skfinalscore = skfinalscore + i rating = int(skfinalscore / s) atafinalscore = rating sr = scores(rating) if printo != checkp: print("Atacking Score (out of 20)", rating, sr) print() print("Team Details") print("###########\n") #add 1 to allow division incrmentalnum = incrmentalnum + 1 rating = int((teamchar / incrmentalnum) * 2) charfinalscore = rating outof = incrmentalnum * 10 sr = scores(rating) if printo != checkp: print("Total Team Characteur", teamchar) # *2 below didn't seem enough so * by 3 rating = int((teamexp / incrmentalnum) * 2) expfinalscore = rating sr = scores(rating) if printo != checkp: print("Total Team Experience", teamexp) rating = int(teamage / incrmentalnum) avgage = rating #sr=scores(rating) if printo != checkp: print("Average Age of team", avgage) print() gkscore = gkfinalscore defscore = deffinalscore midscore = midfinalscore atascore = atafinalscore erating = expfinalscore eteamchar = charfinalscore mylog.fmlog(detail=str(("Gk Score ", gkfinalscore)), verbosity=1) mylog.fmlog(detail=str(("defe Score ", deffinalscore)), verbosity=1) mylog.fmlog(detail=str(("mid Score ", midfinalscore)), verbosity=1) mylog.fmlog(detail=str(("ata Score ", atafinalscore)), verbosity=1) mylog.fmlog(detail=str(("exp Score ", expfinalscore)), verbosity=1) mylog.fmlog(detail=str(("char Score ", charfinalscore)), verbosity=1) ourattackscore = int( ((deffinalscore * 4) + (midfinalscore * 8) + (atafinalscore * 6) + (teamexp / 7) + (teamchar / 4)) / 4.5) ourdefscore = int( ((gkfinalscore * 4) + (deffinalscore * 8) + (midfinalscore * 4) + (atafinalscore * 2) + (teamexp / 7) + (teamchar / 4)) / 4.5) print("Team Game day stats ") print("#########\n") print("Match Day Attack Score", ourattackscore) mylog.fmlog(detail=str(("total att Score ", ourattackscore)), verbosity=1) print("Match Day Defense Score", ourdefscore) mylog.fmlog(detail=str(("total def Score ", ourdefscore)), verbosity=1) print("") #return (gkscore,defscore,midscore,atascore,teamchar,rating,) return (gkscore, defscore, midscore, atascore, teamchar, teamexp, avgage)
def bat(ourgk,ourdef,ourmid,ourata,ourchar,ourexp,ourwins,season): os.system('clear') #global season # work out which round to drop be in #time.sleep(3) resulto="" howwedo="" whowon="" seasonexp=1 #os.system('clear') randomplayoffs=random.randint (7,9) if ourwins < randomplayoffs: print("You team tried vantaltey but have not been good enough to reach the playoffs") input("\nPress Enter to continue\n") #time.sleep(2) else: print ("Playoff Rounds") print ("==============") print ("\nYou are entering the play offs , there are 4 rounds and the games will get harder at each step\nIf you win you players get extra experience\n") # time.sleep(st) if randomplayoffs <= ourwins < 11: print("You team have Reached the Playoffs but you are not a top seed so you will need to work your way through the playoffs starting at the wildcard Weekend") print ("These are the stages\n\n#####Wildcard Weekend##### > Divisonal > Conference > Superbowl") input("\nPress a button to continue\n") os.system('clear') #time.sleep(2) if (ourwins > 10): print ("You team have Reached the Playoffs you are a top seed so you will not have to play in the wildcard weekend and will start in the Divisional round") print ("These are the stages\n\nWildcard Weekend > #####Divisonal#### > Conference > Superbowl") input("\nPress a button to continue\n") os.system('clear') #time.sleep(2) if randomplayoffs <= ourwins < 11: #print ("\nYou are entering the play offs , there are 4 rounds and the games will get harder at each step\nIf you win you players get extra experience but you will also not have as good a draft choice next season\n") # oppgk,oppdef,oppmid,oppata,oppexp,oppchar=wherearewe(round="w",ourgk=ourgk,ourdef=ourdef,ourmid=ourmid,ourata=ourata,ourchar=ourchar,ourexp=ourexp) forscore,against=wherearewe(round="w",ourgk=ourgk,ourdef=ourdef,ourmid=ourmid,ourata=ourata,ourchar=ourchar,ourexp=ourexp,season=season) # tie lets go get a result mylog.fmlog(detail=str(("Forscore ", forscore)), verbosity=1) mylog.fmlog(detail=str(("Againstscore ", against)), verbosity=1) # forscore = 7 # against = 7 # for testing to force playoff: # forscore=1 # against=1 if int(forscore) == int(against): # get overtime result mylog.fmlog(detail="if hit ", verbosity=1) whowon=overtime() mylog.fmlog(detail=str(("Overtime score ", resulto)), verbosity=1) if (int(forscore) > int(against)) or (whowon=="u"): print ("\nYou won,your off to the Divisional round!\n") resulto="u" input("Press a button to continue") os.system('clear') if (int(against) > int(forscore)) or (whowon=="o"): print ("\nPlayoff Summary") print ("===============") print ("You lost") howwedo="Wildcard Weekend" resulto="o" print ("But you gained +1 Exp") seasonexp=1 input("\nPress a button to continue") if (ourwins > 10) or (resulto =="u"): #whowon="" #time.sleep(3) forscore,against=wherearewe(round="d",ourgk=ourgk,ourdef=ourdef,ourmid=ourmid,ourata=ourata,ourchar=ourchar,ourexp=ourexp,season=season) # tie lets go get a result if int(forscore) == int(against): whowon=overtime() if (int(forscore) > int(against)) or (whowon=="u"): print ("\nYou won, you are off to the conference final!\n") resulto="u" input("Press a button to continue") os.system('clear') if (int(against) > int(forscore)) or (whowon=="o"): print ("\nPlayoff Summary") print ("===============") print ("You lost") resulto="o" howwedo="Divisional round" seasonexp=2 print ("But you gained +2 Exp") input("\nPress a button to continue") if (resulto =="u"): #whowon="" #time.sleep(3) forscore,against=wherearewe(round="c",ourgk=ourgk,ourdef=ourdef,ourmid=ourmid,ourata=ourata,ourchar=ourchar,ourexp=ourexp,season=season) # tie lets go get a result if int(forscore) == int(against): whowon=overtime() if (int(forscore) > int(against)) or (whowon=="u"): print ("You won you are off to the superbowl!\n") resulto="u" input("Press a button to continue to the Superbowl") os.system('clear') if int(against) > int(forscore) or (whowon=="o"): print ("\nPlayoff Summary") print ("===============") print ("You lost") resulto="o" howwedo="Conference Final" seasonexp=2 print ("But you gained +2 Exp") input("\nPress a button to continue") if (resulto =="u"): #time.sleep(3) forscore,against=wherearewe(round="s",ourgk=ourgk,ourdef=ourdef,ourmid=ourmid,ourata=ourata,ourchar=ourchar,ourexp=ourexp,season=season) # tie lets go get a result if int(forscore) == int(against): whowon=overtime() print ("\nPlayoff Summary") print ("===============") if (int(forscore) > int(against)) or (whowon=="u"): print ("\nYou have won the Superbowl!") howwedo="Won SuperBowl" print ("Woop Woop") print ("You gained +4 Exp") input("\nPress a button to continue") seasonexp=4 if (int(against) > int(forscore)) or (whowon=="o"): print ("You lost\n") howwedo="Lost SuperBowl" seasonexp=3 print ("But you gained +3 Exp") input("\nPress a button to continue") # time.sleep(3) mylog.fmlog(detail=str(("Experience from playoff ",seasonexp)), verbosity=12) return (howwedo,seasonexp)
def draft(myteam, draft, typeofdraft): ### print Draft team printouttod = typeofdraft os.system('clear') reportneeded = input( "Press enter button to continue or r for team report or t for squad...\n" ) os.system('clear') if reportneeded == "r": teamscore = func_teamratings.teams(gk=1, defe=2, mid=3, ata=4, createteam=myteam, printo="yp") input("Press enter button to continue...\n") if reportneeded == "t": print("\nYour team\n") print("P Name S MS C E A") for i in range(len(createteam)): for j in range(len(createteam[i])): print(createteam[i][j], end=' ') print() print("") print("Key") print("========") print("P=Position") print("S=Skill") print("MS=Max Skill") print("C=Character") print("E=Experience") print("A=Age") print("") input("Press enter button to continue...\n") # print () positioninteam = 0 os.system('clear') print("Avaliable players in the {} of the Draft\n".format(typeofdraft)) print("P Name S MS C E A N") for i in range(len(draft)): positioninteam = positioninteam + 1 #print (positioninteam, end=' ') #print (" ", end= ' ') for j in range(len(draft[i])): print(draft[i][j], end=' ') print(positioninteam, end=' ') print() ### print your team numofplayerscreated = (len(myteam)) numofplayerscreatedwithspace = str(numofplayerscreated) + " " #print ("nopc=",numofplayerscreated) print("\nYour team\n") print("P Name S MS C E A") for i in range(len(myteam)): for j in range(len(myteam[i])): print(myteam[i][j], end=' ') print() print("") print("Key") print("========") print("N=Players number in the draft (this is not sorted)") print("P=Position") print("S=Skill") print("MS=Max Skill") print("C=Character") print("E=Experience") print("A=Age") print("") ############# ### Error check users input is a number while True: #print ("Who do you select in the {} of the draft?" .format(typeofdraft) select1 = input( "Who do you want to select in the {} of the draft? Avaliable options are 1-{} ... or Press e to not select anyone and exit this round of the draft ... \n" .format(typeofdraft, positioninteam)) # select1number = try and convert it into a number i.e is a number if select1 == "e": break if select1.isnumeric() and int(select1) < numofplayerscreated and int( select1) <= positioninteam: break print("Invalid option try again...\n") #### formatting data if select1 != "e": select1 = int(select1) select1 = select1 - 1 nameofselect1 = draft[select1] a2 = draft[select1] a2p = a2[:1] positioninteam = -1 positioninteam1 = -1 z = 0 os.system('clear') # get person drafted print("You have Chosen...\n") mylog.fmlog(detail=str(("Type of Draft ", typeofdraft)), verbosity=2) print("P Name S MS C E A") for i in range(len(draft)): positioninteam1 = positioninteam1 + 1 for j in range(len(draft[i])): if select1 == positioninteam1: print(draft[i][j], end=' ') b = (draft[i][j]) b1 = (draft[i]) b2 = (draft[j]) # mylog.fmlog(detail=str(("Player Drafted ", b)), verbosity=2) # mylog.fmlog(detail=str(("Player Drafted ", b)), verbosity=2) #del draft[i] z = 1 else: z = 0 if z == 1: print() badstring = str(printouttod) + ',' + str(b1) mylog.fmlog(detail=str(("Player Drafted %s" % b)), verbosity=21) mylog.fmlog(detail=str(("Player Drafted ", badstring)), verbosity=22) # mylog.fmlog(detail=str(("Player Drafted %s"%b2 )), verbosity=23) ##############who to replace print( "\nThis are the people in the team who can be replaced, who do you want to remove? :" ) incrementalnumber = 0 z = 0 rangeofpaval = [] print() print("P Name S MS C E A N") for i1 in range(len(myteam)): incrementalnumber = incrementalnumber + 1 for j1 in range(len(myteam[i1])): playerposinteam = myteam[i1][0] if playerposinteam in a2p: print(myteam[i1][j1], end=' ') z = 1 else: z = 0 if z == 1: print(incrementalnumber, end=' ') print() rangeofpaval.append(incrementalnumber) print("") print("Key") print("========") print("N=Players number in the draft (this is not sorted)") print("P=Position") print("S=Skill") print("MS=Max Skill") print("C=Character") print("E=Experience") print("A=Age") print("") ############### buildrange = "" buildrangel = [] for x in range(len(rangeofpaval)): #string version buildrange = buildrange + str(rangeofpaval[x]) + " " #list version buildrangel.append(rangeofpaval[x]) minrange = int(min(buildrangel)) maxrange = int(max(buildrangel)) while True: select1replace = input( "\nAvaliable options are {}...\n".format(buildrange)) #if select1replace.isnumeric and int(minrange) <= int(select1replace) <= int(maxrange): if select1replace.isnumeric( ) and int(minrange) <= int(select1replace) <= int(maxrange): break print("Invalid option please try again") numinsquad = len(createteam) select1replace = int(select1replace) select1replace = select1replace - 1 a2 = draft[select1] del createteam[select1replace] del draft[select1] draftreturned = draft numinsquad = len(createteam) createteam.insert(select1replace, (a2)) return createteam, draftreturned else: draftreturned = createteam, return createteam, draftreturned
"Previous seasons result (most recent at the bottom of the list)& Teamstats" ) print(season) ng = 0 # superbowl and playoff logic seasonoutcome, seasonexp = func_playoffs.bat(ourgk=gkscore, ourdef=defscore, ourmid=midscore, ourata=atascore, ourchar=eteamchar, ourexp=erating, ourwins=win, season=seasonsplayed) mylog.fmlog(detail=str(("Log-Season Wins ", win)), verbosity=1) mylog.fmlog(detail=str(("Log-Season Outcome ", seasonoutcome)), verbosity=1) mylog.fmlog(detail=str(("Log-Season Exp ", seasonexp)), verbosity=1) if int(seasonexp) == 3: totalsuperbowwins = totalsuperbowwins + 1 print("End of season...", seasonsplayed) # teamreport1(createteam=createteam,printto="yp") while True: continuetonextstep = input("please press c button to continue...\n") if continuetonextstep == "c": break # end of season stats
def bat(ourgk, oppgk, ourdef, oppdef, ourmid, oppmid, ourata, oppata, ourchar, oppchar, ourexp, oppexp, ourprevgoals, oppprevgoals): mylog.fmlog(detail=str(("Ourprevgoals ", ourprevgoals)), verbosity=3) mylog.fmlog(detail=str(("Opprevgoals ", oppprevgoals)), verbosity=3) # create scores ourdefscore = 0 ourattackscore = 0 oppdefscore = 0 ourattackscore = 0 oppattackscore = 0 # a slightly different team score caculation to increase effect of exp and char ourattackscore = int(((ourdef * 4) + (ourmid * 8) + (ourata * 6) + (ourexp / 6) + (ourchar / 3)) / 4.5) oppattackscore = int(((oppdef * 4) + (oppmid * 8) + (oppata * 6) + (oppexp / 6) + (oppchar / 3)) / 4.5) ourdefscore = int(((ourgk * 4) + (ourdef * 8) + (ourmid * 4) + (ourata * 2) + (ourexp / 6) + (ourchar / 3)) / 4.5) oppdefscore = int(((oppgk * 4) + (oppdef * 8) + (oppmid * 4) + (oppata * 2) + (oppexp / 6) + (oppchar / 3)) / 4.5) # our goals tally ourcomaprescore = 0 ourgoals = 0 oppgoals = 0 ourcomparescore = int(ourattackscore) + int(ourdefscore) mylog.fmlog(detail=str(("Our compare score ", ourcomparescore)), verbosity=3) oppcomparescore = int(oppattackscore) + int(oppdefscore) mylog.fmlog(detail=str(("Opp compare score", oppcomparescore)), verbosity=3) ourrandomnumber = random.randint(1, ourcomparescore) mylog.fmlog(detail=str(("Our random number ", ourrandomnumber)), verbosity=3) opprandomnumber = random.randint(1, oppcomparescore) mylog.fmlog(detail=str(("Opp random number ", opprandomnumber)), verbosity=3) difference1 = abs(ourrandomnumber - opprandomnumber) mylog.fmlog(detail=str(("Difference in numbers ", difference1)), verbosity=3) difference2 = int(ourrandomnumber - opprandomnumber) if difference1 < 10: ourgoals = ourprevgoals oppgoals = oppprevgoals mylog.fmlog(detail=str(("Our Goals ", ourgoals)), verbosity=3) mylog.fmlog(detail=str(("Opp Goals ", oppgoals)), verbosity=3) elif difference2 >= 11: ourgoals = int(ourprevgoals + 1) oppgoals = oppprevgoals mylog.fmlog(detail=str(("Our Goals ", ourgoals)), verbosity=3) mylog.fmlog(detail=str(("Opp Goals ", oppgoals)), verbosity=3) elif difference2 < 0: ourgoals = ourprevgoals oppgoals = int(oppprevgoals + 1) mylog.fmlog(detail=str(("Our Goals ", ourgoals)), verbosity=3) mylog.fmlog(detail=str(("Opp Goals ", oppgoals)), verbosity=3) else: ourgoals = ourprevgoals oppgoals = oppprevgoals return ourgoals, oppgoals
def changes(ourteam, playoffexppoints, seasonnumber): mylog.fmlog(detail=str( ("playoffexppoints just begening of script ", playoffexppoints)), verbosity=12) # playoffexppoints=0 incrmentalnum = -1 veryold = random.randint(30, 34) verygoodchar = random.randint(8, 9) #was 1,4 verypoorchar = random.randint(5, 7) averagechar = random.randint(7, 8) changes = "" changesp = "" changesn = "" changesms = "" pointslostpadding = "" for i in range(len(ourteam)): ##### loop through players and work out the + and - scores based on char & age (+ maybe a few more later) incrmentalnum = 1 + incrmentalnum singlerecord = ourteam[incrmentalnum] # mylog.fmlog(detail=str(("Player before end of season ",seasonnumber ,singlerecord)), verbosity=13) ageforskills = int(singlerecord[7]) charforskills = int(singlerecord[5]) pluspoints = 0 negativepoints = 0 randomnumberlskillincrease = random.randint(0, 4) # print (randomnumberlskillincrease) veryrandomnumberlskillincrease = random.randint(0, 25) # print (veryrandomnumberlskillincrease) if ageforskills > veryold: negativepoints = negativepoints + 10 elif ageforskills > 30: if charforskills >= int(verygoodchar): negativepoints = negativepoints + 2 elif charforskills <= verypoorchar: negativepoints = negativepoints + 6 else: negativepoints = negativepoints + 4 elif ageforskills < 21: if charforskills >= verygoodchar: pluspoints = pluspoints + 6 elif charforskills <= verypoorchar: pluspoints = pluspoints + 1 else: pluspoints = pluspoints + 4 elif ageforskills < 24: if charforskills >= verygoodchar: pluspoints = pluspoints + 4 elif charforskills <= verypoorchar: pluspoints = pluspoints + 1 else: pluspoints = pluspoints + 2 else: if charforskills >= verygoodchar: pluspoints = pluspoints + 2 elif charforskills <= verypoorchar: pluspoints = pluspoints + 1 else: pluspoints = pluspoints + 2 # added a degree of luck for a young player to boost skill + 2 if (ageforskills <= 24) and (randomnumberlskillincrease >= 3) and (charforskills > 9): pluspoints = pluspoints + 15 if (ageforskills <= 24) and (randomnumberlskillincrease >= 3) and (charforskills > 8): pluspoints = pluspoints + 7 if (ageforskills < 24) and (veryrandomnumberlskillincrease > 24) and (charforskills > 7): pluspoints = pluspoints + 7 if ageforskills > 24 and (veryrandomnumberlskillincrease > 22): negativepoints = negativepoints + 5 if ageforskills > 24 and (veryrandomnumberlskillincrease < 8): negativepoints = negativepoints + 3 randomloss = random.randint(6, 9) if charforskills <= averagechar: negativepoints = negativepoints + int(randomloss) ##### work out scores for max skill increase maxskillpoints = 0 playersmaxskill = int(singlerecord[4]) playercurrentskill = int(singlerecord[3]) playersexperience = int(singlerecord[6]) if ageforskills > veryold: maxskillpoints = maxskillpoints - 4 elif ageforskills > 30: maxskillpoints = maxskillpoints - 2 else: maxskillpoints = maxskillpoints + 2 if charforskills > 8: maxskillpoints = maxskillpoints + 2 elif charforskills > 5: maxskillpoints = maxskillpoints + 1 else: maxskillpoints = maxskillpoints + 0 if playercurrentskill > 15: maxskillpoints = maxskillpoints + 1 if playersexperience > 10: maxskillpoints = maxskillpoints + 2 elif playersexperience > 5: maxskillpoints = maxskillpoints + 1 else: maxskillpoints = maxskillpoints + 0 if playersmaxskill - playercurrentskill < 2: maxskillpoints = maxskillpoints + 3 #stop anyone getting over 20 hack # if playersmaxskill == 20: # maxskillpoints=0 # if playercurrentskill == 20: # pluspoints=0 # insert if winning season... # upgrade/downgrade skills #### based on earlier worked out +- scores #### postive score v random number in 0-8 range = increase in skills #### for every negative points try a random number in 0-1 range (so 50:50) and if = 1 you lose a point #### a if skill is less than 2 has been inserted to stop negative values randomnumber = random.randint(0, 8) randomnumberms = random.randint(0, 15) name = "" nposition = "" pointsadded = "0" if randomnumber <= pluspoints: skill = int(singlerecord[3]) skillpadding = str(int(singlerecord[3])) skillpadding = "{:<2}".format(skillpadding) if pluspoints > 10: singlerecord[3] = "{:<2}".format(skill + 2) # if skill == 19: increasetext = "+2" # else: # increasetext="+2" else: singlerecord[3] = "{:<2}".format(skill + 1) increasetext = "+1" name = singlerecord[1] + " " + singlerecord[2] nposition = singlerecord[0] age = singlerecord[7] newrecord = "" newrecord = nposition + " " + name + " " + increasetext + " " + str( singlerecord[3]) + " " + age + "\n" changesp = changesp + newrecord pointsadded = "1" if negativepoints == 0 or int(pointsadded) > 0: changes = "1" else: count = 0 changed = 0 pointslost = 0 while (negativepoints > count): count = count + 1 nrandomnumber = random.randint(0, 1) # name=singlerecord[1]+singlerecord[2] # changesn=changesn+name+"\n" if nrandomnumber == 1: skill = int(singlerecord[3]) if skill > 2: # stop a negative skill number and an infinte loop singlerecord[3] = "{:<2}".format(skill - 1) changed = 1 pointslost = pointslost + 1 if changed == 1: name = singlerecord[1] + " " + singlerecord[2] pointslostpadding = "{:<2}".format(pointslost) age = singlerecord[7] nposition = singlerecord[0] newline = "" #newline=nposition+" "+name+" "+"-"+str(pointslost)+" "+str(singlerecord[3])+" " +age+"\n" newline = nposition + " " + name + " " + "-" + pointslostpadding + " " + str( singlerecord[3]) + " " + age + "\n" changesn = changesn + newline #max skill if randomnumberms <= maxskillpoints: currentms = int(singlerecord[4]) currentmspadding = str(int(singlerecord[4]) + 1) currentmspadding = "{:<2}".format(currentmspadding) singlerecord[4] = "{:<2}".format(currentms + 1) namems = singlerecord[1] + " " + singlerecord[2] positionms = singlerecord[0] agems = singlerecord[7] newrecordms = "" #newrecordms= positionms+" "+namems+" "+"1"+" "+str(currentms+1)+" "+agems+"\n" newrecordms = positionms + " " + namems + " " + "+1" + " " + currentmspadding + " " + agems + "\n" #pdb.set_trace() changesms = changesms + newrecordms pointsadded = "1" # age +1, experience +1 age = singlerecord[7] age = '{}'.format(int(age) + 1) singlerecord[7] = "{:<2}".format(age) mylog.fmlog(detail=str( ("playoffexppoints just before add ", playoffexppoints)), verbosity=12) experience = singlerecord[6] experience = '{}'.format(int(experience) + playoffexppoints) singlerecord[6] = "{:<2}".format(experience) mylog.fmlog(detail=str( ("Player at end of season ", seasonnumber, singlerecord)), verbosity=13) return (ourteam, changesp, changesn, changesms)