Hello,
I am working on a small game and at the moment, I have a problem concerning saving my objects.
I have a class "Task", which handles the quests for the player:
I don't want to write the tasks in the sourcecode, but to use a seperate file to store them. This should be made to add, modify and remove tasks easily.
The file in which the tasks are saved should be readable for the user and usable by the program.
I would like the file to look a bit like this:
name: task 1
type: task type A
text: dummy text 1
probability: 0.75
name: task 2
type: task type B
text: dummy text 2
probability: 1.0
[...]
I did some research and found out that xml or json might suit my needs, but I don't find a real tutorial for it which fits my use case.
I was able to create a json file with methods from org.json, but I don't understand how I could write more than one object to a file and how to read them back in. Do I have to create an own file for each instance of task? During runtime, the tasks are saved in an ArrayList<Task>. I would prefer to just save the list.
It might be important to notice that this game should be used on Android, which seems to restrict the use of some xml instructions. At least it was not possible for me to create an xml file out of my
test object.
Can anybody give me a hint what to do? Is there maybe amother possibility I did not recognize yet? I am pretty lost at the moment...