diff --git a/battle.go b/battle.go index 01ccec4..8c06b7a 100644 --- a/battle.go +++ b/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) { diff --git a/characters.go b/characters.go index 74d2031..0a3f9e4 100644 --- a/characters.go +++ b/characters.go @@ -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 } diff --git a/rooms.go b/rooms.go index b76c796..00373eb 100644 --- a/rooms.go +++ b/rooms.go @@ -1,5 +1,6 @@ package main +//Room define general type for a basic room type Room struct { reward bool doors string