mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-29 08:32:14 -04:00
Show player statuses as CPE messages.
This commit is contained in:
parent
551f66145f
commit
e34e306363
@ -43,6 +43,7 @@ namespace MCGalaxy.Commands {
|
|||||||
Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
|
Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
|
||||||
Server.zombie.Infected.Remove(p);
|
Server.zombie.Infected.Remove(p);
|
||||||
Server.zombie.Alive.Add(p);
|
Server.zombie.Alive.Add(p);
|
||||||
|
Server.zombie.UpdateAllPlayerStatus();
|
||||||
p.color = p.group.color;
|
p.color = p.group.color;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -51,6 +52,7 @@ namespace MCGalaxy.Commands {
|
|||||||
Player.GlobalDespawn(p, false);
|
Player.GlobalDespawn(p, false);
|
||||||
Server.zombie.Alive.Remove(p);
|
Server.zombie.Alive.Remove(p);
|
||||||
Server.zombie.Infected.Remove(p);
|
Server.zombie.Infected.Remove(p);
|
||||||
|
Server.zombie.UpdateAllPlayerStatus();
|
||||||
p.color = p.group.color;
|
p.color = p.group.color;
|
||||||
if (Server.zombie.RoundInProgress)
|
if (Server.zombie.RoundInProgress)
|
||||||
Server.zombie.AssignFirstZombie();
|
Server.zombie.AssignFirstZombie();
|
||||||
|
@ -94,6 +94,7 @@ namespace MCGalaxy.Games {
|
|||||||
|
|
||||||
Infected.Clear();
|
Infected.Clear();
|
||||||
Infected.Add(first);
|
Infected.Add(first);
|
||||||
|
UpdateAllPlayerStatus();
|
||||||
DoCoreGame(random);
|
DoCoreGame(random);
|
||||||
|
|
||||||
if (Status == ZombieGameStatus.NotStarted) {
|
if (Status == ZombieGameStatus.NotStarted) {
|
||||||
@ -148,6 +149,7 @@ namespace MCGalaxy.Games {
|
|||||||
while ((alive = Alive.Items).Length > 0) {
|
while ((alive = Alive.Items).Length > 0) {
|
||||||
Player[] infected = Infected.Items;
|
Player[] infected = Infected.Items;
|
||||||
foreach (Player pKiller in infected) {
|
foreach (Player pKiller in infected) {
|
||||||
|
pKiller.infected = true;
|
||||||
UpdatePlayerColor(pKiller, Colors.red);
|
UpdatePlayerColor(pKiller, Colors.red);
|
||||||
bool aliveChanged = false;
|
bool aliveChanged = false;
|
||||||
foreach (Player pAlive in alive) {
|
foreach (Player pAlive in alive) {
|
||||||
@ -160,9 +162,7 @@ namespace MCGalaxy.Games {
|
|||||||
if (!pAlive.infected && pKiller.infected && !pAlive.referee && !pKiller.referee && pKiller != pAlive
|
if (!pAlive.infected && pKiller.infected && !pAlive.referee && !pKiller.referee && pKiller != pAlive
|
||||||
&& pKiller.level.name.CaselessEq(CurrentLevelName) && pAlive.level.name.CaselessEq(CurrentLevelName))
|
&& pKiller.level.name.CaselessEq(CurrentLevelName) && pAlive.level.name.CaselessEq(CurrentLevelName))
|
||||||
{
|
{
|
||||||
pAlive.infected = true;
|
InfectPlayer(pAlive);
|
||||||
Infected.Add(pAlive);
|
|
||||||
Alive.Remove(pAlive);
|
|
||||||
aliveChanged = true;
|
aliveChanged = true;
|
||||||
pAlive.blockCount = 25;
|
pAlive.blockCount = 25;
|
||||||
|
|
||||||
@ -281,6 +281,7 @@ namespace MCGalaxy.Games {
|
|||||||
}
|
}
|
||||||
Alive.Clear();
|
Alive.Clear();
|
||||||
Infected.Clear();
|
Infected.Clear();
|
||||||
|
UpdateAllPlayerStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResetPlayer(Player p, ref string playersString) {
|
void ResetPlayer(Player p, ref string playersString) {
|
||||||
|
@ -87,6 +87,7 @@ namespace MCGalaxy.Games {
|
|||||||
Alive.Remove(p);
|
Alive.Remove(p);
|
||||||
Infected.Remove(p);
|
Infected.Remove(p);
|
||||||
AssignFirstZombie();
|
AssignFirstZombie();
|
||||||
|
UpdateAllPlayerStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void PlayerJoinedServer(Player p) {
|
public override void PlayerJoinedServer(Player p) {
|
||||||
@ -96,7 +97,6 @@ namespace MCGalaxy.Games {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void PlayerJoinedLevel(Player p, Level oldLvl) {
|
public override void PlayerJoinedLevel(Player p, Level oldLvl) {
|
||||||
Server.s.Log("CHECK " + p.name);
|
|
||||||
if (RoundInProgress && p.level.name.CaselessEq(CurrentLevelName)) {
|
if (RoundInProgress && p.level.name.CaselessEq(CurrentLevelName)) {
|
||||||
if (Status != ZombieGameStatus.NotStarted && p != null) {
|
if (Status != ZombieGameStatus.NotStarted && p != null) {
|
||||||
p.SendMessage("You joined in the middle of a round. &cYou are now infected!");
|
p.SendMessage("You joined in the middle of a round. &cYou are now infected!");
|
||||||
@ -109,11 +109,13 @@ namespace MCGalaxy.Games {
|
|||||||
double startLeft = (RoundStart - DateTime.UtcNow).TotalSeconds;
|
double startLeft = (RoundStart - DateTime.UtcNow).TotalSeconds;
|
||||||
if (startLeft >= 0)
|
if (startLeft >= 0)
|
||||||
p.SendMessage("%a" + (int)startLeft + " %Sseconds left until the round starts. %aRun!");
|
p.SendMessage("%a" + (int)startLeft + " %Sseconds left until the round starts. %aRun!");
|
||||||
//p.SendMessage(CpeMessageType.BottomRight1, "%SYou have &a" + p.money + " %S" + Server.moneys);
|
p.SendCpeMessage(CpeMessageType.BottomRight1, "%SYou have &a" + p.money + " %S" + Server.moneys);
|
||||||
|
UpdatePlayerStatus(p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.SendMessage(CpeMessageType.BottomRight1, "");
|
p.SendCpeMessage(CpeMessageType.BottomRight1, "");
|
||||||
|
p.SendCpeMessage(CpeMessageType.Status1, "");
|
||||||
Alive.Remove(p);
|
Alive.Remove(p);
|
||||||
Infected.Remove(p);
|
Infected.Remove(p);
|
||||||
}
|
}
|
||||||
|
@ -143,6 +143,7 @@ namespace MCGalaxy.Games {
|
|||||||
Alive.Remove(p);
|
Alive.Remove(p);
|
||||||
p.infected = true;
|
p.infected = true;
|
||||||
UpdatePlayerColor(p, Colors.red);
|
UpdatePlayerColor(p, Colors.red);
|
||||||
|
UpdateAllPlayerStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DisinfectPlayer(Player p) {
|
public void DisinfectPlayer(Player p) {
|
||||||
@ -151,6 +152,7 @@ namespace MCGalaxy.Games {
|
|||||||
Alive.Add(p);
|
Alive.Add(p);
|
||||||
p.infected = false;
|
p.infected = false;
|
||||||
UpdatePlayerColor(p, p.group.color);
|
UpdatePlayerColor(p, p.group.color);
|
||||||
|
UpdateAllPlayerStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangeLevel(string next) {
|
void ChangeLevel(string next) {
|
||||||
@ -190,5 +192,18 @@ namespace MCGalaxy.Games {
|
|||||||
CurrentLevelName = "";
|
CurrentLevelName = "";
|
||||||
CurrentLevel = null;
|
CurrentLevel = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdatePlayerStatus(Player p) {
|
||||||
|
string message = "&a{0} %Salive, &c{1} %Sinfected";
|
||||||
|
message = String.Format(message, Alive.Count, Infected.Count);
|
||||||
|
p.SendCpeMessage(CpeMessageType.Status1, message, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void UpdateAllPlayerStatus() {
|
||||||
|
Player[] players = Alive.Items;
|
||||||
|
foreach (Player p in players) UpdatePlayerStatus(p);
|
||||||
|
players = Infected.Items;
|
||||||
|
foreach (Player p in players) UpdatePlayerStatus(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,44 +177,20 @@ namespace MCGalaxy {
|
|||||||
else
|
else
|
||||||
Server.IRC.Pm(Server.IRC.usedCmd, message);
|
Server.IRC.Pm(Server.IRC.usedCmd, message);
|
||||||
} else {
|
} else {
|
||||||
p.SendMessage(CpeMessageType.Normal, Server.DefaultColor + message, colorParse);
|
p.SendMessage(0, Server.DefaultColor + message, colorParse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendMessage(string message) {
|
public void SendMessage(string message) {
|
||||||
SendMessage(CpeMessageType.Normal, Server.DefaultColor + message, true);
|
SendMessage(0, Server.DefaultColor + message, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendMessage(string message, bool colorParse) {
|
public void SendMessage(string message, bool colorParse) {
|
||||||
SendMessage(CpeMessageType.Normal, Server.DefaultColor + message, colorParse);
|
SendMessage(0, Server.DefaultColor + message, colorParse);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete("Use the overload with the CpeMessageType parameter.")]
|
|
||||||
public void SendMessage(byte id, string message, bool colorParse = true) {
|
public void SendMessage(byte id, string message, bool colorParse = true) {
|
||||||
SendMessage((CpeMessageType)id, message, colorParse);
|
message = ConvertMessage(message, colorParse);
|
||||||
}
|
|
||||||
|
|
||||||
public void SendMessage(CpeMessageType id, string message, bool colorParse = true) {
|
|
||||||
if (id != CpeMessageType.Normal && !HasCpeExt(CpeExt.MessageTypes)) {
|
|
||||||
if (id == CpeMessageType.Announcement) id = CpeMessageType.Normal;
|
|
||||||
else return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (colorParse)
|
|
||||||
message = Colors.EscapeColors(message);
|
|
||||||
StringBuilder sb = new StringBuilder(message);
|
|
||||||
if (colorParse)
|
|
||||||
ParseColors(sb);
|
|
||||||
|
|
||||||
Chat.ApplyTokens(sb, this, colorParse);
|
|
||||||
if ( Server.parseSmiley && parseSmiley ) {
|
|
||||||
sb.Replace(":)", "(darksmile)");
|
|
||||||
sb.Replace(":D", "(smile)");
|
|
||||||
sb.Replace("<3", "(heart)");
|
|
||||||
}
|
|
||||||
|
|
||||||
message = EmotesHandler.ReplaceEmoteKeywords(sb.ToString());
|
|
||||||
message = FullCP437Handler.Replace(message);
|
|
||||||
int totalTries = 0;
|
int totalTries = 0;
|
||||||
if ( MessageRecieve != null )
|
if ( MessageRecieve != null )
|
||||||
MessageRecieve(this, message);
|
MessageRecieve(this, message);
|
||||||
@ -225,6 +201,7 @@ namespace MCGalaxy {
|
|||||||
cancelmessage = false;
|
cancelmessage = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
retryTag: try {
|
retryTag: try {
|
||||||
foreach ( string line in Wordwrap(message) ) {
|
foreach ( string line in Wordwrap(message) ) {
|
||||||
string newLine = line;
|
string newLine = line;
|
||||||
@ -250,6 +227,42 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SendCpeMessage(CpeMessageType id, string message, bool colorParse = true) {
|
||||||
|
if (id != CpeMessageType.Normal && !HasCpeExt(CpeExt.MessageTypes)) {
|
||||||
|
if (id == CpeMessageType.Announcement) id = CpeMessageType.Normal;
|
||||||
|
else return;
|
||||||
|
}
|
||||||
|
message = ConvertMessage(message, colorParse);
|
||||||
|
|
||||||
|
byte[] buffer = new byte[66];
|
||||||
|
buffer[0] = Opcode.Message;
|
||||||
|
buffer[1] = (byte)id;
|
||||||
|
if (HasCpeExt(CpeExt.FullCP437))
|
||||||
|
NetUtils.WriteCP437(message, buffer, 2);
|
||||||
|
else
|
||||||
|
NetUtils.WriteAscii(message, buffer, 2);
|
||||||
|
SendRaw(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
string ConvertMessage(string message, bool colorParse) {
|
||||||
|
if (colorParse)
|
||||||
|
message = Colors.EscapeColors(message);
|
||||||
|
StringBuilder sb = new StringBuilder(message);
|
||||||
|
if (colorParse)
|
||||||
|
ParseColors(sb);
|
||||||
|
|
||||||
|
Chat.ApplyTokens(sb, this, colorParse);
|
||||||
|
if ( Server.parseSmiley && parseSmiley ) {
|
||||||
|
sb.Replace(":)", "(darksmile)");
|
||||||
|
sb.Replace(":D", "(smile)");
|
||||||
|
sb.Replace("<3", "(heart)");
|
||||||
|
}
|
||||||
|
|
||||||
|
message = EmotesHandler.ReplaceEmoteKeywords(sb.ToString());
|
||||||
|
message = FullCP437Handler.Replace(message);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
void ParseColors(StringBuilder sb) {
|
void ParseColors(StringBuilder sb) {
|
||||||
for (int i = 0; i < 128; i++) {
|
for (int i = 0; i < 128; i++) {
|
||||||
if (Colors.IsStandardColor((char)i)) {
|
if (Colors.IsStandardColor((char)i)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user