Explorar el Código

도전과제 및 업적 및 레벨 시스템 기초 제작

잉여개발기 (SPDV) hace 2 años
padre
commit
9a84742d74
Se han modificado 8 ficheros con 223 adiciones y 203 borrados
  1. 7 7
      app.py
  2. 24 5
      lang/en-US.json
  3. 19 6
      lang/ko-KR.json
  4. 14 0
      route/api_user_info.py
  5. 138 141
      route/user_challenge.py
  6. 1 1
      version.json
  7. 5 41
      views/main_css/js/func/func.js
  8. 15 2
      views/main_css/js/func/insert_user_info.js

+ 7 - 7
app.py

@@ -573,13 +573,13 @@ app.route('/change', methods = ['POST', 'GET'])(user_setting)
 app.route('/change/key')(user_setting_key)
 app.route('/change/key/delete')(user_setting_key_delete)
 app.route('/change/pw', methods = ['POST', 'GET'])(user_setting_pw)
-app.route('/change/head', methods=['GET', 'POST'], defaults = { 'skin_name' : '' })(user_setting_head)
-app.route('/change/head/<skin_name>', methods=['GET', 'POST'])(user_setting_head)
-app.route('/change/head_reset', methods=['GET', 'POST'])(user_setting_head_reset)
+app.route('/change/head', methods = ['GET', 'POST'], defaults = { 'skin_name' : '' })(user_setting_head)
+app.route('/change/head/<skin_name>', methods = ['GET', 'POST'])(user_setting_head)
+app.route('/change/head_reset', methods = ['GET', 'POST'])(user_setting_head_reset)
 app.route('/change/skin_set')(user_setting_skin_set)
-app.route('/change/top_menu', methods=['GET', 'POST'])(user_setting_top_menu)
-app.route('/change/user_name', methods=['GET', 'POST'])(user_setting_user_name)
-app.route('/change/user_name/<user_name>', methods=['GET', 'POST'])(user_setting_user_name)
+app.route('/change/top_menu', methods = ['GET', 'POST'])(user_setting_top_menu)
+app.route('/change/user_name', methods = ['GET', 'POST'])(user_setting_user_name)
+app.route('/change/user_name/<user_name>', methods = ['GET', 'POST'])(user_setting_user_name)
 # 하위 호환용 S
 app.route('/skin_set')(user_setting_skin_set)
 # 하위 호환용 E
@@ -588,7 +588,7 @@ app.route('/change/skin_set/main', methods = ['POST', 'GET'])(user_setting_skin_
 app.route('/user')(user_info)
 app.route('/user/<name>')(user_info)
 
-app.route('/challenge')(user_challenge)
+app.route('/challenge', methods = ['GET', 'POST'])(user_challenge)
 
 app.route('/count')(user_count)
 app.route('/count/<name>')(user_count)

+ 24 - 5
lang/en-US.json

@@ -119,6 +119,7 @@
         "popup" : "Popup",
         "popover" : "Popover",
         "trace" : "Trace",
+        "level" : "Level",
         "_comment_1.1_" : "Time",
             "second" : "Second(s)",
             "hour" : "Hour(s)",
@@ -618,14 +619,32 @@
             "backup_warning" : "Warning. Files with the same name may be erased.",
         "_comment_" : "Challenge",
             "challenge_title_register" : "Hello, World!",
-            "challenge_info_register" : "Sign up",
+            "challenge_info_register" : "Sign up<br><br>Reward : 🌳 title",
     
             "challenge_title_first_contribute" : "Well begun is half done.",
-            "challenge_info_first_contribute" : "Make your 1st contribution",
+            "challenge_info_first_contribute" : "Make your 1st contribution<br><br>Reward : 🔰 title and 500 exp",
     
-            "challenge_title_tenthousandth_contribute" : "Rome wasn't built in a day.",
-            "challenge_info_tenthousandth_contribute" : "Make your 1000th contribution",
+            "challenge_title_tenth_contribute" : "Boys, Be Ambitious!",
+            "challenge_info_tenth_contribute" : "Make your 10th contribution<br><br>Reward : 📝 title and 1000 exp",
+
+            "challenge_title_hundredth_contribute" : "Knowledge is power.",
+            "challenge_info_hundredth_contribute" : "Make your 100th contribution<br><br>보상 : 🖊️ title and 3000 exp",
+
+            "challenge_title_thousandth_contribute" : "Rome wasn't built in a day.",
+            "challenge_info_thousandth_contribute" : "Make your 1000th contribution<br><br>Reward : 🏅 title and 10000 exp",
     
+            "challenge_title_first_discussion" : "Truth is generally the best vindication against slander.",
+            "challenge_info_first_discussion" : "Post the 1st discussion thread<br><br>Reward : 💬 title and 500 exp",
+
+            "challenge_title_tenth_discussion" : "I shall either find a way or make one.",
+            "challenge_info_tenth_discussion" : "Post the 10th discussion thread<br><br>Reward : 💡 title and 1000 exp",
+
+            "challenge_title_hundredth_discussion" : "When all think alike, no one thinks very much.",
+            "challenge_info_hundredth_discussion" : "Post the 100th discussion thread<br><br>Reward : 📢 title and 3000 exp",
+
             "challenge_title_thousandth_discussion" : "I think, therefore I am.",
-            "challenge_info_thousandth_discussion" : "Post the 1000th discussion thread"
+            "challenge_info_thousandth_discussion" : "Post the 1000th discussion thread<br><br>Reward : 📜 title and 10000 exp",
+
+            "challenge_title_admin" : "If you want to test a man's character, give him power.",
+            "challenge_info_admin" : "Be the administrator.<br><br>Reward : ✅ title and 10000 exp"
 }

+ 19 - 6
lang/ko-KR.json

@@ -413,13 +413,25 @@
     "make_new_topic": "새 토론 생성",
     "old_page_warning": "이 문서는 오래되었습니다.",
     "challenge_title_register": "Hello, World!",
-    "challenge_info_register": "가입을 하세요.",
+    "challenge_info_register": "가입을 하세요.<br><br>보상 : 🌳 칭호",
     "challenge_title_first_contribute": "시작이 반이다.",
-    "challenge_info_first_contribute": "첫 기여를 하세요.",
-    "challenge_title_tenthousandth_contribute": "대기만성",
-    "challenge_info_tenthousandth_contribute": "1000번째 기여를 하세요.",
+    "challenge_info_first_contribute": "첫 기여를 하세요.<br><br>보상 : 🔰 칭호와 500 경험치",
+    "challenge_title_tenth_contribute" : "소년이여, 야망을 가져라!",
+    "challenge_info_tenth_contribute" : "10번째 기여를 하세요.<br><br>보상 : 📝 칭호와 1000 경험치",
+    "challenge_title_hundredth_contribute" : "아는 것이 힘이다.",
+    "challenge_info_hundredth_contribute" : "100번째 기여를 하세요.<br><br>보상 : 🖊️ 칭호와 3000 경험치",
+    "challenge_title_thousandth_contribute": "대기만성",
+    "challenge_info_thousandth_contribute": "1000번째 기여를 하세요.<br><br>보상 : 🏅 칭호와 10000 경험치",
+    "challenge_title_first_discussion" : "진실은 보통 모함에 맞서는 최고의 해명이다.",
+    "challenge_info_first_discussion" : "1번째 토론 스레드를 올리세요.<br><br>보상 : 💬 칭호와 500 경험치",
+    "challenge_title_tenth_discussion" : "내가 길을 찾아내거나 직접 길을 만들겠다.",
+    "challenge_info_tenth_discussion" : "10번째 토론 스레드를 올리세요.<br><br>보상 : 💡 칭호와 1000 경험치",
+    "challenge_title_hundredth_discussion" : "모두가 비슷한 생각을 한다는 것은, 아무도 생각하고 있지 않다는 말이다.",
+    "challenge_info_hundredth_discussion" : "100번째 토론 스레드를 올리세요.<br><br>보상 : 📢 칭호와 3000 경험치",
     "challenge_title_thousandth_discussion": "나는 생각한다. 고로 존재한다.",
-    "challenge_info_thousandth_discussion": "1000번째 토론 스레드를 올리세요.",
+    "challenge_info_thousandth_discussion": "1000번째 토론 스레드를 올리세요.<br><br>보상 : 📜 칭호와 10000 경험치",
+    "challenge_title_admin" : "왕후장상의 씨가 어찌 따로 있단 말이냐!",
+    "challenge_info_admin" : "관리자가 되세요.<br><br>보상 : ✅ 칭호와 10000 경험치",
     "challenge": "도전과제",
     "user_title": "칭호",
     "alpha": "알파",
@@ -577,5 +589,6 @@
     "trace": "추적",
     "view_history": "문서 열람 추적 사용",
     "start_with_search" : "첫 글자부터 검색",
-    "backup_warning" : "경고. 동일한 이름의 파일이 있는 경우 지워질 수 있습니다."
+    "backup_warning" : "경고. 동일한 이름의 파일이 있는 경우 지워질 수 있습니다.",
+    "level" : "레벨"
 }

+ 14 - 0
route/api_user_info.py

@@ -39,6 +39,20 @@ def api_user_info(name = ''):
                     data_result[user_name]['auth_date'] = db_data[0][0]
                 else:
                     data_result[user_name]['auth_date'] = '0'
+
+                curs.execute(db_change("select data from user_set where id = ? and name = 'level'"), [user_name])
+                db_data = curs.fetchall()
+                if db_data:
+                    data_result[user_name]['level'] = db_data[0][0]
+                else:
+                    data_result[user_name]['level'] = '0'
+
+                curs.execute(db_change("select data from user_set where id = ? and name = 'experience'"), [user_name])
+                db_data = curs.fetchall()
+                if db_data:
+                    data_result[user_name]['exp'] = db_data[0][0]
+                else:
+                    data_result[user_name]['exp'] = '0'
                     
                 # ban part
                 if ban_check(name) == 0:

+ 138 - 141
route/user_challenge.py

@@ -30,146 +30,143 @@ def user_challenge():
         if ip_or_user(ip) == 1:
             return redirect('/user')
 
-        data_html_green = ''
-        data_html_red = ''
-        
-        data_html_green += do_make_challenge_design(
-            '🆕',
-            load_lang('challenge_title_register'), 
-            load_lang('challenge_info_register'),
-            1
-        )
-        
-        curs.execute(db_change('select count(*) from history where ip = ?'), [ip])
-        db_data = curs.fetchall()
-        
-        disable = 1 if db_data[0][0] >= 1 else 0
-        data_html = do_make_challenge_design(
-            '✏',
-            load_lang('challenge_title_first_contribute'), 
-            load_lang('challenge_info_first_contribute'),
-            disable
-        )
-        if disable == 1:
-            data_html_green += data_html
-        else:
-            data_html_red += data_html
-        
-        disable = 1 if db_data[0][0] >= 10 else 0
-        data_html = do_make_challenge_design(
-            '🗊',
-            load_lang('challenge_title_tenth_contribute'), 
-            load_lang('challenge_info_tenth_contribute'),
-            disable
-        )
-        if disable == 1:
-            data_html_green += data_html
-        else:
-            data_html_red += data_html
-        
-        disable = 1 if db_data[0][0] >= 100 else 0
-        data_html = do_make_challenge_design(
-            '🗀',
-            load_lang('challenge_title_hundredth_contribute'), 
-            load_lang('challenge_info_hundredth_contribute'),
-            disable
-        )
-        if disable == 1:
-            data_html_green += data_html
-        else:
-            data_html_red += data_html
-        
-        disable = 1 if db_data[0][0] >= 1000 else 0
-        data_html = do_make_challenge_design(
-            '🖪',
-            load_lang('challenge_title_thousandth_contribute'), 
-            load_lang('challenge_info_thousandth_contribute'),
-            disable
-        )
-        if disable == 1:
-            data_html_green += data_html
-        else:
-            data_html_red += data_html
-        
-        disable = 1 if db_data[0][0] >= 10000 else 0
-        data_html = do_make_challenge_design(
-            '🖴',
-            load_lang('challenge_title_tenthousandth_contribute'), 
-            load_lang('challenge_info_tenthousandth_contribute'),
-            disable
-        )
-        if disable == 1:
-            data_html_green += data_html
-        else:
-            data_html_red += data_html
-        
-        curs.execute(db_change("select count(*) from topic where ip = ?"), [ip])
-        db_data = curs.fetchall()
-        
-        disable = 1 if db_data[0][0] >= 1 else 0
-        data_html = do_make_challenge_design(
-            '🗨',
-            load_lang('challenge_title_first_discussion'), 
-            load_lang('challenge_info_first_discussion'),
-            disable
-        )
-        if disable == 1:
-            data_html_green += data_html
-        else:
-            data_html_red += data_html
-        
-        disable = 1 if db_data[0][0] >= 10 else 0
-        data_html = do_make_challenge_design(
-            '🗪',
-            load_lang('challenge_title_tenth_discussion'), 
-            load_lang('challenge_info_tenth_discussion'),
-            disable
-        )
-        if disable == 1:
-            data_html_green += data_html
-        else:
-            data_html_red += data_html
-        
-        disable = 1 if db_data[0][0] >= 100 else 0
-        data_html = do_make_challenge_design(
-            '🖅',
-            load_lang('challenge_title_hundredth_discussion'), 
-            load_lang('challenge_info_hundredth_discussion'),
-            disable
-        )
-        if disable == 1:
-            data_html_green += data_html
+        if flask.request.method == 'POST':
+            pass
         else:
-            data_html_red += data_html
-        
-        disable = 1 if db_data[0][0] >= 1000 else 0
-        data_html = do_make_challenge_design(
-            '☏',
-            load_lang('challenge_title_thousandth_discussion'), 
-            load_lang('challenge_info_thousandth_discussion'),
-            disable
-        )
-        if disable == 1:
-            data_html_green += data_html
-        else:
-            data_html_red += data_html
-        
-        disable = 1 if db_data[0][0] >= 10000 else 0
-        data_html = do_make_challenge_design(
-            '🖧',
-            load_lang('challenge_title_tenthousandth_discussion'), 
-            load_lang('challenge_info_tenthousandth_discussion'),
-            disable
-        )
-        if disable == 1:
-            data_html_green += data_html
-        else:
-            data_html_red += data_html
+            data_html_green = ''
+            data_html_red = ''
             
-        data_html = data_html_green + data_html_red
-        
-        return easy_minify(flask.render_template(skin_check(),
-            imp = [load_lang('challenge'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
-            data = data_html,
-            menu = [['user', load_lang('return')]]
-        ))
+            data_html_green += do_make_challenge_design(
+                '🌳',
+                load_lang('challenge_title_register'), 
+                load_lang('challenge_info_register', 1),
+                1
+            )
+            
+            curs.execute(db_change('select count(*) from history where ip = ?'), [ip])
+            db_data = curs.fetchall()
+            
+            disable = 1 if db_data[0][0] >= 1 else 0
+            data_html = do_make_challenge_design(
+                '🔰',
+                load_lang('challenge_title_first_contribute'), 
+                load_lang('challenge_info_first_contribute', 1),
+                disable
+            )
+            if disable == 1:
+                data_html_green += data_html
+            else:
+                data_html_red += data_html
+            
+            disable = 1 if db_data[0][0] >= 10 else 0
+            data_html = do_make_challenge_design(
+                '📝',
+                load_lang('challenge_title_tenth_contribute'), 
+                load_lang('challenge_info_tenth_contribute', 1),
+                disable
+            )
+            if disable == 1:
+                data_html_green += data_html
+            else:
+                data_html_red += data_html
+            
+            disable = 1 if db_data[0][0] >= 100 else 0
+            data_html = do_make_challenge_design(
+                '🖊️',
+                load_lang('challenge_title_hundredth_contribute'), 
+                load_lang('challenge_info_hundredth_contribute', 1),
+                disable
+            )
+            if disable == 1:
+                data_html_green += data_html
+            else:
+                data_html_red += data_html
+            
+            disable = 1 if db_data[0][0] >= 1000 else 0
+            data_html = do_make_challenge_design(
+                '🏅',
+                load_lang('challenge_title_thousandth_contribute'), 
+                load_lang('challenge_info_thousandth_contribute', 1),
+                disable
+            )
+            if disable == 1:
+                data_html_green += data_html
+            else:
+                data_html_red += data_html
+            
+            curs.execute(db_change("select count(*) from topic where ip = ?"), [ip])
+            db_data = curs.fetchall()
+            
+            disable = 1 if db_data[0][0] >= 1 else 0
+            data_html = do_make_challenge_design(
+                '💬',
+                load_lang('challenge_title_first_discussion'), 
+                load_lang('challenge_info_first_discussion', 1),
+                disable
+            )
+            if disable == 1:
+                data_html_green += data_html
+            else:
+                data_html_red += data_html
+            
+            disable = 1 if db_data[0][0] >= 10 else 0
+            data_html = do_make_challenge_design(
+                '💡',
+                load_lang('challenge_title_tenth_discussion'), 
+                load_lang('challenge_info_tenth_discussion', 1),
+                disable
+            )
+            if disable == 1:
+                data_html_green += data_html
+            else:
+                data_html_red += data_html
+            
+            disable = 1 if db_data[0][0] >= 100 else 0
+            data_html = do_make_challenge_design(
+                '📢',
+                load_lang('challenge_title_hundredth_discussion'), 
+                load_lang('challenge_info_hundredth_discussion', 1),
+                disable
+            )
+            if disable == 1:
+                data_html_green += data_html
+            else:
+                data_html_red += data_html
+            
+            disable = 1 if db_data[0][0] >= 1000 else 0
+            data_html = do_make_challenge_design(
+                '📜',
+                load_lang('challenge_title_thousandth_discussion'), 
+                load_lang('challenge_info_thousandth_discussion', 1),
+                disable
+            )
+            if disable == 1:
+                data_html_green += data_html
+            else:
+                data_html_red += data_html
+                
+            data_html = data_html_green + data_html_red
+
+            disable = 1 if admin_check('all') == 1 else 0
+            data_html = do_make_challenge_design(
+                '✅',
+                load_lang('challenge_title_admin'), 
+                load_lang('challenge_info_admin', 1),
+                disable
+            )
+            if disable == 1:
+                data_html_green += data_html
+            else:
+                data_html_red += data_html
+                
+            data_html = data_html_green + data_html_red
+            
+            return easy_minify(flask.render_template(skin_check(),
+                imp = [load_lang('challenge'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
+                data = data_html + '''
+                    <form method="post">
+                        <button id="opennamu_save_button" type="submit">''' + load_lang('reload') + '''</button>
+                    </form>
+                ''',
+                menu = [['user', load_lang('return')]]
+            ))

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
     "beta" : {
-        "r_ver" : "v3.4.6-RC5-dev84",
+        "r_ver" : "v3.4.6-RC5-dev85",
         "c_ver" : "3500374",
         "s_ver" : "3500112"
     }

+ 5 - 41
views/main_css/js/func/func.js

@@ -3,114 +3,78 @@
 // https://css-tricks.com/how-to-animate-the-details-element/
 class Accordion {
     constructor(el) {
-        // Store the <details> element
         this.el = el;
-        // Store the <summary> element
         this.summary = el.querySelector('summary');
-        // Store the <div class="content"> element
         this.content = el.querySelector('.opennamu_folding');
     
-        // Store the animation object (so we can cancel it if needed)
         this.animation = null;
-        // Store if the element is closing
         this.isClosing = false;
-        // Store if the element is expanding
         this.isExpanding = false;
-        // Detect user clicks on the summary element
         this.summary.addEventListener('click', (e) => this.onClick(e));
     }
   
     onClick(e) {
-        // Stop default behaviour from the browser
         e.preventDefault();
-        // Add an overflow on the <details> to avoid content overflowing
         this.el.style.overflow = 'hidden';
-        // Check if the element is being closed or is already closed
         if(this.isClosing || !this.el.open) {
             this.open();
-        // Check if the element is being openned or is already open
         } else if(this.isExpanding || this.el.open) {
             this.shrink();
         }
     }
   
     shrink() {
-        // Set the element as "being closed"
         this.isClosing = true;
         
-        // Store the current height of the element
         const startHeight = `${this.el.offsetHeight}px`;
-        // Calculate the height of the summary
         const endHeight = `${this.summary.offsetHeight}px`;
         
-        // If there is already an animation running
         if(this.animation) {
-            // Cancel the current animation
             this.animation.cancel();
         }
         
-        // Start a WAAPI animation
         this.animation = this.el.animate({
-        // Set the keyframes from the startHeight to endHeight
             height: [startHeight, endHeight]
         }, {
             duration: 200,
             easing: 'ease-out'
         });
         
-        // When the animation is complete, call onAnimationFinish()
         this.animation.onfinish = () => this.onAnimationFinish(false);
-        // If the animation is cancelled, isClosing variable is set to false
         this.animation.oncancel = () => this.isClosing = false;
     }
   
     open() {
-        // Apply a fixed height on the element
         this.el.style.height = `${this.el.offsetHeight}px`;
-        // Force the [open] attribute on the details element
         this.el.open = true;
-        // Wait for the next frame to call the expand function
         window.requestAnimationFrame(() => this.expand());
     }
   
     expand() {
-        // Set the element as "being expanding"
         this.isExpanding = true;
-        // Get the current fixed height of the element
         const startHeight = `${this.el.offsetHeight}px`;
-        // Calculate the open height of the element (summary height + content height)
         const endHeight = `${this.summary.offsetHeight + this.content.offsetHeight}px`;
         
-        // If there is already an animation running
         if(this.animation) {
-            // Cancel the current animation
             this.animation.cancel();
         }
         
-        // Start a WAAPI animation
         this.animation = this.el.animate({
-        // Set the keyframes from the startHeight to endHeight
             height: [startHeight, endHeight]
         }, {
             duration: 200,
             easing: 'ease-out'
         });
-        // When the animation is complete, call onAnimationFinish()
         this.animation.onfinish = () => this.onAnimationFinish(true);
-        // If the animation is cancelled, isExpanding variable is set to false
         this.animation.oncancel = () => this.isExpanding = false;
     }
   
     onAnimationFinish(open) {
-      // Set the open attribute based on the parameter
-      this.el.open = open;
-      // Clear the stored animation
-      this.animation = null;
-      // Reset isClosing & isExpanding
-      this.isClosing = false;
-      this.isExpanding = false;
-      // Remove the overflow hidden and the fixed height
-      this.el.style.height = this.el.style.overflow = '';
+        this.el.open = open;
+        this.animation = null;
+        this.isClosing = false;
+        this.isExpanding = false;
+        this.el.style.height = this.el.style.overflow = '';
     }
 }
 

+ 15 - 2
views/main_css/js/func/insert_user_info.js

@@ -18,7 +18,8 @@ function do_insert_user_info() {
             'why',
             'band_blocked',
             'ip',
-            'ban'
+            'ban',
+            'level'
         ];
 
         let data_form = new FormData();
@@ -40,7 +41,6 @@ function do_insert_user_info() {
                     if(this.readyState === 4 && this.status === 200) {
                         let get_data = JSON.parse(this.responseText);
                         
-                        // 한글 지원 필요
                         let get_data_auth = get_data[name]['auth'];
                         if(get_data_auth === '0') {
                             get_data_auth = lang_data['ip'];
@@ -88,6 +88,15 @@ function do_insert_user_info() {
                             
                             get_data_ban += lang_data['why'] + ' : ' + get_data[name]['ban']['reason'];
                         }
+
+                        let level = '0';
+                        let exp = '0';
+                        let max_exp = '0';
+                        if(get_data_auth !== lang_data['ip']) {
+                            level = get_data[name]['level'];
+                            exp = get_data[name]['exp'];
+                            max_exp = String(500 + (Number(get_data[name]['level']) * 50));
+                        }
                         
                         let data = '' +
                             '<table class="user_info_table">' +
@@ -103,6 +112,10 @@ function do_insert_user_info() {
                                     '<td>' + lang_data['state'] + '</td>' +
                                     '<td>' + get_data_ban + '</td>' +
                                 '</tr>' +
+                                '<tr>' +
+                                    '<td>' + lang_data['level'] + '</td>' +
+                                    '<td>' + level + ' (' + exp + ' / ' + max_exp + ')</td>' +
+                                '</tr>' +
                             '</table>' +
                         '';