Commit 3def63bc authored by unknown's avatar unknown

增加配置文件和体力消耗

parent 22da0760
...@@ -282,9 +282,7 @@ if($hp > 0){ ...@@ -282,9 +282,7 @@ if($hp > 0){
if (!isset($choice) || $choice == 'menu') { if (!isset($choice) || $choice == 'menu') {
$mode = 'command'; $mode = 'command';
} else { } else {
var_dump($choice);
$choice_position = (int)(substr($choice, -1)); $choice_position = (int)(substr($choice, -1));
var_dump($choice_position);
//$choice = (int)$choice; //$choice = (int)$choice;
if ($choice_position < 1 || $choice_position > 6) if ($choice_position < 1 || $choice_position > 6)
$log .= '<span class="red">无此物品。</span><br />'; $log .= '<span class="red">无此物品。</span><br />';
...@@ -314,12 +312,10 @@ if($hp > 0){ ...@@ -314,12 +312,10 @@ if($hp > 0){
} }
} elseif ($sp_cmd == 'sp_add_trait_selected') { } elseif ($sp_cmd == 'sp_add_trait_selected') {
if (!isset($choice) || $choice == 'menu') { if (!isset($choice) || $choice == 'menu') {
var_dump($choice);
$mode = 'command'; $mode = 'command';
} else { } else {
$choice = (int)($choice); $choice = (int)($choice);
$choice2 = (int)($choice2); $choice2 = (int)($choice2);
var_dump($choice);
if ($choice < 1 || $choice > 6 || $choice2 < 1 || $choice2 > 6) if ($choice < 1 || $choice > 6 || $choice2 < 1 || $choice2 > 6)
$log .= '<span class="red">无此物品。</span><br />'; $log .= '<span class="red">无此物品。</span><br />';
elseif ($choice == $choice2) elseif ($choice == $choice2)
......
<?php
//码语行人配置文件
//各个属性比率
$itmsk_extract_rate=array(
'A' => 150,
'a' => 150,
'B' => 400,
'b' => 400,
'C' => 30,
'c' => 10,
'D' => 30,
'd' => 20,
'E' => 30,
'e' => 20,
'F' => 30,
'f' => 30,
'G' => 20,
'g' => 5,
'H' => 120,
'h' => 80,
'I' => 30,
'i' => 20,
'J' => 200,
'j' => 200,
'K' => 30,
'k' => 30,
'L' => 50,
'l' => 5,
'M' => 100,
'm' => 100,
'N' => 20,
'n' => 40,
'o' => 5,
'P' => 20,
'p' => 30,
'q' => 30,
'R' => 60,
'r' => 60,
'S' => 20,
's' => 200,
'U' => 30,
'u' => 20,
'V' => 100,
'v' => 100,
'W' => 30,
'w' => 20,
'X' => 800,
'x' => 50,
'y' => 40,
'Z' => 50,
'z' => 1,
'-' => 200,
'*' => 200,
'+' => 200,
'^' => 1200,
'🧰' => 200
);
//物品效果和耐久的场合:按照1:1比率消耗体力进行提取
$itms_extract_rate = 1; //耐久
$itme_extract_rate = 1; //效果
...@@ -481,10 +481,11 @@ function press_bomb(){ ...@@ -481,10 +481,11 @@ function press_bomb(){
//提取代码片段逻辑 //提取代码片段逻辑
function item_extract_trait($which, $item_position) function item_extract_trait($which, $item_position)
{ {
include_once GAME_ROOT . './gamedata/club21cfg.php';
//去掉string which的最后一位 //去掉string which的最后一位
$which = substr($which, 0, -1); $which = substr($which, 0, -1);
global $log, $mode, $club; global $log, $mode, $club, $sp;
if ($club != 21) { if ($club != 21) {
$log .= '你的称号不能使用该技能。'; $log .= '你的称号不能使用该技能。';
$mode = 'command'; $mode = 'command';
...@@ -511,7 +512,6 @@ function item_extract_trait($which, $item_position) ...@@ -511,7 +512,6 @@ function item_extract_trait($which, $item_position)
// 给代码片段命名 // 给代码片段命名
if ($which == 'itm') { if ($which == 'itm') {
preg_match_all('/(改|棍棒)/u', $itm, $matches); preg_match_all('/(改|棍棒)/u', $itm, $matches);
//var_dump($matches);
if (!empty($matches[0])) { if (!empty($matches[0])) {
$itm = implode('', $matches[0]); $itm = implode('', $matches[0]);
//转换成string //转换成string
...@@ -528,12 +528,33 @@ function item_extract_trait($which, $item_position) ...@@ -528,12 +528,33 @@ function item_extract_trait($which, $item_position)
$log .= '该物品无法转换为代码片段。<br>'; $log .= '该物品无法转换为代码片段。<br>';
return; return;
} }
} } elseif ($which == 'itme') {
elseif ($which == 'itme') { if ($sp < $itme_extract_rate * $itme) {
$log .= '体力不足,无法转换为代码片段。<br>';
return;
}
$itm = "效果" . ${$which . $item_position} . '代码片段'; $itm = "效果" . ${$which . $item_position} . '代码片段';
$log .= '消耗体力' . $itme_extract_rate * $itme . '点。<br>';
$sp -= $itme_extract_rate * $itme;
} elseif ($which == 'itms') { } elseif ($which == 'itms') {
if ($sp < $itms_extract_rate * $itms) {
$log .= '体力不足,无法转换为代码片段。<br>';
return;
}
$itm = "耐久" . ${$which . $item_position} . '代码片段'; $itm = "耐久" . ${$which . $item_position} . '代码片段';
$log .= '消耗体力' . $itms_extract_rate * $itms . '点。<br>';
} elseif ($which == 'itmsk') { } elseif ($which == 'itmsk') {
preg_match_all('/./u', $itmsk, $matches);
foreach ($matches[0] as $single_itmsk) {
if (isset($itmsk_extract_rate[$single_itmsk])) {
$sum += 1 * $itmsk_extract_rate[$single_itmsk];
}
}
if ($sp < $sum) {
$log .= '体力不足,无法转换为代码片段。<br>';
return;
}
$itm = "属性" . ${$which . $item_position} . '代码片段'; $itm = "属性" . ${$which . $item_position} . '代码片段';
} }
$itmk = ''; $itmk = '';
...@@ -574,7 +595,6 @@ function item_add_trait($choice1, $choice2) ...@@ -574,7 +595,6 @@ function item_add_trait($choice1, $choice2)
$itmsk2 = &${'itmsk' . $choice2}; $itmsk2 = &${'itmsk' . $choice2};
//检查itmk1是否为🥚,itmk2是否为D或W开头或者是否为🥚 //检查itmk1是否为🥚,itmk2是否为D或W开头或者是否为🥚
if ($itmk1 != '🥚' || (strpos($itmk2, 'D') !== 0 && strpos($itmk2, 'W') !== 0 && ($itmk2 !== '🥚'))) { if ($itmk1 != '🥚' || (strpos($itmk2, 'D') !== 0 && strpos($itmk2, 'W') !== 0 && ($itmk2 !== '🥚'))) {
var_dump($itmk2);
$log .= '该物品无法合并。<br>'; $log .= '该物品无法合并。<br>';
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment