Closed Pharap closed 6 years ago
Proposed solution:
const uint8_t enemyAttack = enemies[attackingEnemyIdx].getAttackPower();
const uint8_t playerDefence = myHero.getDefence();
uint8_t maxHP = (enemyAttack > playerDefence) ? (enemyAttack - playerDefence) : 2;
if(maxHP < 2) maxHP = 2;
if(maxHP > 10) maxHP = 10;
const uint8_t hpLoss = random(0, maxHP);
Adds only 4 bytes of progmem, which is oddly better than many other solutions.
Sovled by #25.
Reported here:
https://community.arduboy.com/t/dark-under-a-dungeon-crawler/4637/167
The problem is here:
https://github.com/Garage-Collective/Dark-And-Under/blob/6562e7b9df40806d59ff40ed993a995e69d8a099/Dark-And-Under/DarkUnder_Battle.ino#L187