commit e6694c63f9bb795d0d4f98f663f886654a5b5075 Author: mollusk Date: Sun Oct 8 22:17:53 2017 -0700 Everthing is a main package now diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b3641e0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +trinket \ No newline at end of file diff --git a/battle.go b/battle.go new file mode 100644 index 0000000..bea9a45 --- /dev/null +++ b/battle.go @@ -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" + } +} \ No newline at end of file diff --git a/magic.go b/magic.go new file mode 100644 index 0000000..3352fbe --- /dev/null +++ b/magic.go @@ -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 + +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..9ad68fd --- /dev/null +++ b/main.go @@ -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) +} \ No newline at end of file