feat(D-01): implement ResistanceComponent, improve stack-aware resistance lookup
This commit is contained in:
@@ -2,11 +2,31 @@ package com.tiedup.remake.v2.bondage.component;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
/**
|
||||
* Component: struggle resistance for data-driven items.
|
||||
*
|
||||
* JSON config: {@code "resistance": {"base": 150}}
|
||||
*/
|
||||
public class ResistanceComponent implements IItemComponent {
|
||||
|
||||
private ResistanceComponent() {}
|
||||
private final int baseResistance;
|
||||
|
||||
private ResistanceComponent(int baseResistance) {
|
||||
this.baseResistance = baseResistance;
|
||||
}
|
||||
|
||||
public static IItemComponent fromJson(JsonObject config) {
|
||||
return new ResistanceComponent();
|
||||
int base = 100;
|
||||
if (config != null && config.has("base")) {
|
||||
base = config.get("base").getAsInt();
|
||||
}
|
||||
return new ResistanceComponent(base);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the base resistance for this item.
|
||||
*/
|
||||
public int getBaseResistance() {
|
||||
return baseResistance;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user