From 52cb843ad2c4f709b5fc9e2b2a55ee48af70664c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrik=20Laur=C3=A9n?= Date: Sat, 25 Nov 2017 14:21:43 +0100 Subject: [PATCH 1/3] Add a no push option Add two new versions of rolling dice that does not allow pushing the die roll. !myz-np and !wmyz-np --- MutantYearZero/MutantYearZero.js | 34 +++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/MutantYearZero/MutantYearZero.js b/MutantYearZero/MutantYearZero.js index a42890f..ca67785 100644 --- a/MutantYearZero/MutantYearZero.js +++ b/MutantYearZero/MutantYearZero.js @@ -626,6 +626,7 @@ var MutantYearZero = MutantYearZero || (function() { pushes, push=false, + nopush=false, pushButton, w=false, cmd, @@ -672,6 +673,16 @@ var MutantYearZero = MutantYearZero || (function() { cmd=matches[1]; hash=parseInt(matches[2],10); } + + if('!wmyz-np' === cmd) { + cmd='!wmyz'; + nopush=true; + } + + if('!myz-np' === cmd) { + cmd='!myz'; + nopush=true; + } switch(cmd) { case '!wmyz': @@ -785,16 +796,18 @@ var MutantYearZero = MutantYearZero || (function() { optional: optional }); - pushButton = (_.reduce([skillDiceArray,baseDiceArray,gearDiceArray],function(m,dice){ return m+getRollableDiceCount(dice);},0) ? - makeButton( - '!'+(w?'w':'')+'myz['+hash+'] '+ - makeRerollExpression(skillDiceArray)+ - makeRerollExpression(baseDiceArray)+ - makeRerollExpression(gearDiceArray), - symbols.push+' '+pushes - ) : - '' - ); + if(!nopush) { + pushButton = (_.reduce([skillDiceArray,baseDiceArray,gearDiceArray],function(m,dice){ return m+getRollableDiceCount(dice);},0) ? + makeButton( + '!'+(w?'w':'')+'myz['+hash+'] '+ + makeRerollExpression(skillDiceArray)+ + makeRerollExpression(baseDiceArray)+ + makeRerollExpression(gearDiceArray), + symbols.push+' '+pushes + ) : + '' + ); + } output = makeOutput([ makeLabel( successes+' '+symbols.radioactive, colors.lightGreen), @@ -905,4 +918,3 @@ on('ready',function() { - From efbe62284143125daec029458069b8c888706a42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrik=20Laur=C3=A9n?= Date: Sun, 26 Nov 2017 23:53:12 +0100 Subject: [PATCH 2/3] Add difficulty dice If the difficulty is higher than the skill the remaining dice shall be rolled and any "successes" of the difficulty dice shall reduce the total number of successes. Difficulty dice are shown in red (ordinary skill dice are shown in green) to help differentiate between the dice. --- MutantYearZero/MutantYearZero.js | 49 ++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/MutantYearZero/MutantYearZero.js b/MutantYearZero/MutantYearZero.js index ca67785..1d1f68d 100644 --- a/MutantYearZero/MutantYearZero.js +++ b/MutantYearZero/MutantYearZero.js @@ -23,7 +23,8 @@ var MutantYearZero = MutantYearZero || (function() { yellow: '#ddcf43', lightYellow: '#FFF699', black: '#1d1d1d', - lightBlack: '#8F8E8E' + lightBlack: '#8F8E8E', + red: '#FF0000' }, defaults = { css: { @@ -118,7 +119,7 @@ var MutantYearZero = MutantYearZero || (function() { reportingModes = { 'off': 'None', 'gm': 'GM', - 'gm+player': 'GM & Player', + 'gm+player': 'GM & Player', 'public': 'Public' }, templates = {}, @@ -390,7 +391,7 @@ var MutantYearZero = MutantYearZero || (function() { ''+ 'Commands'+ '
'+ - '!myz '+ch('[')+'Skill Roll'+ch(']')+' '+ch('[')+'Base Roll'+ch(']')+' '+ch('[')+'Gear Roll'+ch(']')+' '+ch('[')+'--'+ch('<')+'Label'+ch('>')+ch('|')+ch('<')+'Message'+ch('>')+' ...'+ch(']')+''+ + '!myz '+ch('[')+'Skill Roll'+ch(']')+' '+ch('[')+'Base Roll'+ch(']')+' '+ch('[')+'Gear Roll'+ch(']')+' '+ch('[')+'Diff Roll'+ch(']')+' '+ch('[')+'--'+ch('<')+'Label'+ch('>')+ch('|')+ch('<')+'Message'+ch('>')+' ...'+ch(']')+''+ '
'+ '

Performs a Mutant Year Zero Roll.

'+ '
    '+ @@ -403,6 +404,9 @@ var MutantYearZero = MutantYearZero || (function() { '
  • '+ ''+ch('[')+'Gear Roll'+ch(']')+' '+ch('-')+' An inline dice expression rolling the d6s ('+symbols.radioactive+'). 1s are counted as Gear Degradation ('+symbols.explosion+'). Example: '+ch('[')+ch('[')+'2d6'+ch(']')+ch(']')+ '
  • '+ + '
  • '+ + ''+ch('[')+'Diff Roll'+ch(']')+' '+ch('-')+' An inline dice expression rolling the d6s. 6s reduce the number of successes ('+symbols.radioactive+'). Shall be a positive value only if Skill role is a negative number of dice. Example: '+ch('[')+ch('[')+'0d6'+ch(']')+ch(']')+ + '
  • '+ '
  • '+ ''+ch('[')+'--'+ch('<')+'Label'+ch('>')+ch('|')+ch('<')+'Message'+ch('>')+' ...'+ch(']')+' '+ch('-')+' An optional set of text to be shown above the die roll. Label may be omitted to just provid a text field. You can specify as many optional descriptions as you like.'+ '
    '+ @@ -476,12 +480,13 @@ var MutantYearZero = MutantYearZero || (function() { var cnt = getRollableDiceCount(dice); return ' '+ch('[')+ch('[')+cnt+'d6'+ch(']')+ch(']')+' '; }, - validatePlayerRollHash = function(playerid, hash, skill,base,gear){ + validatePlayerRollHash = function(playerid, hash, skill,base,gear,diff){ var obj=state.MutantYearZero.playerRolls[playerid]; return (obj && obj.hash === hash && obj.dice.skillDice === skill && obj.dice.baseDice === base && - obj.dice.gearDice === gear + obj.dice.gearDice === gear && + obj.dice.diffDice === diff ); }, getCountsForRoll = function(playerid,hash){ @@ -614,10 +619,12 @@ var MutantYearZero = MutantYearZero || (function() { skillDice, // skill: green baseDice, // base(stat): yellow, trauma on 1s gearDice, // gear: black, degradation on 1s + diffDice, skillDiceArray, baseDiceArray, gearDiceArray, + diffDiceArray, successes=0, trauma=0, @@ -720,8 +727,8 @@ var MutantYearZero = MutantYearZero || (function() { skillDice=getDiceCounts(msg,rollIndices[0]); baseDice=getDiceCounts(msg,rollIndices[1]); gearDice=getDiceCounts(msg,rollIndices[2]); + diffDice=getDiceCounts(msg,rollIndices[3]); - if(push && ( _.has(state.MutantYearZero.playerRolls,owner) && @@ -730,7 +737,8 @@ var MutantYearZero = MutantYearZero || (function() { !validatePlayerRollHash(owner,hash, getDiceArray(skillDice).length, getDiceArray(baseDice).length, - getDiceArray(gearDice).length + getDiceArray(gearDice).length, + getDiceArray(diffDice).length ) ){ reportBadPushCounts(msg.playerid); @@ -738,18 +746,25 @@ var MutantYearZero = MutantYearZero || (function() { } pushedValues=getCountsForRoll(owner,hash); - successes=pushedValues.success + (skillDice['6']||0) + (baseDice['6']||0) + (gearDice['6']||0) ; + successes=pushedValues.success + (skillDice['6']||0) + (baseDice['6']||0) + (gearDice['6']||0) - (diffDice['6']||0); trauma = pushedValues.trauma + (baseDice['1']||0); gearDamage = pushedValues.damage + (gearDice['1']||0); pushes = pushedValues.pushes+1; optional = (optional.length && optional) || getOptionalForRoll(owner,hash); - skillDiceArray=_.map(getDiceArray(skillDice),function(v){ switch(v){ case '6': - case '-6': + return symbols.radioactive; + default: + return v; + } + }); + + diffDiceArray=_.map(getDiceArray(diffDice),function(v){ + switch(v){ + case '6': return symbols.radioactive; default: return v; @@ -785,7 +800,8 @@ var MutantYearZero = MutantYearZero || (function() { dice: { skillDice: getRollableDiceCount(skillDiceArray), baseDice: getRollableDiceCount(baseDiceArray), - gearDice: getRollableDiceCount(gearDiceArray) + gearDice: getRollableDiceCount(gearDiceArray), + diffDice: getRollableDiceCount(diffDiceArray) }, counts: { success: successes, @@ -802,7 +818,8 @@ var MutantYearZero = MutantYearZero || (function() { '!'+(w?'w':'')+'myz['+hash+'] '+ makeRerollExpression(skillDiceArray)+ makeRerollExpression(baseDiceArray)+ - makeRerollExpression(gearDiceArray), + makeRerollExpression(gearDiceArray)+ + makeRerollExpression(diffDiceArray), symbols.push+' '+pushes ) : '' @@ -819,12 +836,11 @@ var MutantYearZero = MutantYearZero || (function() { makeOptionalText(optional), makeDiceImages(skillDiceArray,colors.green), makeDiceImages(baseDiceArray,colors.yellow, colors.black), - makeDiceImages(gearDiceArray,colors.black) + makeDiceImages(gearDiceArray,colors.black), + makeDiceImages(diffDiceArray,colors.red) ].join('') ); - - who=getObj('player',owner).get('displayname'); if(w){ sendChat(msg.who, '/w gm '+output); @@ -834,7 +850,6 @@ var MutantYearZero = MutantYearZero || (function() { } else { sendChat(who, '/direct '+output); } - break; case '!myz-config': @@ -891,9 +906,7 @@ var MutantYearZero = MutantYearZero || (function() { '
    Unsupported Option:
    '+a+'
    ' ); } - }); - break; } }, From 30b803b292bec159981d9109a9b25136e1f9168f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrik=20Laur=C3=A9n?= Date: Sun, 26 Nov 2017 23:57:13 +0100 Subject: [PATCH 3/3] Fix push button The push button should still be available when only having difficulty dice left. --- MutantYearZero/MutantYearZero.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MutantYearZero/MutantYearZero.js b/MutantYearZero/MutantYearZero.js index 1d1f68d..a21ad4f 100644 --- a/MutantYearZero/MutantYearZero.js +++ b/MutantYearZero/MutantYearZero.js @@ -813,7 +813,7 @@ var MutantYearZero = MutantYearZero || (function() { }); if(!nopush) { - pushButton = (_.reduce([skillDiceArray,baseDiceArray,gearDiceArray],function(m,dice){ return m+getRollableDiceCount(dice);},0) ? + pushButton = (_.reduce([skillDiceArray,baseDiceArray,gearDiceArray,diffDiceArray],function(m,dice){ return m+getRollableDiceCount(dice);},0) ? makeButton( '!'+(w?'w':'')+'myz['+hash+'] '+ makeRerollExpression(skillDiceArray)+