<commit_before>package com.github.lstephen.ootp.ai.report;

import com.google.common.base.Function;
import com.google.common.collect.Ordering;
import com.github.lstephen.ootp.ai.io.Printable;
import com.github.lstephen.ootp.ai.player.Player;
import com.github.lstephen.ootp.ai.roster.Team;
import com.github.lstephen.ootp.ai.site.Salary;
import com.github.lstephen.ootp.ai.site.Site;
import java.io.PrintWriter;
import java.text.NumberFormat;
import javax.annotation.ParametersAreNonnullByDefault;
import org.apache.commons.lang3.StringUtils;

import collection.JavaConversions._

/**
 *
 * @author lstephen
 */
class SalaryReport(team: Team, salary: Salary) extends Printable {

    val currentTotal: Integer = team.map(salary.getCurrentSalary(_).toInt).sum
    val nextTotal: Integer = team.map(salary.getCurrentSalary(_).toInt).sum

    def format(i: Int): String = NumberFormat.getIntegerInstance().format(i)

    def print(w: PrintWriter): Unit = {
        w.println()

        team
          .toSeq
          .filter(salary.getCurrentSalary(_) != 0)
          .sortBy(salary.getCurrentSalary(_))
          .reverse
          .foreach { p =>

            val s = salary getCurrentSalary p

            val nextS = salary getNextSalary p

            val position = p.getPosition
            val name = StringUtils.abbreviate(p.getShortName, 15)
            val age = p.getAge
            val current = format(s)
            val next = if (nextS == 0) "" else format(s)

            w println f"$position%s $name%15s $age%2d| $current%11s $next%11s"
        }

        val totalCurrent = format(currentTotal)
        val totalNext = format(nextTotal)
        val buffer = " " * 21

        w println f"$buffer| $totalCurrent%11s $totalNext%11s"
    }

}<commit_msg>Add salary per replacement level<commit_after>package com.github.lstephen.ootp.ai.report;

import com.google.common.base.Function;
import com.google.common.collect.Ordering;
import com.github.lstephen.ootp.ai.io.Printable;
import com.github.lstephen.ootp.ai.player.Player;
import com.github.lstephen.ootp.ai.roster.Team;
import com.github.lstephen.ootp.ai.site.Salary;
import com.github.lstephen.ootp.ai.site.Site;
import com.github.lstephen.ootp.ai.value.TradeValue;

import java.io.PrintWriter;
import java.text.NumberFormat;

import org.apache.commons.lang3.StringUtils;

import collection.JavaConversions._

/**
 *
 * @author lstephen
 */
class SalaryReport(team: Team, salary: Salary, tv: TradeValue) extends Printable {

    val currentTotal: Int = team.map(salary.getCurrentSalary(_).toInt).sum
    val nextTotal: Int = team.map(salary.getNextSalary(_).toInt).sum

    val replCurrentTotal: Int = team.map(tv.getCurrentValueVsReplacement(_).toInt).sum

    val replNextTotal: Int = team
      .filter(salary.getNextSalary(_) > 0)
      .map(tv.getCurrentValueVsReplacement(_).toInt)
      .sum

    def format(i: Int): String = NumberFormat.getIntegerInstance().format(i)

    def print(w: PrintWriter): Unit = {
        w.println()

        team
          .toSeq
          .filter(salary.getCurrentSalary(_) != 0)
          .sortBy(salary.getCurrentSalary(_))
          .reverse
          .foreach { p =>

            val s = salary getCurrentSalary p

            val nextS = salary getNextSalary p

            val position = p.getPosition
            val name = StringUtils.abbreviate(p.getShortName, 15)
            val age = p.getAge
            val current = format(s)
            val next = if (nextS == 0) "" else format(s)

            w println f"$position%s $name%15s $age%2d| $current%11s $next%11s"
        }

        val totalCurrent = format(currentTotal)
        val totalNext = format(nextTotal)
        val buffer = " " * 21

        val perReplLabel = "$/Repl"
        val perReplCurrent = currentTotal / replCurrentTotal
        val perReplNext = nextTotal / replNextTotal


        w println f"$buffer| $totalCurrent%11s $totalNext%11s"
        w println f"$perReplLabel%21s | $perReplCurrent%11s $perReplNext%11s"
    }

}
{'fraction_non_alphanumeric': 0.11315593136035812, 'fraction_numerical': 0.010693857249440438, 'mean_word_length': 2.8488038277511962, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4940848', 'n_tokens_mistral': 1339, 'n_tokens_neox': 1290, 'n_words': 258}