commit bddf7e7c68e459a357547059e5f363fa77dd8fa2
parent 33243650bfe20374a0cea098153a344e970dd49b
Author: Evan Alba <evanalba@protonmail.com>
Date: Wed, 28 Dec 2022 22:21:05 -0800
feat: Added Go Directory.
Diffstat:
6 files changed, 785 insertions(+), 0 deletions(-)
diff --git a/go/fountain_of_youth_game/about.txt b/go/fountain_of_youth_game/about.txt
@@ -0,0 +1,4 @@
+The Fountain of Youth is a text-based adventure game set during the Age of Discovery.
+You take the role of an explorer in the New World who goes through obstacles to find this
+highly desired and about off treasure called the Fountain of Youth. Will you be able to
+discover the Fountain of Youth?
+\ No newline at end of file
diff --git a/go/fountain_of_youth_game/cinreader.go b/go/fountain_of_youth_game/cinreader.go
@@ -0,0 +1,214 @@
+// Copyright 2019 J Boyd Trolinger. All rights reserved.
+// Use of this source code is governed by a MIT
+// license that can be found in the LICENSE file.
+
+// Package cinreader implements a robust handler for a variety
+// of types for inputs from os.Stdin.
+
+// TODO(jboydt): needs additional testing
+// TODO(jboydt): consider adding additional types?
+// TODO(jboydt): consider allowing clients to change error messages?
+
+package main
+
+import (
+ "bufio"
+ "fmt"
+ "os"
+ "strconv"
+ "strings"
+)
+
+// MessageType encodes the error messages CinReader may emit.
+type MessageType int
+
+// Defined values for MessageType.
+const (
+ emptyStringNotAllowed = iota
+ invalidCharacter
+ invalidCharacterSet
+ invalidFloat
+ invalidInteger
+ invalidIntegerRange
+ invalidStringSet
+)
+
+var default_messages = map[MessageType]string{
+ emptyStringNotAllowed: "Empty input not allowed. Please re-enter: ",
+ invalidCharacter: "Not valid character input. Please re-enter: ",
+ invalidCharacterSet: "Input not in [%s]. Please re-enter: ",
+ invalidFloat: "Not a valid float. Please re-enter: ",
+ invalidInteger: "Not a valid integer. Please re-enter: ",
+ invalidIntegerRange: "Integer must be between %d - %d. Please re-enter: ",
+ invalidStringSet: "\"%s\" not valid input. Please re-enter: ",
+}
+
+// CinReader provides robust input handling from os.Stdin.
+type CinReader struct {
+ reader *bufio.Reader
+ messages map[MessageType]string
+}
+
+// NewCinReader initializes a CinReader.
+func NewCinReader() *CinReader {
+ return &CinReader{bufio.NewReader(os.Stdin), default_messages}
+}
+
+// ReadCharacter returns a rune/character from os.Stdin.
+func (cin *CinReader) ReadCharacter() rune {
+ var charInput rune
+ var err error
+ var countCharacters int
+ for {
+ charInput, _, err = cin.reader.ReadRune()
+ // Added to handle multiple characters on input
+ countCharacters = cin.reader.Buffered()
+ cin.flush()
+ if err != nil || countCharacters > 1 {
+ fmt.Printf(cin.messages[invalidCharacter])
+ continue
+ } else if charInput == '\n' {
+ fmt.Printf(cin.messages[emptyStringNotAllowed])
+ continue
+ }
+ break
+ }
+ return charInput
+}
+
+// ReadCharacterSet returns a rune/character in charset
+// from os.Stdin.
+func (cin *CinReader) ReadCharacterSet(charset []rune) rune {
+ var charInput rune
+ var err error
+ var countCharacters int
+ for {
+ charInput, _, err = cin.reader.ReadRune()
+ // Added to handle multiple characters on input
+ countCharacters = cin.reader.Buffered()
+ cin.flush()
+ if err != nil || countCharacters > 1 {
+ fmt.Printf(cin.messages[invalidCharacter])
+ continue
+ } else {
+ var inCharset bool
+ for _, char := range charset {
+ if charInput == char {
+ inCharset = true
+ break
+ }
+ }
+ if !inCharset {
+ fmt.Printf(cin.messages[invalidCharacterSet], string(charset))
+ continue
+ }
+ }
+ break
+ }
+ return charInput
+}
+
+// ReadFloat returns a float64 from os.Stdin.
+func (cin *CinReader) ReadFloat() float64 {
+ var floatInput float64
+ var err error
+ for {
+ stringInput := cin.ReadString(false)
+ floatInput, err = strconv.ParseFloat(stringInput, 64)
+ if err != nil {
+ fmt.Printf(cin.messages[invalidFloat])
+ continue
+ }
+ break
+ }
+ return floatInput
+}
+
+// ReadInteger returns an int from os.Stdin.
+func (cin *CinReader) ReadInteger() int {
+ var intInput int
+ var err error
+ for {
+ stringInput := cin.ReadString(false)
+ intInput, err = strconv.Atoi(stringInput)
+ if err != nil {
+ fmt.Printf(cin.messages[invalidInteger])
+ continue
+ }
+ break
+ }
+ return intInput
+}
+
+// ReadIntegerRange returns an int between min and max (inclusive)
+// from os.Stdin.
+func (cin *CinReader) ReadIntegerRange(min, max int) int {
+ var intInput int
+ var err error
+ for {
+ stringInput := cin.ReadString(false)
+ intInput, err = strconv.Atoi(stringInput)
+ if err != nil {
+ fmt.Printf(cin.messages[invalidInteger])
+ continue
+ } else if intInput < min || intInput > max {
+ fmt.Printf(cin.messages[invalidIntegerRange], min, max)
+ continue
+ }
+ break
+ }
+ return intInput
+}
+
+// ReadString returns a string from os.Stdin.
+func (cin *CinReader) ReadString(allowEmpty bool) string {
+
+ var input string
+ var err error
+ for {
+ input, err = cin.reader.ReadString('\n')
+ input = strings.Trim(input, " \r\n")
+ if err == nil {
+ if len(input) == 0 && !allowEmpty {
+ fmt.Printf(cin.messages[emptyStringNotAllowed])
+ continue
+ }
+ break
+ }
+ }
+ return input
+}
+
+// ReadStringSet returns a string in stringset from os.Stdin.
+func (cin *CinReader) ReadStringSet(stringset []string, caseSensitive bool) string {
+ if !caseSensitive {
+ for i, str := range stringset {
+ stringset[i] = strings.ToUpper(str)
+ }
+ }
+ var strInput string
+ for {
+ strInput = cin.ReadString(false)
+ if !caseSensitive {
+ strInput = strings.ToUpper(strInput)
+ }
+ var validString bool
+ for _, str := range stringset {
+ if str == strInput {
+ validString = true
+ break
+ }
+ }
+ if !validString {
+ fmt.Printf(cin.messages[invalidStringSet], strInput)
+ continue
+ }
+ break
+ }
+ return strInput
+}
+
+// flush the input buffer.
+func (cin *CinReader) flush() {
+ cin.reader.Discard(cin.reader.Buffered())
+}
diff --git a/go/fountain_of_youth_game/go.mod b/go/fountain_of_youth_game/go.mod
@@ -0,0 +1,3 @@
+module main
+
+go 1.14
diff --git a/go/fountain_of_youth_game/main.go b/go/fountain_of_youth_game/main.go
@@ -0,0 +1,535 @@
+package main
+
+import (
+ "bufio"
+ "fmt"
+ "math/rand"
+ "os"
+ "os/exec"
+ "runtime"
+ "strconv"
+ "time"
+ "unicode"
+)
+
+// Be able to clear screen
+func clearScreen() {
+ var cmd *exec.Cmd
+ if runtime.GOOS == "windows" {
+ cmd = exec.Command("cmd", "/c", "cls")
+
+ } else {
+ cmd = exec.Command("clear")
+ }
+ cmd.Stdout = os.Stdout
+ cmd.Run()
+}
+
+// handle file errors
+func handleError(err error) {
+ if err != nil {
+ panic(err)
+ }
+}
+
+// be able to read files
+func read(name string) {
+ file, err := os.Open(name)
+ handleError(err)
+
+ scanner := bufio.NewScanner(file)
+
+ for scanner.Scan() {
+ fmt.Println(scanner.Text())
+ }
+
+}
+
+// be able to proceed in story and lets user have time to read in story
+func proceed() {
+ reader := NewCinReader()
+ fmt.Print("\nEnter the letter C to continue: ")
+ unicode.ToUpper(reader.ReadCharacterSet([]rune("Cc")))
+ clearScreen()
+}
+
+func menu() {
+ reader := NewCinReader()
+
+ for {
+ // Display Menu
+ read("menu.txt")
+
+ // Ask user to pick option
+ fmt.Print("\nEnter the corresponding letter to select an option (p = Play | a = About): ")
+ option := unicode.ToUpper(reader.ReadCharacterSet([]rune("PpAa")))
+
+ // Option user, display about game section
+ if option == 'A' {
+ clearScreen()
+ read("about.txt")
+ fmt.Print("\nEnter the letter P when you are ready to play: ")
+ reader.ReadCharacterSet([]rune("Pp"))
+ }
+ clearScreen()
+ break
+ }
+}
+
+type data struct {
+ name string
+ age int
+ nation string
+ pieces int
+}
+
+func (explorer *data) intro() {
+ reader := NewCinReader()
+ // Ask user for explorer's info
+ fmt.Println("Before we begin this adventure, please fill in the upcoming prompts.")
+ fmt.Print("\nYour Explorer's name: ")
+ explorer.name = reader.ReadString(false)
+ fmt.Print("\nYour Explorer's Age: ")
+ explorer.age = reader.ReadIntegerRange(1, 150)
+
+ // Display Explorer nations to represent for user to input
+ fmt.Println(`
+ a = Netherlands
+ b = England
+ c = France
+ d = Portugal
+ e = Spain
+ `)
+
+ // Grab input of Explorer Nation
+ fmt.Print("Enter the letter corresponding above to the nation you will represent as an explorer: ")
+ nationChoice := unicode.ToUpper(reader.ReadCharacterSet([]rune("AaBbCcDdEe")))
+
+ // Set the explorer's nation
+ switch nationChoice {
+ case 'A':
+ explorer.nation = "Dutch"
+ case 'B':
+ explorer.nation = "English"
+ case 'C':
+ explorer.nation = "French"
+ case 'D':
+ explorer.nation = "Portuguese"
+ case 'E':
+ explorer.nation = "Spanish"
+ }
+
+ // Clear screen and display intro
+ clearScreen()
+ fmt.Printf("%s, a "+strconv.Itoa(explorer.age)+" year old explorer representing the "+explorer.nation+" crown. %s has been given the grand task to find Fountain of Youth, a rumored area existing in the new world which gives youth if you drink of the fountain of water, and it's treasure holds. You as the player must help %s find the Fountain of Youth and it's treasure before any of the other nations discover it. Back to the story, %s traveled to La Havana, Cuba, a famous trade port and launch point of explorers adventuring into the New World, to talk around to see if anyone had an information on a clue on finding this Fountain of Youth. While in La Havana, Cuba, %s decided to explore and talk to any other sailors or people in the local La Havana bar. While at the bar, %s meets this old white hair and bearded sailor with a black eyepatch on his right eye named Jean Ango, a French sailor who aside in Christopher Colombus's first voyage to the New World.", explorer.name, explorer.name, explorer.name, explorer.name, explorer.name, explorer.name)
+
+ // Ask user if they want to proceed in story
+ // If yes, clear screen and display following text
+ proceed()
+
+ fmt.Println(`Jean Ango:
+So I hear you want to find the Fountain of Youth. During my years as an active sailor I have heard great stories from other sailors about it wanting to find it granting them youth and other things. While in my youth, I have done a bit of research on this topic, I might be able to help you. In order in finding this Fountain of Youth you desire to find, you need to get this 4 pieces of a whole map leading to the treasure scattered around the islands of the Carribbean as follows:
+
+ 1. George Town, Cayman Islands
+ 2. Kingston, Jamaica
+ 3. Santo Domingo, Domincan Republic
+ 4. Port-au-Prince, Haiti
+
+But beware, there might be other explorers or pirates looking for what you desire as well to find. I have heard rumors Ponce de León, a Spanish explorer, is close to finding it, and has a big size crew with him. You might need to fight to death against León for the treasure. Good luck on your journey explorer, safe travels.
+
+`)
+ proceed()
+}
+
+// Guessing Game
+func guessValid() bool {
+ // Setup the random number generator
+ seed := rand.NewSource(time.Now().UnixNano())
+ RandomNumberGenerator := rand.New(seed)
+
+ // Pick a random number from 1-25 and store it.
+ randomNumber := RandomNumberGenerator.Intn(25) + 1
+
+ // User gets variable which holds 10 guesses.
+ var tries int = 10
+
+ // Ask the user to type a number from 1-25 to guess the random number and store it.
+ reader := NewCinReader()
+ for i := 0; i < 10; i++ {
+ fmt.Printf("Guesses remaining: %d", tries)
+ fmt.Print("\nType a number from 1 - 25 to guess the random number generate: ")
+ guess := reader.ReadIntegerRange(1, 25)
+ if guess == randomNumber {
+ // Guess was Correct!
+ fmt.Println("Correct number! You won!\n")
+ return true
+ } else {
+ // Guess was Incorrect!
+ fmt.Println("Incorrect number.\n")
+ tries -= 1
+ }
+ }
+ return false
+}
+
+func (explorer *data) cay() {
+ // Display Progress of map pieces found
+ fmt.Printf("You have found %d out of the 4 pieces of the map. \n\n", explorer.pieces)
+
+ // Display Cayman Island Intro
+ fmt.Println("First, " + explorer.name + " begins traveling to George Town, Cayman Islands. While there he meets a English pirate captain named William Aleyn at a local bar in Georgetown.")
+ proceed()
+ fmt.Println(`William Aleyn: So you told me you are looking for the piece for the Fountain of Youth lad. I have a piece of the map but I have a challenge for you. The challenge is you have to have to guess my number which is between 1 - 25. You have 10 guesses to attempt to guess my number correct. If you lose and do not guess the number correct, a new number will be generated and 10 guesses will be given again.
+`)
+ proceed()
+
+ // Start guessing game
+ for {
+ if guessValid() == true {
+ break
+ }
+ clearScreen()
+ }
+
+ // Add piece of map to track progress
+ fmt.Println(`William Aleyn: Good work. You have guessed my number correct. Here is the first piece of the map to the Fountain of Youth.`)
+ explorer.pieces += 1
+ proceed()
+}
+
+func (explorer *data) battle(emName string, health, damage, emHealth, emDamage int) bool {
+
+ // proceed()
+ reader := NewCinReader()
+
+ const (
+ kAttack rune = 'A'
+ kBlock rune = 'B'
+ kStam rune = 'S'
+ )
+
+ var (
+ round int = 1
+ usrStam int = 0
+ cpuStam int = 0
+ usrMove rune
+ cpuMove rune
+ )
+
+ for {
+ // Print Player & Enemy stats
+ fmt.Printf("%s vs %s \n\n", explorer.name, emName)
+ fmt.Printf("%s's Health: %d\n", explorer.name, health)
+ fmt.Printf("%s's Damage: %d\n\n", explorer.name, damage)
+ //fmt.Println(emName + fmt.Sprintf("'s Health: %d\n", emHealth) + emName + fmt.Sprintf("'s Damage: %d\n\n", emDamage))
+ fmt.Printf("%s's Health: %d\n", emName, health)
+ fmt.Printf("%s's Damage: %d\n\n", emName, emDamage)
+
+ // Generate User Move
+ switch usrStam {
+ case 0:
+ fmt.Print("Enter the letter of the move you want to perform. (S = Stamina | B = Block): ")
+ usrMove = unicode.ToUpper(reader.ReadCharacterSet([]rune("SsBb")))
+ case 1:
+ fmt.Print("Enter the letter of the move you want to perform. (A = Attack | B = Block): ")
+ usrMove = unicode.ToUpper(reader.ReadCharacterSet([]rune("AaBb")))
+ }
+
+ switch usrMove {
+ case kAttack:
+ fmt.Println("You attempt to attack.")
+ usrStam = 0
+ case kBlock:
+ fmt.Println(fmt.Sprintf("You have blocked any incoming possible attack against from %s.", emName))
+ case kStam:
+ fmt.Println("You attempt to regain stamina.")
+ usrStam = 1
+ }
+
+ //fmt.Println(round)
+ // Generate Computer Move
+ if round == 1 || (usrStam == 0 && cpuStam == 0) {
+ fmt.Println(emName + " Regains Stamina.")
+ round, cpuMove, cpuStam = 2, 'S', 1
+ } else {
+
+ // Loop until AI gets a valid move
+ for {
+ // AI Randomly Picks Move
+ ability := []rune{'A', 'B', 'S'}
+ cpuMove = ability[rand.Intn(len(ability))]
+
+ //fmt.Printf("%c\n", cpuMove)
+ if cpuMove == 'A' && cpuStam == 1 {
+ fmt.Println(emName + " attacks.")
+ cpuStam = 0
+ break
+ } else if cpuMove == 'B' {
+ fmt.Println(emName + " blocks.")
+ break
+ } else if cpuMove == 'S' && cpuStam == 0 {
+ fmt.Println(emName + " regains Stamina.")
+ cpuStam = 1
+ break
+ }
+ }
+ }
+
+ // Generate Outcomes of Fight
+ fmt.Println()
+ if usrMove == kAttack && cpuMove == kAttack {
+ // Draw Continue: User Attack = Computer Attack
+ fmt.Println("You both attack each other. No damage was made.")
+ } else if usrMove == kAttack && cpuMove == kBlock {
+ // Continue: User Attack = Computer Block
+ fmt.Println(emName + "has successfully blocked you.")
+ } else if usrMove == kAttack && cpuMove == kStam {
+ // Continue: User Attack = Computer Regains
+ fmt.Println(explorer.name + " have successfully attacked " + emName)
+ fmt.Printf("-%d damage.\n", damage)
+ emHealth -= damage
+ } else if usrMove == kBlock && cpuMove == kAttack {
+ // Continue: User Block = Computer Attack
+ fmt.Println(explorer.name + " has successfully blocked " + emName + "'s attack.")
+ } else if usrMove == kBlock && cpuMove == kBlock {
+ // Continue: User Block = Computer Block
+ fmt.Println("Continue on.")
+ } else if usrMove == kBlock && cpuMove == kStam {
+ // Continue: User Block = Computer Regains
+ fmt.Println("Continue on.")
+ } else if usrMove == kStam && cpuMove == kAttack {
+ // Continue: User Regains = Computer Throws
+ fmt.Println(emName + " has successfully attacked " + explorer.name)
+ fmt.Printf("-%d damage.\n", damage)
+ health -= damage
+ } else if usrMove == kStam && cpuMove == kBlock {
+ // Continue: User Regains = Computer Blocks
+ fmt.Println("Continue on.")
+ } else if usrMove == kStam && cpuMove == kStam {
+ // Continue: User Regains = Computer Regains
+ fmt.Println("Continue on! You both have regained stamina.")
+ }
+
+ // Check if game ended
+ if emHealth == 0 {
+ return true
+ } else if health == 0 {
+ // If explorer fails, restart game.
+ clearScreen()
+ fmt.Println("You have been eliminated. Try again.")
+ proceed()
+ return false
+ }
+ proceed()
+ }
+}
+
+// Jamaica Island
+func (explorer *data) jam() {
+ // Display Progress of map pieces found
+ fmt.Printf("You have found %d out of the 4 pieces of the map. \n\n", explorer.pieces)
+
+ // Display Jamaica Intro
+ fmt.Printf("After heading getting the first piece of the map from the Cayman Islands, %s traveled in his ship to the second location to find the next map piece, Kingston, Jamaica. While in Kingston, Jamaica, %s travels around and finds man by the name of James Alday in a local market in Kingston who was a tobacco farmer who claims he has a piece of the map. But in order to get the piece you have beat him a fighting brawl.\n", explorer.name, explorer.name)
+
+ // Start Battle
+ proceed()
+ fmt.Println(`Welcome to the fighting gamemode, a gamemode which you will use to battle other enemies against your explorer.
+
+How to play:
+
+You will be the following 2 of 3 options each turn to in the battle as it progresses.
+
+A = Attack:
+With the attack ability you can attack and do damage to the enemy but in order to throw you need one stamina point. Note: If you and the enemy at the same time attack, none of you do any damage to each other.
+
+B = Block:
+With the block ability you can block any attacks the other enemy does to you.
+
+S = Regain Stamina:
+With the regain stamina ability you can regain a stamina point in which you could use in the next round to attack the enemy.
+
+How to Win:
+In order to win, you must take all their health points away.
+ `)
+ proceed()
+
+ // Start Battle
+ for {
+ if explorer.battle("James Alday", 100, 50, 50, 50) == true {
+ break
+ }
+ clearScreen()
+ }
+
+ // Add piece of map to track progress
+ clearScreen()
+ fmt.Println("James Alday: I lost. Here is the next piece of the map.")
+ explorer.pieces += 1
+}
+
+// be able to answer in the quiz minigame
+func answer() rune {
+ reader := NewCinReader()
+ fmt.Print("\nEnter the corresponding letter to the option you wish to answer in: ")
+ answer := unicode.ToUpper(reader.ReadCharacterSet([]rune("AaBbCcDd")))
+ clearScreen()
+ return answer
+}
+
+func quiz() int {
+ // create var which holds score
+ var score int = 0
+ // Ask question and collect answer
+ // If answer correct, add to total score.
+ fmt.Println(`What is the capital of Cuba?
+a. La Havana
+b. Madrid
+c. Berlin
+d. Washington D.C.
+`)
+ if answer() == 'A' {
+ score += 1
+ }
+
+ fmt.Println(`What is the smallest country in the world?
+a. Denmark
+b. USA
+c. Vatican City
+d. Japan
+`)
+ if answer() == 'C' {
+ score += 1
+ }
+
+ fmt.Println(`Which religion dominated the Middle Ages?
+a. Protestantism
+b. Buddhism
+c. Catholicism
+d. Gnosticism
+`)
+ if answer() == 'C' {
+ score += 1
+ }
+
+ fmt.Println(`Which animal symbolizes good luck in Europe?
+a. Ladybug
+b. Lion
+c. Camel
+d. Cow
+`)
+ if answer() == 'A' {
+ score += 1
+ }
+
+ fmt.Println(`What is the name that used to refer to a group of frogs?
+a. Herd
+b. Frogs
+c. Army
+d. Colony
+`)
+ if answer() == 'C' {
+ score += 1
+ }
+
+ return score
+
+}
+
+func (explorer *data) dom() {
+ // Display Progress of map pieces found
+ fmt.Printf("You have found %d out of the 4 pieces of the map. \n\n", explorer.pieces)
+
+ // Display Domincan Republic Intro
+ fmt.Printf("Next, %s traveled in his ship to the third location to find the next map piece in Santo Domingo, Domincan Republic. While in Santo Domingo, %s runs into a Catholic monk named Baldassarre Cossa who has an some piece of the map.\n\n", explorer.name, explorer.name)
+ fmt.Println(`Baldassarre Cossa: Well hear you are looking for this piece. I will give it to you, but I am a fool who will ask you to fight me for it. Simply I desire you must get 4 out of 5 questions in trivia I will give you. I will not give my piece to fools who are not smart and will probably lose the piece of the map easily. If you fail, you must try again the trivia. Now let's begin...`)
+ proceed()
+
+ // Start Trivia
+ for {
+ if quiz() >= 4 {
+ break
+ }
+ clearScreen()
+ }
+
+ fmt.Println("Baldassarre Cossa: Well here is your map piece. You are an educated person. Well done.")
+ explorer.pieces += 1
+
+}
+
+func (explorer *data) hai() {
+ // Display Progress of map pieces found
+ fmt.Printf("You have found %d out of the 4 pieces of the map. \n\n", explorer.pieces)
+
+ // Display Domincan Republic Intro
+ fmt.Printf("Next, %s traveled in his ship to the forth and final location to find the last map piece in Port-au-Prince, Haiti. While in Santo Domingo, %s runs into a Catholic monk named Baldassarre Cossa who has an some piece of the map.\n\n", explorer.name, explorer.name)
+ fmt.Println(`Magnus Heinason: So you have all the pieces of the map but I still have the last one. You will have to beat me in a brawl for this one. I am not going to give up with an easy fight.`)
+ proceed()
+
+ // Start Battle
+ for {
+ if explorer.battle("Magnus Heinason", 100, 50, 100, 50) == true {
+ break
+ }
+ clearScreen()
+ }
+
+ // Add piece of map to track progress
+ clearScreen()
+ fmt.Println("Magnus Heinason: You fight well " + explorer.name + ". Now take this last piece of the map and get out here before any other seek this piece of the map.")
+ explorer.pieces += 1
+}
+
+func (explorer *data) final() {
+ // Display Progress of map pieces found
+ fmt.Printf("Nice job! You have found %d out of the 4 pieces of the map. \n\n", explorer.pieces)
+
+ fmt.Println("After getting all the pieces of the map, " + explorer.name + " traveled to an unknown territory which is now present day St. Augustine, Florida.")
+ fmt.Println("Next, " + explorer.name + " reads the clues and eventually you find the Fountain of Youth and it's glorious treasure.")
+ fmt.Println("But wait!!! You quickly discover a Spanish explorer by the name of Ponce de León there as well nearby the Fountain of Youth.")
+ fmt.Println("Ponce de León: So you want this treasure and this Fountain of Youth as well. Well you will have to fight me until the last breathe of my life. I will give my life to protect and take this treasure as much as I please. Get ready to die " + explorer.name + ".")
+
+ // Start Final Battle
+ for {
+ if explorer.battle("Ponce de León", 100, 50, 150, 50) == true {
+ break
+ }
+ clearScreen()
+ }
+
+ // Display treasure ascii and ending text
+ clearScreen()
+ read("treasure.txt")
+ fmt.Println(explorer.name + " has slain Ponce de León. You are victorious. Men and women shall hear and tell great tales about the great explorer name of " + explorer.name + ". The treasure and the Fountain of Youth is " + explorer.name + "'s to keep.\n\n")
+ fmt.Println("Thanks for playing as the legendary " + explorer.name + " in the great story of the Fountain of Youth! I hope you have enjoyed.")
+}
+
+func main() {
+ // Create a CinReader
+ reader := NewCinReader()
+
+ // Create Needed Variables
+ var (
+ again rune = 'Y'
+ explorer data
+ )
+
+ // Loop until the user no longer wants to play
+ // This is the Game Loop
+ for again == 'Y' {
+ explorer.pieces = 0
+ menu()
+ explorer.intro()
+ explorer.cay()
+ explorer.jam()
+ explorer.dom()
+ explorer.hai()
+ explorer.final()
+
+ // Prompt user to see if the want to continue to play
+ fmt.Print("Would you like to play again? (Y / N) ")
+ again = unicode.ToUpper(reader.ReadCharacterSet([]rune("YyNn")))
+ fmt.Println()
+ }
+}
diff --git a/go/fountain_of_youth_game/menu.txt b/go/fountain_of_youth_game/menu.txt
@@ -0,0 +1,8 @@
+The Fountain of Youth
+
+.------.
+| Play |
+'------'
+.-------.
+| About |
+'-------'
+\ No newline at end of file
diff --git a/go/fountain_of_youth_game/treasure.txt b/go/fountain_of_youth_game/treasure.txt
@@ -0,0 +1,19 @@
+ _.--.
+ _.-'_:-'||
+ _.-'_.-::::'||
+ _.-:'_.-::::::' ||
+ .'`-.-:::::::' ||
+ /.'`;|:::::::' ||_
+ || ||::::::' _.;._'-._
+ || ||:::::' _.-!oo @.!-._'-.
+ \'. ||:::::.-!()oo @!()@.-'_.|
+ '.'-;|:.-'.&$@.& ()$%-'o.'\U||
+ `>'-.!@%()@'@_%-'_.-o _.|'||
+ ||-._'-.@.-'_.-' _.-o |'||
+ ||=[ '-._.-\U/.-' o |'||
+ || '-.]=|| |'| o |'||
+ || || |'| _| ';
+ || || |'| _.-'_.-'
+ |'-._ || |'|_.-'_.-'
+ '-._'-.|| |' `_.-'
+ '-.||_/.-'