Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
phpdts
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nemo Ma
phpdts
Commits
8dfad3ce
Commit
8dfad3ce
authored
Jun 14, 2025
by
Nemo Ma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BUGFIX: 0 itme/itms values on diceroll()
parent
7a76cc63
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
145 additions
and
3 deletions
+145
-3
doc/etc/20250614_dice_itme_itms_zero_fix.txt
doc/etc/20250614_dice_itme_itms_zero_fix.txt
+74
-0
include/game/item.dice.php
include/game/item.dice.php
+23
-1
include/game/item.nachster_booster.php
include/game/item.nachster_booster.php
+48
-2
No files found.
doc/etc/20250614_dice_itme_itms_zero_fix.txt
0 → 100644
View file @
8dfad3ce
修改时间:2025-06-14
修改文件:include/game/item.dice.php, include/game/item.nachster_booster.php
修改原因:修复D3骰子等随机机制导致物品itme或itms值变成0的问题
问题描述:
用户汇报在使用D3骰子时,有物品的itme值被骰成了0,导致了一些预期之外的问题。
经过分析发现,diceroll()函数使用random_int(0, $dice),可能返回0值,当这个0值被赋给装备的itme或itms时,会导致游戏逻辑问题。
问题分析:
1. diceroll()函数使用random_int(0, $dice),包含0值
2. D3骰子会随机化玩家装备的效果值(itme)和耐久值(itms)
3. D6、D10骰子会生成新物品,其itme0和itms0值也可能为0
4. item.nachster_booster.php中的妙妙箱也有类似问题
修改内容:
1. include/game/item.dice.php:
- D3骰子逻辑(第41-49行):在随机化装备效果值和耐久值后,添加0值检查
- D6骰子逻辑(第110-118行):在生成物品后,添加itme0和itms0的0值检查
- D10骰子逻辑(第157-165行):在生成物品后,添加itme0和itms0的0值检查
- D1000骰子中的D3部分(第434-450行):在随机化装备效果值和耐久值后,添加0值检查
2. include/game/item.nachster_booster.php:
- 所有使用diceroll()生成itme0和itms0的地方都添加了0值检查
- 包括:略微有趣的玻璃珠、有趣的零食、精心制作的玻璃珠阵、非常有趣的玻璃珠、强而有力的玻璃珠、精心制作的可怕玻璃珠阵、不可名状之物
修改逻辑:
在所有可能导致itme或itms变成0的地方,添加以下检查:
```php
// 确保效果值不会变成0
if ($itme0 == 0) {
$itme0 = 1;
}
// 确保耐久值不会变成0
if ($itms0 == 0) {
$itms0 = 1;
}
```
对于装备的随机化:
```php
foreach ($rand_s as $key => &$value) {
if ($value != 0) {
$value = diceroll($stotal);
// 确保耐久值不会变成0
if ($value == 0) {
$value = 1;
}
}
}
```
预期效果:
1. 修复D3骰子导致装备itme/itms变成0的问题
2. 修复D6、D10骰子生成物品时itme0/itms0为0的问题
3. 修复妙妙箱生成物品时的类似问题
4. 确保所有使用diceroll()的随机机制都不会产生0值的itme/itms
测试建议:
1. 测试D3骰子是否还会导致装备效果值或耐久值变成0
2. 测试D6、D10骰子生成的物品是否还会出现0值
3. 测试妙妙箱生成的物品是否还会出现0值
4. 验证修复后的物品功能是否正常
注意事项:
1. 这个修复确保了最小值为1,符合游戏逻辑
2. 保持了原有的随机性,只是避免了0值
3. 对于已经存在的0值物品,需要另外处理
4. 这个修复是预防性的,不会影响现有的正常物品
后续考虑:
1. 可能需要检查其他使用diceroll()的地方是否也有类似问题
2. 考虑是否需要修改diceroll()函数本身,使其返回1到$dice的值而不是0到$dice
3. 检查数据库中是否存在itme或itms为0的异常物品数据
include/game/item.dice.php
View file @
8dfad3ce
...
@@ -109,6 +109,13 @@ function item_dice($itmn, &$data) {
...
@@ -109,6 +109,13 @@ function item_dice($itmn, &$data) {
//generate the item's effect and stimina, based on player's Yume values.
//generate the item's effect and stimina, based on player's Yume values.
$itme0
=
diceroll
(
$clbpara
[
'randver3'
]
*
3
);
$itme0
=
diceroll
(
$clbpara
[
'randver3'
]
*
3
);
$itms0
=
diceroll
(
$clbpara
[
'randver2'
]);
$itms0
=
diceroll
(
$clbpara
[
'randver2'
]);
// 确保生成的物品效果值和耐久值不会为0
if
(
$itme0
==
0
)
{
$itme0
=
1
;
}
if
(
$itms0
==
0
)
{
$itms0
=
1
;
}
//Generate a random number based on player's 1st Yume Value.
//Generate a random number based on player's 1st Yume Value.
$dicebreak
=
diceroll
(
$clbpara
[
'randver1'
]);
$dicebreak
=
diceroll
(
$clbpara
[
'randver1'
]);
...
@@ -149,6 +156,13 @@ function item_dice($itmn, &$data) {
...
@@ -149,6 +156,13 @@ function item_dice($itmn, &$data) {
//generate the item's effect and stimina, based on player's Yume values.
//generate the item's effect and stimina, based on player's Yume values.
$itme0
=
diceroll
(
$clbpara
[
'randver3'
]
*
3
);
$itme0
=
diceroll
(
$clbpara
[
'randver3'
]
*
3
);
$itms0
=
diceroll
(
$clbpara
[
'randver2'
]);
$itms0
=
diceroll
(
$clbpara
[
'randver2'
]);
// 确保生成的物品效果值和耐久值不会为0
if
(
$itme0
==
0
)
{
$itme0
=
1
;
}
if
(
$itms0
==
0
)
{
$itms0
=
1
;
}
//Generate a random number based on player's 1st Yume Value.
//Generate a random number based on player's 1st Yume Value.
$dicebreak
=
diceroll
(
$clbpara
[
'randver1'
]);
$dicebreak
=
diceroll
(
$clbpara
[
'randver1'
]);
...
@@ -432,12 +446,20 @@ function item_dice($itmn, &$data) {
...
@@ -432,12 +446,20 @@ function item_dice($itmn, &$data) {
foreach
(
$rand_s
as
$key
=>
&
$value
)
{
foreach
(
$rand_s
as
$key
=>
&
$value
)
{
if
(
$value
!=
0
)
{
if
(
$value
!=
0
)
{
$value
=
diceroll
(
$stotal
);
$value
=
diceroll
(
$stotal
);
// 确保耐久值不会变成0
if
(
$value
==
0
)
{
$value
=
1
;
}
}
}
}
}
foreach
(
$rand_e
as
$key
=>
&
$value
)
{
foreach
(
$rand_e
as
$key
=>
&
$value
)
{
if
(
$value
!=
0
)
{
if
(
$value
!=
0
)
{
$value
=
diceroll
(
$etotal
);
$value
=
diceroll
(
$etotal
);
// 确保效果值不会变成0
if
(
$value
==
0
)
{
$value
=
1
;
}
}
}
}
}
...
...
include/game/item.nachster_booster.php
View file @
8dfad3ce
...
@@ -51,6 +51,13 @@ function item_nachster_booster($itmn, &$data) {
...
@@ -51,6 +51,13 @@ function item_nachster_booster($itmn, &$data) {
$itme0
=
diceroll
(
$clbpara
[
'randver1'
]);
$itme0
=
diceroll
(
$clbpara
[
'randver1'
]);
$itms0
=
diceroll
(
5
);
$itms0
=
diceroll
(
5
);
$itmsk0
=
''
;
$itmsk0
=
''
;
// 确保效果值和耐久值不会为0
if
(
$itme0
==
0
)
{
$itme0
=
1
;
}
if
(
$itms0
==
0
)
{
$itms0
=
1
;
}
}
elseif
(
$harukaBoxCheck
<=
23
)
{
}
elseif
(
$harukaBoxCheck
<=
23
)
{
// Get random HB item.
// Get random HB item.
$log
.=
"你从里面翻找出了看起来能作为<span class='yellow'>有趣的补给</span>的东西!<br>"
;
$log
.=
"你从里面翻找出了看起来能作为<span class='yellow'>有趣的补给</span>的东西!<br>"
;
...
@@ -60,6 +67,13 @@ function item_nachster_booster($itmn, &$data) {
...
@@ -60,6 +67,13 @@ function item_nachster_booster($itmn, &$data) {
$itme0
=
diceroll
(
$clbpara
[
'randver1'
])
*
diceroll
(
3
);
$itme0
=
diceroll
(
$clbpara
[
'randver1'
])
*
diceroll
(
3
);
$itms0
=
diceroll
(
17
);
$itms0
=
diceroll
(
17
);
$itmsk0
=
'z'
;
$itmsk0
=
'z'
;
// 确保效果值和耐久值不会为0
if
(
$itme0
==
0
)
{
$itme0
=
1
;
}
if
(
$itms0
==
0
)
{
$itms0
=
1
;
}
}
elseif
(
$harukaBoxCheck
<=
42
)
{
}
elseif
(
$harukaBoxCheck
<=
42
)
{
// Get random mid effect true damage trap.
// Get random mid effect true damage trap.
$log
.=
"你从里面翻找出了看起来能作为<span class='yellow'>精心制作的陷阱</span>的东西!<br>"
;
$log
.=
"你从里面翻找出了看起来能作为<span class='yellow'>精心制作的陷阱</span>的东西!<br>"
;
...
@@ -69,6 +83,13 @@ function item_nachster_booster($itmn, &$data) {
...
@@ -69,6 +83,13 @@ function item_nachster_booster($itmn, &$data) {
$itme0
=
diceroll
(
$clbpara
[
'randver2'
]);
$itme0
=
diceroll
(
$clbpara
[
'randver2'
]);
$itms0
=
diceroll
(
5
);
$itms0
=
diceroll
(
5
);
$itmsk0
=
''
;
$itmsk0
=
''
;
// 确保效果值和耐久值不会为0
if
(
$itme0
==
0
)
{
$itme0
=
1
;
}
if
(
$itms0
==
0
)
{
$itms0
=
1
;
}
}
elseif
(
$harukaBoxCheck
<=
61
)
{
}
elseif
(
$harukaBoxCheck
<=
61
)
{
// Get random high effect trap.
// Get random high effect trap.
$log
.=
"你从里面翻找出了看起来能作为<span class='yellow'>非常有趣的陷阱</span>的东西!<br>"
;
$log
.=
"你从里面翻找出了看起来能作为<span class='yellow'>非常有趣的陷阱</span>的东西!<br>"
;
...
@@ -77,7 +98,14 @@ function item_nachster_booster($itmn, &$data) {
...
@@ -77,7 +98,14 @@ function item_nachster_booster($itmn, &$data) {
$itmk0
=
'TN'
;
$itmk0
=
'TN'
;
$itme0
=
diceroll
(
$clbpara
[
'randver3'
]);
$itme0
=
diceroll
(
$clbpara
[
'randver3'
]);
$itms0
=
diceroll
(
5
);
$itms0
=
diceroll
(
5
);
$itmsk0
=
''
;
$itmsk0
=
''
;
// 确保效果值和耐久值不会为0
if
(
$itme0
==
0
)
{
$itme0
=
1
;
}
if
(
$itms0
==
0
)
{
$itms0
=
1
;
}
}
elseif
(
$harukaBoxCheck
<=
80
)
{
}
elseif
(
$harukaBoxCheck
<=
80
)
{
// Get random percent damage trap.
// Get random percent damage trap.
$log
.=
"你从里面翻找出了看起来能作为<span class='yellow'>十分强力的陷阱</span>的东西!<br>"
;
$log
.=
"你从里面翻找出了看起来能作为<span class='yellow'>十分强力的陷阱</span>的东西!<br>"
;
...
@@ -86,7 +114,11 @@ function item_nachster_booster($itmn, &$data) {
...
@@ -86,7 +114,11 @@ function item_nachster_booster($itmn, &$data) {
$itmk0
=
'TN8'
;
$itmk0
=
'TN8'
;
$itme0
=
1
;
$itme0
=
1
;
$itms0
=
diceroll
(
2
);
$itms0
=
diceroll
(
2
);
$itmsk0
=
'x'
;
$itmsk0
=
'x'
;
// 确保耐久值不会为0
if
(
$itms0
==
0
)
{
$itms0
=
1
;
}
}
elseif
(
$harukaBoxCheck
<=
109
)
{
}
elseif
(
$harukaBoxCheck
<=
109
)
{
// Get high true damage trap.
// Get high true damage trap.
$log
.=
"你从里面翻找出了看起来能作为<span class='yellow'>精心制作的可怕陷阱</span>的东西!<br>"
;
$log
.=
"你从里面翻找出了看起来能作为<span class='yellow'>精心制作的可怕陷阱</span>的东西!<br>"
;
...
@@ -96,6 +128,13 @@ function item_nachster_booster($itmn, &$data) {
...
@@ -96,6 +128,13 @@ function item_nachster_booster($itmn, &$data) {
$itme0
=
diceroll
(
$clbpara
[
'randver3'
]);
$itme0
=
diceroll
(
$clbpara
[
'randver3'
]);
$itms0
=
diceroll
(
5
);
$itms0
=
diceroll
(
5
);
$itmsk0
=
''
;
$itmsk0
=
''
;
// 确保效果值和耐久值不会为0
if
(
$itme0
==
0
)
{
$itme0
=
1
;
}
if
(
$itms0
==
0
)
{
$itms0
=
1
;
}
}
else
{
}
else
{
// Get Chaos Normal Trap.
// Get Chaos Normal Trap.
$log
.=
"你从里面翻找出了一些<span class='yellow'>不可名状</span>的东西!<br>它似乎可以当作陷阱使用……<br>"
;
$log
.=
"你从里面翻找出了一些<span class='yellow'>不可名状</span>的东西!<br>它似乎可以当作陷阱使用……<br>"
;
...
@@ -105,6 +144,13 @@ function item_nachster_booster($itmn, &$data) {
...
@@ -105,6 +144,13 @@ function item_nachster_booster($itmn, &$data) {
$itme0
=
diceroll
(
114514
);
$itme0
=
diceroll
(
114514
);
$itms0
=
diceroll
(
69
);
$itms0
=
diceroll
(
69
);
$itmsk0
=
''
;
$itmsk0
=
''
;
// 确保效果值和耐久值不会为0
if
(
$itme0
==
0
)
{
$itme0
=
1
;
}
if
(
$itms0
==
0
)
{
$itms0
=
1
;
}
}
}
// Troll the player if itms0 somehow rolled an 0. YSK: I encountered that 4 times in a row.
// Troll the player if itms0 somehow rolled an 0. YSK: I encountered that 4 times in a row.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment