package org.studiorailgun.sim.writing;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.studiorailgun.Globals;
import org.studiorailgun.sim.character.Character;
import org.studiorailgun.sim.config.creature.CreatureDef;

/**
 * Describes a group of characters
 */
public class GroupDescriber {
    
    /**
     * Describes a group of characters
     * @param characters The characters
     */
    public static void summarize(List<Character> characters){
        Map<String,Integer> raceCountMap = new HashMap<String,Integer>();
        for(Character currentChar : characters){
            String race = currentChar.getAppearance().getRace();
            if(raceCountMap.containsKey(race)){
                raceCountMap.put(race, raceCountMap.get(race) + 1);
            } else {
                raceCountMap.put(race, 1);
            }
        }
        for(Entry<String,Integer> entry : raceCountMap.entrySet()){
            String race = entry.getKey();
            int count = entry.getValue();
            CreatureDef creatureType = Globals.config.getCreatureDefManager().getDefinition(race);
            if(count > 1){
                String message = "There are " + NumberWordizer.convert(count) + " " + creatureType.getPlural() + ".";
                System.out.println(message);
            } else {
                String message = "There is one " + creatureType.getSingular() + ".";
                System.out.println(message);
            }
        }
    }

    /**
     * Describes a group of characters
     * @param characters The group of characters
     */
    public static void describe(List<Character> characters){
        
    }

}
