#0
j!1eaWpTRkCSUUy1YhfiXM3vSuByrA4yriAMmmodule.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;
let dmgRoll = dice.roll( 1, 6 ) + dmgMod;
let critRoll = dice.roll( 1, 3 );
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/957bab224946882d112db8eba6be686f59be31fedcab7d50623ac86f9d9ed8c2