Commit 97c87f71 authored by JoyJ's avatar JoyJ

use rolls[name]

parent f494b482
ygopro.ctos_follow_before('CHAT', false, async function (buffer, info, client, server, datas) { ygopro.ctos_follow_before('CHAT', false, async function (buffer, info, client, server, datas) {
var room = ROOM_all[client.rid]; var room = ROOM_all[client.rid];
if (room.rolls == undefined)
{
room.rolls = new Object();
}
var msg = _.trim(info.msg); var msg = _.trim(info.msg);
if (msg.substring(0, 5) != "/roll") { if (msg.substring(0, 5) != "/roll") {
return; return;
...@@ -28,13 +32,14 @@ ygopro.ctos_follow_before('CHAT', false, async function (buffer, info, client, s ...@@ -28,13 +32,14 @@ ygopro.ctos_follow_before('CHAT', false, async function (buffer, info, client, s
{ {
result += Math.floor(Math.random()*dicemax) + 1; result += Math.floor(Math.random()*dicemax) + 1;
} }
var message = client.name + "投掷" + dicenum + "d" + dicemax + "并掷出了" + result + ""; var name = client.name;
var message = name + "投掷" + dicenum + "d" + dicemax + "并掷出了" + result + "";
log.warn(message); log.warn(message);
if (client.roll == undefined) if (room.rolls[name] == undefined)
{ {
if (dicenum == 1 || dicemax == 100) if (dicenum == 1 || dicemax == 100)
{ {
client.roll = result; room.rolls[name] = result;
ygopro.stoc_send_chat_to_room(room, message, ygopro.constants.COLORS.YELLOW); ygopro.stoc_send_chat_to_room(room, message, ygopro.constants.COLORS.YELLOW);
} }
else else
...@@ -44,7 +49,7 @@ ygopro.ctos_follow_before('CHAT', false, async function (buffer, info, client, s ...@@ -44,7 +49,7 @@ ygopro.ctos_follow_before('CHAT', false, async function (buffer, info, client, s
} }
else else
{ {
message = message + ";其在本房间内的首次1d100投掷为" + client.roll + ""; message = message + ";首次1d100投掷为" + room.rolls[name] + "";
ygopro.stoc_send_chat_to_room(room, message, ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat_to_room(room, message, ygopro.constants.COLORS.BABYBLUE);
} }
return true; return true;
......
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