Take weapon info from paper doll
This commit is contained in:
parent
2338cf3cc4
commit
1bb390c415
17
battle.go
17
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")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user