<commit_before>package jsettlers.logic.player;

import jsettlers.common.material.EMaterialType;
import jsettlers.common.player.ICombatStrengthInformation;
import jsettlers.common.position.ShortPoint2D;
import jsettlers.logic.map.grid.partition.Partition;
import jsettlers.logic.map.grid.partition.PartitionsGrid;

import java.io.Serializable;

/**
 * @author codingberlin
 */
public class CombatStrengthInformation implements ICombatStrengthInformation, Serializable {
	private static final long serialVersionUID = -2354305349487471882L;

	public static final float COMBAT_STRENGTH_WITHIN_OWN_LAND = 1;
	public static final int BORDER_50_PERCENT = 600;
	public static final int BORDER_85_PERCENT = 1160;
	private static final float[] COMBAT_STRENGTH_INCREASE = {613, 626, 639, 652, 665, 679, 693, 707, 721, 735, 750, 765, 780, 795, 810, 826,
			842, 858, 874, 890, 907, 924, 941, 958, 975, 993, 1011, 1029, 1047, 1065, 1084, 1103, 1122, 1141};
	private final byte playerId;
	private final PartitionsGrid partitionsGrid;
	private final int startAmountIndex;
	private static final float[] START_AMOUNT = {400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400};

	public CombatStrengthInformation(byte playerId, PartitionsGrid partitionsGrid, byte sumOfPlayers) {
		this.playerId = playerId;
		this.partitionsGrid = partitionsGrid;
		this.startAmountIndex = sumOfPlayers - 1;
	}

	@Override public float getCombatStrengthAtPosition(ShortPoint2D position) {
		float combatStrength = getCombatStrength();
		if (combatStrength >= COMBAT_STRENGTH_WITHIN_OWN_LAND) {
			return combatStrength;
		}
		if (partitionsGrid.getPlayerIdAt(position.x, position.y) == playerId) {
			return COMBAT_STRENGTH_WITHIN_OWN_LAND;
		}
		return combatStrength;
	}

	@Override public float getCombatStrength() {
		float amountOfGold = START_AMOUNT[startAmountIndex];
		for (Partition playersPartition : partitionsGrid.getPartitionsOfPlayerId(playerId)) {
			amountOfGold += playersPartition.getMaterialCounts().getAmountOf(EMaterialType.GOLD);
		}

		if (amountOfGold <= BORDER_50_PERCENT) {
			return (amountOfGold / 12) / 100f;
		}
		if (amountOfGold <= BORDER_85_PERCENT) {
			for (int i = COMBAT_STRENGTH_INCREASE.length; i >= 0; i--) {
				if (amountOfGold >= COMBAT_STRENGTH_INCREASE[i]) {
					return (51f + (float) i) / 100f;
				}
				return 0.5f;
			}<commit_msg>add combat strength<commit_after>package jsettlers.logic.player;

import jsettlers.common.material.EMaterialType;
import jsettlers.common.player.ICombatStrengthInformation;
import jsettlers.common.position.ShortPoint2D;
import jsettlers.logic.map.grid.partition.Partition;
import jsettlers.logic.map.grid.partition.PartitionsGrid;

import java.io.Serializable;

/**
 * @author codingberlin
 */
public class CombatStrengthInformation implements ICombatStrengthInformation, Serializable {
	private static final long serialVersionUID = -2354305349487471882L;

	public static final float COMBAT_STRENGTH_WITHIN_OWN_LAND = 1;
	public static final int BORDER_50_PERCENT = 600;
	public static final int BORDER_85_PERCENT = 1160;
	private static final float[] COMBAT_STRENGTH_INCREASE = {613, 626, 639, 652, 665, 679, 693, 707, 721, 735, 750, 765, 780, 795, 810, 826,
			842, 858, 874, 890, 907, 924, 941, 958, 975, 993, 1011, 1029, 1047, 1065, 1084, 1103, 1122, 1141};
	private final byte playerId;
	private final PartitionsGrid partitionsGrid;
	private final int startAmountIndex;
	private static final float[] START_AMOUNT = {652, 600, 504, 444, 396, 348, 312, 300, 276, 252, 228, 216, 204, 192, 180, 168, 163, 156, 149, 144};

	public CombatStrengthInformation(byte playerId, PartitionsGrid partitionsGrid, byte sumOfPlayers) {
		this.playerId = playerId;
		this.partitionsGrid = partitionsGrid;
		this.startAmountIndex = sumOfPlayers - 1;
	}

	@Override public float getCombatStrengthAtPosition(ShortPoint2D position) {
		float combatStrength = getCombatStrength();
		if (combatStrength >= COMBAT_STRENGTH_WITHIN_OWN_LAND) {
			return combatStrength;
		}
		if (partitionsGrid.getPlayerIdAt(position.x, position.y) == playerId) {
			return COMBAT_STRENGTH_WITHIN_OWN_LAND;
		}
		return combatStrength;
	}

	@Override public float getCombatStrength() {
		float amountOfGold = START_AMOUNT[startAmountIndex];
		for (Partition playersPartition : partitionsGrid.getPartitionsOfPlayerId(playerId)) {
			amountOfGold += playersPartition.getMaterialCounts().getAmountOf(EMaterialType.GOLD);
		}

		if (amountOfGold <= BORDER_50_PERCENT) {
			return (amountOfGold / 12f) / 100f;
		}
		if (amountOfGold <= BORDER_85_PERCENT) {
			for (int i = COMBAT_STRENGTH_INCREASE.length; i >= 0; i--) {
				if (amountOfGold >= COMBAT_STRENGTH_INCREASE[i]) {
					return (51f + (float) i) / 100f;
				}
				return 0.5f;
			}
{'fraction_non_alphanumeric': 0.09814157444142828, 'fraction_numerical': 0.09229484234704531, 'mean_word_length': 5.294349540078843, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '18625', 'n_tokens_mistral': 2164, 'n_tokens_neox': 1636, 'n_words': 396}