Adding objectives is a little bit trickier than adding players and quests. We will need to do this manually, because the way objectives are stored in the database requires that we run a Gradle task to have the FreshmanRPG project add the objective for us.
If you are doing this on your local server, open IntelliJ. Any changes that must be made any files can be made here.
If you are doing this on the production server, SSH in to the server first. If you do not know how to use SSH, there is a guide [here.](Connecting With SSH) Any changes that must be made to any files must be made through SSH on the production server.
# The Process
Here is the general process. If you know your way around Gradle tasks, linux commands, and MySQL queries, then you should be able to just follow this general guide. Otherwise, read this and then continue to the next section, choosing the section depending on whether you are doing this on the local or remote servers.
1. In the GameServer folder, open `ObjectivesToAdd.csv`
2. Clear this file to avoid errors with duplicate entries.
3. Create the new objective with the following format:
- name,latitude,longitude,questID,objectiveID
- name: the name that the new objective will have.
- questID: can be found by querying the database's `Quests` table and comparing the descriptions to find the correct quest.
- objectiveID: query the database's `Objectives` table and find the objective with the highest ID. Make the objectiveID for your new quest 1 higher.
- For instance, if the last objectiveID is 23, then specify 24 as your new objective's objectiveID.
- latitude/longitude: the coordinates where the QR code must be scanned.
4. Ensure that *only* the MySQL Docker container is running, not the other servers.
5. Run the `DBAddProductionObjectives` Gradle task, using `gradlew` in the `FreshmanRPG` folder.
6. Restart the other servers.
The objective should now be added to the database! If you need to link the new quests and objectives to players so they can scan/complete them, follow [this guide](Linking-Players-Objectives).
# Doing it Locally (IntelliJ)
1. Open Docker.
2. Click the 3 dots next to the frpg_mysql container.
3. Click `Open in Terminal`.
4. Run these commands (in order):
- use frpg;
- select * from Quests;
- look for the quest you created in the game manager. The quest description should be there. <u>Take note of the quest ID</u>.
- select * from Objectives;
- find the objective with the highest ID. <u>Take note of the *highest* objectiveID.</u>
- exit
5. In IntelliJ, open the GameServer folder, and open `ObjectivesToAdd.csv`
6. Follow steps 2 and 3 in the `The Process` section outlined above.
7. If you have any servers running (other than Docker), stop them. Do not stop Docker.
8. In Intellij, on the rightmost panel, you should see a Gradle button. Click it.
9. A new panel should be open. Navigate through this path in the panel:
-`GameServer > Tasks > other > DBAddProductionObjectives`
10. Run the DBAddProductionObjectives task.
The objective should now be added to the database! If you need to link the new quests and objectives to players so they can scan/complete them, follow [this guide](Linking-Players-Objectives).
# Doing it Remotely (SSH)
1. SSH in to the production server.
2. Run these commands (in order):
- docker exec -it frpg_mysql mysql
- use frpg;
- select * from Quests;
- look for the quest you created in the game manager. The quest description should be there. <u>Take note of the quest ID</u>.
- select * from Objectives;
- find the objective with the highest ID. <u>Take note of the *highest* objectiveID.</u>
- exit
- cd FreshmanRPGSuite/FreshmanRPG/GameServer
- nano ObjectivesToAdd.csv
- now you must add new objectives to this file. Follow steps 2 and 3 outlined in the `The Process` section above.
**Before doing this next part, check with Dr. Wellington if it's fines to shut down the servers for a bit, especially if it's during a semester when students might be playing the game or scanning QR codes.**
- frpg down
- frpg compose up -d frpg_mysql
- ../gradlew DBAddProductionObjectives
- frpg up
The objective should now be added to the database! If you need to link the new quests and objectives to players so they can scan/complete them, follow [this guide](Linking-Players-Objectives).