from mc4 import* def getdrop(base): ret=[] for itemsn in range(len(base)): item="*";aleator=base[itemsn];rando=[1,];result=[] for alo in aleator:rando.append(rando[-1]+alo[0]);result.append(alo[1]) rand=randint(1,rando[-1]) for ele in range(len(result)): if rand<rando[ele+1]:item=result[ele];break ret.append(item) return ret def getblock(x,y,p):return p.actualchunk[x+y*16] def get_item_craft_mini(c): g=get_recipe_mini();r=["*",0] for x in range(13): t=next(g) if c==t[0]:r[0]=t[1];r[1]=t[2];break return r def get_item_craft_big(inv): ret=["*",0];craft="" if inv[25]==inv[28]==inv[31]==inv[30]==inv[29]=="*":return get_item_craft_mini(inv[23]+inv[24]+inv[26]+inv[27]) if inv[23]==inv[26]==inv[29]==inv[30]==inv[31]=="*":return get_item_craft_mini(inv[24]+inv[25]+inv[27]+inv[28]) if inv[23]==inv[24]==inv[25]=="*": if inv[26]==inv[29]=="*":return get_item_craft_mini(inv[27]+inv[28]+inv[30]+inv[31]) if inv[28]==inv[31]=="*":return get_item_craft_mini(inv[26]+inv[27]+inv[29]+inv[30]) for x in inv[23:32]:craft+=x gen=get_recipe_big() for x in range(6): temp=next(gen) if craft==temp[0]:ret[0]=temp[1];ret[1]=temp[2];break return ret def get_recipe_big(): yield("***222***","3",1,{}) yield("******222","3",1,{}) yield("222******","3",1,{}) yield("uuu*,**,*","@",1,{}) yield("(((*,**,*","?",1,{}) yield("uuuu*uuuu","<",1,{}) def get_recipe_mini(): yield("***'","(",4,{}) yield("**'*","(",4,{}) yield("*'**","(",4,{}) yield("'***","(",4,{}) yield("((((",")",1,{}) yield("(*(*",",",4,{}) yield("*(*(",",",4,{}) yield("***Y","Z",2,{}) yield("**Y*","Z",2,{}) yield("*Y**","Z",2,{}) yield("Y***","Z",2,{}) yield("Z*q*","}",1,{}) yield("*Z*q","}",1,{}) def useitem(s,c,n): s.invnumbers[c]-=n if s.invnumbers[c]<=0:s.inventory[c]="*";s.invnumbers[c]=0 def lifeprint(px,py,demi=False): tp="mmbbmmbbmmmbowoooobmbowoooooobboooooooobboooooooobmboooooobmmmboooobmmmmmboobmmmmmmmbbmmmm" for x in range(10): for y in range(9): col=color(188,188,188);te=tp[x+y*10] if te=="o":col="red" if te=="b":col="black" if te=="w":col="white" se(px+x,py+y,col) if demi:f(px+10,py,-5,10,color(188,188,188)) def foodprint(px,py,demi=False): texfood="mmbbmmmmmmbrrbmmmmbrwrebmmmbrreeebmmmbeeeebmmmmbeeebmmmmmbbbjbbmmmmmmbjbmmmmmmbbm" for x in range(9): for y in range(9): col=color(188,188,188);te=texfood[x+y*9] if te=="r":col="red" if te=="b":col="black" if te=="w":col="white" if te=="j":col=color(227,218,201) if te=="e":col="brown" se(px+x,py+y,col) if demi:f(px+10,py,-5,9,color(188,188,188)) def updatefoodsprite(player): dif=player.food-player.oldfood if dif==0:return bsx=160;bsy=180 if dif>0: stc=0;fro=floor(player.oldfood/2) for stc in range(ceil(dif/2)):foodprint(bsx+(stc+fro)*10,bsy,False) if player.food%2==1:foodprint(bsx+(stc+fro)*10,bsy,True) else:f(bsx+100,bsy,int(100-(20-(player.food)/2)*10),10,color(188,188,188)) player.oldfood=player.food def updatelifesprite(player): dif=player.life-player.oldlife if dif==0:return bsx=50;bsy=180 if dif>0: stc=0;to=floor(player.oldlife/2) for stc in range(ceil(dif/2)):lifeprint(bsx+(stc+to)*10,bsy,False) if player.life%2==1:lifeprint(bsx+(stc+to)*10,bsy,True) else:f(bsx+100,bsy,int(100-(20-(player.life)/2)*10),10,color(188,188,188)) player.oldlife=player.life def setactualchunk(self): player=self.player;chx=player.Chx;chy=player.Chy;ochx=player.oldChx;ochy=player.oldChy;dim=player.dimension;odim=player.olddimension;tplkeys=self.chunklist.keys() if dim==2:self.chunklist[str(chx)+";"+str(chy)+";2"]=generatechunk(chx,chy,self) else: for x,y in ((0,0),(-1,0),(1,0),(0,1),(-1,1),(1,1),(0,-1),(-1,-1),(1,-1)): ke=str(chx+x)+";"+str(chy+y)+";"+str(dim) if not ke in tplkeys: try: self.chunklist[ke]=generatechunk(chx+x,chy+y,self) except Exception as err: debug(err) if self.actualchunk and odim!=2: temp="" for du in range(1,8):temp+=self.actualchunk[du*16+1:du*16+15] self.chunklist[str(ochx)+";"+str(ochy)+";"+str(odim)]=temp chunkbase=self.chunklist[str(ochx-1)+";"+str(ochy)+";"+str(odim)] temp="" for add in range(98):temp+=chunkbase[add] if (add+1)%14!=0 else self.actualchunk[(1+(add//14))*16] self.chunklist[str(ochx-1)+";"+str(ochy)+";"+str(odim)]=temp chunkbase=self.chunklist[str(ochx+1)+";"+str(ochy)+";"+str(odim)] temp="" for add in range(98):temp+=chunkbase[add] if add%14!=0 else self.actualchunk[(1+(add//14))*16+15] self.chunklist[str(ochx+1)+";"+str(ochy)+";"+str(odim)]=temp temp=self.chunklist[str(ochx)+";"+str(ochy+1)+";"+str(odim)][0:84] for add in range(14):temp+=self.actualchunk[1+add] self.chunklist[str(ochx)+";"+str(ochy+1)+";"+str(odim)]=temp temp=self.chunklist[str(ochx)+";"+str(ochy-1)+";"+str(odim)][14:98] for add in range(14):temp=self.actualchunk[142-add]+temp self.chunklist[str(ochx)+";"+str(ochy-1)+";"+str(odim)]=temp self.chunklist[str(ochx-1)+";"+str(ochy+1)+";"+str(odim)]=self.chunklist[str(ochx-1)+";"+str(ochy+1)+";"+str(odim)][0:97]+self.actualchunk[0] chunkbase=self.chunklist[str(ochx+1)+";"+str(ochy+1)+";"+str(odim)] temp=chunkbase[0:84] temp+=self.actualchunk[15]+chunkbase[85:98] self.chunklist[str(ochx+1)+";"+str(ochy+1)+";"+str(odim)]=temp chunkbase=self.chunklist[str(ochx-1)+";"+str(ochy-1)+";"+str(odim)] temp=chunkbase[0:13] temp+=self.actualchunk[128]+chunkbase[14:98] self.chunklist[str(ochx-1)+";"+str(ochy-1)+";"+str(odim)]=temp self.chunklist[str(ochx+1)+";"+str(ochy-1)+";"+str(odim)]=self.actualchunk[143]+self.chunklist[str(ochx+1)+";"+str(ochy-1)+";"+str(odim)][1:98] n=0 for ele in self.actualchunk: if ele=="<": da=str(ochx)+";"+str(ochy)+";"+str(odim) if da in self.blocksavor.keys(): pass else: self.blocksavor[da]=[n] n+=1 if dim==2: tp=">"*16 for yu in range(7):tp+=">"+self.chunklist[str(chx)+";"+str(chy)+";"+str(dim)][yu*14:yu*14+14]+">" tp+=">"*16 else: tp="" for a,c,d,e in ((-1,dim,97,98),(0,dim,84,98),(1,dim,84,85)):tp+=self.chunklist[str(chx+a)+";"+str(chy+1)+";"+str(c)][d:e] for yu in range(7): for a,c,d,e in (-1,dim,13,14),(0,dim,0,14),(1,dim,0,1):tp+=self.chunklist[str(chx+a)+";"+str(chy)+";"+str(c)][yu*14+d:yu*14+e] for a,c,d,e in ((-1,dim,13,14),(0,dim,0,14),(1,dim,0,1)):tp+=self.chunklist[str(chx+a)+";"+str(chy-1)+";"+str(c)][d:e] for ele in range(144):self.actualchunkticker[ele]=getblocticks(tp[ele]) player.oldChx=player.Chx;player.oldChy=player.Chy;player.olddimension=player.dimension;self.itemgeror=[];self.actualchunk=tp