diff --git a/.gitignore b/.gitignore index e94e17c8..8c55bef0 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ d_shared d_pic/*.jpg d_pic/*.gif d_pic/*.png +d_pic/*.webp d_pic/uploaded_image d_setting/*.php diff --git a/css/config.css b/css/config.css index d0ef052c..2c2a272f 100644 --- a/css/config.css +++ b/css/config.css @@ -1,182 +1,241 @@ -@charset "utf-8"; - -body { - color:white; background-color:black; font-family: '맑은 고딕'; -} - -table { - border: solid 1px; border-spacing: 0px; border-collapse: separate; border-top-color: gray; border-left-color: gray; border-right-color: black; border-bottom-color: black; - padding: 0px; - font-size: 13px; - word-break: break-all; - text-align: center; - font-family: '맑은 고딕'; -} -th, td { - border: solid 1px; border-spacing: 0px; border-collapse: separate; border-top-color: gray; border-left-color: gray; border-right-color: black; border-bottom-color: black; - padding: 0px; - font-size: 13px; - word-break: break-all; - text-align: center; - font-family: '맑은 고딕'; -} - -a.just_link { - text-decoration: none; -} - -.with_border{ - margin:0; - border: solid 1px; - border-spacing: 0px; - border-collapse: separate; - border-top-color: gray; - border-left-color: gray; - border-right-color: black; - border-bottom-color: black; -} - -.section_title { - height:50px; - line-height:50px; - font-size: 30px; font-weight: bold; - text-align: center; - color:white; - padding:0; -} - -.legacy_layout div { - border: solid 1px; border-spacing: 0px; border-collapse: separate; border-top-color: gray; border-left-color: gray; border-right-color: black; border-bottom-color: black; - padding: 0px; - font-size: 13px; - word-break: break-all; - text-align: center; - font-family: '맑은 고딕';; -} - -.obj_fill{ - display:block; - width:100%; - height:100%; -} - -button.with_skin { - padding:0 4px; - background-color: black; color: white; - font-family: '맑은 고딕'; - font-size: 13px; -} - -button.with_skin:disabled { - background-color:#333333; -} - -input.with_skin { - background-color: black; color: white; - font-family: '맑은 고딕'; - font-size: 13px; -} - -input.with_skin:disabled { - background-color: #333333; -} - -.font0 { font-size: 10px; } -.font1 { font-size: 13px; } -.font2 { font-size: 15px; } -.font3 { font-size: 20px; } -.font4 { font-size: 30px; } -.font5 { font-size: 50px; } - -caption.section_title { - caption-side:top; -} - - -.samButton{ - float:left; - display:block; - padding:0; - margin:0; - text-decoration: none; - position:relative; -} - -a.samButton.disabled { - pointer-events: none; - cursor: default; -} - -.samButtonOuter{ - display: table; - border: outset 2px white; - box-sizing: border-box; - font-weight:bold; - padding: 1px 6px; - width:125px; - height:30px; - background-color:#000000; - color:#ffffff; -} - -.samButtonOuter:active{ - border: inset 2px white; -} - - -.samButtonInner{ - display: table-cell; - vertical-align: middle; - width: 100%; - margin: 0 auto; - text-align: center; - user-select: none; -} - -.samToolbarButton > .samButtonOuter{ - width:125px; - height:30px; - background-color:#225500; - color:white; -} - -.samToolbarButton2 > .samButtonOuter{ - width:125px; - height:30px; - background-color:#225500; - color:magenta; -} - -.samCommandButton > .samButtonOuter{ - width:111px; - height:30px; -} - -.samCommandButton.disabled > .samButtonOuter{ - background-color:transparent !important; - color:gray !important; - border-color:transparent !important; -} - -.samCommandButton.disabled > .samButtonOuter > .samButtonInner::before{ - content:'【' -} - -.samCommandButton.disabled > .samButtonOuter > .samButtonInner::after{ - content:'】' -} - -.tooltip_copyable_info .tooltiptext{ - display: inline; - color: rgba(0,0,0,0); - font-size: 0; -} - -.tooltiptext { - display: none; -} - -.hidden_but_copyable{ - color: rgba(0,0,0,0); - font-size: 0; +@charset "utf-8"; +body { + color: white; + background-color: black; + font-family: '맑은 고딕'; +} + +table { + border: solid 1px; + border-spacing: 0px; + border-collapse: separate; + border-top-color: gray; + border-left-color: gray; + border-right-color: black; + border-bottom-color: black; + padding: 0px; + font-size: 13px; + word-break: break-all; + text-align: center; + font-family: '맑은 고딕'; +} + +th, +td { + border: solid 1px; + border-spacing: 0px; + border-collapse: separate; + border-top-color: gray; + border-left-color: gray; + border-right-color: black; + border-bottom-color: black; + padding: 0px; + font-size: 13px; + word-break: break-all; + text-align: center; + font-family: '맑은 고딕'; +} + +a.just_link { + text-decoration: none; +} + +.with_border { + margin: 0; + border: solid 1px; + border-spacing: 0px; + border-collapse: separate; + border-top-color: gray; + border-left-color: gray; + border-right-color: black; + border-bottom-color: black; +} + +.section_title { + height: 50px; + line-height: 50px; + font-size: 30px; + font-weight: bold; + text-align: center; + color: white; + padding: 0; +} + +.legacy_layout div { + border: solid 1px; + border-spacing: 0px; + border-collapse: separate; + border-top-color: gray; + border-left-color: gray; + border-right-color: black; + border-bottom-color: black; + padding: 0px; + font-size: 13px; + word-break: break-all; + text-align: center; + font-family: '맑은 고딕'; + ; +} + +.obj_fill { + display: block; + width: 100%; + height: 100%; +} + +button.with_skin { + padding: 0 4px; + background-color: black; + color: white; + font-family: '맑은 고딕'; + font-size: 13px; +} + +button.with_skin:disabled { + background-color: #333333; +} + +input.with_skin { + background-color: black; + color: white; + font-family: '맑은 고딕'; + font-size: 13px; +} + +input.with_skin:disabled { + background-color: #333333; +} + +.font0 { + font-size: 10px; +} + +.font1 { + font-size: 13px; +} + +.font2 { + font-size: 15px; +} + +.font3 { + font-size: 20px; +} + +.font4 { + font-size: 30px; +} + +.font5 { + font-size: 50px; +} + +caption.section_title { + caption-side: top; +} + +.samButton { + float: left; + display: block; + padding: 0; + margin: 0; + text-decoration: none; + position: relative; +} + +a.samButton.disabled { + pointer-events: none; + cursor: default; +} + +.samButtonOuter { + display: table; + border: outset 2px white; + box-sizing: border-box; + font-weight: bold; + padding: 1px 6px; + width: 125px; + height: 30px; + background-color: #000000; + color: #ffffff; +} + +.samButtonOuter:active { + border: inset 2px white; +} + +.samButtonInner { + display: table-cell; + vertical-align: middle; + width: 100%; + margin: 0 auto; + text-align: center; + user-select: none; +} + +.samToolbarButton>.samButtonOuter { + width: 125px; + height: 30px; + background-color: #225500; + color: white; +} + +.samToolbarButton2>.samButtonOuter { + width: 125px; + height: 30px; + background-color: #225500; + color: magenta; +} + +.samCommandButton>.samButtonOuter { + width: 111px; + height: 30px; +} + +.samCommandButton.disabled>.samButtonOuter { + background-color: transparent !important; + color: gray !important; + border-color: transparent !important; +} + +.samCommandButton.disabled>.samButtonOuter>.samButtonInner::before { + content: '【' +} + +.samCommandButton.disabled>.samButtonOuter>.samButtonInner::after { + content: '】' +} + +.tooltip_copyable_info .tooltiptext { + display: inline; + color: rgba(0, 0, 0, 0); + font-size: 0; +} + +.tooltiptext { + display: none; +} + +.hidden_but_copyable { + color: rgba(0, 0, 0, 0); + font-size: 0; +} + +.vertical_flex { + height: 100%; + display: flex; + align-content: center; + flex-direction: column; + align-items: stretch; +} + +.vertical_flex .item { + display: block; + flex-grow: 1; +} + +.fill_box { + display: block; + width: 100%; + height: 100%; } \ No newline at end of file diff --git a/css/entrance.css b/css/entrance.css index bd9ea26b..28a4788c 100644 --- a/css/entrance.css +++ b/css/entrance.css @@ -1,141 +1,156 @@ -@charset "utf-8"; - -body{ - line-height: 1.3; -} - -#server_notice { - margin:10px 0; - border: none; - text-align:center; -} - -#server_list_container{ - width:800px; - position:absolute; - left:50%; - margin-left:-400px; -} - -#server_list_table{ - width:100%; -} - -#server_list tr{ - height:66px; -} - -#server_list .server_create_and_select .general_create, -#server_list .server_create_and_select .general_select { - width: 120px; height: 33px; - float: left; -} - -#server_list .general_create, -#server_list .general_login { - width: 120px; height: 66px; - float: left; -} - -.ignore_border{ - border:0; - margin:0; - padding:0; -} - -#user_info { - margin-top:20px; - width: 800px; height: 130px; -} - - -#user_info button{ - width: 200px; - height: 50px; - margin: 10px 50px; -} - -.center_ordered_items{ - text-align:center; -} - -.Entrance_ServerList { - width: 800px; height: 64px; - border: none; - float: left; -} - -.Entrance_ServerListServer { - width: 98px; height: 64px; - float: left; -} - -.Entrance_ServerListDown { - width: 698px; height: 64px; - float: left; -} - -.Entrance_ServerListInfo { - width: 398px; height: 64px; - float: left; -} - -.Entrance_ServerListBlock { - width: 298px; height: 64px; - float: left; - line-height: 64px; -} - -.Entrance_ServerListCharacter { - width: 64px; height: 64px; - float: left; -} - -.Entrance_ServerListName { - width: 112px; height: 64px; - float: left; - line-height: 64px; -} - - -.Entrance_ServerListSelect { - width: 120px; height: 32px; - float: left; -} - -#Entrance_000003 { - width: 798px; height: 155px; - text-align: left; -} - -.Entrance_Alert { - color: red; font-size: 15px; font-weight: bold; -} - -.Entrance_Che { - color: white; font-size: 15px; font-weight: bold; -} - -.Entrance_Kwe { - color: yellow; font-size: 15px; font-weight: bold; -} - -.Entrance_Pwe { - color: orange; font-size: 15px; font-weight: bold; -} - -.Entrance_Twe { - color: magenta; font-size: 15px; font-weight: bold; -} - -.Entrance_Nya { - color: #e67e22; font-size: 15px; font-weight: bold; -} - -.Entrance_Pya { - color: #9b59b6; font-size: 15px; font-weight: bold; -} - -.Entrance_Hwe { - color: red; font-size: 15px; font-weight: bold; +@charset "utf-8"; +body { + line-height: 1.3; +} + +#server_notice { + margin: 10px 0; + border: none; + text-align: center; +} + +#server_list_container { + width: 800px; + position: absolute; + left: 50%; + margin-left: -400px; +} + +#server_list_table { + width: 100%; +} + +#server_list tr { + height: 66px; +} + +.ignore_border { + border: 0; + margin: 0; + padding: 0; +} + +#user_info { + margin-top: 20px; + width: 800px; + height: 130px; +} + +#user_info button { + width: 200px; + height: 50px; + margin: 10px 50px; +} + +.center_ordered_items { + text-align: center; +} + +.Entrance_ServerList { + width: 800px; + height: 64px; + border: none; + float: left; +} + +.Entrance_ServerListServer { + width: 98px; + height: 64px; + float: left; +} + +.Entrance_ServerListDown { + width: 698px; + height: 64px; + float: left; +} + +.Entrance_ServerListInfo { + width: 398px; + height: 64px; + float: left; +} + +.Entrance_ServerListBlock { + width: 298px; + height: 64px; + float: left; + line-height: 64px; +} + +.Entrance_ServerListCharacter { + width: 64px; + height: 64px; + float: left; +} + +.Entrance_ServerListName { + width: 112px; + height: 64px; + float: left; + line-height: 64px; +} + +.Entrance_ServerListSelect { + width: 120px; + height: 32px; + float: left; +} + +#Entrance_000003 { + width: 798px; + height: 155px; + text-align: left; +} + +.Entrance_Alert { + color: red; + font-size: 15px; + font-weight: bold; +} + +.Entrance_Che { + color: white; + font-size: 15px; + font-weight: bold; +} + +.Entrance_Kwe { + color: yellow; + font-size: 15px; + font-weight: bold; +} + +.Entrance_Pwe { + color: orange; + font-size: 15px; + font-weight: bold; +} + +.Entrance_Twe { + color: magenta; + font-size: 15px; + font-weight: bold; +} + +.Entrance_Nya { + color: #e67e22; + font-size: 15px; + font-weight: bold; +} + +.Entrance_Pya { + color: #9b59b6; + font-size: 15px; + font-weight: bold; +} + +.Entrance_Hwe { + color: red; + font-size: 15px; + font-weight: bold; +} + +.BtnPlate { + height: inherit; } \ No newline at end of file diff --git a/hwe/b_myPage.php b/hwe/b_myPage.php index 0372f5d9..aa07ee0a 100644 --- a/hwe/b_myPage.php +++ b/hwe/b_myPage.php @@ -14,7 +14,7 @@ $generalID = $session->generalID; $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); -$gameStor->cacheValues(['turntime', 'opentime', 'autorun_user']); +$gameStor->cacheValues(['turntime', 'opentime', 'autorun_user', 'npcmode']); increaseRefresh("내정보", 1); @@ -113,6 +113,11 @@ var availableDieImmediately = ;

+npcmode==2 && $me->getNPCType()==0): ?> + 다른 장수 선택 (getAuxVar('next_change')??TimeUtil::now(), 0, 19)?> 부터)
+

+ + 개인용 CSS
diff --git a/hwe/css/common.css b/hwe/css/common.css index 8f5091be..664b4c21 100644 --- a/hwe/css/common.css +++ b/hwe/css/common.css @@ -1,40 +1,56 @@ @charset "UTF-8"; /* font-boostring Block */ -html * {max-height:1000000px;} - -html, body{ - background-color:black; - color:white; - line-height:1.3; - font-family:'맑은 고딕'; - font-size:13px; +html * { + max-height: 1000000px; } -table { font-family:'맑은 고딕'; } -font { font-family:'맑은 고딕'; } -input { font-family:'맑은 고딕'; font-size:13px; } -select { font-family:'굴림'; line-height:100%; } - -.center{ - text-align:center; +html, +body { + background-color: black; + color: white; + line-height: 1.3; + font-family: '맑은 고딕'; + font-size: 13px; } -table.mimic_flex{ +table { + font-family: '맑은 고딕'; +} + +font { + font-family: '맑은 고딕'; +} + +input { + font-family: '맑은 고딕'; + font-size: 13px; +} + +select { + font-family: '굴림'; + line-height: 100%; +} + +.center { + text-align: center; +} + +table.mimic_flex { border-collapse: collapse; - border:none; - padding:0; + border: none; + padding: 0; } -.mimic_flex td, .mimic_flex th { - border:none !important; +.mimic_flex td, +.mimic_flex th { + border: none !important; padding: 0px; word-break: break-all; } - -table.tb_layout { +table.tb_layout { border-collapse: collapse; padding: 0px; font-size: 13px; @@ -42,159 +58,161 @@ table.tb_layout { font-family: '맑은 고딕'; } -.tb_layout td, .tb_layout th { - border:solid 1px gray; +.tb_layout td, +.tb_layout th { + border: solid 1px gray; padding: 0px; word-break: break-all; - font-family: '맑은 고딕';; + font-family: '맑은 고딕'; + ; } -div.bar_out{ - position:relative; - border-top:solid 1px #888888; - border-bottom:solid 1px #333333; - padding:0; - margin:0; - width:100%; +div.bar_out { + position: relative; + border-top: solid 1px #888888; + border-bottom: solid 1px #333333; + padding: 0; + margin: 0; + width: 100%; overflow: hidden; } -div.bar_out div{ - position:absolute; - left:0; - top:0; - height:100%; +div.bar_out div { + position: absolute; + left: 0; + top: 0; + height: 100%; } -div.bar_out div.bar_in{ - width:100%; +div.bar_out div.bar_in { + width: 100%; } + /* */ -.ev_warning{ - color:orangered; +.ev_warning { + color: orangered; } -.ev_notice{ - color:orangered; +.ev_notice { + color: orangered; } -.ev_succes{ - color:lightgreen; +.ev_succes { + color: lightgreen; } -.ev_sell{ - color:orange; +.ev_sell { + color: orange; } -.ev_failed{ - color:orangered; +.ev_failed { + color: orangered; } -.ev_highlight{ - color:orangered; +.ev_highlight { + color: orangered; } + /* TODO: 색상값이 아니라 의미에 따라 클래스 지정 */ -.o_bullet::before{ - color:cyan; - content:"●"; +.o_bullet::before { + color: cyan; + content: "●"; } -.o_diamond::before{ - color:orangered; - content:"◆"; +.o_diamond::before { + color: orangered; + content: "◆"; } -.small_war_log{ - display:inline-block; +.small_war_log { + display: inline-block; } -.small_war_log .war_type_attack{ - color:cyan; +.small_war_log .war_type_attack { + color: cyan; } -.small_war_log .war_type_defense{ - color:magenta; +.small_war_log .war_type_defense { + color: magenta; } -.small_war_log .war_type_siege{ - color:white; +.small_war_log .war_type_siege { + color: white; } - - -.small_war_log .name_plate{ +.small_war_log .name_plate { font-size: 0.75em; } -.small_war_log .name_plate_cover{ - color:yellow; +.small_war_log .name_plate_cover { + color: yellow; } -.small_war_log .crew_plate{ - color:orangered; - font-size:90%; +.small_war_log .crew_plate { + color: orangered; + font-size: 90%; } -.t_date{ +.t_date { font-size: 0.75em; } -.t_red{ - color:red; +.t_red { + color: red; } -.t_blue{ - color:blue; +.t_blue { + color: blue; } -.t_green{ - color:green; +.t_green { + color: green; } -.t_magenta{ - color:magenta; +.t_magenta { + color: magenta; } -.t_cyan{ - color:cyan; +.t_cyan { + color: cyan; } -.t_limegreen{ - color:limegreen; +.t_limegreen { + color: limegreen; } -.t_skyblue{ - color:skyblue; +.t_skyblue { + color: skyblue; } -.t_orangered{ - color:orangered; +.t_orangered { + color: orangered; } -.t_yellow{ - color:yellow; +.t_yellow { + color: yellow; } -.t_white{ - color:white; +.t_white { + color: white; } -.float_left{ - float:left; +.float_left { + float: left; } -.tooltip{ - font-size:12px; +.tooltip { + font-size: 12px; font-family: '맑은 고딕'; } -.tooltip_copyable_info .tooltiptext{ +.tooltip_copyable_info .tooltiptext { display: inline; - color: rgba(0,0,0,0); + color: rgba(0, 0, 0, 0); font-size: 0; } @@ -202,67 +220,69 @@ div.bar_out div.bar_in{ display: none; } -.hidden_but_copyable{ - color: rgba(0,0,0,0); +.hidden_but_copyable { + color: rgba(0, 0, 0, 0); font-size: 0; } -.btn-group-xs > .btn, .btn-xs { - padding : .25rem .4rem; - font-size : .875rem; - line-height : .5; - border-radius : .2rem; +.btn-group-xs>.btn, +.btn-xs { + padding: .25rem .4rem; + font-size: .875rem; + line-height: .5; + border-radius: .2rem; } -.edit_form.viewer{ - max-height:200px; - overflow-y:auto; +.edit_form.viewer { + max-height: 200px; + overflow-y: auto; } -.trumbowyg-box{ - margin:0; - border-left:none; - border-right:none; +.trumbowyg-box { + margin: 0; + border-left: none; + border-right: none; } -.edit_form.trumbowyg-editor{ - margin:0; - padding:0; +.edit_form.trumbowyg-editor { + margin: 0; + padding: 0; } -.commandBasic{ - background-color:black; - color:white; +.commandBasic { + background-color: black; + color: white; } -.compensatePositive{ - color:skyblue; +.compensatePositive { + color: skyblue; } -.compensateNegative{ - color:orange; +.compensateNegative { + color: orange; } -.compensateNeutral{ - color:white; +.compensateNeutral { + color: white; } -.commandBasic.commandImpossible{ - background-color:red; - color:white; +.commandBasic.commandImpossible { + background-color: red; + color: white; } + .select2-selection--single.simple-select2-align-center .select2-selection__rendered { text-align: center; } -.select2-dropdown.simple-select2-align-center li.select2-results__option{ +.select2-dropdown.simple-select2-align-center li.select2-results__option { text-align: center; } -.select2-container--bootstrap4 .select2-selection--single.text-secondary .select2-selection__rendered{ - color:white; +.select2-container--bootstrap4 .select2-selection--single.text-secondary .select2-selection__rendered { + color: white; } -.select2-container--bootstrap4 .text-secondary .select2-results__option[aria-selected=false]{ - color:white; -} +.select2-container--bootstrap4 .text-secondary .select2-results__option[aria-selected=false] { + color: white; +} \ No newline at end of file diff --git a/hwe/css/select_general_from_pool.css b/hwe/css/select_general_from_pool.css new file mode 100644 index 00000000..3af9c79e --- /dev/null +++ b/hwe/css/select_general_from_pool.css @@ -0,0 +1,64 @@ +@charset "UTF-8"; +.container { + width: 1000px; + margin: 0 auto; +} + +.card_holder { + text-align: center; +} + +.general_card { + width: 125px; + display: inline-block; +} + +.general_card h4 { + margin: 0; +} + +.general_card p { + margin: 0; +} + +.general_card .select_btn { + width: 100%; +} + +.general_card label { + display: block; + padding-left: 15px; + text-indent: -15px; +} + +.general_card input { + width: 13px; + height: 13px; + padding: 0; + margin: 0; + vertical-align: bottom; + position: relative; + top: -1px; + *overflow: hidden; +} + +#outdate_token { + color: red; + display: none; +} + +#left_pad button { + display: none; +} + +.custom_picture { + display: none; +} + +.custom_personality { + display: none; +} + +.custom_stat { + display: none; +} \ No newline at end of file diff --git a/hwe/func_converter.php b/hwe/func_converter.php index e788afa1..7c696083 100644 --- a/hwe/func_converter.php +++ b/hwe/func_converter.php @@ -378,6 +378,30 @@ function buildWarUnitTriggerClass(?string $type, WarUnit $unit, ?array $args = n return $class->newInstanceArgs(array_merge([$unit], $args)); } +function getGeneralPoolClass(string $type){ + static $basePath = __NAMESPACE__.'\\GeneralPool\\'; + $classPath = ($basePath.$type); + + if(class_exists($classPath)){ + return $classPath; + } + + throw new \InvalidArgumentException("{$type}은 GeneralPool이 아님"); +} + +/** + * @param \MeekroDB $db + * @param int $owner + * @param int $pickCnt + * @param null|string $prefix + * @return AbsGeneralPool[] + */ +function pickGeneralFromPool(\MeekroDB $db, int $owner, int $pickCnt, ?string $prefix=null):array{ + /** @var AbsGeneralPool */ + $class = getGeneralPoolClass(GameConst::$targetGeneralPool); + return $class::pickGeneralFromPool($db, $owner, $pickCnt, $prefix); +} + function countPureGeneralFromRawList(?array $rawGeneralList=null):int{ if(!$rawGeneralList){ return 0; diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index c0d74ec6..2ffae56f 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -680,31 +680,22 @@ function updateNationState() while ($assemblerCnt < $maxAssemblerCnt) { $lastAssemblerID += 1; - $npcObj = new Scenario\NPC( - 999, + $npcObj = new Scenario\GeneralBuilder( sprintf('부대장%4d', $lastAssemblerID), + 0, null, - $nation['nation'], - null, - 10, - 10, - 10, - 1, - $admin['year'] - 15, - $admin['year'] + 15, - '은둔', - '척사' + $nation['nation'] ); - $npcObj->killturn = 70; - $npcObj->gold = 0; - $npcObj->rice = 0; - $npcObj->npc = 5; + $npcObj->setAffinity(999)->setStat(10, 10, 10) + ->setSpecialSingle('척사')->setEgo('은둔') + ->setKillturn(70)->setGoldRice(0, 0) + ->setNPCType(5)->fillRemainSpecAsZero($admin); $npcObj->build($admin); - $npcID = $npcObj->generalID; + $npcID = $npcObj->getGeneralID(); $db->insert('troop', [ 'troop_leader' => $npcID, - 'name' => $npcObj->realName, + 'name' => $npcObj->getGeneralName(), 'nation' => $nation['nation'], ]); $db->update('general', [ diff --git a/hwe/index.php b/hwe/index.php index 266502cb..61fedcb4 100644 --- a/hwe/index.php +++ b/hwe/index.php @@ -79,9 +79,11 @@ if ($gameStor->fiction == 0) { } if ($gameStor->npcmode == 0) { $npcmode = "불가능"; -} else { +} else if($gameStor->npcmode == 1){ $npcmode = "가능"; $valid = 1; +} else { + $npcmode = "선택 생성"; } $color = "cyan"; $mapTheme = $gameStor->map_theme; @@ -134,7 +136,7 @@ $(function(){
-
npcmode!=0)?>
+
npcmode==1)?>
@@ -341,7 +343,7 @@ else if($session->userGrade == 4){
내용 없이 '서신전달&갱신'을 누르면 메세지창이 갱신됩니다. -
npcmode!=0)?>
+
npcmode==1)?>
전체 메시지(최고99자)
@@ -361,7 +363,7 @@ else if($session->userGrade == 4){
-
npcmode!=0)?>
+
npcmode==1)?>
userGrade < 5 && !$allowReset){
- +
@@ -138,6 +138,20 @@ if($session->userGrade < 5 && !$allowReset){
+
+ +
+
+ + +
+
+
+
@@ -148,6 +162,9 @@ if($session->userGrade < 5 && !$allowReset){ +
diff --git a/hwe/j_autoreset.php b/hwe/j_autoreset.php index 63fede2c..000f1588 100644 --- a/hwe/j_autoreset.php +++ b/hwe/j_autoreset.php @@ -85,6 +85,7 @@ $result = ResetHelper::buildScenario( $options['scenario'], $options['fiction'], $options['extend'], + $options['block_general_create'], $options['npcmode'], $options['show_img_level'], $options['tournament_trig'], diff --git a/hwe/j_get_select_npc_token.php b/hwe/j_get_select_npc_token.php index 4a8ceced..03c6398c 100644 --- a/hwe/j_get_select_npc_token.php +++ b/hwe/j_get_select_npc_token.php @@ -37,7 +37,7 @@ list( $npcmode ) = $gameStor->getValuesAsArray(['maxgeneral', 'turnterm', 'npcmode']); -if(!$npcmode){ +if($npcmode!=1){ Json::die([ 'result'=>false, 'reason'=>'빙의 가능한 서버가 아닙니다' diff --git a/hwe/j_get_select_pool.php b/hwe/j_get_select_pool.php new file mode 100644 index 00000000..c57d15e7 --- /dev/null +++ b/hwe/j_get_select_pool.php @@ -0,0 +1,90 @@ +array_sum($rhs['dex']); + }); +} + +function putInfoText(&$info){ + if(key_exists('specialDomestic', $info)){ + $class = buildGeneralSpecialDomesticClass($info['specialDomestic']); + $info['specialDomesticName'] = $class->getName(); + $info['specialDomesticInfo'] = $class->getInfo(); + } + + if(key_exists('specialWar', $info)){ + $class = buildGeneralSpecialDomesticClass($info['specialWar']); + $info['specialWarName'] = $class->getName(); + $info['specialWarInfo'] = $class->getInfo(); + } +} + +$session = Session::requireLogin([])->setReadOnly(); +$userID = Session::getUserID(); + +$oNow = new \DateTimeImmutable(); + +$now = $oNow->format('Y-m-d H:i:s'); + +$db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game_env'); + +$npcmode = $gameStor->getValue('npcmode'); +if($npcmode!=2){ + Json::die([ + 'result'=>false, + 'reason'=>'선택 가능한 서버가 아닙니다' + ]); +} + +$rawGeneral = $db->queryFirstRow('SELECT no, aux FROM general WHERE `owner` = %i', $userID); +if($rawGeneral){ + $generalAux = Json::decode($rawGeneral['aux']); + if(key_exists('next_change', $generalAux)&& $generalAux['next_change'] > $now){ + Json::die([ + 'result'=>false, + 'reason'=>'아직 다시 고를 수 없습니다' + ]); + } +} + +$tokens = $db->query('SELECT unique_name, reserved_until, info FROM `select_pool` WHERE `owner`=%i AND `reserved_until`>=%s', $userID, $now); + +if($tokens){ + $pick = []; + $valid_until = null; + $specialInfo = []; + foreach($tokens as $token){ + $valid_until = $token['reserved_until']; + $info = Json::decode($token['info']); + putInfoText($info); + $info['uniqueName'] = $token['unique_name']; + $pick[] = $info; + } + sortTokens($pick);//좀 무식하지만.. + Json::die([ + 'result'=>true, + 'pick'=>$pick, + 'validUntil'=>$valid_until + ]); +} + +$pick = []; +$valid_until = null; +foreach(pickGeneralFromPool($db, $userID, 5) as $pickObj){ + $valid_until = $pickObj->getValidUntil(); + $info = $pickObj->getInfo(); + putInfoText($info); + $pick[] = $info; +} +sortTokens($pick);//좀 무식하지만.. +Json::die([ + 'result'=>true, + 'pick'=>$pick, + 'validUntil'=>$valid_until +]); \ No newline at end of file diff --git a/hwe/j_install.php b/hwe/j_install.php index e69aaaaf..4a7c1317 100644 --- a/hwe/j_install.php +++ b/hwe/j_install.php @@ -57,6 +57,7 @@ $v->rule('required', [ 'scenario', 'fiction', 'extend', + 'block_general_create', 'join_mode', 'npcmode', 'show_img_level', @@ -67,6 +68,7 @@ $v->rule('required', [ 'scenario', 'fiction', 'extend', + 'block_general_create', 'npcmode', 'show_img_level', 'tournament_trig', @@ -109,11 +111,13 @@ $scenario = (int)$_POST['scenario']; $fiction = (int)$_POST['fiction']; $extend = (int)$_POST['extend']; $npcmode = (int)$_POST['npcmode']; +$block_general_create = (bool)$_POST['block_general_create']; $show_img_level = (int)$_POST['show_img_level']; $tournament_trig = (int)$_POST['tournament_trig']; $join_mode = $_POST['join_mode']; $autorun_user_minutes = (int)$_POST['autorun_user_minutes']; $autorun_user_options = []; + foreach(Util::getPost('autorun_user', 'array_string', []) as $autorun_option){ $autorun_user_options[$autorun_option] = 1; } @@ -165,6 +169,7 @@ if($reserve_open){ 'scenarioName'=>$scenarioObj->getTitle(), 'fiction'=>$fiction, 'extend'=>$extend, + 'block_general_create'=>$block_general_create, 'npcmode'=>$npcmode, 'show_img_level'=>$show_img_level, 'tournament_trig'=>$tournament_trig, @@ -200,6 +205,7 @@ Json::die(ResetHelper::buildScenario( $scenario, $fiction, $extend, + $block_general_create, $npcmode, $show_img_level, $tournament_trig, diff --git a/hwe/j_select_npc.php b/hwe/j_select_npc.php index a1c44b63..d8a2f176 100644 --- a/hwe/j_select_npc.php +++ b/hwe/j_select_npc.php @@ -59,7 +59,7 @@ list( $npcmode ) = $gameStor->getValuesAsArray(['year', 'month', 'maxgeneral', 'npcmode']); -if(!$npcmode){ +if($npcmode!=1){ Json::die([ 'result'=>false, 'reason'=>'빙의 가능한 서버가 아닙니다' diff --git a/hwe/j_select_picked_general.php b/hwe/j_select_picked_general.php new file mode 100644 index 00000000..cfa864a4 --- /dev/null +++ b/hwe/j_select_picked_general.php @@ -0,0 +1,167 @@ +false, + 'reason'=>'장수를 선택하지 않았습니다' + ]); +} + +$session = Session::requireLogin([])->setReadOnly(); +$userID = Session::getUserID(); +$db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game_env'); + +$rootDB = RootDB::db(); +$oNow = new \DateTimeImmutable(); +$now = $oNow->format('Y-m-d H:i:s'); + +$hasGeneralID = $db->queryFirstField('SELECT no FROM general WHERE owner = %i', $userID); +if($hasGeneralID){ + Json::die([ + 'result'=>false, + 'reason'=>'이미 장수를 생성했습니다.' + ]); +} + +$env = $gameStor->getValues(['startyear', 'year', 'month', 'maxgeneral', 'npcmode', 'show_img_level', 'icon_path', 'turnterm', 'turntime']); +$env['fiction'] = false; + +$npcmode = $env['npcmode']; +$maxgeneral = $env['maxgeneral']; + +if($npcmode!=2){ + Json::die([ + 'result'=>false, + 'reason'=>'선택 가능한 서버가 아닙니다' + ]); +} + +$selectInfo = $db->queryFirstField('SELECT info FROM select_pool WHERE `owner` = %i AND `reserved_until`>=%s AND `unique_name`=%s', $userID, $now, $pick); +if(!$selectInfo){ + Json::die([ + 'result'=>false, + 'reason'=>'유효한 장수 목록이 없습니다.' + ]); +} +$selectInfo = Json::decode($selectInfo); + +$ownerInfo = RootDB::db()->queryFirstRow('SELECT `name`,`picture`,`imgsvr` FROM member WHERE `NO`=%i',$userID); +if(!$ownerInfo){ + Json::die([ + 'result'=>false, + 'reason'=>'멤버 정보를 가져오지 못했습니다.' + ]); +} + + +$gencount = $db->queryFirstField('SELECT count(`no`) FROM general WHERE npc<2'); + +if ($gencount >= $maxgeneral) { + Json::die([ + 'result'=>false, + 'reason'=>'더 이상 등록 할 수 없습니다.' + ]); +} + +$poolClass = getGeneralPoolClass(GameConst::$targetGeneralPool); +/** @var AbsGeneralPool */ +$pickedGeneral = new $poolClass($db, $selectInfo, $now); + +$builder = $pickedGeneral->getGeneralBuilder(); + +foreach(GameConst::$generalPoolAllowOption as $allowOption){ + if($allowOption == 'stat'){ + $leadership = Util::valueFit($leadership, GameConst::$defaultStatMin, GameConst::$defaultStatMax); + $strength = Util::valueFit($strength, GameConst::$defaultStatMin, GameConst::$defaultStatMax); + $intel = Util::valueFit($intel, GameConst::$defaultStatMin, GameConst::$defaultStatMax); + + if($leadership + $strength + $intel > GameConst::$defaultStatTotal){ + Json::die([ + 'result'=>false, + 'reason'=>'스탯의 총 합이 올바르지 않습니다.' + ]); + } + $builder->setStat($leadership, $strength, $intel); + } + else if($allowOption == 'picture' && $use_own_picture){ + $builder->setPicture($ownerInfo['imgsvr'], $ownerInfo['picture']); + } + else if($allowOption == 'ego'){ + if(!$personal || $personal == 'Random'){ + $personal = Util::choiceRandom(GameConst::$availablePersonality); + } + if(!array_search($personal, GameConst::$availablePersonality)){ + Json::die([ + 'result'=>false, + 'reason'=>'올바르지 않은 성격입니다.' + ]); + } + $builder->setEgo($personal); + } +} + +$builder->setOwner($userID); +$builder->setKillturn(5); +$builder->setNPCType(0); +$builder->setAuxVar('next_change', TimeUtil::nowAddDays(1)); +$builder->fillRemainSpecAsZero($env); +$builder->build($env); +$generalID = $builder->getGeneralID(); +if(!$generalID){ + Json::die([ + 'result'=>false, + 'reason'=>'장수 등록에 실패했습니다.' + ]); +} +$pickedGeneral->occupyGeneralName(); + +$db->update('select_pool',[ + 'owner'=>null, + 'reserved_until'=>null, +], '(owner=%i or reserved_until < %s) AND general_id is NULL', $userID, $now); + +$userNick = $ownerInfo['name']; +$josaYi = JosaUtil::pick($userNick, '이'); +$generalName = $builder->getGeneralName(); +$josaRo = JosaUtil::pick($generalName, '로'); + +$cityName = CityConst::byID($builder->getCityID())->name; + +$logger = new ActionLogger($generalID, 0, $env['year'], $env['month']); +$logger->pushGeneralHistoryLog("{$generalName}, {$cityName}에서 등장"); +$logger->pushGlobalActionLog("{$cityName}에서 {$userNick}{$josaYi} {$generalName}{$josaRo} 등장합니다."); +$logger->flush(); + +pushAdminLog(["가입 : {$userID} // {$session->userName} // {$pick} // ".getenv("REMOTE_ADDR")]); + +$rootDB->insert('member_log', [ + 'member_no' => $userID, + 'date'=>TimeUtil::now(), + 'action_type'=>'make_general', + 'action'=>Json::encode([ + 'server'=>DB::prefix(), + 'type'=>'select', + 'generalID'=>$generalID, + 'generalName'=>$generalName + ]) +]); + +Json::die([ + 'result'=>true, + 'reason'=>'success' +]); \ No newline at end of file diff --git a/hwe/j_server_basic_info.php b/hwe/j_server_basic_info.php index 7e04d937..334d8f67 100644 --- a/hwe/j_server_basic_info.php +++ b/hwe/j_server_basic_info.php @@ -91,7 +91,8 @@ if(file_exists(__DIR__.'/.htaccess')){ 'scenarioName'=>$options['scenarioName'], 'turnterm'=>$options['turnterm'], 'fictionMode'=>($options['fiction']?'가상':'사실'), - 'npcMode'=>($options['npcmode']?'가능':'불가'), + 'block_general_create'=>(!!$options['block_general_create']), + 'npcMode'=>([0=>'불가',1=>'가능',2=>'선택 생성'][$options['npcmode']]), 'openDatetime'=>$reserved['date'], 'starttime'=>$options['starttime'], 'gameConf'=>$options['gameConf'], @@ -104,7 +105,7 @@ if(file_exists(__DIR__.'/.htaccess')){ //TODO: 천통시에도 예약 오픈 알림이 필요..? -$admin = $gameStor->getValues(['isunited', 'npcmode', 'year', 'month', 'scenario', 'scenario_text', 'maxgeneral', 'turnterm', 'opentime', 'turntime', 'join_mode', 'fiction', 'autorun_user']); +$admin = $gameStor->getValues(['isunited', 'npcmode', 'year', 'month', 'scenario', 'scenario_text', 'maxgeneral', 'turnterm', 'opentime', 'turntime', 'join_mode', 'fiction', 'block_general_create', 'autorun_user']); $admin['maxUserCnt'] = $admin['maxgeneral']; $admin['npcMode'] = $admin['npcmode']; $admin['turnTerm'] = $admin['turnterm']; @@ -124,8 +125,8 @@ $admin['scenario'] = $admin['scenario_text']; $admin['userCnt'] = $genCnt; $admin['npcCnt'] = $npcCnt; $admin['nationCnt'] = $nationCnt; - -$admin['npcMode'] = $admin['npcMode']?'가능':'불가'; +$admin['block_general_create'] = !!$admin['block_general_create']; +$admin['npcMode'] = [0=>'불가',1=>'가능',2=>'선택 생성'][$admin['npcMode']]; $admin['fictionMode'] = $admin['fiction']?'가상':'사실'; $otherTextInfo = []; diff --git a/hwe/j_update_picked_general.php b/hwe/j_update_picked_general.php new file mode 100644 index 00000000..0df07f1c --- /dev/null +++ b/hwe/j_update_picked_general.php @@ -0,0 +1,149 @@ +false, + 'reason'=>'장수를 선택하지 않았습니다' + ]); +} + +$session = Session::requireLogin([])->setReadOnly(); +$userID = Session::getUserID(); +$db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game_env'); + +$rootDB = RootDB::db(); +$oNow = new \DateTimeImmutable(); +$now = $oNow->format('Y-m-d H:i:s'); + +$generalID = $db->queryFirstField('SELECT no FROM general WHERE owner = %i', $userID); +if(!$generalID){ + Json::die([ + 'result'=>false, + 'reason'=>'장수가 생성하지 않았습니다. 이미 사망하지 않았는지 확인해보세요.' + ]); +} + +list( + $year, + $month, + $maxgeneral, + $npcmode +) = $gameStor->getValuesAsArray(['year', 'month', 'maxgeneral', 'npcmode']); + +if($npcmode!=2){ + Json::die([ + 'result'=>false, + 'reason'=>'선택 가능한 서버가 아닙니다' + ]); +} + +$info = $db->queryFirstField('SELECT info FROM select_pool WHERE `owner` = %i AND `reserved_until`>=%s AND `unique_name`=%s', $userID, $now, $pick); +if(!$info){ + Json::die([ + 'result'=>false, + 'reason'=>'유효한 장수 목록이 없습니다.' + ]); +} + +$ownerInfo = RootDB::db()->queryFirstRow('SELECT `name`,`picture`,`imgsvr` FROM member WHERE `NO`=%i',$userID); +if(!$ownerInfo){ + Json::die([ + 'result'=>false, + 'reason'=>'멤버 정보를 가져오지 못했습니다.' + ]); +} + +$info = Json::decode($info); + + +$generalObj = General::createGeneralObjFromDB($generalID); +$oldGeneralName = $generalObj->getName(); +$db->update('select_pool', [ + 'general_id'=>-$generalID, + 'owner'=>null, + 'reserved_until'=>null +], 'unique_name=%s AND `reserved_until` IS NOT NULL AND owner = %i', $info['uniqueName'], $userID); + +if($db->affectedRows()==0){ + Json::die([ + 'result'=>false, + 'reason'=>'동시성 제어에 문제가 발생했습니다. 버그 제보를 부탁드립니다.' + ]); +} + +$db->update('select_pool', [ + 'general_id'=>null, + 'owner'=>null, + 'reserved_until'=>null, +], 'unique_name != %s AND general_id = %i', $info['uniqueName'], $generalID); + +$db->update('select_pool', [ + 'general_id'=>$generalID, +], 'general_id=%i', -$generalID); +if($db->affectedRows()==0){ + Json::die([ + 'result'=>false, + 'reason'=>'장수 선택 과정에 문제가 발생했습니다.. 버그 제보를 부탁드립니다.' + ]); +} +$db->update('select_pool',[ + 'owner'=>null, + 'reserved_until'=>null, +], '(owner=%i or reserved_until < %s) AND general_id is NULL', $userID, $now); + +if(key_exists('leadership', $info)){ + $generalObj->updateVar('leadership', $info['leadership']); + $generalObj->updateVar('strength', $info['strength']); + $generalObj->updateVar('intel', $info['intel']); +} +if(key_exists('picture', $info)){ + $generalObj->updateVar('imgsvr', $info['imgsvr']); + $generalObj->updateVar('picture', $info['picture']); +} +if(key_exists('generalName', $info)){ + $generalObj->updateVar('name', $info['generalName']); +} +if(key_exists('dex', $info)){ + $generalObj->updateVar('dex1', $info['dex'][0]); + $generalObj->updateVar('dex2', $info['dex'][1]); + $generalObj->updateVar('dex3', $info['dex'][2]); + $generalObj->updateVar('dex4', $info['dex'][3]); + $generalObj->updateVar('dex5', $info['dex'][4]); +} +if(key_exists('ego', $info)){ + $generalObj->updateVar('personal', $info['ego']); +} +if(key_exists('specialDomestic', $info)){ + $generalObj->updateVar('special', $info['specialDomestic']); +} +if(key_exists('specialWar', $info)){ + $generalObj->updateVar('special2', $info['specialWar']); +} +$generalObj->setAuxVar('next_change', TimeUtil::nowAddDays(1)); + +$userNick = $ownerInfo['name']; +$josaYi = JosaUtil::pick($userNick, '이'); + +$generalName = $info['generalName']; +$josaRo = JosaUtil::pick($generalName, '로'); + + +$logger = $generalObj->getLogger(); +$logger->pushGeneralHistoryLog("장수를 {$oldGeneralName}에서 {$generalName}{$josaRo} 변경"); +$logger->pushGlobalActionLog("{$userNick}{$josaYi} 장수를 {$oldGeneralName}에서 {$generalName}{$josaRo} 변경합니다."); +$generalObj->applyDB($db); + + +Json::die([ + 'result'=>true, + 'reason'=>'success' +]); \ No newline at end of file diff --git a/hwe/join.php b/hwe/join.php index 5189c265..5273ac80 100644 --- a/hwe/join.php +++ b/hwe/join.php @@ -24,7 +24,12 @@ if (!$member) { $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); - +$admin = $gameStor->getValues(['block_general_create','show_img_level','maxgeneral']); +if($admin['block_general_create']){ + MessageBox("잘못된 접근입니다!!!"); + echo ""; + exit(1); +} ?> @@ -66,7 +71,6 @@ echo Json::encode((object)$charInfoText);
삼국지 모의전투 HiDCHe 기 ()
getValues(['show_img_level','maxgeneral']); $gencount = $db->queryFirstField('SELECT count(no) FROM general WHERE npc<2'); diff --git a/hwe/js/common.js b/hwe/js/common.js index 8665bb3b..e66a5b94 100644 --- a/hwe/js/common.js +++ b/hwe/js/common.js @@ -372,4 +372,46 @@ function getNpcColor(npcType) { return 'skyblue'; } return null; +} + +function initTooltip($obj) { + if ($obj === undefined) { + $obj = $('.obj_tooltip'); + } else if (!$obj.hasClass('obj_tooltip')) { + $obj = $obj.find('.obj_tooltip'); + } + console.log($obj); + + $obj.each(function() { + $target = $(this); + + if ($target.data('installHandler')) { + return true; + } + $target.data('installHandler', true); + + $target.mouseover(function() { + var $objTooltip = $(this); + if ($objTooltip.data('setObjTooltip')) { + return true; + } + + var tooltipClassText = $objTooltip.data('tooltip-class'); + if (!tooltipClassText) { + tooltipClassText = ''; + } + var template = '' + .format(tooltipClassText); + + $objTooltip.tooltip({ + title: function() { + return $.trim($(this).find('.tooltiptext').html()); + }, + template: template, + html: true + }).tooltip('show'); + + $objTooltip.data('setObjTooltip', true); + }); + }); } \ No newline at end of file diff --git a/hwe/js/install.js b/hwe/js/install.js index 762017b7..293b7bd5 100644 --- a/hwe/js/install.js +++ b/hwe/js/install.js @@ -1,4 +1,3 @@ - /* function showCityGeneral(cityIdx){ @@ -21,13 +20,13 @@ function loadScenarioPreview(scenarioIdx){ -function loadScenarios(){ +function loadScenarios() { $.ajax({ - method:'post', - url:'j_load_scenarios.php', - dataType:'json' - }).then(function(result){ - if(!result.result){ + method: 'post', + url: 'j_load_scenarios.php', + dataType: 'json' + }).then(function(result) { + if (!result.result) { var deferred = $.Deferred(); deferred.reject('fail'); return deferred.promise(); @@ -37,18 +36,18 @@ function loadScenarios(){ var list = {}; - $.each(result.scenario, function(idx, value){ + $.each(result.scenario, function(idx, value) { var title = value.title || "-"; var pat = /【(.*?)[0-9\-_\.a-zA-Z]*】/; var category = pat.exec(title); - category = category?category[1]:'-'; + category = category ? category[1] : '-'; value.title = title; value.category = category; value.idx = idx; value.year = value.year || 180; - if(!(category in list)){ + if (!(category in list)) { list[category] = {}; } @@ -56,12 +55,12 @@ function loadScenarios(){ }); var $select = $('#scenario_sel'); - $.each(list, function(category, items){ + $.each(list, function(category, items) { var $optgroup = $('').attr('label', category); - - $.each(items, function(idx, scenario){ + + $.each(items, function(idx, scenario) { var $option = $('
\ -\ -\ -\ -"; +\ +<%if(canCreate) {%>\ +\ +<%}%>\ +<%if(canSelectNPC) {%>\ +\ +<%}%>\ +<%if(canSelectPool) {%>\ +\ +<%}%>\ +"; var serverLoginTemplate = "\ \ <%name%>\ -\ -\ +\ +\ \ "; - var serverReservedTemplate = "\ \ <%openDatetime==starttime?'':'- 가오픈 일시 : '+openDatetime+ '-
'%>\ @@ -63,38 +84,38 @@ var serverReservedTemplate = "\ \ "; -$(function(){ +$(function() { $("#btn_logout").click(Entrance_Logout); Entrance_UpdateServer(); }); function Entrance_UpdateServer() { $.ajax({ - type:'post', - url:"j_server_get_status.php", - dataType:'json', - }).then(function(response){ - if(response.result == "SUCCESS") { + type: 'post', + url: "j_server_get_status.php", + dataType: 'json', + }).then(function(response) { + if (response.result == "SUCCESS") { Entrance_drawServerList(response.server); } }); } -function Entrance_drawServerList(serverInfos){ +function Entrance_drawServerList(serverInfos) { var $serverList = $('#server_list'); var now = moment().format('YYYY-MM-DD HH:mm:ss'); - $.each(serverInfos, function(idx, serverInfo){ + $.each(serverInfos, function(idx, serverInfo) { var $serverHtml = $(TemplateEngine(serverListTemplate, serverInfo)); $serverList.append($serverHtml); - if(!serverInfo.exists){ + if (!serverInfo.exists) { return true; } - var serverPath = "../"+serverInfo.name; + var serverPath = "../" + serverInfo.name; - $.getJSON("../"+serverInfo.name+'/j_server_basic_info.php',{}, function(result){ - if(result.reserved){ + $.getJSON("../" + serverInfo.name + '/j_server_basic_info.php', {}, function(result) { + if (result.reserved) { $serverHtml.find('.server_down').detach(); $serverHtml.append( TemplateEngine(serverReservedTemplate, result.reserved) @@ -103,64 +124,59 @@ function Entrance_drawServerList(serverInfos){ return; } - if(!result.game){ + if (!result.game) { return; } - var game= result.game; + var game = result.game; //TODO: 서버 폐쇄 방식을 새롭게 변경 $serverHtml.find('.server_down').detach(); var serverTime = '%s ~ %s'.format(game.startFrom) - if(game.isUnited == 2){ + if (game.isUnited == 2) { $serverHtml.find('.n_country').html('§천하통일§'); $serverHtml.find('.server_date').html('{0}
~ {1}'.format(game.starttime, game.turntime)); - } - else if(game.opentime <= now){ + } else if (game.opentime <= now) { $serverHtml.find('.n_country').html('<{0}국 경쟁중>'.format(game.nationCnt)); $serverHtml.find('.server_date').html('{0} ~'.format(game.starttime)); - } - else{ + } else { $serverHtml.find('.n_country').html('-가오픈 중-'); $serverHtml.find('.server_date').html('{0} ~'.format(game.starttime)); } - if(game.opentime <= now){ + if (game.opentime <= now) { $serverHtml.append( TemplateEngine(serverTextInfo, game) ); - } - else{ + } else { $serverHtml.append( TemplateEngine(serverProvisionalInfo, game) ); } - - if(result.me && result.me.name){ + + console.log(game.npcMode); + if (result.me && result.me.name) { var me = result.me; me.serverPath = serverPath; $serverHtml.append( TemplateEngine(serverLoginTemplate, me) ); - } - else if(game.userCnt >= game.maxUserCnt){ + } else if (game.userCnt >= game.maxUserCnt) { $serverHtml.append( TemplateEngine(serverFullTemplate, {}) ); - } - else if(game.npcMode == '가능'){ + } else { $serverHtml.append( - TemplateEngine(serverCreateAndSelectTemplate, {serverPath:serverPath}) - ).addClass('server_create_and_select'); + TemplateEngine(serverCreateTemplate, { + serverPath: serverPath, + canCreate: !game.block_general_create, + canSelectNPC: game.npcMode == '가능', + canSelectPool: game.npcMode == '선택 생성' + }) + ) } - else{ - $serverHtml.append( - TemplateEngine(serverCreateTemplate, {serverPath:serverPath}) - ); - } - initTooltip($serverHtml); }); }); @@ -168,14 +184,14 @@ function Entrance_drawServerList(serverInfos){ function Entrance_Logout() { $.ajax({ - type:'post', - url:"j_logout.php", - dataType:'json', + type: 'post', + url: "j_logout.php", + dataType: 'json', }).then(function(response) { - if(response.result) { - location.href="../"; + if (response.result) { + location.href = "../"; } else { alert('로그아웃 실패'); } }); -} +} \ No newline at end of file