Class MetricController
- java.lang.Object
-
- bytemusketeers.heslingtonhustle.metrics.MetricController
-
public class MetricController extends java.lang.Object
AMetricController
stores and manages manyMetricEntry
items and their associatedMetricController.Metric
keys, providing a unified interface through which higher-level controllers may manipulate the values ofMetricEntry
objects and post runtime alteration updates to theMetricUpdater
.- Author:
- ENG1 Team 23 (Cohort 3)
- See Also:
MetricEntry
,MetricUpdater
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MetricController.Metric
Distinguish between the standard metrics represented in theMetricEntry
objects
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<MetricController.Metric,MetricEntry>
metrics
The associative key-value map betweenMetricController.Metric
identifiers andMetricEntry
storage classesprivate MetricUpdater
updateAction
The callback to execute following anyMetricEntry
value updates
-
Constructor Summary
Constructors Constructor Description MetricController(MetricUpdater updateAction)
Instantiates a newMetricController
and populates themetrics
with sensible defaults
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
advanceDOWMetric()
Advances the day-of-the-week metric: theMetricEntry
associated withMetricController.Metric.Day
void
changeAreaMetric(Area.Name areaName)
Updates the area metric with the givenArea.Name
: theMetricEntry
associated withMetricController.Metric.Area
void
decrementPlayerMetric(MetricController.Metric metric, int multiplier)
Decrements the specifiedPlayerMetric
with the given integral multiplierprivate MetricEntry
getDynamicMetricEntry(java.lang.Class<? extends MetricEntry> metricType, MetricController.Metric metric)
Retrieves aMetricEntry
of the given variety associated with the givenMetricController.Metric
keyjava.lang.String
getMetricStringValue(MetricController.Metric metric)
void
incrementPlayerMetric(MetricController.Metric metric, int multiplier)
Increments the specifiedPlayerMetric
with the given integral multiplierboolean
isFinalDay()
Does theDOWMetric
entry suggested that the end is nigh?
-
-
-
Field Detail
-
updateAction
private final MetricUpdater updateAction
The callback to execute following anyMetricEntry
value updates- See Also:
MetricUpdater
-
metrics
private final java.util.Map<MetricController.Metric,MetricEntry> metrics
The associative key-value map betweenMetricController.Metric
identifiers andMetricEntry
storage classes
-
-
Constructor Detail
-
MetricController
public MetricController(MetricUpdater updateAction)
Instantiates a newMetricController
and populates themetrics
with sensible defaults- See Also:
MetricEntry
-
-
Method Detail
-
getDynamicMetricEntry
private MetricEntry getDynamicMetricEntry(java.lang.Class<? extends MetricEntry> metricType, MetricController.Metric metric)
Retrieves aMetricEntry
of the given variety associated with the givenMetricController.Metric
key- Parameters:
metricType
- The expected received value-type frommetrics
metric
- TheMetricController.Metric
associated with the desiredMetricEntry
, of the given type- Returns:
- The requested
MetricEntry
, or null if there was a type mismatch or nonexistent key
-
incrementPlayerMetric
public void incrementPlayerMetric(MetricController.Metric metric, int multiplier)
Increments the specifiedPlayerMetric
with the given integral multiplier- Parameters:
metric
- The key associated with the targetPlayerMetric
multiplier
- The integral multiplier- See Also:
PlayerMetric.incrementMetric(int)
-
decrementPlayerMetric
public void decrementPlayerMetric(MetricController.Metric metric, int multiplier)
Decrements the specifiedPlayerMetric
with the given integral multiplier- Parameters:
metric
- The key associated with the targetPlayerMetric
multiplier
- The integral multiplier- See Also:
PlayerMetric.decrementMetric(int)
-
advanceDOWMetric
public void advanceDOWMetric()
Advances the day-of-the-week metric: theMetricEntry
associated withMetricController.Metric.Day
- See Also:
DOWMetric.nextDay()
-
isFinalDay
public boolean isFinalDay()
Does theDOWMetric
entry suggested that the end is nigh?- Returns:
- Is the game on the final day?
-
changeAreaMetric
public void changeAreaMetric(Area.Name areaName)
Updates the area metric with the givenArea.Name
: theMetricEntry
associated withMetricController.Metric.Area
- Parameters:
areaName
- The updatedArea.Name
- See Also:
AreaMetric.setArea(Area.Name)
-
getMetricStringValue
public java.lang.String getMetricStringValue(MetricController.Metric metric)
- Parameters:
metric
- TheMetricController.Metric
key associated with the desiredMetricEntry
- Returns:
- A human-readable formatted
String
representing the value of the requestedMetricEntry
- See Also:
MetricEntry.getValue()
-
-