Changeset 5188
- Timestamp:
- Feb 22, 2012 7:52:10 PM (3 months ago)
- Location:
- branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/model/olympiad
- Files:
-
- 6 edited
-
CompetitionType.java (modified) (2 diffs)
-
Olympiad.java (modified) (18 diffs)
-
OlympiadGameNormal.java (modified) (5 diffs)
-
OlympiadGameTeams.java (modified) (7 diffs)
-
OlympiadManager.java (modified) (9 diffs)
-
Participant.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/model/olympiad/CompetitionType.java
r4432 r5188 16 16 17 17 /** 18 *19 18 * @author DS 20 *21 19 */ 22 20 public enum CompetitionType … … 26 24 TEAMS("teams"), 27 25 OTHER("other"); 28 26 29 27 private final String _name; 30 28 31 29 private CompetitionType(String name) 32 30 { 33 31 _name = name; 34 32 } 35 33 36 34 @Override 37 35 public final String toString() -
branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/model/olympiad/Olympiad.java
r5177 r5188 58 58 private static final Map<Integer, StatsSet> _nobles = new FastMap<>(); 59 59 protected static L2FastList<StatsSet> _heroesToBe; 60 private static TIntIntHashMap _noblesRank;60 private static final TIntIntHashMap _noblesRank = new TIntIntHashMap(); 61 61 62 62 private static final String OLYMPIAD_DATA_FILE = "config/olympiad.properties"; … … 79 79 private static final int[] HERO_IDS = 80 80 { 81 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 131, 132, 133, 134 81 88, 82 89, 83 90, 84 91, 85 92, 86 93, 87 94, 88 95, 89 96, 90 97, 91 98, 92 99, 93 100, 94 101, 95 102, 96 103, 97 104, 98 105, 99 106, 100 107, 101 108, 102 109, 103 110, 104 111, 105 112, 106 113, 107 114, 108 115, 109 116, 110 117, 111 118, 112 131, 113 132, 114 133, 115 134 82 116 }; 83 117 … … 245 279 { 246 280 con = L2DatabaseFactory.getInstance().getConnection(); 247 PreparedStatement statement = con.prepareStatement(OLYMPIAD_LOAD_NOBLES);248 ResultSet rset = statement.executeQuery();249 281 final PreparedStatement statement = con.prepareStatement(OLYMPIAD_LOAD_NOBLES); 282 final ResultSet rset = statement.executeQuery(); 283 StatsSet statData; 250 284 while (rset.next()) 251 285 { 252 StatsSet statData = new StatsSet(); 253 int charId = rset.getInt(CHAR_ID); 286 statData = new StatsSet(); 254 287 statData.set(CLASS_ID, rset.getInt(CLASS_ID)); 255 288 statData.set(CHAR_NAME, rset.getString(CHAR_NAME)); … … 265 298 statData.set("to_save", false); 266 299 267 _nobles.put(charId, statData);300 addNobleStats(rset.getInt(CHAR_ID), statData); 268 301 } 269 302 … … 302 335 } 303 336 304 _log.info("Olympiad System: " + Math.round(milliToEnd / 60000) + " minutes until period ends");337 _log.info("Olympiad System: " + (milliToEnd / 60000) + " minutes until period ends"); 305 338 306 339 if (_period == 0) … … 308 341 milliToEnd = getMillisToWeekChange(); 309 342 310 _log.info("Olympiad System: Next weekly change is in " + Math.round(milliToEnd / 60000) + " minutes");343 _log.info("Olympiad System: Next weekly change is in " + (milliToEnd / 60000) + " minutes"); 311 344 } 312 345 } … … 318 351 public void loadNoblesRank() 319 352 { 320 _noblesRank = new TIntIntHashMap();353 _noblesRank.clear(); 321 354 TIntIntHashMap tmpPlace = new TIntIntHashMap(); 322 355 … … 459 492 { 460 493 return _nobles.get(playerId); 461 }462 463 protected static synchronized void updateNobleStats(int playerId, StatsSet stats)464 {465 _nobles.remove(playerId);466 _nobles.put(playerId, stats);467 494 } 468 495 … … 694 721 } 695 722 696 for (Entry<Integer, StatsSet> entry : _nobles.entrySet())697 {698 final StatsSet nobleInfo = entry.getValue();699 intcurrentPoints = nobleInfo.getInteger(POINTS);723 int currentPoints; 724 for (StatsSet nobleInfo : _nobles.values()) 725 { 726 currentPoints = nobleInfo.getInteger(POINTS); 700 727 currentPoints += WEEKLY_POINTS; 701 728 nobleInfo.set(POINTS, currentPoints); 702 703 updateNobleStats(entry.getKey(), nobleInfo);704 729 } 705 730 } … … 715 740 } 716 741 717 for (Entry<Integer, StatsSet> entry : _nobles.entrySet()) 718 { 719 StatsSet nobleInfo = entry.getValue(); 742 for (StatsSet nobleInfo : _nobles.values()) 743 { 720 744 nobleInfo.set(COMP_DONE_WEEK, 0); 721 745 nobleInfo.set(COMP_DONE_WEEK_CLASSED, 0); 722 746 nobleInfo.set(COMP_DONE_WEEK_NON_CLASSED, 0); 723 747 nobleInfo.set(COMP_DONE_WEEK_TEAM, 0); 724 725 updateNobleStats(entry.getKey(), nobleInfo);726 748 } 727 749 } … … 790 812 791 813 nobleInfo.set("to_save", false); 792 793 updateNobleStats(charId, nobleInfo);794 814 } 795 815 else … … 910 930 { 911 931 _logResults.info("Noble,charid,classid,compDone,points"); 912 932 StatsSet nobleInfo; 913 933 for (Entry<Integer, StatsSet> entry : _nobles.entrySet()) 914 934 { 915 final StatsSetnobleInfo = entry.getValue();935 nobleInfo = entry.getValue(); 916 936 if (nobleInfo == null) 917 937 { … … 928 948 record.setParameters(new Object[] 929 949 { 930 charId, classId, compDone, points 950 charId, 951 classId, 952 compDone, 953 points 931 954 }); 932 955 _logResults.log(record); … … 968 991 record.setParameters(new Object[] 969 992 { 970 hero.getInteger(CHAR_ID), hero.getInteger(CLASS_ID) 993 hero.getInteger(CHAR_ID), 994 hero.getInteger(CLASS_ID) 971 995 }); 972 996 _logResults.log(record); … … 995 1019 record.setParameters(new Object[] 996 1020 { 997 hero.getInteger(CHAR_ID), hero.getInteger(CLASS_ID) 1021 hero.getInteger(CHAR_ID), 1022 hero.getInteger(CLASS_ID) 998 1023 }); 999 1024 _logResults.log(record); … … 1052 1077 record.setParameters(new Object[] 1053 1078 { 1054 hero.getInteger(CHAR_ID), hero.getInteger(CLASS_ID) 1079 hero.getInteger(CHAR_ID), 1080 hero.getInteger(CLASS_ID) 1055 1081 }); 1056 1082 _logResults.log(record); … … 1163 1189 { 1164 1190 noble.set(POINTS, 0); 1165 updateNobleStats(objId, noble);1166 1191 } 1167 1192 points *= Config.ALT_OLY_GP_PER_POINT; … … 1362 1387 } 1363 1388 1389 /** 1390 * @param charId the noble object Id. 1391 * @param data the stats set data to add. 1392 * @return the old stats set if the noble is already present, null otherwise. 1393 */ 1394 protected static StatsSet addNobleStats(int charId, StatsSet data) 1395 { 1396 return _nobles.put(Integer.valueOf(charId), data); 1397 } 1398 1364 1399 @SuppressWarnings("synthetic-access") 1365 1400 private static class SingletonHolder -
branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/model/olympiad/OlympiadGameNormal.java
r4942 r5188 36 36 37 37 /** 38 *39 38 * @author GodKratos, Pere, DS 40 39 */ … … 311 310 points = Math.min(playerOnePoints / 3, Config.ALT_OLY_MAX_POINTS); 312 311 removePointsFromParticipant(_playerOne, points); 313 _playerOne.updateNobleStats();314 312 315 313 if (Config.ALT_OLY_LOG_FIGHTS) … … 331 329 points = Math.min(playerTwoPoints / 3, Config.ALT_OLY_MAX_POINTS); 332 330 removePointsFromParticipant(_playerTwo, points); 333 _playerTwo.updateNobleStats();334 331 335 332 if (Config.ALT_OLY_LOG_FIGHTS) … … 425 422 _playerOne.updateStat(getWeeklyMatchType(), 1); 426 423 _playerTwo.updateStat(getWeeklyMatchType(), 1); 427 428 _playerOne.updateNobleStats();429 _playerTwo.updateNobleStats();430 424 return; 431 425 } … … 532 526 _playerOne.updateStat(getWeeklyMatchType(), 1); 533 527 _playerTwo.updateStat(getWeeklyMatchType(), 1); 534 535 _playerOne.updateNobleStats();536 _playerTwo.updateNobleStats();537 528 538 529 if (Config.ALT_OLY_LOG_FIGHTS) -
branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/model/olympiad/OlympiadGameTeams.java
r4942 r5188 33 33 34 34 /** 35 *36 35 * @author Pere, DS 37 36 */ … … 506 505 par = _teamOne[i]; 507 506 removePointsFromParticipant(par, Math.min(par.stats.getInteger(POINTS) / 3, Config.ALT_OLY_MAX_POINTS)); 508 par.updateNobleStats();509 507 } 510 508 } … … 515 513 par = _teamTwo[i]; 516 514 removePointsFromParticipant(par, Math.min(par.stats.getInteger(POINTS) / 3, Config.ALT_OLY_MAX_POINTS)); 517 par.updateNobleStats();518 515 } 519 516 } … … 685 682 par.updateStat(COMP_DONE_WEEK, 1); 686 683 par.updateStat(getWeeklyMatchType(), 1); 687 par.updateNobleStats();688 684 } 689 685 … … 694 690 par.updateStat(COMP_DONE_WEEK, 1); 695 691 par.updateStat(getWeeklyMatchType(), 1); 696 par.updateNobleStats();697 692 } 698 693 } … … 817 812 par.updateStat(COMP_DONE_WEEK, 1); 818 813 par.updateStat(getWeeklyMatchType(), 1); 819 par.updateNobleStats();820 814 } 821 815 … … 826 820 par.updateStat(COMP_DONE_WEEK, 1); 827 821 par.updateStat(getWeeklyMatchType(), 1); 828 par.updateNobleStats();829 822 } 830 823 } -
branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/model/olympiad/OlympiadManager.java
r5083 r5188 39 39 public class OlympiadManager 40 40 { 41 private List<Integer> _nonClassBasedRegisters;42 private Map<Integer, List<Integer>> _classBasedRegisters;43 private List<List<Integer>> _teamsBasedRegisters;41 private final List<Integer> _nonClassBasedRegisters; 42 private final Map<Integer, List<Integer>> _classBasedRegisters; 43 private final List<List<Integer>> _teamsBasedRegisters; 44 44 45 45 private OlympiadManager() … … 219 219 } 220 220 221 if (Olympiad.getInstance().getRemainingWeeklyMatches(player.getObjectId()) < 1) 221 final int charId = player.getObjectId(); 222 if (Olympiad.getInstance().getRemainingWeeklyMatches(charId) < 1) 222 223 { 223 224 player.sendPacket(SystemMessageId.MAX_OLY_WEEKLY_MATCHES_REACHED); … … 232 233 return false; 233 234 234 if (Olympiad.getInstance().getRemainingWeeklyMatchesClassed( player.getObjectId()) < 1)235 if (Olympiad.getInstance().getRemainingWeeklyMatchesClassed(charId) < 1) 235 236 { 236 237 player.sendPacket(SystemMessageId.MAX_OLY_WEEKLY_MATCHES_REACHED_60_NON_CLASSED_30_CLASSED_10_TEAM); … … 240 241 List<Integer> classed = _classBasedRegisters.get(player.getBaseClass()); 241 242 if (classed != null) 242 classed.add( player.getObjectId());243 classed.add(charId); 243 244 else 244 245 { 245 246 classed = new FastList<Integer>().shared(); 246 classed.add( player.getObjectId());247 classed.add(charId); 247 248 _classBasedRegisters.put(player.getBaseClass(), classed); 248 249 } … … 256 257 return false; 257 258 258 if (Olympiad.getInstance().getRemainingWeeklyMatchesNonClassed( player.getObjectId()) < 1)259 if (Olympiad.getInstance().getRemainingWeeklyMatchesNonClassed(charId) < 1) 259 260 { 260 261 player.sendPacket(SystemMessageId.MAX_OLY_WEEKLY_MATCHES_REACHED_60_NON_CLASSED_30_CLASSED_10_TEAM); … … 262 263 } 263 264 264 _nonClassBasedRegisters.add( player.getObjectId());265 _nonClassBasedRegisters.add(charId); 265 266 player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REGISTERED_IN_A_WAITING_LIST_OF_NO_CLASS_GAMES); 266 267 break; … … 455 456 return false; 456 457 } 457 458 if (TvTEvent.isPlayerParticipant(noble.getObjectId())) 458 459 final int charId = noble.getObjectId(); 460 if (TvTEvent.isPlayerParticipant(charId)) 459 461 { 460 462 player.sendMessage("You can't join olympiad while participating on TvT Event."); … … 468 470 return false; 469 471 470 StatsSet statDat = Olympiad.getNobleStats( noble.getObjectId());472 StatsSet statDat = Olympiad.getNobleStats(charId); 471 473 if (statDat == null) 472 474 { … … 484 486 statDat.set(Olympiad.COMP_DONE_WEEK_TEAM, 0); 485 487 statDat.set("to_save", true); 486 Olympiad. updateNobleStats(noble.getObjectId(), statDat);487 } 488 489 final int points = Olympiad.getInstance().getNoblePoints( noble.getObjectId());488 Olympiad.addNobleStats(charId, statDat); 489 } 490 491 final int points = Olympiad.getInstance().getNoblePoints(charId); 490 492 if (points <= 0) 491 493 { -
branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/model/olympiad/Participant.java
r5083 r5188 20 20 21 21 /** 22 *23 22 * @author DS 24 *25 23 */ 26 24 public final class Participant … … 65 63 stats.set(statName, Math.max(stats.getInteger(statName) + increment, 0)); 66 64 } 67 68 public final void updateNobleStats()69 {70 Olympiad.updateNobleStats(objectId, stats);71 }72 65 }
Note: See TracChangeset
for help on using the changeset viewer.
