Update the money figure in the CPE bottomright1 message when player's money changes.

This commit is contained in:
UnknownShadow200 2016-03-21 09:35:33 +11:00
parent 2e1aa7055d
commit cb85dab5d4
12 changed files with 102 additions and 83 deletions

View File

@ -56,6 +56,7 @@ namespace MCGalaxy.Commands
if (ReachedMax(p, who.money, amount)) return; if (ReachedMax(p, who.money, amount)) return;
ecos.money = who.money; ecos.money = who.money;
who.money += amount; who.money += amount;
who.OnMoneyChanged();
ecos = Economy.RetrieveEcoStats(who.name); ecos = Economy.RetrieveEcoStats(who.name);
Player.GlobalMessage(giver + " %Sgave " + who.FullName + " %f" + amount + " %3" + Server.moneys); Player.GlobalMessage(giver + " %Sgave " + who.FullName + " %f" + amount + " %3" + Server.moneys);
} }

View File

@ -60,6 +60,7 @@ namespace MCGalaxy.Commands
receiver.money = who.money; receiver.money = who.money;
who.money += amount; who.money += amount;
who.OnMoneyChanged();
target = who.color + who.name; target = who.color + who.name;
Player.GlobalMessage(p.FullName + " %Spaid " + who.FullName + " %f" + amount + " %3" + Server.moneys); Player.GlobalMessage(p.FullName + " %Spaid " + who.FullName + " %f" + amount + " %3" + Server.moneys);
} }
@ -68,6 +69,7 @@ namespace MCGalaxy.Commands
receiver.salary = "%f" + amount + " %3" + Server.moneys + " by " + p.color + p.name + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture); receiver.salary = "%f" + amount + " %3" + Server.moneys + " by " + p.color + p.name + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
receiver.money += amount; receiver.money += amount;
p.money -= amount; p.money -= amount;
p.OnMoneyChanged();
payer.money = p.money; payer.money = p.money;
Economy.UpdateEcoStats(payer); Economy.UpdateEcoStats(payer);
Economy.UpdateEcoStats(receiver); Economy.UpdateEcoStats(receiver);

View File

@ -57,6 +57,7 @@ namespace MCGalaxy.Commands
ecos.money = who.money; ecos.money = who.money;
Take(all, ref ecos, ref amount); Take(all, ref ecos, ref amount);
who.money = ecos.money; who.money = ecos.money;
who.OnMoneyChanged();
Player.GlobalMessage(taker + " %Stook %f" + amount + " %3" + Server.moneys + " %Sfrom " + who.prefix + who.name); Player.GlobalMessage(taker + " %Stook %f" + amount + " %3" + Server.moneys + " %Sfrom " + who.prefix + who.name);
} }
ecos.fine = "%f" + amount + " %3" + Server.moneys + " by " + takerRaw + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture); ecos.fine = "%f" + amount + " %3" + Server.moneys + " by " + takerRaw + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);

View File

@ -42,7 +42,7 @@ namespace MCGalaxy.Commands
Player.SendMessage(p, "Cannot use this on someone of equal or greater rank."); return; Player.SendMessage(p, "Cannot use this on someone of equal or greater rank."); return;
} }
Command.all.Find("hide").Use(who, ""); Command.all.Find("hide").Use(who, "");
Player.SendMessage(p, "Used /hide on " + who.color + who.name + Server.DefaultColor + "%S."); Player.SendMessage(p, "Used /hide on " + who.color + who.name + "%S.");
} }
public override void Help(Player p) public override void Help(Player p)

View File

@ -50,6 +50,7 @@ namespace MCGalaxy.Eco {
protected static void MakePurchase(Player p, int cost, string item) { protected static void MakePurchase(Player p, int cost, string item) {
Economy.EcoStats ecos = Economy.RetrieveEcoStats(p.name); Economy.EcoStats ecos = Economy.RetrieveEcoStats(p.name);
p.money -= cost; p.money -= cost;
p.OnMoneyChanged();
ecos.money = p.money; ecos.money = p.money;
ecos.totalSpent += cost; ecos.totalSpent += cost;
ecos.purchase = item + "%3 - Price: %f" + cost + " %3" + Server.moneys + ecos.purchase = item + "%3 - Price: %f" + cost + " %3" + Server.moneys +
@ -88,7 +89,7 @@ namespace MCGalaxy.Eco {
} }
// Must always provide an argument. // Must always provide an argument.
if (args.Length < 2) { cmd.Help(p); return; } if (args.Length < 2) { cmd.Help(p); return; }
if (!p.EnoughMoney(Price)) { if (p.money < Price) {
Player.SendMessage(p, "%cYou don't have enough %3" + Server.moneys + "%c to buy a " + Name + "."); return; Player.SendMessage(p, "%cYou don't have enough %3" + Server.moneys + "%c to buy a " + Name + "."); return;
} }
OnBuyCommand(p, message, args); OnBuyCommand(p, message, args);

View File

@ -85,7 +85,7 @@ namespace MCGalaxy.Eco {
LevelPreset preset = FindPreset(args[1]); LevelPreset preset = FindPreset(args[1]);
if (preset == null) { Player.SendMessage(p, "%cThat isn't a level preset"); return; } if (preset == null) { Player.SendMessage(p, "%cThat isn't a level preset"); return; }
if (!p.EnoughMoney(preset.price)) { if (p.money < preset.price) {
Player.SendMessage(p, "%cYou don't have enough %3" + Server.moneys + "%c to buy that map"); return; Player.SendMessage(p, "%cYou don't have enough %3" + Server.moneys + "%c to buy that map"); return;
} }
string name = p.name + "_" + args[2]; string name = p.name + "_" + args[2];

View File

@ -75,7 +75,7 @@ namespace MCGalaxy.Eco {
Player.SendMessage(p, "%cYou cannot buy anymore ranks, because you passed the max buyable rank: " + maxrank.color + maxrank.name); Player.SendMessage(p, "%cYou cannot buy anymore ranks, because you passed the max buyable rank: " + maxrank.color + maxrank.name);
return; return;
} }
if (!p.EnoughMoney(NextRank(p).price)) { if (p.money < NextRank(p).price) {
Player.SendMessage(p, "%cYou don't have enough %3" + Server.moneys + "%c to buy the next rank"); return; Player.SendMessage(p, "%cYou don't have enough %3" + Server.moneys + "%c to buy the next rank"); return;
} }

View File

@ -33,13 +33,13 @@ namespace MCGalaxy.Eco {
if (args.Length >= 3 && !byte.TryParse(args[2], out count) || count == 0 || count > 10) { if (args.Length >= 3 && !byte.TryParse(args[2], out count) || count == 0 || count > 10) {
Player.SendMessage(p, "Number of groups of 10 blocks to buy must be an integer between 1 and 10."); return; Player.SendMessage(p, "Number of groups of 10 blocks to buy must be an integer between 1 and 10."); return;
} }
if (!p.EnoughMoney(Price * count)) { if (p.money < Price * count) {
Player.SendMessage(p, "%cYou don't have enough %3" + Server.moneys + Player.SendMessage(p, "%cYou don't have enough %3" + Server.moneys +
"%c to buy " + (count * 10) + " " + Name + "."); return; "%c to buy " + (count * 10) + " " + Name + "."); return;
} }
p.blocksStacked += 10 * count; p.blocksStacked += 10 * count;
MakePurchase(p, Price, "%3Blocks: " + (10 * count)); MakePurchase(p, Price * count, "%3Blocks: " + (10 * count));
} }
} }

View File

@ -44,5 +44,7 @@ namespace MCGalaxy.Games {
public virtual void PlayerLeftGame(Player p) { } public virtual void PlayerLeftGame(Player p) { }
public virtual void PlayerJoinedLevel(Player p, Level oldLvl) { } public virtual void PlayerJoinedLevel(Player p, Level oldLvl) { }
public virtual void PlayerMoneyChanged(Player p) { }
} }
} }

View File

@ -166,8 +166,9 @@ namespace MCGalaxy.Games {
if (lastPlayerToInfect == pKiller.name) { if (lastPlayerToInfect == pKiller.name) {
infectCombo++; infectCombo++;
if (infectCombo >= 2) { if (infectCombo >= 2) {
pKiller.SendMessage("You gained " + (4 - infectCombo) + " " + Server.moneys); pKiller.SendMessage("You gained " + (4 + infectCombo) + " " + Server.moneys);
pKiller.money += 4 - infectCombo; pKiller.money += 4 + infectCombo;
pKiller.OnMoneyChanged();
CurrentLevel.ChatLevel(pKiller.FullName + " is on a rampage! " + (infectCombo + 1) + " infections in a row!"); CurrentLevel.ChatLevel(pKiller.FullName + " is on a rampage! " + (infectCombo + 1) + " infections in a row!");
} }
} else { } else {
@ -188,7 +189,9 @@ namespace MCGalaxy.Games {
CurrentLevel.ChatLevel(pKiller.FullName + " %Scollected the bounty of &a" + CurrentLevel.ChatLevel(pKiller.FullName + " %Scollected the bounty of &a" +
bounty.Amount + " %S" + Server.moneys + " on " + pAlive.FullName + "%S."); bounty.Amount + " %S" + Server.moneys + " on " + pAlive.FullName + "%S.");
bounty.Origin.money = Math.Max(0, bounty.Origin.money - bounty.Amount); bounty.Origin.money = Math.Max(0, bounty.Origin.money - bounty.Amount);
bounty.Origin.OnMoneyChanged();
pKiller.money += bounty.Amount; pKiller.money += bounty.Amount;
pKiller.OnMoneyChanged();
} }
UpdatePlayerColor(pAlive, Colors.red); UpdatePlayerColor(pAlive, Colors.red);
} }
@ -274,6 +277,7 @@ namespace MCGalaxy.Games {
pl.SendMessage("You gained one " + Server.moneys + " because you're a ref. Would you like a medal as well?"); pl.SendMessage("You gained one " + Server.moneys + " because you're a ref. Would you like a medal as well?");
pl.money++; pl.money++;
} }
pl.OnMoneyChanged();
} }
Alive.Clear(); Alive.Clear();
Infected.Clear(); Infected.Clear();

View File

@ -123,5 +123,11 @@ namespace MCGalaxy.Games {
Alive.Remove(p); Alive.Remove(p);
Infected.Remove(p); Infected.Remove(p);
} }
public override void PlayerMoneyChanged(Player p) {
if (Status == ZombieGameStatus.NotStarted
|| !p.level.name.CaselessEq(CurrentLevelName)) return;
p.SendCpeMessage(CpeMessageType.BottomRight1, "%SYou have &a" + p.money + " %S" + Server.moneys);
}
} }
} }

View File

@ -46,8 +46,6 @@ namespace MCGalaxy {
System.Timers.Timer muteTimer = new System.Timers.Timer(1000); System.Timers.Timer muteTimer = new System.Timers.Timer(1000);
public static List<string> emoteList = new List<string>(); public static List<string> emoteList = new List<string>();
public List<string> listignored = new List<string>(); public List<string> listignored = new List<string>();
public List<string> mapgroups = new List<string>();
public static int totalMySQLFailed = 0;
public static byte number { get { return (byte)PlayerInfo.Online.Count; } } public static byte number { get { return (byte)PlayerInfo.Online.Count; } }
static System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); static System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
static MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); static MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
@ -866,10 +864,14 @@ Next: continue;
} }
public bool EnoughMoney(int amount) { public bool EnoughMoney(int amount) {
if (this.money >= amount) return money >= amount;
return true;
return false;
} }
public void OnMoneyChanged() {
if (Server.ZombieModeOn) Server.zombie.PlayerMoneyChanged(this);
if (Server.lava.active) Server.lava.PlayerMoneyChanged(this);
}
public void ReviewTimer() { public void ReviewTimer() {
this.canusereview = false; this.canusereview = false;
System.Timers.Timer Clock = new System.Timers.Timer(1000 * Server.reviewcooldown); System.Timers.Timer Clock = new System.Timers.Timer(1000 * Server.reviewcooldown);