From dd955b6166529c540cb30d92f07b4ea4f92aebce Mon Sep 17 00:00:00 2001 From: mollusk Date: Tue, 20 Nov 2018 17:23:43 -0700 Subject: [PATCH] Initial commit --- LICENSE | 21 ++++++++++++++++ README.md | 0 lib/dock.jl | 11 ++++++++ lib/flight.jl | 17 +++++++++++++ lib/player.jl | 64 +++++++++++++++++++++++++++++++++++++++++++++++ lib/saveGame.jl | 43 +++++++++++++++++++++++++++++++ src/spacetrack.jl | 10 ++++++++ 7 files changed, 166 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 lib/dock.jl create mode 100755 lib/flight.jl create mode 100755 lib/player.jl create mode 100644 lib/saveGame.jl create mode 100755 src/spacetrack.jl diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4ad549d --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Justin Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/lib/dock.jl b/lib/dock.jl new file mode 100644 index 0000000..f8e3812 --- /dev/null +++ b/lib/dock.jl @@ -0,0 +1,11 @@ +#!/usr/bin/julia + +include("player.jl") +function main_dock() + + print("\nWill be the main dock\n") + + + + +end \ No newline at end of file diff --git a/lib/flight.jl b/lib/flight.jl new file mode 100755 index 0000000..d98fe97 --- /dev/null +++ b/lib/flight.jl @@ -0,0 +1,17 @@ +#!/usr/bin/julia + +include("player.jl") + +function take_off(playerName, shipName) + + local p = Pilot() + local s = Ship() + local p.Name = playerName + local s.Name = shipName + + print(p.Name, " starts the ship and takes off in ", s.Name, "!\n") + + +end + +take_off("Jerry", "Falcon") \ No newline at end of file diff --git a/lib/player.jl b/lib/player.jl new file mode 100755 index 0000000..c2d3c04 --- /dev/null +++ b/lib/player.jl @@ -0,0 +1,64 @@ +#!/usr/bin/julia + +include("saveGame.jl") + +mutable struct Pilot + Name::String + Planet::String + Pilot() = new() +end + +mutable struct Ship + Name::String + Class::String + Speed::Float64 + Ship() = new() +end + + + +function create_pilot() + print("\nWhat name for new pilot?: ") + pname = readline() + + print("What name for ship?: ") + sname = readline() + + pilot = Pilot() + ship = Ship() + + playerId = "100" + pilot.Name = pname + ship.Name = sname + + + print("\nYour Pilot's Name is: ", pilot.Name, "\n") + print("Your Ship's name is: ", ship.Name, "\n\n") + + print("Is this correct? [Y/n]: ") + pconfirm = readline() + + if pconfirm == "y" + + + + if isdir(saveDir) == true && isfile(saveFile) == true + print("Do you want to overwrite previous game?[y/N]: " ) + overwrite = readline() + + if overwrite == "y" + savegame(playerId, pilot.Name, ship.Name, true) + println("Game saved to: ", saveFile) + else + exit(0) + end + else + savegame(playerId, pilot.Name, ship.Name, true) + println("Game saved to: ", saveFile) + end + + else + println("Exiting") + exit(0) + end +end \ No newline at end of file diff --git a/lib/saveGame.jl b/lib/saveGame.jl new file mode 100644 index 0000000..5503201 --- /dev/null +++ b/lib/saveGame.jl @@ -0,0 +1,43 @@ +saveDir = "~/.config/spacetrack" + + + +function savegame( + playerid::String, + playerName::String, + shipName::String, + createSave::Bool + ) + + local io = IOBuffer() + + + + if createSave == true + mkpath(saveDir) + + print("Name youe save file: ") + saveFileName = readline() + + if isempty(saveFileName) == true + + global saveFile = untitled.conf + else + + saveFile = saveFileName + end + + open("$saveDir/$saveFile", "w") do io + write(io, "player-id = ", playerid, "\n") + write(io, "pilot-name = ", playerName, "\n"); + write(io, "ship-name = ", shipName, "\n"); + end; + + close(io) + end + + return saveFile + +end + +saveFile = saveFile \ No newline at end of file diff --git a/src/spacetrack.jl b/src/spacetrack.jl new file mode 100755 index 0000000..ba0da8f --- /dev/null +++ b/src/spacetrack.jl @@ -0,0 +1,10 @@ +#!/usr/bin/julia + +include("../lib/player.jl") +function main_menu() + create_pilot() + + +end + +main_menu()