mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-29 08:32:14 -04:00
More modularisation in ZombieGame code.
This commit is contained in:
parent
8ea680ed26
commit
d1764a7ee0
@ -38,10 +38,10 @@ namespace MCGalaxy.Commands
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player.SendMessage(p, who.color + who.name + " %S(" + who.DisplayName + ") %Sis on &b" + who.level.name);
|
Player.SendMessage(p, who.color + who.name + " %S(" + who.DisplayName + ") %Sis on &b" + who.level.name);
|
||||||
Player.SendMessage(p, who.FullName + Server.DefaultColor + " %Shas :");
|
Player.SendMessage(p, who.FullName + " %Shas :");
|
||||||
Player.SendMessage(p, "> > the rank of " + who.group.color + who.group.name);
|
Player.SendMessage(p, "> > the rank of " + who.group.color + who.group.name);
|
||||||
if (Economy.Enabled)
|
if (Economy.Enabled)
|
||||||
Player.SendMessage(p, "> > &a" + who.money + Server.DefaultColor + " " + Server.moneys);
|
Player.SendMessage(p, "> > &a" + who.money + " %S" + Server.moneys);
|
||||||
|
|
||||||
Player.SendMessage(p, "> > &cdied &a" + who.overallDeath + Server.DefaultColor + " times");
|
Player.SendMessage(p, "> > &cdied &a" + who.overallDeath + Server.DefaultColor + " times");
|
||||||
Player.SendMessage(p, "> > &bmodified &a" + who.overallBlocks + " &eblocks &eand &a" + who.loginBlocks + " &ewere changed &9since logging in&e.");
|
Player.SendMessage(p, "> > &bmodified &a" + who.overallBlocks + " &eblocks &eand &a" + who.loginBlocks + " &ewere changed &9since logging in&e.");
|
||||||
@ -50,7 +50,7 @@ namespace MCGalaxy.Commands
|
|||||||
Player.SendMessage(p, "> > time spent on server: " + time.Days + " Days, " + time.Hours + " Hours, " + time.Minutes + " Minutes, " + time.Seconds + " Seconds.");
|
Player.SendMessage(p, "> > time spent on server: " + time.Days + " Days, " + time.Hours + " Hours, " + time.Minutes + " Minutes, " + time.Seconds + " Seconds.");
|
||||||
Player.SendMessage(p, "> > been logged in for &a" + storedTime);
|
Player.SendMessage(p, "> > been logged in for &a" + storedTime);
|
||||||
Player.SendMessage(p, "> > first logged into the server on &a" + who.firstLogin.ToString("yyyy-MM-dd") + " at " + who.firstLogin.ToString("HH:mm:ss"));
|
Player.SendMessage(p, "> > first logged into the server on &a" + who.firstLogin.ToString("yyyy-MM-dd") + " at " + who.firstLogin.ToString("HH:mm:ss"));
|
||||||
Player.SendMessage(p, "> > logged in &a" + who.totalLogins + Server.DefaultColor + " times, &c" + who.totalKicked + Server.DefaultColor + " of which ended in a kick.");
|
Player.SendMessage(p, "> > logged in &a" + who.totalLogins + " %Stimes, &c" + who.totalKicked + " %Sof which ended in a kick.");
|
||||||
Player.SendMessage(p, "> > " + Awards.awardAmount(who.name) + " awards");
|
Player.SendMessage(p, "> > " + Awards.awardAmount(who.name) + " awards");
|
||||||
if (Ban.IsBanned(who.name)) {
|
if (Ban.IsBanned(who.name)) {
|
||||||
string[] data = Ban.GetBanData(who.name);
|
string[] data = Ban.GetBanData(who.name);
|
||||||
|
@ -59,13 +59,13 @@ namespace MCGalaxy.Commands
|
|||||||
|
|
||||||
if (p.modeType == b)
|
if (p.modeType == b)
|
||||||
{
|
{
|
||||||
Player.SendMessage(p, "&b" + Block.Name(p.modeType)[0].ToString().ToUpper() + Block.Name(p.modeType).Remove(0, 1).ToLower() + Server.DefaultColor + " %Smode: &cOFF");
|
Player.SendMessage(p, "&b" + Block.Name(p.modeType)[0].ToString().ToUpper() + Block.Name(p.modeType).Remove(0, 1).ToLower() + " %Smode: &cOFF");
|
||||||
p.modeType = 0;
|
p.modeType = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p.modeType = b;
|
p.modeType = b;
|
||||||
Player.SendMessage(p, "&b" + Block.Name(p.modeType)[0].ToString().ToUpper() + Block.Name(p.modeType).Remove(0, 1).ToLower() + Server.DefaultColor + " %Smode: &aON");
|
Player.SendMessage(p, "&b" + Block.Name(p.modeType)[0].ToString().ToUpper() + Block.Name(p.modeType).Remove(0, 1).ToLower() + " %Smode: &aON");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,13 +69,13 @@ namespace MCGalaxy.Commands
|
|||||||
|
|
||||||
if (number > 1)
|
if (number > 1)
|
||||||
{
|
{
|
||||||
Player.SendMessage(p, "Your password must be &cone " + Server.DefaultColor + "word!");
|
Player.SendMessage(p, "Your password must be &cone %Sword!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Directory.Exists("extra/passwords"))
|
if (!Directory.Exists("extra/passwords"))
|
||||||
{
|
{
|
||||||
Player.SendMessage(p, "You have not &cset a password, " + Server.DefaultColor + "use &a/setpass [Password] &cto set one!");
|
Player.SendMessage(p, "You have not &cset a password, %Suse &a/setpass [Password] &cto set one!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,23 +83,20 @@ namespace MCGalaxy.Commands
|
|||||||
FileInfo[] fi = di.GetFiles("*.dat");
|
FileInfo[] fi = di.GetFiles("*.dat");
|
||||||
if (!File.Exists("extra/passwords/" + p.name + ".dat"))
|
if (!File.Exists("extra/passwords/" + p.name + ".dat"))
|
||||||
{
|
{
|
||||||
Player.SendMessage(p, "You have not &cset a password, " + Server.DefaultColor + "use &a/setpass [Password] &cto set one!");
|
Player.SendMessage(p, "You have not &cset a password, %Suse &a/setpass [Password] &cto set one!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PasswordHasher.MatchesPass(p.name, message))
|
if (PasswordHasher.MatchesPass(p.name, message))
|
||||||
{
|
{
|
||||||
Player.SendMessage(p, "Thank you, " + p.color + p.name + Server.DefaultColor + "! You have now &averified " + Server.DefaultColor + "and have &aaccess to admin commands and features!");
|
Player.SendMessage(p, "Thank you, " + p.color + p.name + "%S! You have now &averified %Sand have &aaccess to admin commands and features!");
|
||||||
if (p.adminpen)
|
|
||||||
{
|
|
||||||
p.adminpen = false;
|
p.adminpen = false;
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.passtries++;
|
p.passtries++;
|
||||||
Player.SendMessage(p, "&cWrong Password. " + Server.DefaultColor + "Remember your password is &ccase sensitive!");
|
Player.SendMessage(p, "&cWrong Password. %SRemember your password is &ccase sensitive!");
|
||||||
Player.SendMessage(p, "Forgot your password? " + Server.DefaultColor + "Contact the owner so they can reset it!");
|
Player.SendMessage(p, "Forgot your password? %SContact the owner so they can reset it!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Help(Player p)
|
public override void Help(Player p)
|
||||||
|
@ -36,7 +36,7 @@ namespace MCGalaxy.Commands
|
|||||||
Directory.CreateDirectory("extra/passwords");
|
Directory.CreateDirectory("extra/passwords");
|
||||||
if (p.group.Permission < Server.verifyadminsrank)
|
if (p.group.Permission < Server.verifyadminsrank)
|
||||||
{
|
{
|
||||||
Player.SendMessage(p, "You do not have the &crequired rank " + Server.DefaultColor + "to use this command!");
|
Player.SendMessage(p, "You do not have the &crequired rank %Sto use this command!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Server.verifyadmins)
|
if (!Server.verifyadmins)
|
||||||
@ -48,7 +48,8 @@ namespace MCGalaxy.Commands
|
|||||||
{
|
{
|
||||||
if (File.Exists("extra/passwords/" + p.name + ".dat"))
|
if (File.Exists("extra/passwords/" + p.name + ".dat"))
|
||||||
{
|
{
|
||||||
Player.SendMessage(p, "&cYou already have a password set. " + Server.DefaultColor + "You &ccannot change " + Server.DefaultColor + "it unless &cyou verify it with &a/pass [Password]. " + Server.DefaultColor + "If you have &cforgotten " + Server.DefaultColor + "your password, contact &c" + Server.server_owner + Server.DefaultColor + " and they can &creset it!");
|
Player.SendMessage(p, "&cYou already have a password set. %SYou &ccannot change %Sit unless &cyou verify it with &a/pass [Password]. " +
|
||||||
|
"%SIf you have &cforgotten %Syour password, contact &c" + Server.server_owner + " %Sand they can &creset it!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -289,19 +289,8 @@ namespace MCGalaxy.Games {
|
|||||||
online = PlayerInfo.Online.Items;
|
online = PlayerInfo.Online.Items;
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
foreach (Player pl in online) {
|
foreach (Player pl in online) {
|
||||||
int money = 0;
|
|
||||||
if (!pl.level.name.CaselessEq(CurLevelName)) continue;
|
if (!pl.level.name.CaselessEq(CurLevelName)) continue;
|
||||||
bool inBlock = pl.CheckIfInsideBlock();
|
int money = GetMoney(pl, alive, rand);
|
||||||
|
|
||||||
if (pl.CheckIfInsideBlock()) {
|
|
||||||
money = -1;
|
|
||||||
} else if (alive.Length == 0) {
|
|
||||||
money = rand.Next(1 + pl.Game.NumInfected, 5 + pl.Game.NumInfected);
|
|
||||||
} else if (alive.Length == 1 && !pl.Game.Infected) {
|
|
||||||
money = rand.Next(5, 10);
|
|
||||||
} else if (alive.Length > 1 && !pl.Game.Infected) {
|
|
||||||
money = rand.Next(2, 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
Player.GlobalDespawn(pl, false);
|
Player.GlobalDespawn(pl, false);
|
||||||
Player.GlobalSpawn(pl, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1], false);
|
Player.GlobalSpawn(pl, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1], false);
|
||||||
@ -326,6 +315,19 @@ namespace MCGalaxy.Games {
|
|||||||
Infected.Clear();
|
Infected.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GetMoney(Player pl, Player[] alive, Random rand) {
|
||||||
|
if (pl.CheckIfInsideBlock()) return -1;
|
||||||
|
|
||||||
|
if (alive.Length == 0) {
|
||||||
|
return rand.Next(1 + pl.Game.NumInfected, 5 + pl.Game.NumInfected);
|
||||||
|
} else if (alive.Length == 1 && !pl.Game.Infected) {
|
||||||
|
return rand.Next(5, 10);
|
||||||
|
} else if (alive.Length > 1 && !pl.Game.Infected) {
|
||||||
|
return rand.Next(2, 6);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void ResetPlayer(Player p, ref string playersString) {
|
void ResetPlayer(Player p, ref string playersString) {
|
||||||
p.Game.BlocksLeft = 50;
|
p.Game.BlocksLeft = 50;
|
||||||
p.Game.Infected = false;
|
p.Game.Infected = false;
|
||||||
@ -346,7 +348,7 @@ namespace MCGalaxy.Games {
|
|||||||
|
|
||||||
if (levels.Count <= 2 && UseLevelList) { Server.s.Log("You must have more than 2 levels in your level list to change levels in Zombie Survival"); return; }
|
if (levels.Count <= 2 && UseLevelList) { Server.s.Log("You must have more than 2 levels in your level list to change levels in Zombie Survival"); return; }
|
||||||
|
|
||||||
string selectedLevel1 = "", selectedLevel2 = "";
|
string picked1 = "", picked2 = "";
|
||||||
Random r = new Random();
|
Random r = new Random();
|
||||||
|
|
||||||
LevelChoice:
|
LevelChoice:
|
||||||
@ -355,16 +357,16 @@ namespace MCGalaxy.Games {
|
|||||||
|
|
||||||
if (level == lastLevel1 || level == lastLevel2 || level == CurLevelName ||
|
if (level == lastLevel1 || level == lastLevel2 || level == CurLevelName ||
|
||||||
level2 == lastLevel1 || level2 == lastLevel2 || level2 == CurLevelName ||
|
level2 == lastLevel1 || level2 == lastLevel2 || level2 == CurLevelName ||
|
||||||
level == selectedLevel1) {
|
level == picked1) {
|
||||||
goto LevelChoice;
|
goto LevelChoice;
|
||||||
} else if (selectedLevel1 == "") {
|
} else if (picked1 == "") {
|
||||||
selectedLevel1 = level; goto LevelChoice;
|
picked1 = level; goto LevelChoice;
|
||||||
} else {
|
} else {
|
||||||
selectedLevel2 = level2;
|
picked2 = level2;
|
||||||
}
|
}
|
||||||
|
|
||||||
Level1Vote = 0; Level2Vote = 0; Level3Vote = 0;
|
Level1Vote = 0; Level2Vote = 0; Level3Vote = 0;
|
||||||
lastLevel1 = selectedLevel1; lastLevel2 = selectedLevel2;
|
lastLevel1 = picked1; lastLevel2 = picked2;
|
||||||
if (!Running || Status == ZombieGameStatus.LastRound) return;
|
if (!Running || Status == ZombieGameStatus.LastRound) return;
|
||||||
|
|
||||||
if (initialChangeLevel) {
|
if (initialChangeLevel) {
|
||||||
@ -372,33 +374,36 @@ namespace MCGalaxy.Games {
|
|||||||
Player[] players = PlayerInfo.Online.Items;
|
Player[] players = PlayerInfo.Online.Items;
|
||||||
foreach (Player pl in players) {
|
foreach (Player pl in players) {
|
||||||
if (pl.level != CurLevel) continue;
|
if (pl.level != CurLevel) continue;
|
||||||
SendVoteMessage(pl, selectedLevel1, selectedLevel2);
|
SendVoteMessage(pl, picked1, picked2);
|
||||||
}
|
}
|
||||||
System.Threading.Thread.Sleep(15000);
|
System.Threading.Thread.Sleep(15000);
|
||||||
Server.votingforlevel = false;
|
Server.votingforlevel = false;
|
||||||
} else { Level1Vote = 1; Level2Vote = 0; Level3Vote = 0; }
|
} else { Level1Vote = 1; Level2Vote = 0; Level3Vote = 0; }
|
||||||
|
|
||||||
if (!Running || Status == ZombieGameStatus.LastRound) return;
|
if (!Running || Status == ZombieGameStatus.LastRound) return;
|
||||||
|
MoveToNextLevel(r, levels, picked1, picked2);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Server.ErrorLog(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MoveToNextLevel(Random r, List<string> levels, string picked1, string picked2) {
|
||||||
if (Level1Vote >= Level2Vote) {
|
if (Level1Vote >= Level2Vote) {
|
||||||
if (Level3Vote > Level1Vote && Level3Vote > Level2Vote) {
|
if (Level3Vote > Level1Vote && Level3Vote > Level2Vote) {
|
||||||
ChangeLevel(levels[r.Next(0, levels.Count)]);
|
ChangeLevel(levels[r.Next(0, levels.Count)]);
|
||||||
} else {
|
} else {
|
||||||
ChangeLevel(selectedLevel1);
|
ChangeLevel(picked1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Level3Vote > Level1Vote && Level3Vote > Level2Vote) {
|
if (Level3Vote > Level1Vote && Level3Vote > Level2Vote) {
|
||||||
ChangeLevel(levels[r.Next(0, levels.Count)]);
|
ChangeLevel(levels[r.Next(0, levels.Count)]);
|
||||||
} else {
|
} else {
|
||||||
ChangeLevel(selectedLevel2);
|
ChangeLevel(picked2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Player[] online = PlayerInfo.Online.Items;
|
Player[] online = PlayerInfo.Online.Items;
|
||||||
foreach (Player pl in online)
|
foreach (Player pl in online)
|
||||||
pl.voted = false;
|
pl.voted = false;
|
||||||
} catch (Exception ex) {
|
|
||||||
Server.ErrorLog(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<string> GetCandidateLevels() {
|
List<string> GetCandidateLevels() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user