j!1eaWpTRkCSUUy1YhfiXM3vSuByrA4yriAMumodule.exports = async function(context, dice) {
const attacker = context.players[context.playerToAct];
const defender = context.players[context.playerToAct ? 0 : 1];
let atkMod = attacker.strengthMod;
let dmgMod = attacker.strengthMod;
let atkRoll = dice.roll( 1, 20 ) + atkMod - 1;
let dmgRoll = dice.roll( 1, 6 ) + dmgMod + dice.roll( 1, 4 );
let critRoll = 0;
let atkStatus = atkRoll < defender.evasion ? 0: atkRoll > 19 ? 2 : 1;
let dmg = atkStatus == 0 ? 0: atkStatus == 1 ? dmgRoll : dmgRoll + critRoll;
defender.hp -= dmg;
context.actionLog = [{
hand: 0,
attackMod: atkMod,
damageMod: dmgMod,
attackRolls: {
attackRoll: atkRoll,
damageRoll: dmgRoll,
criticalRoll: critRoll
},
attackStatus: atkStatus,
damageOutput: {
damage: [ 0, dmg, 0, 0, 0, 0, 0, 0, 0, 0 ],
defenderReduction: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
defenderHp: defender.hp
},
playerIndex : context.playerToAct
}];
return context;
}
https://whatsonchain.com/tx/f64ef7e0954b498ead9496722ea30a2943a68b4e8575a6a62fcdee5ad4785280