Search in sources :

Example 1 with MyLotroConfig

use of delta.games.lotro.MyLotroConfig in project lotro-tools by dmorcellet.

the class MainTestCharacterActivityLogIO method main.

/**
 * Basic main method for test.
 * @param args Not used.
 */
public static void main(String[] args) {
    List<CharacterFile> toons = new ArrayList<CharacterFile>();
    LotroTestUtils utils = new LotroTestUtils();
    CharacterFile glumlug = utils.getMainToon();
    toons.add(glumlug);
    MyLotroConfig cfg = MyLotroConfig.getInstance();
    CharacterLogPageParser parser = new CharacterLogPageParser();
    for (CharacterFile toon : toons) {
        String url = cfg.getCharacterURL(toon.getServerName(), toon.getName());
        CharacterLog log = parser.parseLogPages(url, null);
        if (log != null) {
            System.out.println(log);
            CharacterLogsManager manager = toon.getLogsManager();
            boolean ok = manager.writeNewLog(log);
            if (ok) {
                System.out.println("OK");
            }
        }
    }
}
Also used : LotroTestUtils(delta.games.lotro.character.log.LotroTestUtils) ArrayList(java.util.ArrayList) MyLotroConfig(delta.games.lotro.MyLotroConfig) CharacterFile(delta.games.lotro.character.CharacterFile) CharacterLogsManager(delta.games.lotro.character.log.CharacterLogsManager) CharacterLog(delta.games.lotro.character.log.CharacterLog)

Example 2 with MyLotroConfig

use of delta.games.lotro.MyLotroConfig in project lotro-tools by dmorcellet.

the class CharacterLogRepair method doIt.

/**
 * Do the job.
 * @param toon Targeted toon.
 * @return <code>true</code> if it succeeded, <code>false</code> otherwise.
 */
public boolean doIt(CharacterFile toon) {
    boolean ok = true;
    CharacterLog log = toon.getLastCharacterLog();
    List<Long> dates = getDatesToUpdate(log);
    if (dates.size() > 0) {
        Collections.sort(dates);
        Long oldest = dates.get(0);
        CharacterLogPageParser parser = new CharacterLogPageParser();
        MyLotroConfig cfg = MyLotroConfig.getInstance();
        String url = cfg.getCharacterURL(toon.getServerName(), toon.getName());
        CharacterLog newLog = parser.parseLogPages(url, oldest);
        if (newLog != null) {
            for (Long date : dates) {
                handleLogItemsReplacementForDate(date, log, newLog);
            }
            CharacterLogsManager logsManager = toon.getLogsManager();
            ok = logsManager.writeNewLog(log);
        } else {
            ok = false;
        }
    }
    return ok;
}
Also used : MyLotroConfig(delta.games.lotro.MyLotroConfig) CharacterLogsManager(delta.games.lotro.character.log.CharacterLogsManager) CharacterLog(delta.games.lotro.character.log.CharacterLog)

Aggregations

MyLotroConfig (delta.games.lotro.MyLotroConfig)2 CharacterLog (delta.games.lotro.character.log.CharacterLog)2 CharacterLogsManager (delta.games.lotro.character.log.CharacterLogsManager)2 CharacterFile (delta.games.lotro.character.CharacterFile)1 LotroTestUtils (delta.games.lotro.character.log.LotroTestUtils)1 ArrayList (java.util.ArrayList)1