# CUBE
def BINARY_Cube_Open(self, npcVNUM):
self.currentCubeNPC = npcVNUM
self.cubeInformation.clear()
self.interface.wndCube.ClearOldSlots()
self.interface.OpenCubeWindow()
if npcVNUM not in self.cubeInformation:
net.SendChatPacket("/cube r_info")
else:
cubeInfoList = self.cubeInformation[npcVNUM]
i = 0
for cubeInfo in cubeInfoList:
self.interface.wndCube.AddCubeResultItem(cubeInfo["vnum"], cubeInfo["count"])
j = 0
for materialList in cubeInfo["materialList"]:
for materialInfo in materialList:
itemVnum, itemCount = materialInfo
self.interface.wndCube.AddMaterialInfo(i, j, itemVnum, itemCount)
j = j + 1
i = i + 1
self.interface.wndCube.Refresh()
def BINARY_Cube_Close(self):
self.interface.CloseCubeWindow()
# 제작에 필요한 골드, 예상되는 완성품의 VNUM과 개수 정보 update
def BINARY_Cube_UpdateInfo(self, gold, itemVnum, count):
self.interface.UpdateCubeInfo(gold, itemVnum, count)
def BINARY_Cube_Succeed(self, itemVnum, count):
print "큐브 제작 성공"
self.interface.SucceedCubeWork(itemVnum, count)
pass
def BINARY_Cube_Failed(self):
print "큐브 제작 실패"
self.interface.FailedCubeWork()
pass
def BINARY_Cube_ResultList(self, npcVNUM, listText):
# ResultList Text Format : 72723,1/72725,1/72730.1/50001,5 이런식으로 "/" 문자로 구분된 리스트를 줌
#print listText
if npcVNUM == 0:
npcVNUM = self.currentCubeNPC
self.cubeInformation[npcVNUM] = []
try:
for eachInfoText in listText.split("/"):
eachInfo = eachInfoText.split(",")
itemVnum = int(eachInfo[0])
itemCount = int(eachInfo[1])
self.cubeInformation[npcVNUM].append({"vnum": itemVnum, "count": itemCount})
self.interface.wndCube.AddCubeResultItem(itemVnum, itemCount)
resultCount = len(self.cubeInformation[npcVNUM])
requestCount = 7
modCount = resultCount % requestCount
splitCount = resultCount / requestCount
for i in xrange(splitCount):
#print("/cube r_info %d %d" % (i * requestCount, requestCount))
net.SendChatPacket("/cube r_info %d %d" % (i * requestCount, requestCount))
if 0 < modCount:
#print("/cube r_info %d %d" % (splitCount * requestCount, modCount))
net.SendChatPacket("/cube r_info %d %d" % (splitCount * requestCount, modCount))
except RuntimeError, msg:
dbg.TraceError(msg)
return 0
pass
def BINARY_Cube_MaterialInfo(self, startIndex, listCount, listText):
# Material Text Format : 125,1|126,2|127,2|123,5&555,5&555,4/120000
try:
#print listText
if 3 > len(listText):
dbg.TraceError("Wrong Cube Material Infomation")
return 0
eachResultList = listText.split("@")
cubeInfo = self.cubeInformation[self.currentCubeNPC]
itemIndex = 0
for eachResultText in eachResultList:
cubeInfo[startIndex + itemIndex]["materialList"] = [[], [], [], [], []]
materialList = cubeInfo[startIndex + itemIndex]["materialList"]
gold = 0
splitResult = eachResultText.split("/")
if 1 < len(splitResult):
gold = int(splitResult[1])
#print "splitResult : ", splitResult
eachMaterialList = splitResult[0].split("&")
i = 0
for eachMaterialText in eachMaterialList:
complicatedList = eachMaterialText.split("|")
if 0 < len(complicatedList):
for complicatedText in complicatedList:
(itemVnum, itemCount) = complicatedText.split(",")
itemVnum = int(itemVnum)
itemCount = int(itemCount)
self.interface.wndCube.AddMaterialInfo(itemIndex + startIndex, i, itemVnum, itemCount)
materialList.append((itemVnum, itemCount))
else:
itemVnum, itemCount = eachMaterialText.split(",")
itemVnum = int(itemVnum)
itemCount = int(itemCount)
self.interface.wndCube.AddMaterialInfo(itemIndex + startIndex, i, itemVnum, itemCount)
materialList.append((itemVnum, itemCount))
i = i + 1
itemIndex = itemIndex + 1
self.interface.wndCube.Refresh()
except RuntimeError, msg:
dbg.TraceError(msg)
return 0
pass
# END_OF_CUBE