Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ece7651
Added shields
softwaremagico Oct 14, 2018
127d684
Renamed class
softwaremagico Oct 15, 2018
aa4003b
More txt export logic added
softwaremagico Oct 16, 2018
9d968f7
More txt export logic added
softwaremagico Oct 16, 2018
52f959a
Added random profiles
softwaremagico Oct 15, 2018
e1d5678
Basic TXT export
softwaremagico Oct 15, 2018
2d32ee8
basic character text representation finished
softwaremagico Oct 18, 2018
f85c090
Added test to txt conversor
softwaremagico Oct 18, 2018
3c769e0
Fixed some random irregularities
softwaremagico Oct 18, 2018
e932288
Added armours
softwaremagico Oct 19, 2018
ec2d68f
Fixed sorted elements in TXT char
softwaremagico Oct 20, 2018
8e49863
Generalized random definitions
softwaremagico Oct 20, 2018
54cbcce
Generalized some random controls
softwaremagico Oct 20, 2018
ab91171
Updated weapons probability
softwaremagico Oct 20, 2018
ec7058b
Sorting skills by specialization
softwaremagico Oct 21, 2018
26dfaa7
Fixed test
softwaremagico Oct 21, 2018
f715777
Added json serializers to increase json performance
softwaremagico Oct 22, 2018
a177e07
Fixed NPE
softwaremagico Oct 22, 2018
29c4936
Searching specialization
softwaremagico Oct 22, 2018
374a123
Added more json serializers to increase json performance
softwaremagico Oct 23, 2018
52e8958
Defining armour random rules
softwaremagico Oct 24, 2018
dc84970
Defining shield random rules
softwaremagico Oct 26, 2018
f6433f1
Defining armour specifications
softwaremagico Oct 26, 2018
f769d5e
Refactorized random selections
softwaremagico Oct 28, 2018
5f1c0ad
Fixed tests
softwaremagico Oct 29, 2018
1b244a6
Fixed tests
softwaremagico Nov 2, 2018
f466d96
Fixed tests
softwaremagico Nov 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Renamed class
  • Loading branch information
softwaremagico committed Oct 15, 2018
commit 127d68465a95f77e105036a62d32dd7bd6b6d040
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@
import com.softwaremagico.tm.log.RandomGenerationLog;
import com.softwaremagico.tm.random.exceptions.InvalidRandomElementSelectedException;
import com.softwaremagico.tm.random.selectors.IGaussianDistribution;
import com.softwaremagico.tm.random.selectors.IRandomPreferences;
import com.softwaremagico.tm.random.selectors.IRandomPreference;
import com.softwaremagico.tm.random.selectors.StatusPreferences;
import com.softwaremagico.tm.random.selectors.TraitCostPreferences;

public class RandomBeneficeDefinition extends RandomSelector<BeneficeDefinition> {
private static final int MAX_AFFLICTIONS = 2;
private static final int VERY_GOOD_PROBABILITY = 10000;

protected RandomBeneficeDefinition(CharacterPlayer characterPlayer, Set<IRandomPreferences> preferences)
protected RandomBeneficeDefinition(CharacterPlayer characterPlayer, Set<IRandomPreference> preferences)
throws InvalidXmlElementException {
super(characterPlayer, preferences);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
import com.softwaremagico.tm.random.selectors.BlessingNumberPreferences;
import com.softwaremagico.tm.random.selectors.BlessingPreferences;
import com.softwaremagico.tm.random.selectors.IGaussianDistribution;
import com.softwaremagico.tm.random.selectors.IRandomPreferences;
import com.softwaremagico.tm.random.selectors.IRandomPreference;
import com.softwaremagico.tm.random.selectors.SpecializationPreferences;

public class RandomBlessingDefinition extends RandomSelector<Blessing> {
private final static int MAX_PROBABILITY = 100000;
private final static int GOOD_PROBABILITY = 20;
private final static int FAIR_PROBABILITY = 10;

protected RandomBlessingDefinition(CharacterPlayer characterPlayer, Set<IRandomPreferences> preferences) throws InvalidXmlElementException {
protected RandomBlessingDefinition(CharacterPlayer characterPlayer, Set<IRandomPreference> preferences) throws InvalidXmlElementException {
super(characterPlayer, preferences);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
import com.softwaremagico.tm.character.creation.FreeStyleCharacterCreation;
import com.softwaremagico.tm.character.factions.FactionGroup;
import com.softwaremagico.tm.random.exceptions.InvalidRandomElementSelectedException;
import com.softwaremagico.tm.random.selectors.BodyPreferences;
import com.softwaremagico.tm.random.selectors.CharacteristicsPreferences;
import com.softwaremagico.tm.random.selectors.CombatPreferences;
import com.softwaremagico.tm.random.selectors.IRandomPreferences;
import com.softwaremagico.tm.random.selectors.IRandomPreference;
import com.softwaremagico.tm.random.selectors.PsiqueLevelPreferences;
import com.softwaremagico.tm.random.selectors.SpecializationPreferences;
import com.softwaremagico.tm.random.selectors.TechnologicalPreferences;
Expand All @@ -46,7 +46,7 @@ public class RandomCharacteristics extends RandomSelector<Characteristic> {
private final static int MAX_PROBABILITY = 100000;
private final static int GOOD_PROBABILITY = 10;

public RandomCharacteristics(CharacterPlayer characterPlayer, Set<IRandomPreferences> preferences)
public RandomCharacteristics(CharacterPlayer characterPlayer, Set<IRandomPreference> preferences)
throws InvalidXmlElementException {
super(characterPlayer, preferences);
}
Expand All @@ -73,7 +73,7 @@ private void assignMinimumValuesOfCharacteristics() {
getCharacterPlayer().getStartingValue(characteristicName));
}

for (IRandomPreferences preference : getPreferences()) {
for (IRandomPreference preference : getPreferences()) {
if (preference instanceof TechnologicalPreferences) {
getCharacterPlayer().getCharacteristic(CharacteristicName.TECH).setValue(
((TechnologicalPreferences) preference).minimum());
Expand Down Expand Up @@ -109,20 +109,20 @@ protected int getWeight(Characteristic characteristic) {

int weight = 1;
if (CharacteristicType.BODY.equals(characteristic.getType())) {
if (getPreferences().contains(BodyPreferences.BODY)) {
if (getPreferences().contains(CharacteristicsPreferences.BODY)) {
weight += 2;
}
if (getPreferences().contains(CombatPreferences.BELLIGERENT)) {
weight += 1;
}
}
if (CharacteristicType.MIND.equals(characteristic.getType())) {
if (getPreferences().contains(BodyPreferences.MIND)) {
if (getPreferences().contains(CharacteristicsPreferences.MIND)) {
weight += 2;
}
}
if (CharacteristicType.SPIRIT.equals(characteristic.getType())) {
if (getPreferences().contains(BodyPreferences.SPIRIT)) {
if (getPreferences().contains(CharacteristicsPreferences.SPIRIT)) {
weight += 2;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
import com.softwaremagico.tm.character.creation.FreeStyleCharacterCreation;
import com.softwaremagico.tm.log.RandomGenerationLog;
import com.softwaremagico.tm.random.exceptions.InvalidRandomElementSelectedException;
import com.softwaremagico.tm.random.selectors.IRandomPreferences;
import com.softwaremagico.tm.random.selectors.IRandomPreference;

public class RandomCharacteristicsExtraPoints extends RandomCharacteristics {

public RandomCharacteristicsExtraPoints(CharacterPlayer characterPlayer, Set<IRandomPreferences> preferences)
public RandomCharacteristicsExtraPoints(CharacterPlayer characterPlayer, Set<IRandomPreference> preferences)
throws InvalidXmlElementException {
super(characterPlayer, preferences);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
import com.softwaremagico.tm.random.selectors.CombatPreferences;
import com.softwaremagico.tm.random.selectors.CurseNumberPreferences;
import com.softwaremagico.tm.random.selectors.IGaussianDistribution;
import com.softwaremagico.tm.random.selectors.IRandomPreferences;
import com.softwaremagico.tm.random.selectors.IRandomPreference;
import com.softwaremagico.tm.random.selectors.SpecializationPreferences;

public class RandomCursesDefinition extends RandomSelector<Blessing> {
private final static int MAX_PROBABILITY = 100000;

protected RandomCursesDefinition(CharacterPlayer characterPlayer, Set<IRandomPreferences> preferences)
protected RandomCursesDefinition(CharacterPlayer characterPlayer, Set<IRandomPreference> preferences)
throws InvalidXmlElementException {
super(characterPlayer, preferences);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
import com.softwaremagico.tm.character.race.InvalidRaceException;
import com.softwaremagico.tm.random.exceptions.InvalidRandomElementSelectedException;
import com.softwaremagico.tm.random.selectors.FactionPreferences;
import com.softwaremagico.tm.random.selectors.IRandomPreferences;
import com.softwaremagico.tm.random.selectors.IRandomPreference;

public class RandomFaction extends RandomSelector<Faction> {

protected RandomFaction(CharacterPlayer characterPlayer, Set<IRandomPreferences> preferences) throws InvalidXmlElementException {
protected RandomFaction(CharacterPlayer characterPlayer, Set<IRandomPreference> preferences) throws InvalidXmlElementException {
super(characterPlayer, preferences);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
import com.softwaremagico.tm.character.equipment.weapons.Weapon;
import com.softwaremagico.tm.character.equipment.weapons.WeaponType;
import com.softwaremagico.tm.log.RandomGenerationLog;
import com.softwaremagico.tm.random.selectors.IRandomPreferences;
import com.softwaremagico.tm.random.selectors.IRandomPreference;

public class RandomMeleeWeapon extends RandomWeapon {

protected RandomMeleeWeapon(CharacterPlayer characterPlayer, Set<IRandomPreferences> preferences) throws InvalidXmlElementException {
protected RandomMeleeWeapon(CharacterPlayer characterPlayer, Set<IRandomPreference> preferences) throws InvalidXmlElementException {
super(characterPlayer, preferences);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
import com.softwaremagico.tm.character.race.InvalidRaceException;
import com.softwaremagico.tm.log.RandomGenerationLog;
import com.softwaremagico.tm.random.exceptions.InvalidRandomElementSelectedException;
import com.softwaremagico.tm.random.selectors.IRandomPreferences;
import com.softwaremagico.tm.random.selectors.IRandomPreference;
import com.softwaremagico.tm.random.selectors.NamesPreferences;

public class RandomName extends RandomSelector<Name> {
private final static int GOOD_PROBABILITY = 1;

protected RandomName(CharacterPlayer characterPlayer, Set<IRandomPreferences> preferences) throws InvalidXmlElementException {
protected RandomName(CharacterPlayer characterPlayer, Set<IRandomPreference> preferences) throws InvalidXmlElementException {
super(characterPlayer, preferences);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
import com.softwaremagico.tm.character.planet.PlanetFactory;
import com.softwaremagico.tm.character.race.InvalidRaceException;
import com.softwaremagico.tm.random.exceptions.InvalidRandomElementSelectedException;
import com.softwaremagico.tm.random.selectors.IRandomPreferences;
import com.softwaremagico.tm.random.selectors.IRandomPreference;

public class RandomPlanet extends RandomSelector<Planet> {
private final static int FACTION_PLANET = 50;
private final static int NEUTRAL_PLANET = 5;
private final static int ENEMY_PLANET = 1;

protected RandomPlanet(CharacterPlayer characterPlayer, Set<IRandomPreferences> preferences) throws InvalidXmlElementException {
protected RandomPlanet(CharacterPlayer characterPlayer, Set<IRandomPreference> preferences) throws InvalidXmlElementException {
super(characterPlayer, preferences);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
import com.softwaremagico.tm.log.RandomGenerationLog;
import com.softwaremagico.tm.random.exceptions.InvalidRandomElementSelectedException;
import com.softwaremagico.tm.random.selectors.IGaussianDistribution;
import com.softwaremagico.tm.random.selectors.IRandomPreferences;
import com.softwaremagico.tm.random.selectors.IRandomPreference;
import com.softwaremagico.tm.random.selectors.PsiqueLevelPreferences;

public class RandomPsique extends RandomSelector<OccultismType> {

protected RandomPsique(CharacterPlayer characterPlayer, Set<IRandomPreferences> preferences) throws InvalidXmlElementException {
protected RandomPsique(CharacterPlayer characterPlayer, Set<IRandomPreference> preferences) throws InvalidXmlElementException {
super(characterPlayer, preferences);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import com.softwaremagico.tm.random.exceptions.InvalidRandomElementSelectedException;
import com.softwaremagico.tm.random.selectors.CombatPreferences;
import com.softwaremagico.tm.random.selectors.IGaussianDistribution;
import com.softwaremagico.tm.random.selectors.IRandomPreferences;
import com.softwaremagico.tm.random.selectors.IRandomPreference;
import com.softwaremagico.tm.random.selectors.PsiqueLevelPreferences;
import com.softwaremagico.tm.random.selectors.PsiquePathLevelPreferences;
import com.softwaremagico.tm.random.selectors.SpecializationPreferences;
Expand All @@ -57,7 +57,7 @@ public class RandomPsiquePath extends RandomSelector<OccultismPath> {

private int totalPowers;

protected RandomPsiquePath(CharacterPlayer characterPlayer, Set<IRandomPreferences> preferences)
protected RandomPsiquePath(CharacterPlayer characterPlayer, Set<IRandomPreference> preferences)
throws InvalidXmlElementException {
super(characterPlayer, preferences);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
import com.softwaremagico.tm.character.race.Race;
import com.softwaremagico.tm.character.race.RaceFactory;
import com.softwaremagico.tm.random.exceptions.InvalidRandomElementSelectedException;
import com.softwaremagico.tm.random.selectors.IRandomPreferences;
import com.softwaremagico.tm.random.selectors.IRandomPreference;
import com.softwaremagico.tm.random.selectors.RacePreferences;

public class RandomRace extends RandomSelector<Race> {

protected RandomRace(CharacterPlayer characterPlayer, Set<IRandomPreferences> preferences) throws InvalidXmlElementException {
protected RandomRace(CharacterPlayer characterPlayer, Set<IRandomPreference> preferences) throws InvalidXmlElementException {
super(characterPlayer, preferences);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
import com.softwaremagico.tm.character.equipment.weapons.Weapon;
import com.softwaremagico.tm.character.equipment.weapons.WeaponType;
import com.softwaremagico.tm.log.RandomGenerationLog;
import com.softwaremagico.tm.random.selectors.IRandomPreferences;
import com.softwaremagico.tm.random.selectors.IRandomPreference;

public class RandomRangeWeapon extends RandomWeapon {

protected RandomRangeWeapon(CharacterPlayer characterPlayer, Set<IRandomPreferences> preferences) throws InvalidXmlElementException {
protected RandomRangeWeapon(CharacterPlayer characterPlayer, Set<IRandomPreference> preferences) throws InvalidXmlElementException {
super(characterPlayer, preferences);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@
import com.softwaremagico.tm.InvalidXmlElementException;
import com.softwaremagico.tm.character.CharacterPlayer;
import com.softwaremagico.tm.random.exceptions.InvalidRandomElementSelectedException;
import com.softwaremagico.tm.random.selectors.IRandomPreferences;
import com.softwaremagico.tm.random.selectors.IRandomPreference;

public abstract class RandomSelector<Element extends com.softwaremagico.tm.Element<?>> {
private CharacterPlayer characterPlayer;
private final Set<IRandomPreferences> preferences;
private final Set<IRandomPreference> preferences;
private Random rand = new Random();

// Weight -> Characteristic.
private final TreeMap<Integer, Element> weightedElements;
private final int totalWeight;

protected RandomSelector(CharacterPlayer characterPlayer, Set<IRandomPreferences> preferences)
protected RandomSelector(CharacterPlayer characterPlayer, Set<IRandomPreference> preferences)
throws InvalidXmlElementException {
this.characterPlayer = characterPlayer;
this.preferences = preferences;
Expand All @@ -65,7 +65,7 @@ protected CharacterPlayer getCharacterPlayer() {
return characterPlayer;
}

protected Set<IRandomPreferences> getPreferences() {
protected Set<IRandomPreference> getPreferences() {
return preferences;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
import com.softwaremagico.tm.character.skills.AvailableSkill;
import com.softwaremagico.tm.log.RandomGenerationLog;
import com.softwaremagico.tm.random.exceptions.InvalidRandomElementSelectedException;
import com.softwaremagico.tm.random.selectors.IRandomPreferences;
import com.softwaremagico.tm.random.selectors.IRandomPreference;

public class RandomSkillExtraPoints extends RandomSkills {

public RandomSkillExtraPoints(CharacterPlayer characterPlayer, Set<IRandomPreferences> preferences) throws InvalidXmlElementException {
public RandomSkillExtraPoints(CharacterPlayer characterPlayer, Set<IRandomPreference> preferences) throws InvalidXmlElementException {
super(characterPlayer, preferences);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import com.softwaremagico.tm.log.RandomGenerationLog;
import com.softwaremagico.tm.random.exceptions.InvalidRandomElementSelectedException;
import com.softwaremagico.tm.random.selectors.CombatPreferences;
import com.softwaremagico.tm.random.selectors.IRandomPreferences;
import com.softwaremagico.tm.random.selectors.IRandomPreference;
import com.softwaremagico.tm.random.selectors.SkillGroupPreferences;
import com.softwaremagico.tm.random.selectors.SpecializationPreferences;
import com.softwaremagico.tm.random.selectors.TechnologicalPreferences;
Expand All @@ -63,7 +63,7 @@ public class RandomSkills extends RandomSelector<AvailableSkill> {

private List<Entry<CharacteristicType, Integer>> preferredCharacteristicsTypeSorted;

public RandomSkills(CharacterPlayer characterPlayer, Set<IRandomPreferences> preferences) throws InvalidXmlElementException {
public RandomSkills(CharacterPlayer characterPlayer, Set<IRandomPreference> preferences) throws InvalidXmlElementException {
super(characterPlayer, preferences);
}

Expand Down Expand Up @@ -111,7 +111,7 @@ public void mergeSkills(AvailableSkill availableSkill, SkillGroup skillGroup) th
}

private void assignMinimumValuesOfSkills() {
for (IRandomPreferences preference : getPreferences()) {
for (IRandomPreference preference : getPreferences()) {
if (preference instanceof TechnologicalPreferences) {
getCharacterPlayer().getCharacteristic(CharacteristicName.TECH).setValue(((TechnologicalPreferences) preference).minimum());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
import com.softwaremagico.tm.character.race.InvalidRaceException;
import com.softwaremagico.tm.log.RandomGenerationLog;
import com.softwaremagico.tm.random.exceptions.InvalidRandomElementSelectedException;
import com.softwaremagico.tm.random.selectors.IRandomPreferences;
import com.softwaremagico.tm.random.selectors.IRandomPreference;

public class RandomSurname extends RandomSelector<Surname> {
private final static int GOOD_PROBABILITY = 1;

protected RandomSurname(CharacterPlayer characterPlayer, Set<IRandomPreferences> preferences) throws InvalidXmlElementException {
protected RandomSurname(CharacterPlayer characterPlayer, Set<IRandomPreference> preferences) throws InvalidXmlElementException {
super(characterPlayer, preferences);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
import com.softwaremagico.tm.character.skills.AvailableSkillsFactory;
import com.softwaremagico.tm.log.RandomGenerationLog;
import com.softwaremagico.tm.random.exceptions.InvalidRandomElementSelectedException;
import com.softwaremagico.tm.random.selectors.IRandomPreferences;
import com.softwaremagico.tm.random.selectors.IRandomPreference;

public abstract class RandomWeapon extends RandomSelector<Weapon> {
protected final static int TECH_LEVEL_BONUS = 1000000;
private Integer currentMoney = null;

protected RandomWeapon(CharacterPlayer characterPlayer, Set<IRandomPreferences> preferences) throws InvalidXmlElementException {
protected RandomWeapon(CharacterPlayer characterPlayer, Set<IRandomPreference> preferences) throws InvalidXmlElementException {
super(characterPlayer, preferences);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,28 @@
import com.softwaremagico.tm.random.selectors.AgePreferences;
import com.softwaremagico.tm.random.selectors.CombatPreferences;
import com.softwaremagico.tm.random.selectors.IGaussianDistribution;
import com.softwaremagico.tm.random.selectors.IRandomPreferences;
import com.softwaremagico.tm.random.selectors.IRandomPreference;
import com.softwaremagico.tm.random.selectors.PsiqueLevelPreferences;
import com.softwaremagico.tm.random.selectors.SpecializationPreferences;
import com.softwaremagico.tm.random.selectors.TraitCostPreferences;
import com.softwaremagico.tm.random.selectors.WeaponsPreferences;

public class RandomizeCharacter {
private CharacterPlayer characterPlayer;
private final Set<IRandomPreferences> preferences;
private final Set<IRandomPreference> preferences;
private final Random random = new Random();

public RandomizeCharacter(CharacterPlayer characterPlayer, int experiencePoints, IRandomPreferences... preferences) throws DuplicatedPreferenceException {
public RandomizeCharacter(CharacterPlayer characterPlayer, int experiencePoints, IRandomPreference... preferences) throws DuplicatedPreferenceException {
this.characterPlayer = characterPlayer;
this.preferences = new HashSet<>(Arrays.asList(preferences));

checkValidPreferences();
}

private void checkValidPreferences() throws DuplicatedPreferenceException {
Set<Class<? extends IRandomPreferences>> existingPreferences = new HashSet<>();
Set<Class<? extends IRandomPreference>> existingPreferences = new HashSet<>();
// Only one of each class allowed.
for (IRandomPreferences preference : preferences) {
for (IRandomPreference preference : preferences) {
if (existingPreferences.contains(preference.getClass())) {
throw new DuplicatedPreferenceException("Preference '" + preference + "' collides with another preference. Only one of each type is allowed.");
}
Expand Down
Loading