├── README.md └── converter.py /README.md: -------------------------------------------------------------------------------- 1 | # Majsoul-Tenhou-Converter 2 | Majsoul paifu to Tenhou converter 雀魂天凤牌谱格式转换 3 | 4 | 最近连续吃四被飞,决定用AI(NAGA)看看自己到底有多少鸡打。 5 | 6 | 参考了https://lions-blue.hatenablog.jp/entry/2021/10/23/191220 这个Blog的方法: 7 | 8 | ## 使用方法 9 | ### 安装tampermonkey 10 | [下载链接](https://www.tampermonkey.net/) 11 | 12 | ### 运行script 13 | 使用tampermonkey运行上面blog中的script. 14 | 15 | ### 下载牌谱 16 | 打开雀魂牌谱,按s会自动下载。因为用了上面Blog中的script,亲测需要复制牌谱链接到日服打开才能下载。(感觉国服应该也可以,希望javascript大神来写个国服的) 17 | 18 | ### 转换格式 19 | 把converter.py里面的文件名改成自己的,然后python converter.py 20 | 21 | ### 牌谱分析 22 | [NAGA链接](https://naga.dmv.nico/naga_report/order_form/) 23 | 24 | ### 待更新 25 | 目前还有一些bug,主要是役种不全,以后遇到了就更新(反正以后还要继续吃四) 26 | -------------------------------------------------------------------------------- /converter.py: -------------------------------------------------------------------------------- 1 | #Based on https://lions-blue.hatenablog.jp/entry/2021/10/23/191220 2 | #Coded by zzw (我爱豆腐) 3 | import json 4 | import sys 5 | 6 | #qh_paipu_name = "1_11_2022_Jade_Room_South.json" 7 | qh_paipu_name = "2_13_2022_Jade_Room_South4.json" 8 | th_paipu_name = "output.json" 9 | 10 | hand_dict = { 11 | "Mangan": "満貫", 12 | "Haneman": "跳満", 13 | "Baiman": "倍満", 14 | "Sanbaiman": "三倍満", 15 | "Yakuman": "役満", 16 | "Kazoeyakuman": "数え役満", 17 | "Kiriagemangan": "切り上げ満貫" 18 | } 19 | 20 | yaku_dict = { 21 | "White Dragon": "役牌 白", 22 | "Green Dragon": "役牌 發", 23 | "Red Dragon": "役牌 中", 24 | "Seat Wind": "自風 南", #These two are wrong but they don't matter 25 | "Prevalent Wind": "場風 南", 26 | "Dora": "ドラ", 27 | "Ura Dora": "裏ドラ", 28 | "Red Five": "赤ドラ", 29 | "Riichi": "立直", 30 | "Double Riichi": "両立直", 31 | "Ippatsu": "一発", 32 | "Fully Concealed Hand": "門前清自摸和", 33 | "Mixed Triple Sequence": "三色同順", 34 | "Triple Triplets": "三色同刻", 35 | "Pure Double Sequence": "一盃口", 36 | "Twice Pure Double Sequence": "二盃口", 37 | "Pinfu": "平和", 38 | "All Simples": "断幺九", 39 | "Pure Straight": "一気通貫", 40 | "Seven Pairs": "七対子", 41 | "All Triplets":"対々和", 42 | "Half Outside Hand": "混全帯幺九", 43 | "Fully Outside Hand": "純全帯幺九", 44 | "After a Kan":"嶺上開花", 45 | "Under the Sea":"海底摸月", 46 | "Under the River":"河底撈魚", 47 | "Half Flush": "混一色", 48 | "Full Flush": "清一色", 49 | "Three Concealed Triplets": "三暗刻", 50 | "Thirteen Orphans": "国士無双" 51 | } 52 | 53 | ending_dict = { 54 | "Ryuukyoku":"流局", 55 | "Kyuushu Kyuuhai":"九種九牌" 56 | } 57 | def get_th_title(qh_title): 58 | room_name = qh_title[0].split(' ')[0] 59 | game_length = qh_title[0].split(' ')[2] 60 | game_date = qh_title[1] 61 | 62 | if room_name == "Bronze": 63 | room = "铜之间" 64 | elif room_name == "Silver": 65 | room = "银之间" 66 | elif room_name == "Gold": 67 | room = "金之间" 68 | elif room_name == "Jade": 69 | room = "玉之间" 70 | elif room_name == "Throne": 71 | room = "王座之间" 72 | else: 73 | room = "?之间" 74 | 75 | if game_length == "South": 76 | length = "四人南" 77 | elif game_length == "East": 78 | length = "四人东" 79 | 80 | return ([room+length, game_date]) 81 | 82 | def get_th_log(qh_log): 83 | #Basically changing english names to japanese names 84 | #print (qh_log) 85 | #dict: 86 | 87 | #special endings 88 | if qh_log[-1][0] in ending_dict.keys(): 89 | qh_log[-1][0] = ending_dict[qh_log[-1][0]] 90 | return ([qh_log]) 91 | 92 | if qh_log[-1][2][3].split(' ')[0] in hand_dict.keys(): 93 | qh_log[-1][2][3] = hand_dict[qh_log[-1][2][3].split(' ')[0]]+qh_log[-1][2][3].split(' ')[1] 94 | 95 | new_yakus = [] 96 | new_yakus.append(qh_log[-1][2][0]) 97 | new_yakus.append(qh_log[-1][2][1]) 98 | new_yakus.append(qh_log[-1][2][2]) 99 | new_yakus.append(qh_log[-1][2][3]) 100 | for i in range(4,len(qh_log[-1][2])): 101 | if qh_log[-1][2][i].split('(')[0] in yaku_dict.keys(): 102 | new_yakus.append(yaku_dict[qh_log[-1][2][i].split('(')[0]]+'('+qh_log[-1][2][i].split('(')[1]) 103 | else: 104 | new_yakus.append(qh_log[-1][2][i]) 105 | qh_log[-1][2] = new_yakus 106 | return ([qh_log]) 107 | 108 | with open(qh_paipu_name, 'r') as f: 109 | #To remove \n from json file 110 | qh_paipu = ''.join(f.readlines()) 111 | qh_paipu = json.loads(qh_paipu) 112 | 113 | th_paipu = {} 114 | th_paipu["title"] = get_th_title(qh_paipu["title"]) 115 | th_paipu["name"] = qh_paipu["name"] 116 | th_paipu["rule"] = qh_paipu["rule"] 117 | 118 | with open(qh_paipu_name[:-5]+"_th"+".txt", 'w') as f: 119 | for i in range(len(qh_paipu["log"])): 120 | th_paipu["log"] = get_th_log(qh_paipu["log"][i]) 121 | th_paipu_line = 'https://tenhou.net/6/#json=' + json.dumps(th_paipu, ensure_ascii = False , separators = ( ',' , ':' )) 122 | f.write (th_paipu_line+'\n') 123 | --------------------------------------------------------------------------------