public static TcpPacket CreateTournamentSpectateListingPacket() { TcpPacket packet = new TcpPacket(); int validTournyCount = 0; for (int i = 0; i < TournamentManager.Tournaments.Count; i++) { Tournament tourny = TournamentManager.Tournaments[i]; if (tourny.TournamentStarted == false) { validTournyCount++; packet.AppendParameter(tourny.Name); packet.AppendParameter(tourny.ID); for (int n = 0; n < tourny.RegisteredMembers.Count; n++) { if (tourny.RegisteredMembers[n].Admin) { packet.AppendParameter(tourny.RegisteredMembers[n].Client.Player.Name); break; } } } } packet.PrependParameters("tournamentspectatelisting", validTournyCount.ToString()); return packet; }
public static void SendTrade(Client client, int ShopNum) { TcpPacket packet = new TcpPacket(); //int X = 0; //int i = 0; int XX = 0; //packet.AppendParameters(ShopNum.ToString(), ShopManager.Shops[ShopNum].LeaveSay); for (int i = 0; i < Constants.MAX_TRADES; i++) { if (ShopManager.Shops[ShopNum].Items[i].GetItem > 0) { XX++; packet.AppendParameters( ShopManager.Shops[ShopNum].Items[i].GiveItem.ToString(), ShopManager.Shops[ShopNum].Items[i].GiveValue.ToString(), ShopManager.Shops[ShopNum].Items[i].GetItem.ToString()); } } //for (XX = 0; XX < Constants.MAX_TRADES; XX++) { // if (ShopManager.Shops[ShopNum].Items[XX].GetItem > 0) { // for (int j = 0; j < XX - z - 1; j++) { // packet.AppendParameters("0", "0", "0"); // } // z = XX + 1; // packet.AppendParameters(ShopManager.Shops[ShopNum].Items[XX].GiveItem.ToString(), ShopManager.Shops[ShopNum].Items[XX].GiveValue.ToString(), ShopManager.Shops[ShopNum].Items[XX].GetItem.ToString()); // } //} //packet.AppendParameter(z.ToString()); packet.PrependParameters("trade", ShopNum.ToString(), ShopManager.Shops[ShopNum].LeaveSay, XX.ToString()); packet.FinalizePacket(); if (ShopManager.Shops[ShopNum].JoinSay != "") { PlayerMsg(client, ShopManager.Shops[ShopNum].JoinSay, Text.Yellow); } if (XX == 0) { SendDataTo(client, packet); PlayerMsg(client, "This shop has nothing to sell!", Text.BrightRed); } else { SendDataTo(client, packet); } }
public static TcpPacket CreatePlayerAllRecruitsPacket(Client client) { TcpPacket packet = new TcpPacket(); int recruitCount = 0; int[] team = new int[4] { -1, -1, -1, -1 }; using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players)) { foreach (AssemblyRecruitData assemblyRecruit in PlayerDataManager.LoadPlayerAssemblyRecruits(dbConnection.Database, client.Player.CharID)) { recruitCount++; if (client.Player.IsInTeam(assemblyRecruit.RecruitIndex) == false) { int size = 1; //int mugshot = -1; int species = assemblyRecruit.Species; //int sprite = 0; //if (species > -1 && species <= Constants.TOTAL_POKEMON) { // Pokedex.PokemonForm pokemon = Pokedex.Pokedex.GetPokemonForm(species, assemblyRecruit.Form); // mugshot = pokemon.Mugshot[assemblyRecruit.Shiny, assemblyRecruit.Sex]; // sprite = pokemon.Sprite[assemblyRecruit.Shiny, assemblyRecruit.Sex]; //} packet.AppendParameters(assemblyRecruit.RecruitIndex, species, (int)assemblyRecruit.Sex, assemblyRecruit.Form, (int)assemblyRecruit.Shiny, assemblyRecruit.Level); packet.AppendParameter(assemblyRecruit.Name); } else { int teamSlot = client.Player.FindTeamSlot(assemblyRecruit.RecruitIndex); team[teamSlot] = assemblyRecruit.RecruitIndex; //int mugshot = Pokedex.Pokedex.GetPokemonForm(client.Player.Team[teamSlot].Species, client.Player.Team[teamSlot].Form).Mugshot[assemblyRecruit.Shiny, assemblyRecruit.Sex]; if (teamSlot > -1 && teamSlot < 4) { packet.AppendParameters(assemblyRecruit.RecruitIndex.ToString(), client.Player.Team[teamSlot].Sprite.ToString(), ((int)client.Player.Team[teamSlot].Sex).ToString(), client.Player.Team[teamSlot].Form.ToString(), ((int)client.Player.Team[teamSlot].Shiny).ToString(), client.Player.Team[teamSlot].Level.ToString(), client.Player.Team[teamSlot].Name); } } } } packet.PrependParameters("allrecruits", recruitCount.ToString(), team[0].ToString(), team[1].ToString(), team[2].ToString(), team[3].ToString()); return packet; }
public static void SendOnlineList(Client client) { TcpPacket packet = new TcpPacket(); int n = 0; foreach (Client i in ClientManager.GetClients()) { if (i.IsPlaying()) { packet.AppendParameter(i.Player.Name); n++; } } packet.PrependParameters("onlinelist", n.ToString()); packet.FinalizePacket(); SendDataTo(client, packet); }