From b962452832e8409a925c851bcacd54b4f9b29fe0 Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Mon, 9 Oct 2017 00:26:36 -0700 Subject: [PATCH] Updated battle.go to allow for weapons --- battle.go | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/battle.go b/battle.go index bea9a45..d9c34b1 100644 --- a/battle.go +++ b/battle.go @@ -7,26 +7,25 @@ import ( ) type Character struct { - Name string - Health int - Damage int - Spell Spell + Name string + Health int + Damage int + Weapons [5]Weapon + 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)) + fmt.Println("Random Int: ", rand.Intn(11)) //time.Sleep(speed) - print("Hero: ",hero.Name, "\n") - print("Enemy: ",enemy.Name, "\n") + print("Hero: ", hero.Name, "\n") + print("Enemy: ", enemy.Name, "\n") - if spellOrAttack() == "spell"{ - print("Spell Damage: ",hero.Spell.Damage, "\n") - }else{ + if spellOrAttack() == "spell" { + print("Spell Damage: ", hero.Spell.Damage, "\n") + } else { print("Attack Damage: ", hero.Damage, "\n") } @@ -35,11 +34,10 @@ func Battle(hero, enemy Character, speed time.Duration) { } } - func spellOrAttack() string { - if rand.Intn(2) == 1{ + if rand.Intn(2) == 1 { return "spell" - }else{ - return "attack" - } -} \ No newline at end of file + } else { + return "attack" + } +}