Updated battle.go to allow for weapons
This commit is contained in:
parent
6db16d0ed3
commit
b962452832
34
battle.go
34
battle.go
@ -7,26 +7,25 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Character struct {
|
type Character struct {
|
||||||
Name string
|
Name string
|
||||||
Health int
|
Health int
|
||||||
Damage int
|
Damage int
|
||||||
Spell Spell
|
Weapons [5]Weapon
|
||||||
|
Spell Spell
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func Battle(hero, enemy Character, speed time.Duration) {
|
func Battle(hero, enemy Character, speed time.Duration) {
|
||||||
speed *= time.Second
|
speed *= time.Second
|
||||||
|
|
||||||
rand.Seed(time.Now().Unix())
|
rand.Seed(time.Now().Unix())
|
||||||
fmt.Println("Random Int: ",rand.Intn(11))
|
fmt.Println("Random Int: ", rand.Intn(11))
|
||||||
//time.Sleep(speed)
|
//time.Sleep(speed)
|
||||||
print("Hero: ",hero.Name, "\n")
|
print("Hero: ", hero.Name, "\n")
|
||||||
print("Enemy: ",enemy.Name, "\n")
|
print("Enemy: ", enemy.Name, "\n")
|
||||||
|
|
||||||
if spellOrAttack() == "spell"{
|
if spellOrAttack() == "spell" {
|
||||||
print("Spell Damage: ",hero.Spell.Damage, "\n")
|
print("Spell Damage: ", hero.Spell.Damage, "\n")
|
||||||
}else{
|
} else {
|
||||||
print("Attack Damage: ", hero.Damage, "\n")
|
print("Attack Damage: ", hero.Damage, "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,11 +34,10 @@ func Battle(hero, enemy Character, speed time.Duration) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func spellOrAttack() string {
|
func spellOrAttack() string {
|
||||||
if rand.Intn(2) == 1{
|
if rand.Intn(2) == 1 {
|
||||||
return "spell"
|
return "spell"
|
||||||
}else{
|
} else {
|
||||||
return "attack"
|
return "attack"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user