add early structure

This commit is contained in:
mollusk 2018-02-05 19:52:50 -07:00
parent d73b1c5902
commit f9b0853266
11 changed files with 150 additions and 0 deletions

1
battle.go Normal file
View File

@ -0,0 +1 @@
package main

9
character.go Normal file
View File

@ -0,0 +1,9 @@
package main
var (
//Player player character
Player = Character{
name: "Daniel",
location: "town",
}
)

BIN
daniel Executable file

Binary file not shown.

1
enemies.go Normal file
View File

@ -0,0 +1 @@
package main

7
events.go Normal file
View File

@ -0,0 +1,7 @@
package main
/*
func forestEvent() {
print("You enter the forest \n")
}
*/

13
generate.go Normal file
View File

@ -0,0 +1,13 @@
package main
import (
"math/rand"
"time"
)
func genMessage(messageList []string) string {
rand.Seed(time.Now().UnixNano())
n := rand.Int() % len(messageList)
return messageList[n]
}

1
items.go Normal file
View File

@ -0,0 +1 @@
package main

6
main.go Normal file
View File

@ -0,0 +1,6 @@
package main
func main() {
print(genMessage(deathMessages), "\n")
//Movement(&Player)
}

13
messages.go Normal file
View File

@ -0,0 +1,13 @@
package main
var (
deathMessages = []string{
"You have done something foolish...died",
"Do not expect a darwin award any time soon..",
"Don't give up on dying, you are doing great!",
"One day you should try...living",
"Only those who lack common sense resemble you",
"Give youself a break, you only failed to stay alive afterall",
"God himself can't save you from stupidity",
}
)

18
structs.go Normal file
View File

@ -0,0 +1,18 @@
package main
//Area places to explore
type Area struct {
description string
weather string
}
//Event current event state
type Event struct {
battle bool
}
//Character creates format for any entity
type Character struct {
name string
location string
}

81
world.go Normal file
View File

@ -0,0 +1,81 @@
package main
import (
"fmt"
"sort"
"strings"
)
var (
areas = map[string]*Area{
"town": {
description: "You are in town",
weather: "Sunny",
},
"forest": {
description: "You are in the forest",
weather: "the sun beats down on you",
},
}
)
//Movement define world movement
func Movement(player *Character) {
//areaList := getAreaList(areas)
var command [2]string
var quit bool = false
print("Character: ",
player.name, "\n",
"Location: ",
player.location, "\n",
"Description: ", areas["town"].description, "\n",
"Weather: ", areas["town"].weather, "\n\n")
var isArea string
for quit != true {
print("Enter text: ")
fmt.Scanln(&command[0], &command[1])
command[0] = strings.ToLower(command[0])
command[1] = strings.ToLower(command[1])
if _, ok := areas[command[0]]; ok {
isArea = command[0]
}
switch command[0] {
case "q", "quit", "exit":
print("Are you sure you want to quit?: (y/n) ")
fmt.Scanln(&command[0])
if strings.ToLower(command[0]) == "y" {
quit = true
}
case isArea:
player.location = command[0]
print(areas[player.location].description, "\n")
//forestEvent(areas[player.location])
case "list":
var areaList []string
for key := range areas {
areaList = append(areaList, key)
}
sort.Sort(sort.StringSlice(areaList))
print("\nPlaces:\n\n")
//Ignore key iterator and print the range of the value only.
for _, val := range areaList {
print(val, "\n")
}
default:
print("Wrong command\n")
}
}
}