Skip to content

Commit

Permalink
#676 Adds more attributes for planetary status.
Browse files Browse the repository at this point in the history
Creates base.json for planetary status and method to get all.
  • Loading branch information
tuomount committed Mar 31, 2024
1 parent 140980e commit 26a7014
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/*
* Open Realm of Stars game project
* Copyright (C) 2023 BottledByte
* Copyright (C) 2024 Tuomo Untinen
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -83,7 +84,11 @@ public static boolean isConflictingWith(final PlanetaryStatus status,
private int prodBonus;
/** Bonus/malus to credits production */
private int credBonus;

/** Status is not visible, until it is applied. This cannot be revealed even
* by sending away team. */
private boolean hidden;
/** Status can be found with away team */
private boolean awayTeam;
/**
* Create new planetary status definition
* @param id ID of planetary status definition
Expand All @@ -97,6 +102,8 @@ public static boolean isConflictingWith(final PlanetaryStatus status,
this.name = Objects.requireNonNull(name);
this.description = Objects.requireNonNull(description);
this.conflictingIds = Objects.requireNonNull(conflictingIds);
this.hidden = false;
this.setAwayTeam(false);
}

/**
Expand Down Expand Up @@ -202,4 +209,32 @@ void setCredBonus(final int credBonus) {
this.credBonus = credBonus;
}

/**
* @return the hidden
*/
public boolean isHidden() {
return hidden;
}

/**
* @param hidden the hidden to set
*/
public void setHidden(final boolean hidden) {
this.hidden = hidden;
}

/**
* @return the awayTeam
*/
public boolean isAwayTeam() {
return awayTeam;
}

/**
* @param awayTeam the awayTeam to set
*/
public void setAwayTeam(final boolean awayTeam) {
this.awayTeam = awayTeam;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/*
* Open Realm of Stars game project
* Copyright (C) 2023 BottledByte
* Copyright (C) 2024 Tuomo Untinen
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -92,6 +93,25 @@ private void init() {
ErrorLogger.log("Loaded planetary statuses: " + loadedTotal);
}

/**
* Create/Retrieve all planetary statuses, initialize factory if not yet
* @return Status array
*/
private PlanetaryStatus[] getAll() {
if (!initialized) {
initialized = true;
init();
}
return validStatuses.values().toArray(new PlanetaryStatus[0]);
}

/**
* Get All statuses in array.
* @return Statuses array
*/
public static PlanetaryStatus[] getValues() {
return SINGLETON.getAll();
}
}

/** PlanetaryStatus JSON data loader */
Expand Down Expand Up @@ -128,6 +148,8 @@ protected Optional<PlanetaryStatus> parseFromJson(final JSONObject jobj) {
tmp.setProdBonus(jobj.optInt("prodBonus", 0));
tmp.setHappinessBonus(jobj.optInt("happinesBonus", 0));
tmp.setCredBonus(jobj.optInt("credBonus", 0));
tmp.setHidden(jobj.optBoolean("hidden", false));
tmp.setAwayTeam(jobj.optBoolean("awayTeam", false));

return Optional.of(tmp);
}
Expand Down
38 changes: 37 additions & 1 deletion src/main/resources/resources/data/planet_statuses/base.json
Original file line number Diff line number Diff line change
@@ -1 +1,37 @@
[]
[
{
"id": "METAL_RICH_SURFACE",
"name": "Metal rich surface",
"description": "Planet's surface is covered with easy access metal. This will grant one extra metal per star year.",
"conflictsWith": [
"FERTILE_SOIL",
"MOLTEN_LAVA"
],
"mineBonus": 1,
"awayTeam": true
},
{
"id": "FERTILE_SOIL",
"name": "Fertile soil",
"description": "Planet's surface has fertile soil where plants grow faster. This will grant one extra food per star year.",
"conflictsWith": [
"METAL_RICH_SURFACE",
"MOLTEN_LAVA"
],
"foodBonus": 1,
"awayTeam": true
},
{
"id": "MOLTEN_LAVA",
"name": "Molten lava",
"description": "Planet surface has big lava pool or river. This can be used to easy access metal and temperature can be used to increase productivity, downside is this cause unhappiness to population.",
"conflictsWith": [
"FERTILE_SOIL",
"METAL_RICH_SURFACE"
],
"mineBonus": 1,
"prodBonus": 1,
"happinessBonus": -1,
"awayTeam": true
}
]

0 comments on commit 26a7014

Please sign in to comment.