trinket/battle.go

45 lines
698 B
Go
Raw Normal View History

2017-10-08 22:17:53 -07:00
package main
import (
"fmt"
"math/rand"
"time"
)
type Character struct {
Name string
Health int
Damage int
Spell Spell
}
func Battle(hero, enemy Character, speed time.Duration) {
speed *= time.Second
rand.Seed(time.Now().Unix())
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"
}
}