diff --git a/client/amusement.js b/client/amusement.js index bfb73b9..0e36a41 100644 --- a/client/amusement.js +++ b/client/amusement.js @@ -10,9 +10,14 @@ function queue_roll(bit) { info.bit = bit; info.$tag = $(this.callback(safe(''))); this.strong = true; + var audio = undefined; if(bit =='#loli' && info.dice) { this.callback(safe("")); } + else if (info.dice && (audio = readable_audio(bit, info.dice))) { + this.callback(safe(""+bit+"")); + this.callback(safe("")); + } else this.callback(info.dice ? readable_dice(bit, info.dice) : bit); this.strong = false; this.callback(safe('')); @@ -35,7 +40,19 @@ oneeSama.hook('insertOwnPost', function (extra) { info = rolls[n] = {}; info.dice = extra.dice[i]; if (info.$tag) { - if(info.bit == "#loli") + var audio = readable_audio(info.bit, info.dice); + if (audio) + { + var $audio = $(""+info.bit+""); + var $aaudio = $(""); + info.$tag.text(''); + info.$tag.append($audio); + info.$tag.append($aaudio); + if(info.$tag.children && info.$tag.children[0]) //wha? works for chakai + info.$tag.children[0].text(info.bit); + + } + else if(info.bit == "#loli") info.$tag.html(""); else info.$tag.text(readable_dice(info.bit, info.dice)); } diff --git a/common.js b/common.js index 1a95e01..b105c1c 100644 --- a/common.js +++ b/common.js @@ -388,7 +388,7 @@ OS.karada = function (body) { return output; } -var dice_re = /(#flip|#when|#du|#pyu|#pcount|#test|#sleep|#janken|#8ball|#imfey|#\?(?:\[(?:\w,*)+\])?|#\d{0,2}d\d{1,4}(?:[+-]\d{1,4})?)/i; +var dice_re = /(#dame|#muri|#flip|#when|#du|#pyu|#pcount|#test|#sleep|#janken|#8ball|#imfey|#\?(?:\[(?:\w,*)+\])?|#\d{0,2}d\d{1,4}(?:[+-]\d{1,4})?)/i; exports.dice_re = dice_re; var WHEN = [ @@ -444,7 +444,10 @@ var IMFEY = [ 'elwind!', ]; -function parse_dice(frag) { +function parse_dice(frag) +{ + if(/^#(dame|muri)$/i.test(frag)) + return {n:1, faces:2}; if(frag == '#loli') { return {n:1, faces:3}; } @@ -492,6 +495,15 @@ function parse_dice(frag) { } exports.parse_dice = parse_dice; +const audio_root = "/s/audio"; + +function readable_audio(bit, d) { + if (bit=='#dame') + return "dame.wav"; + else if (bit=='#muri') + return "muri.wav"; +} + function readable_dice(bit, d) { if(bit == '#loli') { return "you should not see this"; @@ -591,7 +603,13 @@ OS.geimu = function (text) { var d = this.dice.shift(); this.callback(safe('')); this.strong = true; // for client DOM insertion - if(bit == "#loli") { + var audio = readable_audio(bit,d); + if(audio) + { + this.callback(safe(""+bit+"")); + this.callback(safe("")); + } + else if(bit == "#loli") { this.callback(safe("")); } else