Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
dc-plugins
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
JoyJ
dc-plugins
Commits
57d97b02
Commit
57d97b02
authored
Nov 25, 2020
by
JoyJ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update diceroll & dc-random
parent
d13087a5
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
369 additions
and
273 deletions
+369
-273
DiceRoll.js
DiceRoll.js
+93
-63
DuelChronicle_Random.js
DuelChronicle_Random.js
+276
-210
No files found.
DiceRoll.js
View file @
57d97b02
ygopro
.
ctos_follow_before
(
'
CHAT
'
,
false
,
async
function
(
buffer
,
info
,
client
,
server
,
datas
)
{
var
room
=
ROOM_all
[
client
.
rid
];
if
(
room
.
rolls
==
undefined
)
{
room
.
rolls
=
new
Object
();
}
ygopro
.
ctos_follow_before
(
"
CHAT
"
,
false
,
async
function
(
buffer
,
info
,
client
,
server
,
datas
)
{
var
room
=
ROOM_all
[
client
.
rid
];
if
(
room
.
rolls
==
undefined
)
{
room
.
rolls
=
new
Object
();
}
var
msg
=
_
.
trim
(
info
.
msg
);
if
(
msg
.
substring
(
0
,
5
)
==
"
/dice
"
)
{
var
diceresult
=
Math
.
floor
(
Math
.
random
()
*
6
)
+
1
;
var
dicemessage
=
client
.
name
+
"
投掷1d6并掷出了
"
+
diceresult
+
"
点
"
;
ygopro
.
stoc_send_chat_to_room
(
room
,
dicemessage
,
ygopro
.
constants
.
COLORS
.
PINK
);
return
;
if
(
msg
.
substring
(
0
,
5
)
==
"
/dice
"
)
{
var
diceresult
=
Math
.
floor
(
Math
.
random
()
*
6
)
+
1
;
var
dicemessage
=
client
.
name
+
"
投掷1d6并掷出了
"
+
diceresult
+
"
点
"
;
ygopro
.
stoc_send_chat_to_room
(
room
,
dicemessage
,
ygopro
.
constants
.
COLORS
.
PINK
);
return
;
}
if
(
msg
.
substring
(
0
,
5
)
==
"
/coin
"
)
{
var
coinresult
=
Math
.
floor
(
Math
.
random
()
*
2
)
==
1
?
"
正面
"
:
"
反面
"
;
var
coinmessage
=
client
.
name
+
"
投掷硬币并掷出了
"
+
coinresult
;
ygopro
.
stoc_send_chat_to_room
(
room
,
coinmessage
,
ygopro
.
constants
.
COLORS
.
BLUE
);
return
;
if
(
msg
.
substring
(
0
,
5
)
==
"
/coin
"
)
{
var
coinresult
=
Math
.
floor
(
Math
.
random
()
*
2
)
==
1
?
"
正面
"
:
"
反面
"
;
var
coinmessage
=
client
.
name
+
"
投掷硬币并掷出了
"
+
coinresult
;
ygopro
.
stoc_send_chat_to_room
(
room
,
coinmessage
,
ygopro
.
constants
.
COLORS
.
BLUE
);
return
;
}
if
(
msg
.
substring
(
0
,
5
)
!=
"
/roll
"
)
{
return
;
return
;
}
var
regex
=
/
[
0-9
]
*d
[
0-9
]
+/
;
var
found
=
regex
.
exec
(
msg
);
var
dicenum
=
1
;
var
dicemax
=
100
;
if
(
found
)
{
found
=
found
.
toString
();
var
split
=
found
.
split
(
'
d
'
);
dicenum
=
split
[
0
];
dicemax
=
split
[
1
];
}
if
(
dicenum
>
100
)
dicenum
=
100
;
if
(
dicenum
<
1
)
dicenum
=
1
;
if
(
dicemax
>
60000
)
dicemax
=
60000
;
if
(
dicemax
<
1
)
dicemax
=
1
;
var
result
=
0
;
for
(
var
i
=
0
;
i
<
dicenum
;
i
++
)
{
result
+=
Math
.
floor
(
Math
.
random
()
*
dicemax
)
+
1
;
}
var
name
=
client
.
name
;
var
message
=
name
+
"
投掷
"
+
dicenum
+
"
d
"
+
dicemax
+
"
并掷出了
"
+
result
+
"
点
"
;
log
.
warn
(
message
);
if
(
room
.
rolls
[
name
]
==
undefined
)
{
if
(
dicenum
==
1
||
dicemax
==
100
)
{
room
.
rolls
[
name
]
=
result
;
ygopro
.
stoc_send_chat_to_room
(
room
,
message
,
ygopro
.
constants
.
COLORS
.
YELLOW
);
}
else
{
ygopro
.
stoc_send_chat_to_room
(
room
,
message
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
}
else
{
message
=
message
+
"
;首次1d100投掷为
"
+
room
.
rolls
[
name
]
+
"
点
"
;
ygopro
.
stoc_send_chat_to_room
(
room
,
message
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
var
regex2
=
/
[
0-9
]
*d
[
0-9
]
+
[\+][
0-9
]
+/
;
var
regex2m
=
/
[
0-9
]
*d
[
0-9
]
+
[\-][
0-9
]
+/
;
var
found2
=
regex2
.
exec
(
msg
);
var
found2m
=
regex2m
.
exec
(
msg
);
var
dicenum
=
1
;
var
dicemax
=
100
;
var
diceadd
=
0
;
if
(
found2
)
{
found2
=
found2
.
toString
();
var
split
=
found2
.
split
(
"
+
"
);
diceadd
=
split
[
1
];
msg
=
split
[
0
];
}
if
(
found2m
)
{
found2m
=
found2m
.
toString
();
var
split
=
found2
.
split
(
"
-
"
);
diceadd
=
-
split
[
1
];
msg
=
split
[
0
];
}
var
found
=
regex
.
exec
(
msg
);
if
(
found
)
{
found
=
found
.
toString
();
var
split
=
found
.
split
(
"
d
"
);
dicenum
=
split
[
0
];
dicemax
=
split
[
1
];
}
if
(
dicenum
>
100
)
dicenum
=
100
;
if
(
dicenum
<
1
)
dicenum
=
1
;
if
(
dicemax
>
60000
)
dicemax
=
60000
;
if
(
dicemax
<
1
)
dicemax
=
1
;
if
(
diceadd
>
1000000
)
diceadd
=
1000000
;
if
(
diceadd
<
-
1000000
)
diceadd
=
-
1000000
;
var
result
=
0
;
for
(
var
i
=
0
;
i
<
dicenum
;
i
++
)
{
result
+=
Math
.
floor
(
Math
.
random
()
*
dicemax
)
+
1
;
}
result
+=
diceadd
;
var
name
=
client
.
name
;
var
message
=
name
+
"
投掷
"
+
dicenum
+
"
d
"
+
dicemax
+
"
并掷出了
"
+
result
+
"
点
"
;
log
.
warn
(
message
);
if
(
room
.
rolls
[
client
.
ip
]
==
undefined
)
{
if
(
dicenum
==
1
&&
dicemax
==
100
&&
diceadd
==
0
)
{
room
.
rolls
[
client
.
ip
]
=
result
;
ygopro
.
stoc_send_chat_to_room
(
room
,
message
,
ygopro
.
constants
.
COLORS
.
YELLOW
);
}
else
{
ygopro
.
stoc_send_chat_to_room
(
room
,
message
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
}
else
{
message
=
message
+
"
;首次1d100投掷为
"
+
room
.
rolls
[
client
.
ip
]
+
"
点
"
;
ygopro
.
stoc_send_chat_to_room
(
room
,
message
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
return
true
;
});
\ No newline at end of file
}
);
DuelChronicle_Random.js
View file @
57d97b02
This diff is collapsed.
Click to expand it.
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