Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RepairRule as subclass to ProductionRule #12985

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
public class ProductionRule extends DefaultNamed implements Rule {
private static final long serialVersionUID = -6598296283127741307L;

private IntegerMap<Resource> costs = new IntegerMap<>();
private IntegerMap<NamedAttachable> results = new IntegerMap<>();
protected IntegerMap<Resource> costs = new IntegerMap<>();
protected IntegerMap<NamedAttachable> results = new IntegerMap<>();

public ProductionRule(final String name, final GameData data) {
super(name, data);
Expand Down Expand Up @@ -41,7 +41,7 @@ public IntegerMap<NamedAttachable> getResults() {

@Override
public String toString() {
return "ProductionRule:" + getName();
return "ProductionRule: " + getName();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
import org.triplea.java.collections.IntegerMap;

/** A repair rule. */
public class RepairRule extends DefaultNamed implements Rule {
public class RepairRule extends ProductionRule {
private static final long serialVersionUID = -45646671022993959L;

private final IntegerMap<Resource> costs;
private final IntegerMap<NamedAttachable> results;

public RepairRule(final String name, final GameData data) {
this(name, data, new IntegerMap<>(), new IntegerMap<>());
}
Expand All @@ -20,31 +17,14 @@ public RepairRule(
final GameData data,
final IntegerMap<NamedAttachable> results,
final IntegerMap<Resource> costs) {
super(name, data);
super(name, data, results, costs);

checkNotNull(results);
checkNotNull(costs);

this.costs = new IntegerMap<>(costs);
this.results = new IntegerMap<>(results);
}

public void addCost(final Resource resource, final int quantity) {
costs.put(resource, quantity);
}

@Override
public IntegerMap<Resource> getCosts() {
return new IntegerMap<>(costs);
}

@Override
public IntegerMap<NamedAttachable> getResults() {
return results;
}

@Override
public String toString() {
return "RepairRule:" + getName();
return "RepairRule: " + getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
public class RepairRules extends GameDataComponent {
private static final long serialVersionUID = 8153102637443800391L;

private final Map<String, RepairRule> repairRules = new HashMap<>();
private final Map<String, RepairRule> mapRepairRules = new HashMap<>();

public RepairRules(final GameData data) {
super(data);
}

public void addRepairRule(final RepairRule pf) {
repairRules.put(pf.getName(), pf);
mapRepairRules.put(pf.getName(), pf);
}

public RepairRule getRepairRule(final String name) {
return repairRules.get(name);
return mapRepairRules.get(name);
}

public Collection<RepairRule> getRepairRules() {
return repairRules.values();
return mapRepairRules.values();
}
}
Loading