Search in sources :

Example 1 with CharacterStatsComputer

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!");
    }
}
Also used : CharactersManager(delta.games.lotro.character.CharactersManager) CharacterData(delta.games.lotro.character.CharacterData) CharacterStatsComputer(delta.games.lotro.character.stats.CharacterStatsComputer) Race(delta.games.lotro.common.Race) CharacterSex(delta.games.lotro.common.CharacterSex) CharacterFile(delta.games.lotro.character.CharacterFile) CharacterClass(delta.games.lotro.common.CharacterClass)

Example 2 with CharacterStatsComputer

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);
    }
}
Also used : CharacterSummary(delta.games.lotro.character.CharacterSummary) CharacterEvent(delta.games.lotro.character.events.CharacterEvent) CharacterData(delta.games.lotro.character.CharacterData) CharacterStatsComputer(delta.games.lotro.character.stats.CharacterStatsComputer) CharacterInfosManager(delta.games.lotro.character.CharacterInfosManager)

Example 3 with CharacterStatsComputer

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();
        }
    }
}
Also used : CharacterEventType(delta.games.lotro.character.events.CharacterEventType) CharacterData(delta.games.lotro.character.CharacterData) CharacterStatsComputer(delta.games.lotro.character.stats.CharacterStatsComputer) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet) CharacterFile(delta.games.lotro.character.CharacterFile)

Example 4 with CharacterStatsComputer

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();
}
Also used : JPanel(javax.swing.JPanel) STAT(delta.games.lotro.character.stats.STAT) ContribsByStat(delta.games.lotro.character.stats.contribs.ContribsByStat) BorderLayout(java.awt.BorderLayout) StatsContributionsManager(delta.games.lotro.character.stats.contribs.StatsContributionsManager) CharacterStatsComputer(delta.games.lotro.character.stats.CharacterStatsComputer) DefaultWindowController(delta.common.ui.swing.windows.DefaultWindowController) JTabbedPane(javax.swing.JTabbedPane) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet)

Example 5 with CharacterStatsComputer

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);
}
Also used : CharacterData(delta.games.lotro.character.CharacterData) CharacterGeneratorMeva(delta.games.lotro.character.stats.CharacterGeneratorMeva) CharacterStatsComputer(delta.games.lotro.character.stats.CharacterStatsComputer) JFrame(javax.swing.JFrame) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet) CharacterGenerationTools(delta.games.lotro.character.stats.CharacterGenerationTools)

Aggregations

CharacterStatsComputer (delta.games.lotro.character.stats.CharacterStatsComputer)6 CharacterData (delta.games.lotro.character.CharacterData)5 BasicStatsSet (delta.games.lotro.character.stats.BasicStatsSet)4 DefaultWindowController (delta.common.ui.swing.windows.DefaultWindowController)2 CharacterFile (delta.games.lotro.character.CharacterFile)2 CharacterGenerationTools (delta.games.lotro.character.stats.CharacterGenerationTools)2 JPanel (javax.swing.JPanel)2 CharacterInfosManager (delta.games.lotro.character.CharacterInfosManager)1 CharacterSummary (delta.games.lotro.character.CharacterSummary)1 CharactersManager (delta.games.lotro.character.CharactersManager)1 CharacterEvent (delta.games.lotro.character.events.CharacterEvent)1 CharacterEventType (delta.games.lotro.character.events.CharacterEventType)1 CharacterGeneratorGiswald (delta.games.lotro.character.stats.CharacterGeneratorGiswald)1 CharacterGeneratorMeva (delta.games.lotro.character.stats.CharacterGeneratorMeva)1 STAT (delta.games.lotro.character.stats.STAT)1 ContribsByStat (delta.games.lotro.character.stats.contribs.ContribsByStat)1 StatsContributionsManager (delta.games.lotro.character.stats.contribs.StatsContributionsManager)1 CharacterClass (delta.games.lotro.common.CharacterClass)1 CharacterSex (delta.games.lotro.common.CharacterSex)1 Race (delta.games.lotro.common.Race)1