Initial commit
This commit is contained in:
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
|
||||
Reference in New Issue
Block a user