-
Notifications
You must be signed in to change notification settings - Fork 0
/
hero_Attack.go
47 lines (40 loc) · 1.34 KB
/
hero_Attack.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"fmt"
)
func heroSuccessfullyAttack(weaponMissChance int, chance int) bool {
var successfulAttack bool
if chance > 100-weaponMissChance {
fmt.Printf("You missed with chance %d!\n", chance)
} else {
successfulAttack = true
}
return successfulAttack
}
func heroAttack(hero Hero, dragon Dragon, crossbow, pan, sword, weapon Weapon, successfulAttack bool) (int, Weapon, Weapon, Weapon, Weapon) {
damageReduction := heroTiredness(hero)
if weapon.minDamage > weapon.damage-damageReduction {
hero.damage = weapon.minDamage
} else {
hero.damage = weapon.damage - damageReduction
}
if weapon.damage > 0 {
if successfulAttack == true {
dragon.health = dragon.health - hero.damage
crossbow, pan, sword = increaseWeaponDamage(weapon, crossbow, pan, sword)
/*if weapon.name == "crossbow" {
crossbow = increaseWeaponDamage(crossbow)
} else if weapon.name == "pan" {
pan = increaseWeaponDamage(pan)
} else if weapon.name == "sword" {
sword = increaseWeaponDamage(sword)
}*/
}
} else if weapon.damage <= 0 {
fmt.Printf("WEAPON IS BROKEN %s \n", weapon.name)
choosedWeapon := chooseWeapon()
usingWeapon, _, _ := usingWeapon(crossbow, pan, sword, choosedWeapon)
heroAttack(hero, dragon, crossbow, pan, sword, usingWeapon, successfulAttack)
}
return dragon.health, weapon, crossbow, pan, sword
}