Package name.moore.kevin.ze.game
Class gamefile
java.lang.Object
name.moore.kevin.ze.game.gamefile
A game file is a snapshot of the gameplay and settings that can be saved and
reloaded to/from disk.
The class is focused on reading and writing a XML format snapshot of the gamefile. Once parsed it is used populate the runtime entities, components for actual gameplay.
All games run relative to the install directory, files and resources are relative to that location.
<?xml version="1.0" ?><game><starDate>25 Dec 2410</starDate></game>- Author:
- Kevin Moore
<dev@kevin.moore.name>
-
Field Summary
FieldsModifier and TypeFieldDescriptionList of the processed <faction> elements, stored as faction objects.private Fileprivate static org.slf4j.Loggerprivate FileThe filename of the starmap used in this game.private LocalDateTimeRealworld timestamp of the last save of this gamefile as XML element <saved>>2021-06-14T21:46:58.547886</saved>.List of the processed <ship> elements, stored as ship objects.private starDateThe current in-gamefile datetime as XML element <stardate>>01 Jun 2456</stardate>>.private static starDatestatic com.thoughtworks.xstream.XStreamExpects a valid XStream instance to be provided by the caller. -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
xstream
public static com.thoughtworks.xstream.XStream xstreamExpects a valid XStream instance to be provided by the caller. The xstream instance must register this class as a converter as well. -
STARTDATE
-
stardate
The current in-gamefile datetime as XML element <stardate>>01 Jun 2456</stardate>>. Required. -
mapf
@XStreamConverter(com.thoughtworks.xstream.converters.extended.FileConverter.class) private File mapfThe filename of the starmap used in this game. The actual map is parsed elsewhere. -
factions
List of the processed <faction> elements, stored as faction objects. -
ships
List of the processed <ship> elements, stored as ship objects. -
saved
@XStreamConverter(com.thoughtworks.xstream.converters.time.LocalDateTimeConverter.class) private LocalDateTime savedRealworld timestamp of the last save of this gamefile as XML element <saved>>2021-06-14T21:46:58.547886</saved>. Required and defaults to LocalDateTime.now(). -
loadedFrom
-
-
Constructor Details
-
gamefile
public gamefile()
-
-
Method Details
-
getStardate
- Returns:
-
getSaved
- Returns:
-
getMapf
The filename that was recorded in the gamefile file.- Returns:
-
getFactions
The faction objects loaded from the file.- Returns:
-
getShips
- Returns:
-
load
Create a new game by loading a specified XML file.The file is parsed by this class into 'this' and is relative to the working directory.
Requires a valid XStream object injected.
- Parameters:
gf-
-