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