Skip to content

Instantly share code, notes, and snippets.

@isidore
Created January 17, 2022 13:54
Show Gist options
  • Save isidore/44fd16b85d8b28052fea38a0e6b4421c to your computer and use it in GitHub Desktop.
Save isidore/44fd16b85d8b28052fea38a0e6b4421c to your computer and use it in GitHub Desktop.
public static int calculateDamageForDice(Character atk, Character def, int dice)
{
boolean hits = def.getArmorClass() < atk.getForce() + dice;
if (hits && dice != 1)
{
int modifier = dice == 20 ? 2 : 1;
return atk.getWeaponDamage() * modifier;
}
else
{
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment