Skip to content

Commit

Permalink
Reformat TeamResearchData
Browse files Browse the repository at this point in the history
  • Loading branch information
yuesha-yc committed Jan 18, 2025
1 parent ceda042 commit 6d960d6
Show file tree
Hide file tree
Showing 5 changed files with 445 additions and 333 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
import com.mojang.serialization.codecs.RecordCodecBuilder;
import com.teammoeg.chorda.util.io.codec.CompressDifferCodec;

import lombok.ToString;
import net.minecraft.nbt.CompoundTag;

@ToString
public class ClueData{
public static final Codec<ClueData> FULL_CODEC=RecordCodecBuilder.create(t->t.group(
Codec.BOOL.fieldOf("completed").forGetter(o->o.completed),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.teammoeg.frostedheart.content.research.research.effects.Effect;
import com.teammoeg.chorda.util.evaluator.IEnvironment;
import com.teammoeg.chorda.util.io.CodecUtil;
import lombok.Getter;

public class ResearchData implements IEnvironment {

Expand Down Expand Up @@ -149,13 +150,41 @@ public ResearchDataPacket(int committed, boolean[] flags, int level, List<ClueDa
this(flags[0],flags[1],level,committed,clueData,BitSet.valueOf(effectData));
}
}
@Getter
boolean active;// is all items fulfilled?
@Getter
boolean finished;
int level;
private int committed;// points committed
@Getter
private Map<String, ClueData> clueData = new HashMap<>();
@Getter
private Map<String, Boolean> effectData = new HashMap<>();
public static final Codec<ResearchData> CODEC=RecordCodecBuilder.create(t->t.group(


public List<String> getFieldNames() {
return List.of("active","finished","level","committed","clueData","effectData");
}

public Object getField(String key) {
return switch (key) {
case "active" -> active;
case "finished" -> finished;
case "level" -> level;
case "committed" -> committed;
case "clueData" -> clueData;
case "effectData" -> effectData;
default -> "no such field";
};
}

@Override
public String toString() {
return "ResearchData [active=" + active + ", finished=" + finished + ", level=" + level + ", committed=" + committed
+ ", clueData=" + clueData + ", effectData=" + effectData + "]";
}

public static final Codec<ResearchData> CODEC=RecordCodecBuilder.create(t->t.group(
Codec.INT.fieldOf("committed").forGetter(o->o.committed),
CodecUtil.<ResearchData>booleans("flags")
.flag("active", o->o.active)
Expand Down
Loading

0 comments on commit 6d960d6

Please sign in to comment.