Comply to formatting guidelines for golint
This commit is contained in:
parent
9b973356a8
commit
38f4dc7ada
11
battle.go
11
battle.go
@ -5,6 +5,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
//Battle allow two character types to battle each other
|
||||
func Battle(hero, enemy Character) {
|
||||
speed := time.Second * 1
|
||||
|
||||
@ -19,9 +20,9 @@ func Battle(hero, enemy Character) {
|
||||
|
||||
if heroInitiative == enemyInitiative {
|
||||
if flipCoin() == "heads" {
|
||||
heroInitiative -= 1
|
||||
heroInitiative-- //does the same as -= 1
|
||||
} else {
|
||||
enemyInitiative -= 1
|
||||
enemyInitiative--
|
||||
}
|
||||
}
|
||||
printCombatantStats(&hero, &enemy, heroInitiative, enemyInitiative)
|
||||
@ -71,9 +72,9 @@ func Battle(hero, enemy Character) {
|
||||
func flipCoin() string {
|
||||
if rand.Intn(10) < 5 {
|
||||
return "heads"
|
||||
} else {
|
||||
return "tails"
|
||||
}
|
||||
} //no need for 'else', this format is the Go style
|
||||
return "tails"
|
||||
|
||||
}
|
||||
|
||||
func printCombatantStats(hero, enemy *Character, heroInitiative, enemyInitiative int) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package main
|
||||
|
||||
//Character define general type for characters
|
||||
type Character struct {
|
||||
Name string
|
||||
Health int
|
||||
@ -10,6 +11,7 @@ type Character struct {
|
||||
Gear PaperDoll
|
||||
}
|
||||
|
||||
//PaperDoll define type for creating basic paper doll feature
|
||||
type PaperDoll struct {
|
||||
Weapon Weapon
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user