use of com.solinia.solinia.Models.SoliniaRace in project solinia3-core by mixxit.
the class SoliniaRaceFactory method CreateRace.
public static ISoliniaRace CreateRace(String racename, int strength, int stamina, int agility, int dexterity, int wisdom, int intelligence, int charisma, boolean adminonly) throws CoreStateInitException, SoliniaRaceCreationException {
if (StateManager.getInstance().getConfigurationManager().getRace(racename.toUpperCase()) != null)
throw new SoliniaRaceCreationException("Race already exists");
SoliniaRace race = new SoliniaRace();
race.setId(StateManager.getInstance().getConfigurationManager().getNextRaceId());
race.setName(racename.toUpperCase());
race.setStrength(strength);
race.setStamina(stamina);
race.setAgility(agility);
race.setDexterity(dexterity);
race.setWisdom(wisdom);
race.setIntelligence(intelligence);
race.setCharisma(charisma);
race.setAdmin(adminonly);
StateManager.getInstance().getConfigurationManager().addRace(race);
return race;
}
use of com.solinia.solinia.Models.SoliniaRace in project solinia3-core by mixxit.
the class JsonRaceRepository method commit.
@Override
public void commit() {
// TODO Auto-generated method stub
GsonBuilder gsonbuilder = new GsonBuilder();
// gsonbuilder.setPrettyPrinting();
Gson gson = gsonbuilder.create();
String jsonOutput = gson.toJson(races.values(), new TypeToken<List<SoliniaRace>>() {
}.getType());
try {
File file = new File(filePath);
if (!file.exists())
file.createNewFile();
FileOutputStream fileOut = new FileOutputStream(file);
OutputStreamWriter outWriter = new OutputStreamWriter(fileOut);
outWriter.append(jsonOutput);
outWriter.close();
fileOut.close();
System.out.println("Commited " + races.size() + " races");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Aggregations