mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-21 20:25:51 +12:00
push changes i have
This commit is contained in:
parent
6256c38414
commit
7686680c09
7 changed files with 244 additions and 5 deletions
|
@ -5025,6 +5025,26 @@ namespace HISP.Server
|
|||
}
|
||||
}
|
||||
|
||||
public static void AddNewWinner(int playerId, string gameTitle, int wins, int looses)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "INSERT INTO Leaderboards VALUES(@playerId,@gameTitle,@wins,@loose,1,0,@type)";
|
||||
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
|
||||
sqlCommand.Parameters.AddWithValue("@gameTitle", gameTitle);
|
||||
sqlCommand.Parameters.AddWithValue("@wins", wins);
|
||||
sqlCommand.Parameters.AddWithValue("@loose", looses);
|
||||
sqlCommand.Parameters.AddWithValue("@type", "WINLOSS");
|
||||
sqlCommand.Prepare();
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
|
||||
sqlCommand.Dispose();
|
||||
return;
|
||||
}
|
||||
}
|
||||
public static void AddNewHighscore(int playerId, string gameTitle, int score, string type)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
|
@ -5076,6 +5096,38 @@ namespace HISP.Server
|
|||
}
|
||||
}
|
||||
|
||||
public static Highscore.HighscoreTableEntry[] GetTopWinners(string gameTitle, int limit)
|
||||
{
|
||||
List<Highscore.HighscoreTableEntry> entires = new List<Highscore.HighscoreTableEntry>();
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "SELECT * FROM Leaderboards WHERE minigame=@gameTitle ORDER BY wins DESC LIMIT @limit";
|
||||
sqlCommand.Parameters.AddWithValue("@gameTitle", gameTitle);
|
||||
sqlCommand.Parameters.AddWithValue("@limit", limit);
|
||||
sqlCommand.Prepare();
|
||||
MySqlDataReader reader = sqlCommand.ExecuteReader();
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
Highscore.HighscoreTableEntry highscoreEntry = new Highscore.HighscoreTableEntry();
|
||||
highscoreEntry.UserId = reader.GetInt32(0);
|
||||
highscoreEntry.GameName = gameTitle;
|
||||
highscoreEntry.Wins = reader.GetInt32(2);
|
||||
highscoreEntry.Looses = reader.GetInt32(3);
|
||||
highscoreEntry.TimesPlayed = reader.GetInt32(4);
|
||||
highscoreEntry.Score = reader.GetInt32(5);
|
||||
highscoreEntry.Type = reader.GetString(6);
|
||||
entires.Add(highscoreEntry);
|
||||
}
|
||||
|
||||
|
||||
sqlCommand.Dispose();
|
||||
return entires.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public static Highscore.HighscoreTableEntry[] GetTopScores(string gameTitle, int limit)
|
||||
{
|
||||
List<Highscore.HighscoreTableEntry> entires = new List<Highscore.HighscoreTableEntry>();
|
||||
|
@ -5131,6 +5183,40 @@ namespace HISP.Server
|
|||
return i;
|
||||
}
|
||||
}
|
||||
public static void UpdateHighscoreWinGame(int playerId, string gameTitle)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "UPDATE Leaderboards SET wins=wins+1, timesplayed=timesplayed+1 WHERE playerId=@playerId AND minigame=@gameTitle";
|
||||
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
|
||||
sqlCommand.Parameters.AddWithValue("@gameTitle", gameTitle);
|
||||
sqlCommand.Prepare();
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
|
||||
sqlCommand.Dispose();
|
||||
return;
|
||||
}
|
||||
}
|
||||
public static void UpdateHighscoreLooseGame(int playerId, string gameTitle)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "UPDATE Leaderboards SET looses=looses+1, timesplayed=timesplayed+1 WHERE playerId=@playerId AND minigame=@gameTitle";
|
||||
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
|
||||
sqlCommand.Parameters.AddWithValue("@gameTitle", gameTitle);
|
||||
sqlCommand.Prepare();
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
|
||||
sqlCommand.Dispose();
|
||||
return;
|
||||
}
|
||||
}
|
||||
public static void UpdateHighscore(int playerId, string gameTitle, int score)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
|
|
|
@ -4020,9 +4020,10 @@ namespace HISP.Server
|
|||
return;
|
||||
}
|
||||
}
|
||||
else if (method == PacketBuilder.SECCODE_SCORE || method == PacketBuilder.SECCODE_TIME)
|
||||
else if (method == PacketBuilder.SECCODE_SCORE || method == PacketBuilder.SECCODE_TIME || method == PacketBuilder.SECCODE_WINLOOSE)
|
||||
{
|
||||
bool time = (method == PacketBuilder.SECCODE_TIME);
|
||||
bool winloose = (method == PacketBuilder.SECCODE_WINLOOSE);
|
||||
|
||||
byte[] ExpectedSecCode = sender.LoggedinUser.GenerateSecCode();
|
||||
byte[] GotSecCode = new byte[4];
|
||||
|
@ -4032,12 +4033,39 @@ namespace HISP.Server
|
|||
{
|
||||
if (packet.Length < 6)
|
||||
{
|
||||
Logger.ErrorPrint(sender.LoggedinUser.Username + " Sent a seccode score request with invalid size");
|
||||
Logger.ErrorPrint(sender.LoggedinUser.Username + " Sent a seccode score/time/winloose request with invalid size");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
string packetStr = Encoding.UTF8.GetString(packet);
|
||||
string gameInfoStr = packetStr.Substring(6, packetStr.Length - 6 - 2);
|
||||
if (winloose)
|
||||
{
|
||||
string gameTitle = gameInfoStr.Substring(1);
|
||||
byte pmethod = packet[6];
|
||||
if(pmethod == PacketBuilder.WINLOOSE_WIN)
|
||||
{
|
||||
sender.LoggedinUser.Highscores.Win(gameTitle);
|
||||
}
|
||||
else if(pmethod == PacketBuilder.WINLOOSE_LOOSE)
|
||||
{
|
||||
sender.LoggedinUser.Highscores.Loose(gameTitle);
|
||||
}
|
||||
|
||||
if (sender.LoggedinUser.Highscores.HighscoreList.Length >= 30)
|
||||
sender.LoggedinUser.Awards.AddAward(Award.GetAwardById(12)); // Minigame Player
|
||||
|
||||
if (sender.LoggedinUser.Highscores.HighscoreList.Length >= 60)
|
||||
sender.LoggedinUser.Awards.AddAward(Award.GetAwardById(13)); // Minigame Master
|
||||
|
||||
if (Database.GetPlayerTotalMinigamesPlayed(sender.LoggedinUser.Id) >= 1000)
|
||||
sender.LoggedinUser.Awards.AddAward(Award.GetAwardById(14)); // Minigame Nut
|
||||
|
||||
if (Database.GetPlayerTotalMinigamesPlayed(sender.LoggedinUser.Id) >= 10000)
|
||||
sender.LoggedinUser.Awards.AddAward(Award.GetAwardById(15)); // Minigame Crazy
|
||||
return;
|
||||
}
|
||||
if (gameInfoStr.Contains("|"))
|
||||
{
|
||||
string[] gameInfo = gameInfoStr.Split('|');
|
||||
|
@ -4348,7 +4376,18 @@ namespace HISP.Server
|
|||
byte[] metaTag = PacketBuilder.CreateMetaPacket(Meta.BuildTopTimes(gameName));
|
||||
sender.SendPacket(metaTag);
|
||||
}
|
||||
|
||||
else if (method == PacketBuilder.PROFILE_WINLOOSE_LIST)
|
||||
{
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
string packetStr = Encoding.UTF8.GetString(packet);
|
||||
string gameName = packetStr.Substring(2, packetStr.Length - 4);
|
||||
byte[] metaTag = PacketBuilder.CreateMetaPacket(Meta.BuildTopWinners(gameName));
|
||||
sender.SendPacket(metaTag);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.DebugPrint("Unknown Profile Packet! " + BitConverter.ToString(packet).Replace("-", " "));
|
||||
}
|
||||
}
|
||||
public static void OnMovementPacket(GameClient sender, byte[] packet)
|
||||
{
|
||||
|
|
|
@ -141,10 +141,14 @@ namespace HISP.Server
|
|||
public const byte SECCODE_GIVE_ITEM = 0x28;
|
||||
public const byte SECCODE_DELETE_ITEM = 0x29;
|
||||
public const byte SECCODE_SCORE = 0x3D;
|
||||
public const byte SECCODE_WINLOOSE = 0x3C;
|
||||
public const byte SECCODE_TIME = 0x3E;
|
||||
public const byte SECCODE_MONEY = 0x1E;
|
||||
public const byte SECCODE_AWARD = 0x33;
|
||||
|
||||
public const byte WINLOOSE_WIN = 0x14;
|
||||
public const byte WINLOOSE_LOOSE = 0x15;
|
||||
|
||||
public const byte NPC_START_CHAT = 0x14;
|
||||
public const byte NPC_CONTINUE_CHAT = 0x15;
|
||||
|
||||
|
@ -152,6 +156,7 @@ namespace HISP.Server
|
|||
public const byte PLAYERINFO_UPDATE_OR_CREATE = 0x15;
|
||||
public const byte PLAYERINFO_PLAYER_LIST = 0x14;
|
||||
|
||||
public const byte PROFILE_WINLOOSE_LIST = 0x50;
|
||||
public const byte PROFILE_HIGHSCORES_LIST = 0x51;
|
||||
public const byte PROFILE_BESTTIMES_LIST = 0x52;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue