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"
|
"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) {
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user