You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Written in Python, requires zlib and tkinter library UPDATE: since the last code has some bugs in parsing replays.
importzlibfromtkinterimportfiledialogrep_file=filedialog.askopenfilename()
ifrep_file=='': quit()
else: origin=open(rep_file,"rb").read()
# Decompress, let Zlib detect window buffer size and contentdecompressed_data=zlib.decompress(origin,wbits=0).split(b"\n")
defdecode_code(string, point):
value_return=0whileTrue:
b=string[point] # string here is already bytespoint=point+1value_return=value_return*128+ (bifb<128elseb-128)
ifb<128:
returnvalue_return, pointdefpump_recording(rep_string):
# currentFrame in original Techmino can be a value different from 0# It is only different from 0 if it has to decode a net replaycurrentFrame=0result= []
p=0; length=len(rep_string) -1# p is position, please check carefully to see if array/list/table in your using language has index started with which number?# In Python and JS, they start with 0, while Lua starts with 1. AGAIN, PLEASE CHECK CAREFULLY!whilep<=length:
# Read delta timedelta, p=decode_code(rep_string, p)
currentFrame+=deltaresult.append(currentFrame)
# Read eventevent, p=decode_code(rep_string, p)
result.append(event)
returnresultdefprint_result(input):
allKey= ["",
"Move Left", "Move Right",
"Rotate Right", "Rotate Left", "Rotate 180°",
"Hard Drop", "Soft Drop", "Hold",
"Function 1", "Function 2",
"Instant Left", "Instant Right",
"Sonic Drop", "Down 1", "Down 4", "Down 10",
"Left Drop", "Right Drop", "Left Zangi", "Right Zangi"
]
accept_key= []
accept_key+= (range(1 ,21))
accept_key+= (range(33,53))
iflen(input) %2!=0: input.pop()
# Find the largest value in the string and get len of itboard_width=len(str(max(input)))
# Print the table to Terminalforiinrange(0, len(input), 2):
frame=input[i]; event_key=input[i+1]
ifnotevent_key<frameornotevent_keyinaccept_key: continueprint(f"\nFrame {str(frame).rjust(board_width)}", end=" | ")
ifevent_key>32: print(f" R: {str(event_key):>3} | {allKey[event_key-32]:<15}", end=" | ")
else : print(f"P : {str(event_key):>3} | {allKey[event_key ]:<15}", end=" | ")
print("\n\nTHIS IS THE END OF THE REPLAY FILE!")
# Print the JSON partprint(decompressed_data[0])
print('')
# Print the result tableprint_result(pump_recording(b'\n'.join(decompressed_data[1::])))
# NOTE: decompressed_data[1::] is the data mess# Because I have to use decompressed_data.split to get the metadata. But this will cause# mess in the body part of the replay file# So I have to reconnect by using str.join() to revert data mess to original before I can decode
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Written in Python, requires zlib and tkinter library
UPDATE: since the last code has some bugs in parsing replays.
Beta Was this translation helpful? Give feedback.
All reactions