mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-25 06:04:46 -04:00
Persist max/total rounds survived and infections.
This commit is contained in:
parent
b436852419
commit
171c5a8e90
@ -96,7 +96,7 @@ namespace MCGalaxy.Commands {
|
||||
ParameterisedQuery query = ParameterisedQuery.Create();
|
||||
DataTable Messages = Database.fillData(query, "SELECT * FROM `Messages" + p.level.name + "` WHERE X=" + x + " AND Y=" + y + " AND Z=" + z);
|
||||
|
||||
query.AddParam("@Message", cpos.message);
|
||||
query.AddParam("@Message", cpos.message);
|
||||
if (Messages.Rows.Count == 0)
|
||||
Database.executeQuery(query, "INSERT INTO `Messages" + p.level.name + "` (X, Y, Z, Message) VALUES (" + x + ", " + y + ", " + z + ", @Message)");
|
||||
else
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using MCGalaxy.SQL;
|
||||
@ -69,7 +70,7 @@ namespace MCGalaxy.Games {
|
||||
p.SetPrefix();
|
||||
|
||||
if (p.Game.Invisible) {
|
||||
p.SendCpeMessage(CpeMessageType.BottomRight2, "", false);
|
||||
p.SendCpeMessage(CpeMessageType.BottomRight2, "", false);
|
||||
Player.GlobalSpawn(p, false);
|
||||
p.Game.ResetInvisibility();
|
||||
}
|
||||
@ -94,7 +95,7 @@ namespace MCGalaxy.Games {
|
||||
void ChangeLevel(string next) {
|
||||
Player[] online = PlayerInfo.Online.Items;
|
||||
if (CurLevel != null) {
|
||||
Level.SaveSettings(CurLevel);
|
||||
Level.SaveSettings(CurLevel);
|
||||
CurLevel.ChatLevel("The next map has been chosen - " + Colors.red + next.ToLower());
|
||||
CurLevel.ChatLevel("Please wait while you are transfered.");
|
||||
}
|
||||
@ -130,14 +131,14 @@ namespace MCGalaxy.Games {
|
||||
Player[] online = PlayerInfo.Online.Items;
|
||||
|
||||
foreach (Player pl in online) {
|
||||
pl.Game.ResetZombieState();
|
||||
pl.Game.ResetZombieState();
|
||||
|
||||
if (pl.Game.Invisible) {
|
||||
pl.Game.ResetInvisibility();
|
||||
pl.Game.ResetInvisibility();
|
||||
Entities.GlobalSpawn(pl, false);
|
||||
}
|
||||
pl.SetPrefix();
|
||||
|
||||
pl.SetPrefix();
|
||||
|
||||
if (pl.level == null || !pl.level.name.CaselessEq(CurLevelName))
|
||||
continue;
|
||||
ResetCpeMessages(pl);
|
||||
@ -186,6 +187,27 @@ namespace MCGalaxy.Games {
|
||||
return ((seconds + 59) / 60) + " mins left";
|
||||
}
|
||||
|
||||
static string[] defMessages = new string[] { "{0} WIKIWOO'D {1}", "{0} stuck their teeth into {1}",
|
||||
"{0} licked {1}'s brain ", "{0} danubed {1}", "{0} made {1} meet their maker", "{0} tripped {1}",
|
||||
"{0} made some zombie babies with {1}", "{0} made {1} see the dark side", "{0} tweeted {1}",
|
||||
"{0} made {1} open source", "{0} infected {1}", "{0} iDotted {1}", "{1} got nommed on",
|
||||
"{0} transplanted {1}'s living brain" };
|
||||
|
||||
public void LoadInfectMessages() {
|
||||
messages.Clear();
|
||||
try {
|
||||
if (!File.Exists("text/infectmessages.txt"))
|
||||
File.WriteAllLines("text/infectmessages.txt", defMessages);
|
||||
messages = CP437Reader.ReadAllLines("text/infectmessages.txt");
|
||||
} catch (Exception ex) {
|
||||
Server.ErrorLog(ex);
|
||||
}
|
||||
if (messages.Count == 0)
|
||||
messages = new List<string>(defMessages);
|
||||
}
|
||||
|
||||
#region Database
|
||||
|
||||
const string createSyntax =
|
||||
@"CREATE TABLE if not exists ZombieStats (
|
||||
ID INTEGER {0}{1} NOT NULL,
|
||||
@ -206,23 +228,43 @@ Additional4 INT{2});"; // reserve space for possible future additions
|
||||
Database.executeQuery(string.Format(createSyntax, primKey, autoInc, primKey2));
|
||||
}
|
||||
|
||||
static string[] defMessages = new string[] { "{0} WIKIWOO'D {1}", "{0} stuck their teeth into {1}",
|
||||
"{0} licked {1}'s brain ", "{0} danubed {1}", "{0} made {1} meet their maker", "{0} tripped {1}",
|
||||
"{0} made some zombie babies with {1}", "{0} made {1} see the dark side", "{0} tweeted {1}",
|
||||
"{0} made {1} open source", "{0} infected {1}", "{0} iDotted {1}", "{1} got nommed on",
|
||||
"{0} transplanted {1}'s living brain" };
|
||||
|
||||
public void LoadInfectMessages() {
|
||||
messages.Clear();
|
||||
try {
|
||||
if (!File.Exists("text/infectmessages.txt"))
|
||||
File.WriteAllLines("text/infectmessages.txt", defMessages);
|
||||
messages = CP437Reader.ReadAllLines("text/infectmessages.txt");
|
||||
} catch (Exception ex) {
|
||||
Server.ErrorLog(ex);
|
||||
public void LoadZombieStats(Player p) {
|
||||
ParameterisedQuery query = ParameterisedQuery.Create();
|
||||
query.AddParam("@Name", p.name);
|
||||
DataTable table = Database.fillData(query, "SELECT * FROM ZombieStats WHERE Name=@Name");
|
||||
if (table.Rows.Count > 0) {
|
||||
Server.s.Log("GOTTEM" );
|
||||
DataRow row = table.Rows[0];
|
||||
foreach (var t in row.ItemArray)
|
||||
Server.s.Log(t.ToString());
|
||||
p.Game.TotalRoundsSurvived = int.Parse(row["TotalRounds"].ToString());
|
||||
p.Game.MaxRoundsSurvived = int.Parse(row["MaxRounds"].ToString());
|
||||
p.Game.TotalInfected = int.Parse(row["TotalInfected"].ToString());
|
||||
p.Game.MaxInfected = int.Parse(row["MaxInfected"].ToString());
|
||||
}
|
||||
if (messages.Count == 0)
|
||||
messages = new List<string>(defMessages);
|
||||
table.Dispose();
|
||||
}
|
||||
|
||||
public void SaveZombieStats(Player p) {
|
||||
if (p.Game.TotalRoundsSurvived == 0 && p.Game.TotalInfected == 0) return;
|
||||
ParameterisedQuery query = ParameterisedQuery.Create();
|
||||
query.AddParam("@Name", p.name);
|
||||
DataTable table = Database.fillData(query, "SELECT * FROM ZombieStats WHERE Name=@Name");
|
||||
|
||||
query.AddParam("@Name", p.name);
|
||||
query.AddParam("@TR", p.Game.TotalRoundsSurvived);
|
||||
query.AddParam("@MR", p.Game.MaxRoundsSurvived);
|
||||
query.AddParam("@TI", p.Game.TotalInfected);
|
||||
query.AddParam("@MI", p.Game.MaxInfected);
|
||||
|
||||
if (table.Rows.Count == 0)
|
||||
Database.executeQuery(query, "INSERT INTO ZombieStats (TotalRounds, MaxRounds, " +
|
||||
"TotalInfected, MaxInfected, Name) VALUES (@TR, @MR, @TI, @MI, @Name)");
|
||||
else
|
||||
Database.executeQuery(query, "UPDATE ZombieStats SET TotalRounds=@TR, MaxRounds=@MR, " +
|
||||
"TotalInfected=@TI, MaxInfected=@MI WHERE Name=@NAME");
|
||||
table.Dispose();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -504,6 +504,7 @@ namespace MCGalaxy {
|
||||
InitPlayerStats(playerDb);
|
||||
else
|
||||
LoadPlayerStats(playerDb);
|
||||
Server.zombie.LoadZombieStats(this);
|
||||
|
||||
if (!Directory.Exists("players"))
|
||||
Directory.CreateDirectory("players");
|
||||
|
@ -376,7 +376,8 @@ namespace MCGalaxy {
|
||||
Economy.EcoStats ecos = Economy.RetrieveEcoStats(name);
|
||||
ecos.money = money;
|
||||
Economy.UpdateEcoStats(ecos);
|
||||
}
|
||||
}
|
||||
Server.zombie.SaveZombieStats(this);
|
||||
|
||||
try {
|
||||
if ( !smileySaved ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user