diff --git a/battle.go b/battle.go new file mode 100644 index 0000000..06ab7d0 --- /dev/null +++ b/battle.go @@ -0,0 +1 @@ +package main diff --git a/character.go b/character.go new file mode 100644 index 0000000..33a4810 --- /dev/null +++ b/character.go @@ -0,0 +1,9 @@ +package main + +var ( + //Player player character + Player = Character{ + name: "Daniel", + location: "town", + } +) diff --git a/daniel b/daniel new file mode 100755 index 0000000..e1ab63b Binary files /dev/null and b/daniel differ diff --git a/enemies.go b/enemies.go new file mode 100644 index 0000000..06ab7d0 --- /dev/null +++ b/enemies.go @@ -0,0 +1 @@ +package main diff --git a/events.go b/events.go new file mode 100644 index 0000000..51eb1bb --- /dev/null +++ b/events.go @@ -0,0 +1,7 @@ +package main + +/* +func forestEvent() { + print("You enter the forest \n") +} +*/ diff --git a/generate.go b/generate.go new file mode 100644 index 0000000..8808a28 --- /dev/null +++ b/generate.go @@ -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] + +} diff --git a/items.go b/items.go new file mode 100644 index 0000000..06ab7d0 --- /dev/null +++ b/items.go @@ -0,0 +1 @@ +package main diff --git a/main.go b/main.go new file mode 100644 index 0000000..12f6ecc --- /dev/null +++ b/main.go @@ -0,0 +1,6 @@ +package main + +func main() { + print(genMessage(deathMessages), "\n") + //Movement(&Player) +} diff --git a/messages.go b/messages.go new file mode 100644 index 0000000..ef5e32a --- /dev/null +++ b/messages.go @@ -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", + } +) diff --git a/structs.go b/structs.go new file mode 100644 index 0000000..9463c87 --- /dev/null +++ b/structs.go @@ -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 +} diff --git a/world.go b/world.go new file mode 100644 index 0000000..0fddf59 --- /dev/null +++ b/world.go @@ -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") + } + } + +}