use of delta.games.lotro.character.stats.CharacterStatsComputer in project lotro-companion by dmorcellet.
the class NewToonDialogController method okImpl.
@Override
protected void okImpl() {
String toonName = _toonName.getText();
String server = _server.getSelectedItem();
CharacterClass cClass = _class.getComboBoxController().getSelectedItem();
Race race = _race.getSelectedItem();
CharacterSex sex = _sex.getSelectedItem();
CharacterData info = new CharacterData();
info.setName(toonName);
info.setServer(server);
info.setCharacterClass(cClass);
info.setCharacterSex(sex);
info.setRace(race);
info.setLevel(1);
info.setDate(Long.valueOf(System.currentTimeMillis()));
// Compute stats
CharacterStatsComputer computer = new CharacterStatsComputer();
info.getStats().setStats(computer.getStats(info));
CharactersManager manager = CharactersManager.getInstance();
CharacterFile toon = manager.addToon(info);
if (toon == null) {
showErrorMessage("Character creation failed!");
}
}
use of delta.games.lotro.character.stats.CharacterStatsComputer in project lotro-companion by dmorcellet.
the class CharacterFileWindowController method startNewCharacterData.
private void startNewCharacterData() {
CharacterInfosManager infos = _toon.getInfosManager();
CharacterData lastInfos = infos.getLastCharacterDescription();
CharacterData newInfos = new CharacterData();
CharacterSummary newSummary;
if (lastInfos != null) {
newSummary = new CharacterSummary(lastInfos.getSummary());
} else {
newSummary = new CharacterSummary(_toon.getSummary());
}
newInfos.setSummary(newSummary);
newInfos.setDate(Long.valueOf(System.currentTimeMillis()));
// Compute stats
CharacterStatsComputer computer = new CharacterStatsComputer();
newInfos.getStats().setStats(computer.getStats(newInfos));
boolean ok = _toon.getInfosManager().writeNewCharacterData(newInfos);
if (ok) {
CharacterEvent event = new CharacterEvent(CharacterEventType.CHARACTER_DATA_ADDED, _toon, newInfos);
EventsManager.invokeEvent(event);
showCharacterData(newInfos);
}
}
use of delta.games.lotro.character.stats.CharacterStatsComputer in project lotro-companion by dmorcellet.
the class CharacterDataWindowController method eventOccurred.
/**
* Handle character events.
* @param event Source event.
*/
@Override
public void eventOccurred(CharacterEvent event) {
CharacterEventType type = event.getType();
if (type == CharacterEventType.CHARACTER_DATA_UPDATED) {
CharacterData data = event.getToonData();
if (data == _data) {
// Compute new stats
CharacterStatsComputer computer = new CharacterStatsComputer();
BasicStatsSet stats = computer.getStats(data);
BasicStatsSet toonStats = _data.getStats();
toonStats.clear();
toonStats.setStats(stats);
// Update stats display
_statsController.update();
// Update buffs display
_buffsController.update();
}
}
if (type == CharacterEventType.CHARACTER_SUMMARY_UPDATED) {
CharacterFile toonFile = event.getToonFile();
if (toonFile == _toonFile) {
// Update sex
_attrsController.updateSexDisplay();
}
}
}
use of delta.games.lotro.character.stats.CharacterStatsComputer in project lotro-companion by dmorcellet.
the class MainTestStatContribsChart method doIt.
private void doIt(CharacterData data) {
StatsContributionsManager contribs = new StatsContributionsManager(data.getCharacterClass());
CharacterStatsComputer statsComputer = new CharacterStatsComputer(contribs);
BasicStatsSet stats = statsComputer.getStats(data);
System.out.println(stats);
contribs.setResolveIndirectContributions(true);
contribs.compute();
JPanel panel = GuiFactory.buildBackgroundPanel(new BorderLayout());
JTabbedPane tabs = GuiFactory.buildTabbedPane();
panel.add(tabs, BorderLayout.CENTER);
for (STAT stat : STAT.values()) {
ContribsByStat contribsForStat = contribs.getContribs(stat);
if (contribsForStat != null) {
StatContribsChartPanelController chartController = new StatContribsChartPanelController();
chartController.setContributions(contribsForStat);
JPanel statPanel = chartController.getPanel();
tabs.add(stat.getName(), statPanel);
}
}
DefaultWindowController w = new DefaultWindowController();
w.getFrame().add(panel);
w.getFrame().pack();
w.show();
}
use of delta.games.lotro.character.stats.CharacterStatsComputer in project lotro-companion by dmorcellet.
the class MainTestCharacterStatsSummaryPanelController method main.
/**
* Basic main method for test.
* @param args Not used.
*/
public static void main(String[] args) {
CharacterGenerationTools tools = new CharacterGenerationTools();
CharacterGeneratorMeva mevaGenerator = new CharacterGeneratorMeva(tools);
CharacterData meva = mevaGenerator.buildCharacter();
CharacterStatsComputer statsComputer = new CharacterStatsComputer();
BasicStatsSet stats = statsComputer.getStats(meva);
meva.getStats().setStats(stats);
CharacterStatsSummaryPanelController panelCtrl = new CharacterStatsSummaryPanelController(null, meva);
JFrame frame = new JFrame();
frame.add(panelCtrl.getPanel());
frame.pack();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setVisible(true);
}
Aggregations