Browse Source

feat(pkuxkx): 支持 skills 命令的新格式

dzp 1 year ago
parent
commit
e04d86cabf
1 changed files with 68 additions and 82 deletions
  1. 68 82
      mud/pkuxkx/plugins/basic/char/skills.tin

+ 68 - 82
mud/pkuxkx/plugins/basic/char/skills.tin

@@ -17,30 +17,37 @@ PaoTin++ © 2020~2023 的所有版权均由担子炮(dzp <danzipao@gmail.com>) 
     }
 };
 
-#nop ╭───技能列表(共十六项)─┬─────────────┬──────┬──────┬──────╮
-#nop │名称                      │ID                        │描述        │级别        │最大级别    │
-#nop ├───一项职业技能────┼─────────────┼──────┼──────┼──────┤
-#nop │  占卜之术                │divination                │不足挂齿    │82.0        │387         │
-#nop ├───六项基本知识────┼─────────────┼──────┼──────┼──────┤
-#nop │  禅宗心法                │buddhism                  │半生不熟    │153.0       │-           │
-#nop │  鉴定之术                │identification            │初窥门径    │54.0        │-           │
-#nop │  读书写字                │literate                  │半生不熟    │152.0       │-           │
-#nop │  医术                    │medical-skill             │新学乍用    │30.0        │-           │
-#nop │  妙手空空                │stealing                  │新学乍用    │10.0        │-           │
-#nop │  道家养生术              │taoism                    │深不可测    │948.23      │-           │
-#nop ├───六项基本功夫────┼─────────────┼──────┼──────┼──────┤
-#nop │  基本拳法                │cuff                      │半生不熟    │386.0       │387         │
-#nop │  基本轻功                │dodge                     │半生不熟    │386.0       │387         │
-#nop │  基本内功                │force                     │半生不熟    │386.0       │387         │
-#nop │  基本招架                │parry                     │半生不熟    │386.0       │387         │
-#nop │  基本剑法                │sword                     │半生不熟    │386.0       │387         │
-#nop ├───四项特殊功夫────┼─────────────┼──────┼──────┼──────┤
-#nop │□太极剑法                │taiji-jian                │半生不熟    │386.0       │387         │
-#nop │□太极拳                  │taiji-quan                │半生不熟    │386.0       │387         │
-#nop │□太极神功                │taiji-shengong            │第五重楼    │387.0       │387         │
-#nop │□梯云纵                  │tiyunzong                 │半生不熟    │386.0       │387         │
-#nop ╰─────────────┴─────────────┴──────┴────北大侠客行────╯
-#nop;
+/*
+2024-12-02 09:37:00 INPUT: sk
+╭───技能列表(共二十项)──────────┬──────┬───────╮
+│技能                                          │描述        │级别/上限     │
+├───二项职业技能──────────────┼──────┼───────┤
+│  火眼金睛(anti-disguise)                     │不堪一击    │    1.00/346  │
+│  占卜之术(divination)                        │不足挂齿    │   83.32/346  │
+├───五项基本知识──────────────┼──────┼───────┤
+│  鉴定之术(identification)                    │初窥门径    │   50.00/-    │
+│  读书写字(literate)                          │已有小成    │  257.16/-    │
+│+音律(music)                                 │略知一二    │  102.00/-    │
+│  奇门八卦(qimen-bagua)                       │已有小成    │  250.00/-    │
+├───八项基本功夫──────────────┼──────┼───────┤
+│  基本轻功(dodge)                             │平淡无奇    │  325.01/346  │
+│  基本指法(finger)                            │粗通皮毛    │  346.00/346  │
+│  基本内功(force)                             │平淡无奇    │  315.04/346  │
+│  基本手法(hand)                              │粗通皮毛    │  346.00/346  │
+│  基本招架(parry)                             │粗通皮毛    │  346.00/346  │
+│  基本掌法(strike)                            │粗通皮毛    │  346.00/346  │
+│  基本剑法(sword)                             │平淡无奇    │  327.00/346  │
+├───十项特殊功夫──────────────┼──────┼───────┤
+│□碧海神功(bihai-shengong)                    │平淡无奇    │  314.07/346  │
+│□兰花拂穴手(fuxue-shou)                      │粗通皮毛    │  346.00/346  │
+│□落英身法(luoying-shenfa)                    │平淡无奇    │  325.00/346  │
+│□落英神剑掌(luoying-zhang)                   │粗通皮毛    │  346.00/346  │
+│□弹指神通(tanzhi-shentong)                   │粗通皮毛    │  346.00/346  │
+│□玉箫剑法(yuxiao-jian)                       │平淡无奇    │  327.00/346  │
+├───────────────────────┴──────┴───────┤
+│共使用了27.5个技能槽位,无技能槽位限制。级别上限:+1.67%。                  │
+╰─────────────────────────────北大侠客行────╯
+*/
 
 load-lib event;
 
@@ -80,58 +87,26 @@ event.Define {char/skbrief} {无参}  {$MODULE} {已经获取到 skbrief 命令
     #var char[Skills][currentType]  {};
     #var char[Skills][nameList]     {};
 
-    #gag {^│名称};
+    #gag {^│技能 %s │描述 %s │级别/上限 %s │};
 
     #action {^├───%%1项%%2──} {
         #var char[Skills][currentType] {%%2};
     };
 
-    #local RST      {\e[0m};
-    #local RST__    {\e[2;37;0m};
-    #local __I__    {$RST__│};
-
-    #action {~^$RST│%*│%*│%*│%*│%*│{|ID=char.skills}} {
-        #local line     {%%0};
-        #local code     {%%2};
-        #local level    {%%4};
-        #local limit    {%%5};
-        #replace {code}   {\x1b[2;37;0m} {};
-        #replace {level}  {\x1b[2;37;0m} {};
-        #replace {limit}  {\x1b[2;37;0m} {};
-
-        #replace level {+} {};
-
-        #if { "$limit" == "%s%d%s" } {
-            #math limit {$limit + 0};
-        };
-        #elseif { "$limit" == "%s-%s" } {
-            #nop 知识类技能没有上限;
-            #local limit {0};
-        };
-        #else {
-            #return;
-        };
-
-        #nop 给技能加上彩色进度条,用来表示当前级别距离上限的程度;
-        #local newCode {@__char_skills_colorit__{{$code};$level;$limit}};
-        #replace code { } {};
-        #replace line {$code\x1b[2;37;0m%s} {$newCode\e[0m};
-        #replace line {\x1b[34m} {\x1b[94m};
-        #echo {%s} {@Beautify{{$line}}};
-        #local line {Skill/%%1/%%2/%%3/%%4/$limit};
-        #replace line { } {};
-        #showme {$line};
-        #line gag;
-    };
-
-    #action {^Skill/{□|Θ|}%%2/%%3/%%4/%%5/%%6$} {
-        #local type ${char[Skills][currentType]};
+    #nop □已激发,☆真传武功,+有子技能。;
+    #action {^│{□|☆|+|  }%S(%S) %!s │%S {|↑}%!s │%!s %S/%S %!s│{|ID=char.skills}} {
+        #local rawLine  {%%99};
+        #local type     {$char[Skills][currentType]};
         #local enabled  {%%1};
         #local name     {%%2};
         #local code     {%%3};
         #local rank     {%%4};
-        #local level    {%%5};
-        #local limit    {%%6};
+        #local level    {%%6};
+        #local limit    {%%7};
+
+        #if { "$limit" == "-" } {
+            #local limit {0};
+        };
 
         #replace name { } {};
 
@@ -159,6 +134,13 @@ event.Define {char/skbrief} {无参}  {$MODULE} {已经获取到 skbrief 命令
             #var char-skill-limit $limit;
         };
 
+        #if { $limit == 0 } {
+            #return;
+        };
+
+        #nop 接下来给技能加上彩色进度条,用来表示当前级别距离上限的程度;
+        #replace rawLine {^%*│%*(%S)%C│%*│%+1c%c %*│%*$} {&1│&2@char.Skills.colorIt{{&3};{&4};{&7};$level;$limit;10}│&5│&6&7 &8│&9};
+        #echo {%s} {@Beautify{{$rawLine}}};
         #line gag;
     };
 
@@ -205,22 +187,26 @@ event.Define {char/skbrief} {无参}  {$MODULE} {已经获取到 skbrief 命令
     #class {ParseSkills} close;
 };
 
-#func {__char_skills_colorit__} {
+#func {char.Skills.colorIt} {
     #local code     {%1};
-    #local level    {%2};
-    #local limit    {%3};
-
-    #local p {@math.Int{@math.Eval{$level * 100 / $limit}}};
-    #local color {@util.Grade{$p;<271>;15;<171>;30;<203>;60;<274>;90;<134>;100;<132>;101;<506>}};
-
-    #local spaceLen {@str.Len{$code}};
-    #local code     {@str.Trim{$code}};
-    #local textLen  {@str.Len{$code}};
-    #math spaceLen {$spaceLen - $textLen};
-    #cat code {@str.AlignRight{{$p%}; $spaceLen}};
-
-    #local {rest} {@math.Eval{100 - $p}};
-    #return {@util.ColorBar{{$code};$color;$p;<g08>;$rest}};
+    #local space    {@str.Plain{%2}};
+    #local pColor   {%3};
+    #local level    {%4};
+    #local limit    {%5};
+    #local barLen   {%6};
+
+    #local text     {($code)$space};
+    #local textLen  {@str.Len{$text}};
+    #local leftLen  {@math.Eval{$textLen - $barLen - 5}};
+    #local left     {@str.Left{{$text}; $leftLen}};
+    #local right    {@str.Right{{$text}; $barLen}};
+
+    #local percent  {@math.Int{@math.Eval{$level * 100 / $limit}}};
+    #local color    {@util.Grade{$percent;<271>;15;<171>;30;<203>;60;<274>;90;<134>;100;<132>;101;<506>}};
+    #local rest     {@math.Eval{100 - $percent}};
+    #local pStr     {@str.Format{%%3d%;$percent}};
+
+    #return {$left$pColor$pStr<299> @util.ColorBar{{$right};$color;$percent;<g08>;$rest}};
 };
 
 #alias {char.Skbrief} {