feat: restore hooks for flags, quest progress, switch state
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package thb.jeanluc.adventure.game;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
@@ -24,4 +25,10 @@ public class GameState {
|
||||
public Set<String> all() {
|
||||
return Collections.unmodifiableSet(flags);
|
||||
}
|
||||
|
||||
/** Replaces all flags with the given collection (used by load). */
|
||||
public void restore(Collection<String> newFlags) {
|
||||
flags.clear();
|
||||
flags.addAll(newFlags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package thb.jeanluc.adventure.game;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
@@ -46,4 +47,12 @@ public class QuestLog {
|
||||
public Set<String> completed() {
|
||||
return Collections.unmodifiableSet(completed);
|
||||
}
|
||||
|
||||
/** Replaces all progress with the given stage map and completed set (load). */
|
||||
public void restore(Map<String, Integer> stages, Collection<String> completedIds) {
|
||||
stageIndex.clear();
|
||||
stageIndex.putAll(stages);
|
||||
completed.clear();
|
||||
completed.addAll(completedIds);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,4 +53,14 @@ public class SwitchableItem extends Item {
|
||||
public boolean isOn() {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly sets the on/off state without running effects or printing.
|
||||
* Used only when restoring a saved game.
|
||||
*
|
||||
* @param state the state to restore
|
||||
*/
|
||||
public void setState(boolean state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user