Comply to formatting guidelines for golint

This commit is contained in:
mollusk 2018-07-06 04:37:30 -07:00
parent 9b973356a8
commit 38f4dc7ada
3 changed files with 9 additions and 5 deletions

View File

@ -5,6 +5,7 @@ import (
"time" "time"
) )
//Battle allow two character types to battle each other
func Battle(hero, enemy Character) { func Battle(hero, enemy Character) {
speed := time.Second * 1 speed := time.Second * 1
@ -19,9 +20,9 @@ func Battle(hero, enemy Character) {
if heroInitiative == enemyInitiative { if heroInitiative == enemyInitiative {
if flipCoin() == "heads" { if flipCoin() == "heads" {
heroInitiative -= 1 heroInitiative-- //does the same as -= 1
} else { } else {
enemyInitiative -= 1 enemyInitiative--
} }
} }
printCombatantStats(&hero, &enemy, heroInitiative, enemyInitiative) printCombatantStats(&hero, &enemy, heroInitiative, enemyInitiative)
@ -71,9 +72,9 @@ func Battle(hero, enemy Character) {
func flipCoin() string { func flipCoin() string {
if rand.Intn(10) < 5 { if rand.Intn(10) < 5 {
return "heads" return "heads"
} else { } //no need for 'else', this format is the Go style
return "tails" return "tails"
}
} }
func printCombatantStats(hero, enemy *Character, heroInitiative, enemyInitiative int) { func printCombatantStats(hero, enemy *Character, heroInitiative, enemyInitiative int) {

View File

@ -1,5 +1,6 @@
package main package main
//Character define general type for characters
type Character struct { type Character struct {
Name string Name string
Health int Health int
@ -10,6 +11,7 @@ type Character struct {
Gear PaperDoll Gear PaperDoll
} }
//PaperDoll define type for creating basic paper doll feature
type PaperDoll struct { type PaperDoll struct {
Weapon Weapon Weapon Weapon
} }

View File

@ -1,5 +1,6 @@
package main package main
//Room define general type for a basic room
type Room struct { type Room struct {
reward bool reward bool
doors string doors string