package net.rk.splendid.dao.entities;

import com.google.common.collect.Lists;
import net.rk.splendid.dto.PlayerHand;
import net.rk.splendid.dto.ResourceFactory;
import org.springframework.util.Assert;

import java.util.List;

public class OfyPlayerHand {
  private List<OfyResourceFactory> factories = Lists.newArrayList();
  private OfyResourceMap resources = new OfyResourceMap();

  OfyPlayerHand() {}

  public static PlayerHand toDto(OfyPlayerHand ofyPlayerHand) {
    return new PlayerHand(
        ofyPlayerHand.factories.stream().map(OfyResourceFactory::toDto).toArray(ResourceFactory[]::new),
        OfyResourceMap.toResourceArray(ofyPlayerHand.resources));
  }

  public OfyResourceMap getResources() {
    return resources;
  }

  public OfyResourceMap getFactoryResources() {
    OfyResourceMap resourceMap = new OfyResourceMap();
    for (OfyResourceFactory factory : factories) {
      resourceMap = resourceMap.increment(factory.getResource());
    }
    return resourceMap;
  }

  public void setResources(OfyResourceMap resources) {
    this.resources = resources;
  }

  public void addFactory(OfyResourceFactory factory) {
    Assert.notNull(factory, "Attempting to add a null factory.");
    factories.add(factory);
  }

  public static OfyPlayerHand create() {
    return new OfyPlayerHand();
  }
}

@@ -847,73 +847,29 @@
    f
-or (OfyResourceFactory factory : factories) %7B%0A      resourceMap =
+actories.forEach(f -%3E
  res
@@ -888,22 +888,16 @@
 rement(f
-actory
 .getReso
@@ -907,15 +907,10 @@
 e())
+)
 ;
-%0A    %7D
 %0A   
@@ -1179,31 +1179,24 @@
 ry);%0A  %7D%0A%0A  
-public 
 static OfyPl

Simplify OfyResourceMap.getFactoryResources().