files/ 0040777 0000000 0000000 00000000000 13430546765 007133 5 ustar 00 files/files.tar 0100777 0000000 0000000 00000013000 13431013124 010712 0 ustar 00 js/ 0040777 0000000 0000000 00000000000 13430351320 006422 5 ustar 00 js/Dalang.net/ 0040777 0000000 0000000 00000000000 13431011402 010370 5 ustar 00 js/Dalang.net/Chat/ 0040777 0000000 0000000 00000000000 13430351351 011260 5 ustar 00 js/Dalang.net/Chat/Command/ 0040777 0000000 0000000 00000000000 13430351365 012643 5 ustar 00 js/Dalang.net/Chat/Command/Dice.js 0100777 0000000 0000000 00000000727 13431011644 014045 0 ustar 00 /**
* dice command
*
* @author Daniel (Keito) Lang
* @copyright 2014-2019 da-lang.net
* @package net.dalang.chat.command.dice
*/
define(['Bastelstu.be/Chat/Command', 'Bastelstu.be/Chat/Parser'], function (Command, Parser) {
"use strict";
class Dice extends Command {
getParameterParser() {
return Parser.N.digits.then(Parser.C.char(' ').drop()).then(Parser.N.digits).map(([dice, value]) => ({ dice, value }))
}
}
return Dice
}); js/Dalang.net/Chat/MessageType/ 0040777 0000000 0000000 00000000000 13430351406 013507 5 ustar 00 js/Dalang.net/Chat/MessageType/Dice.js 0100777 0000000 0000000 00000000450 13431012100 014672 0 ustar 00 /**
* dice message type
*
* @author Daniel (Keito) Lang
* @copyright 2014-2019 da-lang.net
* @package net.dalang.chat.command.dice
*/
define(['Bastelstu.be/Chat/MessageType'], function (MessageType) {
"use strict";
class Dice extends MessageType { }
return Dice
}); files/files_chat.tar 0100777 0000000 0000000 00000020000 13431013142 011707 0 ustar 00 lib/ 0040777 0000000 0000000 00000000000 13430351467 006570 5 ustar 00 lib/system/ 0040777 0000000 0000000 00000000000 13430351537 010112 5 ustar 00 lib/system/command/ 0040777 0000000 0000000 00000000000 13430351514 011523 5 ustar 00 lib/system/command/DiceCommand.class.php 0100777 0000000 0000000 00000004631 13431011767 015513 0 ustar 00 canWritePublicly($user)) {
throw new PermissionDeniedException();
}
if (!$user->getPermission('user.chat.canUseDice')) {
throw new PermissionDeniedException();
}
$this->dice = $this->assertParameter($parameters, 'dice');
$this->value = $this->assertParameter($parameters, 'value');
// validate max dice number
if ($this->dice < 1) $this->dice = 1;
if ($this->dice > CHAT_DICE_MAXDICE) $this->dice = CHAT_DICE_MAXDICE;
// validate max dice value
if ($this->value < 1) $this->value = 1;
if ($this->value > CHAT_DICE_MAXVALUE) $this->value = CHAT_DICE_MAXVALUE;
}
/**
* @inheritdoc
*/
public function execute($parameters, Room $room, UserProfile $user = null) {
if ($user === null) $user = new UserProfile(WCF::getUser());
// throw the dice, baby!
$values = [];
for ($i = 1; $i <= $this->dice; $i++) {
$values[] = mt_rand(1, $this->value);
}
$rollString = ($this->dice > 20 ? '' : implode(' + ', $values));
$totalValue = array_sum($values);
$action = new MessageAction([], 'create', [
'data' => [
'roomID' => $room->roomID,
'userID' => $user->userID,
'username' => $user->username,
'time' => TIME_NOW,
'objectTypeID' => $this->getMessageObjectTypeID('net.dalang.chat.messageType.dice'),
'payload' => serialize(['dice' => $this->dice, 'value' => $this->value, 'rollString' => $rollString, 'totalValue' => $totalValue])
],
'updateTimestamp' => true,
'grantPoints' => false
]);
$action->executeAction();
}
} lib/system/message/ 0040777 0000000 0000000 00000000000 13430351545 011535 5 ustar 00 lib/system/message/type/ 0040777 0000000 0000000 00000000000 13430351566 012521 5 ustar 00 lib/system/message/type/DiceMessageType.class.php 0100777 0000000 0000000 00000001371 13431012005 017332 0 ustar 00 getPermission('mod.chat.canDelete');
}
} files/templates_chat.tar 0100777 0000000 0000000 00000010000 13430611670 012613 0 ustar 00 diceCommandLanguage.tpl 0100777 0000000 0000000 00000000240 13430610463 012400 0 ustar 00 Language.addObject({
'chat.messageType.net.dalang.chat.messageType.dice': '{lang __literal=true}chat.messageType.net.dalang.chat.messageType.dice{/lang}',
}) diceCommandMessageTypes.tpl 0100777 0000000 0000000 00000002605 13430610634 013275 0 ustar 00 {literal}
{/literal} language/ 0040777 0000000 0000000 00000000000 13430346266 007606 5 ustar 00 language/de.xml 0100777 0000000 0000000 00000002552 13430615530 010715 0 ustar 00
- {#$message.payload.totalValue}]]>