From d1d81e03d1f78c8a6662b6bb87ff19b631764919 Mon Sep 17 00:00:00 2001 From: hide_d Date: Mon, 11 Jun 2018 20:27:55 +0900 Subject: [PATCH] =?UTF-8?q?makenation=20=ED=85=8D=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EC=97=90=20null=EC=9D=B4=20=EB=93=A4=EC=96=B4=EA=B0=80?= =?UTF-8?q?=EB=8A=94=EA=B2=BD=EC=9A=B0(=3F=3F)=EC=97=90=EB=8F=84=20?= =?UTF-8?q?=EC=9A=B0=ED=9A=8C=20=EB=8F=99=EC=9E=91.=20=EB=B3=80=ED=99=98?= =?UTF-8?q?=20=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=88=AB=EC=9E=90=20=EC=9E=A5=EC=88=98=EB=AA=85=20=EB=8C=80?= =?UTF-8?q?=EC=9D=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/commandlist.php | 4 +--- hwe/func_command.php | 16 ++++++---------- src/conv_general_stat.py | 35 ++++++++++++++++++----------------- 3 files changed, 25 insertions(+), 30 deletions(-) diff --git a/hwe/commandlist.php b/hwe/commandlist.php index b1e96a9c..458468c5 100644 --- a/hwe/commandlist.php +++ b/hwe/commandlist.php @@ -76,9 +76,7 @@ function myCommandList() { // 명령 목록 $admin = $gameStor->getValues(['year','month','turnterm']); - $query = "select no,turntime,term,turn0,turn1,turn2,turn3,turn4,turn5,turn6,turn7,turn8,turn9,turn10,turn11,turn12,turn13,turn14,turn15,turn16,turn17,turn18,turn19,turn20,turn21,turn22,turn23 from general where owner='{$userID}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $me = MYDB_fetch_array($result); + $me = $db->queryFirstRow("SELECT `no`,turntime,term,turn0,turn1,turn2,turn3,turn4,turn5,turn6,turn7,turn8,turn9,turn10,turn11,turn12,turn13,turn14,turn15,turn16,turn17,turn18,turn19,turn20,turn21,turn22,turn23 FROM general WHERE `owner`=%s", $userID); if(!$me){ echo "로그인 되어있지 않습니다."; return; diff --git a/hwe/func_command.php b/hwe/func_command.php index 6a874125..ad28bf7c 100644 --- a/hwe/func_command.php +++ b/hwe/func_command.php @@ -183,12 +183,10 @@ function getTurn(array $general, $type, $font=1) { $str[$i] = "하야"; break; case 46: //건국 - $query = "select makenation from general where no='{$general['no']}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $general = MYDB_fetch_array($result); + $nationName = $db->queryFirstField('SELECT makenation FROM general WHERE `no`=%i', $general['no'])??''; - $josaUl = JosaUtil::pick($general['makenation'], '을'); - $str[$i] = "【{$general['makenation']}】{$josaUl} 건국"; + $josaUl = JosaUtil::pick($nationName, '을'); + $str[$i] = "【{$nationName}】{$josaUl} 건국"; break; case 47: //방랑 $str[$i] = "방랑"; @@ -342,15 +340,13 @@ function getCoreTurn($nation, $level) { $str[$i] = "【{$nation['name']}】에게 국고 {$third} 병량 {$fourth} 원조"; break; case 53: //통합제의 - $query = "select makenation from general where level='$level' and nation='{$nation['nation']}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $general = MYDB_fetch_array($result); + $nationName = $db->queryFirstField('SELECT makenation FROM general WHERE `level`=%i AND `nation`=%i', $level, $nation['nation'])??''; $double = (int)$command[1]; $nation = getNationStaticInfo($double); - $josaRo = JosaUtil::pick($general['makenation'], '로'); - $str[$i] = "【{$nation['name']}】에 【{$general['makenation']}】{$josaRo} 통합 제의"; + $josaRo = JosaUtil::pick($nationName, '로'); + $str[$i] = "【{$nation['name']}】에 【{$nationName}】{$josaRo} 통합 제의"; break; case 61: //불가침제의 $third = $command[2]; diff --git a/src/conv_general_stat.py b/src/conv_general_stat.py index cb04ffd2..c34aa3d1 100644 --- a/src/conv_general_stat.py +++ b/src/conv_general_stat.py @@ -17,8 +17,9 @@ nationLevelMap = { '방랑군':0 } -print(sys.argv[1]) -wb = xlrd.open_workbook(sys.argv[1]) +xlsxpath = sys.argv[1] +print(xlsxpath) +wb = xlrd.open_workbook(xlsxpath) def extractNationList(nationSheet): jsonNationList = [] @@ -78,10 +79,10 @@ def extractGeneralList(generalSheet, nationList={}): row[0] = int(row[0]) #이름 - row[1] = row[1].strip() + row[1] = str(row[1]).strip() if row[1] == '': continue - + print(row[1]) #전콘 row[2] = str(row[2]).strip() if row[2].isdigit(): @@ -144,19 +145,19 @@ nationInfo = extractNationList(wb.sheet_by_name('국가')) generalList = extractGeneralList(wb.sheet_by_name('장수 목록'), nationInfo) +with open('%s.json'%xlsxpath, 'wt', encoding='utf-8') as fp: + fp.write(' "nation":[\n ') + fp.write(',\n '.join([json.dumps(nation, ensure_ascii=False) for nation in nationInfo])) + fp.write('\n ],\n') -print(' "nation":[\n ', end='') -print(',\n '.join([json.dumps(nation, ensure_ascii=False) for nation in nationInfo])) -print(' ],') + fp.write(' "diplomacy":[],\n') -print(' "diplomacy":[],') + fp.write(' "general":[\n ') + fp.write(',\n '.join([json.dumps(general, ensure_ascii=False) for general in generalList])) + fp.write('\n ],\n') -print(' "general":[\n ', end='') -print(',\n '.join([json.dumps(general, ensure_ascii=False) for general in generalList])) -print(' ],') - -if '확장 장수 목록' in wb.sheet_names(): - generalExList = extractGeneralList(wb.sheet_by_name('확장 장수 목록'), nationInfo) - print(' "general_ex":[\n ', end='') - print(',\n '.join([json.dumps(general, ensure_ascii=False) for general in generalExList])) - print(' ],') \ No newline at end of file + if '확장 장수 목록' in wb.sheet_names(): + generalExList = extractGeneralList(wb.sheet_by_name('확장 장수 목록'), nationInfo) + fp.write(' "general_ex":[\n ') + fp.write(',\n '.join([json.dumps(general, ensure_ascii=False) for general in generalExList])) + fp.write('\n ],\n') \ No newline at end of file