Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package l2r.gameserver.network.serverpackets;
- import java.util.Collections;
- import java.util.List;
- public class ExPVPMatchRecord extends L2GameServerPacket
- {
- public static List<PlayerStats> NO_PLAYER_STATS = Collections.emptyList();
- public enum MatchRecordType
- {
- INIT_SCORE, // 0 = Score (Always 0:0) + Time (Static 10min) + Party Names (if there are ppl in the list) + Match Results button -> http://i.imgur.com/qdwL2JY.png
- UPDATE_SCORE, // 1 = Update Score (Defining Win/Lose/Player Teams is unnecessary)
- FINAL_SCORE_WINDOW, // 2 = Score Window. Stops score timer -> http://i.imgur.com/msrZVR3.png
- ADD_PLAYERS_TO_SCORE_WINDOW // 3+ = Adds players to score window. It will add them ontop of previous records
- }
- public enum MatchRecordWinner
- {
- NONE, // 0 - Blank
- BLUE, // 1 - Win
- RED // 2 - Lose
- }
- private MatchRecordType _type;
- private MatchRecordWinner _winner;
- private int _blueScore;
- private int _redScore;
- List<PlayerStats> _bluePlayers;
- List<PlayerStats> _redPlayers;
- public ExPVPMatchRecord(MatchRecordType type, MatchRecordWinner winner, int blueScore, int redScore, List<PlayerStats> bluePlayers, List<PlayerStats> redPlayers)
- {
- _type = type;
- _winner = winner;
- _blueScore = blueScore;
- _redScore = redScore;
- _bluePlayers = (bluePlayers != null) ? bluePlayers : NO_PLAYER_STATS;
- _redPlayers = (redPlayers != null) ? redPlayers : NO_PLAYER_STATS;
- }
- public ExPVPMatchRecord(MatchRecordType type, int blueScore, int redScore, List<PlayerStats> bluePlayers, List<PlayerStats> redPlayers)
- {
- _type = type;
- _winner = blueScore > redScore ? MatchRecordWinner.BLUE : redScore > blueScore ? MatchRecordWinner.RED : MatchRecordWinner.NONE;
- _blueScore = blueScore;
- _redScore = redScore;
- _bluePlayers = (bluePlayers != null) ? bluePlayers : NO_PLAYER_STATS;
- _redPlayers = (redPlayers != null) ? redPlayers : NO_PLAYER_STATS;
- }
- public static ExPVPMatchRecord updateScore(int blueScore, int redScore)
- {
- return new ExPVPMatchRecord(MatchRecordType.UPDATE_SCORE, MatchRecordWinner.NONE, blueScore, redScore, null, null);
- }
- public static ExPVPMatchRecord initScore(List<PlayerStats> bluePlayers, List<PlayerStats> redPlayers)
- {
- return new ExPVPMatchRecord(MatchRecordType.INIT_SCORE, MatchRecordWinner.NONE, 0, 0, bluePlayers, redPlayers);
- }
- public static ExPVPMatchRecord addPlayers(List<PlayerStats> bluePlayers, List<PlayerStats> redPlayers)
- {
- return new ExPVPMatchRecord(MatchRecordType.ADD_PLAYERS_TO_SCORE_WINDOW, MatchRecordWinner.NONE, 0, 0, bluePlayers, redPlayers);
- }
- @Override
- protected void writeImpl()
- {
- writeEx(0x7E);
- writeD(_type.ordinal()); // Type
- writeD(_winner == MatchRecordWinner.BLUE ? 1 : _winner.ordinal()); // Blue(Left) Blank/Win/Lose
- writeD(_winner == MatchRecordWinner.RED ? 1 : _winner == MatchRecordWinner.BLUE ? 2 : 0); // Red(Red) Blank/Win/Lose
- writeD(_blueScore); // Score Blue
- writeD(_redScore); // Score Red
- writeD(_bluePlayers.size()); // Blue Team Player size
- for (PlayerStats ps : _bluePlayers)
- {
- writeS(ps.playerName); // Player Name
- writeD(ps.kills); // Kills
- writeD(ps.deaths); // Deaths
- }
- writeD(_redPlayers.size()); // Red Team Player size
- for (PlayerStats ps : _redPlayers)
- {
- writeS(ps.playerName); // Player Name
- writeD(ps.kills); // Kills
- writeD(ps.deaths); // Deaths
- }
- }
- public static class PlayerStats
- {
- String playerName;
- int kills;
- int deaths;
- public PlayerStats(String playerName, int kills, int deaths)
- {
- this.playerName = playerName;
- this.kills = kills;
- this.deaths = deaths;
- }
- public PlayerStats(String playerName)
- {
- this.playerName = playerName;
- kills = 0;
- deaths = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement