use of com.solinia.solinia.Models.RaceChoice in project solinia3-core by mixxit.
the class ConfigurationManager method getCharacterCreationChoices.
@Override
public CharacterCreation getCharacterCreationChoices() {
CharacterCreation characterCreation = new CharacterCreation();
List<ISoliniaClass> classes = getClasses();
for (ISoliniaRace race : this.getRaces()) {
if (race.isAdmin())
continue;
for (ISoliniaClass solclass : classes) {
if (!solclass.getValidRaceClasses().containsKey(race.getId()))
continue;
RaceChoice raceChoice = new RaceChoice(race.getId(), solclass.getId(), race.getName(), solclass.getName(), race.getShortName(), solclass.getShortName(), race.getDescription(), solclass.getDescription(), race.getStrength(), race.getStamina(), race.getAgility(), race.getDexterity(), race.getIntelligence(), race.getWisdom(), race.getCharisma(), race.getAlignment());
characterCreation.raceChoices.put(raceChoice.RaceName + "_" + raceChoice.ClassName, raceChoice);
}
}
return characterCreation;
}
use of com.solinia.solinia.Models.RaceChoice in project solinia3-core by mixxit.
the class PacketOpenCharacterCreationTest method WhenGivenPacketDataReturnsAllValues.
@Test
public void WhenGivenPacketDataReturnsAllValues() {
String testPacketData = "";
boolean first = true;
List<String> races = new ArrayList<String>();
races.add("Meroei");
races.add("Caerthain");
List<String> classes = new ArrayList<String>();
classes.add("Druid");
classes.add("Paladin");
for (int i = 1; i <= races.size(); i++) {
for (int i2 = 1; i2 <= classes.size(); i2++) {
if (first)
first = false;
else
testPacketData += "^";
String raceName = races.get(i - 1);
String className = classes.get(i2 - 1);
testPacketData += i + "|" + i2 + "|" + raceName + "|" + className + "|" + raceName.substring(0, 3) + "|" + className.substring(0, 3) + "|raceDesc|classDesc|" + "1|2|3|4|5|6|7";
}
}
try {
PacketOpenCharacterCreation vitals = new PacketOpenCharacterCreation();
vitals.fromPacketData(testPacketData);
for (Map.Entry<String, RaceChoice> entry : vitals.getCharacterCreation().raceChoices.entrySet()) {
assertEquals(true, entry.getValue().RaceId > 0);
assertEquals(true, entry.getValue().ClassId > 0);
assertEquals(true, entry.getValue().RaceName.length() > 0);
assertEquals(true, entry.getValue().ClassName.length() > 0);
assertEquals(true, entry.getValue().RaceShort.length() > 0);
assertEquals(true, entry.getValue().ClassShort.length() > 0);
assertEquals(true, entry.getValue().RaceDescription.length() > 0);
assertEquals(true, entry.getValue().ClassDescription.length() > 0);
assertEquals(true, entry.getValue().STR > 0);
assertEquals(true, entry.getValue().STA > 0);
assertEquals(true, entry.getValue().AGI > 0);
assertEquals(true, entry.getValue().DEX > 0);
assertEquals(true, entry.getValue().INT > 0);
assertEquals(true, entry.getValue().WIS > 0);
assertEquals(true, entry.getValue().CHA > 0);
}
} catch (InvalidPacketException e) {
e.printStackTrace();
}
}
use of com.solinia.solinia.Models.RaceChoice in project solinia3-core by mixxit.
the class PlayerUtils method sendCharCreationNoMod.
private static void sendCharCreationNoMod(Player sender) {
ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
BookMeta bookMeta = (BookMeta) book.getItemMeta();
bookMeta.setTitle("Creation");
bookMeta.setAuthor("Server");
try {
CharacterCreation choices = StateManager.getInstance().getConfigurationManager().getCharacterCreationChoices();
String pageText = "";
BaseComponent[] introPage = new ComponentBuilder(ChatColor.RED + "Race/Class Selection\n" + ChatColor.RESET + "---------------\n" + "\n" + "Please cycle through\n" + "our choice of races\n" + "and classes\n" + "\n" + "When you are ready \n" + "click " + ChatColor.BLUE + "SELECT" + ChatColor.RESET + " on the page\n").create();
bookMeta.spigot().addPage(introPage);
for (String choiceKey : choices.raceChoices.keySet()) {
RaceChoice choice = choices.raceChoices.get(choiceKey);
int passiveId = StateManager.getInstance().getConfigurationManager().getRace(choice.RaceId).getPassiveAbilityId();
ISoliniaSpell passiveSpell = StateManager.getInstance().getConfigurationManager().getSpell(passiveId);
String header = ChatColor.RED + "" + choice.RaceName + " " + choice.ClassName + ChatColor.RESET + "\n";
String hover = "[" + ChatColor.RED + "Hover for More Info" + ChatColor.RESET + "]\n";
String text = "";
text += "\n";
text += "STR " + ChatColor.BLUE + choice.STR + ChatColor.RESET + " STA " + ChatColor.BLUE + choice.STA + ChatColor.RESET + " AGI " + ChatColor.BLUE + choice.AGI + ChatColor.RESET + "\n";
text += "DEX " + ChatColor.BLUE + choice.DEX + ChatColor.RESET + " INT " + ChatColor.BLUE + choice.INT + ChatColor.RESET + " WIS " + ChatColor.BLUE + choice.WIS + ChatColor.RESET + "\n";
text += "CHA " + ChatColor.BLUE + choice.CHA + ChatColor.RESET + "\n";
text += "\n";
text += "Racial Benefit: " + ChatColor.RED + passiveSpell.getName() + ChatColor.RESET + "\n";
text += "\n";
String details = ChatColor.GOLD + choice.RaceName + ChatColor.RESET + System.lineSeparator() + "Recommended Alignment: " + ChatColor.GOLD + choice.Alignment + ChatColor.RESET + System.lineSeparator() + choice.RaceDescription + System.lineSeparator() + ChatColor.GOLD + choice.ClassName + ChatColor.RESET + System.lineSeparator() + choice.ClassDescription;
String click = "\n[" + ChatColor.BLUE + "SELECT" + ChatColor.RESET + "]\n";
BaseComponent[] racePage = new ComponentBuilder(header).append(new ComponentBuilder(hover).event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(details).create())).create()).append(new ComponentBuilder(text).create()).append(new ComponentBuilder(click).event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/createcharactershort " + choice.RaceId + " " + choice.ClassId)).create()).create();
//
// )
bookMeta.spigot().addPage(racePage);
}
/* .event(new ClickEvent(ClickEvent.Action.OPEN_URL, "http://spigotmc.org"))
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Go to the spigot website!").create()))
.create();*/
book.setItemMeta(bookMeta);
sender.openBook(book);
} catch (CoreStateInitException e) {
}
}
Aggregations