diff --git a/battle.go b/battle.go index 0f1d9c5..598c1c5 100644 --- a/battle.go +++ b/battle.go @@ -10,18 +10,26 @@ import ( func Battle(hero, enemy Character) { speed := time.Second * 1 - heroDamage := hero.Damage + hero.Weapons[0].Damage - enemyDamage := enemy.Damage + enemy.Weapons[0].Damage + heroDamage := hero.Damage + hero.Weapons[hero.Gear.Weapon.Name].Damage + enemyDamage := enemy.Damage + enemy.Weapons[enemy.Gear.Weapon.Name].Damage heroInitiative := rand.Intn(7) + hero.Initiative enemyInitiative := rand.Intn(7) + enemy.Initiative + + if heroInitiative == enemyInitiative{ + if flipCoin() == "heads"{ + heroInitiative -=1 + }else{ + enemyInitiative -= 1 + } + } damage := 0 for { printCombatantStats(&hero, &enemy, heroInitiative, enemyInitiative) - if heroInitiative >= enemyInitiative { + if heroInitiative > enemyInitiative { damage = rand.Intn(heroDamage) enemy.Health -= damage print(enemy.Name, " was hit for ", damage, " damage!\n") @@ -75,5 +83,6 @@ func printCombatantStats(hero, enemy *Character, heroInitiative, enemyInitiative print("Hero: ", hero.Name, "\t", "Enemy: ", enemy.Name, "\n") print("Health: ", hero.Health, "\t", "Health: ", enemy.Health, "\n") - print("Initiative: ", heroInitiative, "\t", "Initiative: ", enemyInitiative, "\n\n") + print("Initiative: ", heroInitiative, "\t", "Initiative: ", enemyInitiative, "\n") + print("Weapon: ", hero.Gear.Weapon.Name, "\t", "Weapon: ", enemy.Gear.Weapon.Name, "\n\n") }