trinket/battle.go

43 lines
674 B
Go

package main
import (
"fmt"
"math/rand"
"time"
)
type Character struct {
Name string
Health int
Damage int
Weapons [5]Weapon
Spell Spell
}
func Battle(hero, enemy Character) {
speed := time.Second
fmt.Println("Random Int: ", rand.Intn(11))
time.Sleep(speed)
print("Hero: ", hero.Name, "\n")
print("Enemy: ", enemy.Name, "\n")
if spellOrAttack() == "spell" {
print("Spell Damage: ", hero.Spell.Damage, "\n")
} else {
print("Attack Damage: ", hero.Damage, "\n")
}
if enemy.Name == "Goblin" {
print("This is a goblin character\n")
}
}
func spellOrAttack() string {
if rand.Intn(2) == 1 {
return "spell"
} else {
return "attack"
}
}