Class MetricController
- java.lang.Object
 - 
- bytemusketeers.heslingtonhustle.metrics.MetricController
 
 
- 
public class MetricController extends java.lang.ObjectAMetricControllerstores and manages manyMetricEntryitems and their associatedMetricController.Metrickeys, providing a unified interface through which higher-level controllers may manipulate the values ofMetricEntryobjects 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 classMetricController.MetricDistinguish between the standard metrics represented in theMetricEntryobjects 
- 
Field Summary
Fields Modifier and Type Field Description private java.util.Map<MetricController.Metric,MetricEntry>metricsThe associative key-value map betweenMetricController.Metricidentifiers andMetricEntrystorage classesprivate MetricUpdaterupdateActionThe callback to execute following anyMetricEntryvalue updates 
- 
Constructor Summary
Constructors Constructor Description MetricController(MetricUpdater updateAction)Instantiates a newMetricControllerand populates themetricswith sensible defaults 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadvanceDOWMetric()Advances the day-of-the-week metric: theMetricEntryassociated withMetricController.Metric.DayvoidchangeAreaMetric(Area.Name areaName)Updates the area metric with the givenArea.Name: theMetricEntryassociated withMetricController.Metric.AreavoiddecrementPlayerMetric(MetricController.Metric metric, int multiplier)Decrements the specifiedPlayerMetricwith the given integral multiplierprivate MetricEntrygetDynamicMetricEntry(java.lang.Class<? extends MetricEntry> metricType, MetricController.Metric metric)Retrieves aMetricEntryof the given variety associated with the givenMetricController.Metrickeyjava.lang.StringgetMetricStringValue(MetricController.Metric metric)voidincrementPlayerMetric(MetricController.Metric metric, int multiplier)Increments the specifiedPlayerMetricwith the given integral multiplierbooleanisFinalDay()Does theDOWMetricentry suggested that the end is nigh? 
 - 
 
- 
- 
Field Detail
- 
updateAction
private final MetricUpdater updateAction
The callback to execute following anyMetricEntryvalue updates- See Also:
 MetricUpdater
 
- 
metrics
private final java.util.Map<MetricController.Metric,MetricEntry> metrics
The associative key-value map betweenMetricController.Metricidentifiers andMetricEntrystorage classes 
 - 
 
- 
Constructor Detail
- 
MetricController
public MetricController(MetricUpdater updateAction)
Instantiates a newMetricControllerand populates themetricswith sensible defaults- See Also:
 MetricEntry
 
 - 
 
- 
Method Detail
- 
getDynamicMetricEntry
private MetricEntry getDynamicMetricEntry(java.lang.Class<? extends MetricEntry> metricType, MetricController.Metric metric)
Retrieves aMetricEntryof the given variety associated with the givenMetricController.Metrickey- Parameters:
 metricType- The expected received value-type frommetricsmetric- TheMetricController.Metricassociated 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 specifiedPlayerMetricwith the given integral multiplier- Parameters:
 metric- The key associated with the targetPlayerMetricmultiplier- The integral multiplier- See Also:
 PlayerMetric.incrementMetric(int)
 
- 
decrementPlayerMetric
public void decrementPlayerMetric(MetricController.Metric metric, int multiplier)
Decrements the specifiedPlayerMetricwith the given integral multiplier- Parameters:
 metric- The key associated with the targetPlayerMetricmultiplier- The integral multiplier- See Also:
 PlayerMetric.decrementMetric(int)
 
- 
advanceDOWMetric
public void advanceDOWMetric()
Advances the day-of-the-week metric: theMetricEntryassociated withMetricController.Metric.Day- See Also:
 DOWMetric.nextDay()
 
- 
isFinalDay
public boolean isFinalDay()
Does theDOWMetricentry 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: theMetricEntryassociated 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.Metrickey associated with the desiredMetricEntry- Returns:
 - A human-readable formatted 
Stringrepresenting the value of the requestedMetricEntry - See Also:
 MetricEntry.getValue()
 
 - 
 
 -