Everthing is a main package now
This commit is contained in:
commit
e6694c63f9
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
trinket
|
45
battle.go
Normal file
45
battle.go
Normal file
@ -0,0 +1,45 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Character struct {
|
||||
Name string
|
||||
Health int
|
||||
Damage int
|
||||
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))
|
||||
//time.Sleep(speed)
|
||||
print("Hero: ",hero.Name, "\n")
|
||||
print("Enemy: ",enemy.Name, "\n")
|
||||
|
||||
if spellOrAttack() == "spell"{
|
||||
print("Spell Damage: ",hero.Spell.Damage, "\n")
|
||||
}else{
|
||||
print("Attack Damage: ", hero.Damage, "\n")
|
||||
}
|
||||
|
||||
if enemy.Name == "Goblin" {
|
||||
print("This is a goblin character\n")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func spellOrAttack() string {
|
||||
if rand.Intn(2) == 1{
|
||||
return "spell"
|
||||
}else{
|
||||
return "attack"
|
||||
}
|
||||
}
|
11
magic.go
Normal file
11
magic.go
Normal file
@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
//Spell contains all the magic spells
|
||||
type Spell struct {
|
||||
Name string
|
||||
Damage int
|
||||
Cost int
|
||||
Level int
|
||||
Active bool
|
||||
|
||||
}
|
29
main.go
Normal file
29
main.go
Normal file
@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
|
||||
|
||||
//Characters
|
||||
var (
|
||||
player = Character{
|
||||
|
||||
Name: "Daniel",
|
||||
Health: 100,
|
||||
Damage: 60,
|
||||
Spell: firearrow}
|
||||
|
||||
goblin = Character{
|
||||
|
||||
Name: "Goblin",
|
||||
Health: 100,
|
||||
Damage: 20}
|
||||
|
||||
firearrow = Spell{
|
||||
Name: "Fire Arrow",
|
||||
Damage: 50,
|
||||
Cost: 10,
|
||||
Level: 1,
|
||||
Active: true}
|
||||
)
|
||||
func main(){
|
||||
Battle(player, goblin, 1)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user