Initial commit
This commit is contained in:
commit
dd955b6166
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -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.
|
11
lib/dock.jl
Normal file
11
lib/dock.jl
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/julia
|
||||||
|
|
||||||
|
include("player.jl")
|
||||||
|
function main_dock()
|
||||||
|
|
||||||
|
print("\nWill be the main dock\n")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
17
lib/flight.jl
Executable file
17
lib/flight.jl
Executable file
@ -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")
|
64
lib/player.jl
Executable file
64
lib/player.jl
Executable file
@ -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
|
43
lib/saveGame.jl
Normal file
43
lib/saveGame.jl
Normal file
@ -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
|
10
src/spacetrack.jl
Executable file
10
src/spacetrack.jl
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/julia
|
||||||
|
|
||||||
|
include("../lib/player.jl")
|
||||||
|
function main_menu()
|
||||||
|
create_pilot()
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
main_menu()
|
Loading…
x
Reference in New Issue
Block a user