Merge branch 'master' into 'master'
Calculate initiative every round of battle See merge request mollusk/trinket!2
This commit is contained in:
commit
8171922eed
20
battle.go
20
battle.go
@ -11,19 +11,19 @@ func Battle(hero, enemy Character) {
|
|||||||
heroDamage := hero.Damage + hero.Weapons[hero.Gear.Weapon.Name].Damage
|
heroDamage := hero.Damage + hero.Weapons[hero.Gear.Weapon.Name].Damage
|
||||||
enemyDamage := enemy.Damage + enemy.Weapons[enemy.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
|
damage := 0
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
heroInitiative := rand.Intn(7) + hero.Initiative
|
||||||
|
enemyInitiative := rand.Intn(7) + enemy.Initiative
|
||||||
|
|
||||||
|
if heroInitiative == enemyInitiative {
|
||||||
|
if flipCoin() == "heads" {
|
||||||
|
heroInitiative -= 1
|
||||||
|
} else {
|
||||||
|
enemyInitiative -= 1
|
||||||
|
}
|
||||||
|
}
|
||||||
printCombatantStats(&hero, &enemy, heroInitiative, enemyInitiative)
|
printCombatantStats(&hero, &enemy, heroInitiative, enemyInitiative)
|
||||||
|
|
||||||
if heroInitiative > enemyInitiative {
|
if heroInitiative > enemyInitiative {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user