public static void HandleJoinBattle(object packet, Session session) { // TODO : handle better AI avatar Battle battle; if (BattleManager.Battles.TryGetValue(session.Player.Id, out battle) && WorldManager.AddPlayerSession(session)) { BattleSide playerSide = battle.FindSideByUsername(session.Player.Username); Avatar playerAvatar = session.Player.Avatar; Avatar opponentAvatar; Session opponentSession = WorldManager.GetPlayerSession(playerSide.OpponentSide.PlayerName); if (opponentSession == null) opponentAvatar = new Avatar(); else opponentAvatar = opponentSession.Player.Avatar; Avatar whiteAvatar; Avatar blackAvatar; if (playerSide.Color == PlayerColor.white) { whiteAvatar = playerAvatar; blackAvatar = opponentAvatar; } else { whiteAvatar = opponentAvatar; blackAvatar = playerAvatar; } var gameInfo = new PacketGameInfo() { White = battle.WhiteSide.PlayerName, Black = battle.BlackSide.PlayerName, GameType = battle.Type, GameId = 1, Color = playerSide.Color, roundTimerSeconds = battle.RoundTimeSeconds, Phase = battle.Phase, WhiteAvatar = whiteAvatar, BlackAvatar = blackAvatar, WhiteIdolTypes = new PacketIdolTypes() { ProfileId = battle.WhiteSide.PlayerId, Type = "DEFAULT", Idol1 = 0, Idol2 = 0, Idol3 = 0, Idol4 = 0, Idol5 = 0, }, BlackIdolTypes = new PacketIdolTypes() { ProfileId = battle.BlackSide.PlayerId, Type = "DEFAULT", Idol1 = 0, Idol2 = 0, Idol3 = 0, Idol4 = 0, Idol5 = 0, }, CustomSettings = new List<string>(), RewardForIdolKill = battle.RewardForIdolKill, NodeId = ((IPEndPoint)session.Socket.LocalEndPoint).Address.ToString(), Port = (uint)ConfigManager.Config.Network.BattlePort, MaxTierRewardMultiplier = 0.5f, TierRewardMultiplierDelta = new List<float>(), WhiteIdols = battle.WhiteSide.Idols, BlackIdols = battle.BlackSide.Idols }; session.Send(gameInfo); } else { LogManager.Write("JoinBattle", "player {0} failed to join battle ! Either battle not created or could not add player session!", session.Player.Username); } }
public Player() { CurrentRooms = new List<string>(); Scrolls = new List<ScrollInstance>(); Decks = new List<Deck>(); ValidatedDeck = new List<ulong>(); Avatar = new Avatar(); }