mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-27 23:43:45 -04:00
ZS: Bounties now persist between rounds, or until either the target or setter leaves the server.
This commit is contained in:
parent
d438504787
commit
509fa5d1d7
@ -14,7 +14,7 @@
|
|||||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using MCGalaxy.Games;
|
using MCGalaxy.Games;
|
||||||
|
|
||||||
@ -31,16 +31,16 @@ namespace MCGalaxy.Commands {
|
|||||||
public CmdBounties() { }
|
public CmdBounties() { }
|
||||||
|
|
||||||
public override void Use(Player p, string message) {
|
public override void Use(Player p, string message) {
|
||||||
Dictionary<string, BountyData> bounties = Server.zombie.Bounties;
|
BountyData[] bounties = Server.zombie.Bounties.Items;
|
||||||
if (bounties.Count == 0) {
|
if (bounties.Length == 0) {
|
||||||
Player.Message(p, "There are no active bounties.");
|
Player.Message(p, "There are no active bounties."); return;
|
||||||
} else {
|
}
|
||||||
foreach (var pair in bounties) {
|
|
||||||
Player pl = PlayerInfo.FindExact(pair.Key);
|
foreach (BountyData bounty in bounties) {
|
||||||
if (pl == null) continue;
|
Player pl = PlayerInfo.FindExact(bounty.Target);
|
||||||
Player.Message(p, "Bounty for " + pl.ColoredName + " %Sis &a"
|
if (pl == null) continue;
|
||||||
+ pair.Value.Amount + "%S" + Server.moneys + ".");
|
Player.Message(p, "Bounty for {0} %Sis &a{1} %S{2}.",
|
||||||
}
|
pl.ColoredName, bounty.Amount, Server.moneys);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,19 +42,20 @@ namespace MCGalaxy.Commands {
|
|||||||
Player.Message(p, "You do not have enough " + Server.moneys + " to place such a large bountry."); return;
|
Player.Message(p, "You do not have enough " + Server.moneys + " to place such a large bountry."); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BountyData old;
|
BountyData old = Server.zombie.FindBounty(who.name);
|
||||||
if (Server.zombie.Bounties.TryGetValue(who.name, out old) && old.Amount >= amount) {
|
if (old != null && old.Amount >= amount) {
|
||||||
Player.Message(p, "There is already a larger active bounty for " + who.name + "."); return;
|
Player.Message(p, "There is already a larger active bounty for " + who.name + "."); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (old == null) {
|
if (old == null) {
|
||||||
Chat.MessageAll("Looks like someone really wants the brains of {0}%S! A bounty of &a{1} %S{2} was placed on them.",
|
Chat.MessageAll("Looks like someone really wants the brains of {0}%S! A bounty of &a{1} %S{2} was placed on them.",
|
||||||
who.ColoredName, amount, Server.moneys);
|
who.ColoredName, amount, Server.moneys);
|
||||||
} else {
|
} else {
|
||||||
Chat.MessageAll("{0} %Sis popular! The bounty on them was increased from &a{3} %Sto &a{1} %S{2}.",
|
Chat.MessageAll("{0} %Sis popular! The bounty on them was increased from &a{3} %Sto &a{1} %S{2}.",
|
||||||
who.ColoredName, amount, Server.moneys, old.Amount);
|
who.ColoredName, amount, Server.moneys, old.Amount);
|
||||||
|
Server.zombie.Bounties.Remove(old);
|
||||||
}
|
}
|
||||||
Server.zombie.Bounties[who.name] = new BountyData(p, amount);
|
Server.zombie.Bounties.Add(new BountyData(p.name, who.name, amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
|
@ -268,13 +268,18 @@ namespace MCGalaxy.Games {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CheckBounty(Player pAlive, Player pKiller) {
|
void CheckBounty(Player pAlive, Player pKiller) {
|
||||||
BountyData bounty;
|
BountyData bounty = FindBounty(pAlive.name);
|
||||||
if (Bounties.TryGetValue(pAlive.name, out bounty))
|
if (bounty == null) return;
|
||||||
Bounties.Remove(pAlive.name);
|
Bounties.Remove(bounty);
|
||||||
if (bounty != null) {
|
|
||||||
|
Player origin = PlayerInfo.FindExact(bounty.Origin);
|
||||||
|
if (origin == null) {
|
||||||
|
Player.Message(pKiller, "Cannot collect the bounty, as the player who set it is offline.");
|
||||||
|
} else {
|
||||||
CurLevel.ChatLevel(pKiller.ColoredName + " %Scollected the bounty of &a" +
|
CurLevel.ChatLevel(pKiller.ColoredName + " %Scollected the bounty of &a" +
|
||||||
bounty.Amount + " %S" + Server.moneys + " on " + pAlive.ColoredName + "%S.");
|
bounty.Amount + " %S" + Server.moneys + " on " + pAlive.ColoredName + "%S.");
|
||||||
bounty.Origin.SetMoney(Math.Max(0, bounty.Origin.money - bounty.Amount));
|
|
||||||
|
origin.SetMoney(Math.Max(0, origin.money - bounty.Amount));
|
||||||
pKiller.SetMoney(pKiller.money + bounty.Amount);
|
pKiller.SetMoney(pKiller.money + bounty.Amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -304,7 +309,6 @@ namespace MCGalaxy.Games {
|
|||||||
RoundInProgress = false;
|
RoundInProgress = false;
|
||||||
RoundStart = DateTime.MinValue;
|
RoundStart = DateTime.MinValue;
|
||||||
RoundEnd = DateTime.MinValue;
|
RoundEnd = DateTime.MinValue;
|
||||||
Bounties.Clear();
|
|
||||||
|
|
||||||
if (!Running) return;
|
if (!Running) return;
|
||||||
Rewards.HandOut(this);
|
Rewards.HandOut(this);
|
||||||
|
@ -97,10 +97,23 @@ namespace MCGalaxy.Games {
|
|||||||
Alive.Remove(p);
|
Alive.Remove(p);
|
||||||
Infected.Remove(p);
|
Infected.Remove(p);
|
||||||
p.Game.Infected = false;
|
p.Game.Infected = false;
|
||||||
|
RemoveBounties(p);
|
||||||
|
|
||||||
AssignFirstZombie();
|
AssignFirstZombie();
|
||||||
UpdateAllPlayerStatus();
|
UpdateAllPlayerStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RemoveBounties(Player p) {
|
||||||
|
BountyData[] bounties = Bounties.Items;
|
||||||
|
foreach (BountyData b in bounties) {
|
||||||
|
if (!(b.Origin.CaselessEq(p.name) || b.Target.CaselessEq(p.name))) continue;
|
||||||
|
|
||||||
|
string target = PlayerInfo.GetColoredName(p, b.Target);
|
||||||
|
CurLevel.ChatLevel("Bounty on " + target + " %Sis no longer active.");
|
||||||
|
Bounties.Remove(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void PlayerJoinedServer(Player p) {
|
public override void PlayerJoinedServer(Player p) {
|
||||||
if (!Running || ZombieGameProps.SetMainLevel) return;
|
if (!Running || ZombieGameProps.SetMainLevel) return;
|
||||||
Player.Message(p, "Zombie Survival is running! Type %T/g " + CurLevelName + " %Sto join.");
|
Player.Message(p, "Zombie Survival is running! Type %T/g " + CurLevelName + " %Sto join.");
|
||||||
|
@ -24,11 +24,11 @@ using MCGalaxy.Config;
|
|||||||
namespace MCGalaxy.Games {
|
namespace MCGalaxy.Games {
|
||||||
|
|
||||||
public class BountyData {
|
public class BountyData {
|
||||||
public Player Origin;
|
public string Origin, Target;
|
||||||
public int Amount;
|
public int Amount;
|
||||||
|
|
||||||
public BountyData(Player origin, int amount) {
|
public BountyData(string origin, string target, int amount) {
|
||||||
Origin = origin; Amount = amount;
|
Origin = origin; Target = target; Amount = amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +90,8 @@ namespace MCGalaxy.Games {
|
|||||||
string lastPlayerToInfect = "";
|
string lastPlayerToInfect = "";
|
||||||
int infectCombo = 0;
|
int infectCombo = 0;
|
||||||
|
|
||||||
public Dictionary<string, BountyData> Bounties = new Dictionary<string, BountyData>();
|
/// <summary> List of players who have a bounty on them. </summary>
|
||||||
|
public VolatileArray<BountyData> Bounties = new VolatileArray<BountyData>(false);
|
||||||
|
|
||||||
/// <summary> List of players who are in the lottery. </summary>
|
/// <summary> List of players who are in the lottery. </summary>
|
||||||
public VolatileArray<string> Lottery = new VolatileArray<string>(false);
|
public VolatileArray<string> Lottery = new VolatileArray<string>(false);
|
||||||
|
@ -186,6 +186,15 @@ namespace MCGalaxy.Games {
|
|||||||
CurLevel = null;
|
CurLevel = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BountyData FindBounty(string target) {
|
||||||
|
BountyData[] bounties = Bounties.Items;
|
||||||
|
foreach (BountyData bounty in bounties) {
|
||||||
|
if (bounty.Target.CaselessEq(target)) return bounty;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void UpdatePlayerStatus(Player p) {
|
void UpdatePlayerStatus(Player p) {
|
||||||
int seconds = (int)(RoundEnd - DateTime.UtcNow).TotalSeconds;
|
int seconds = (int)(RoundEnd - DateTime.UtcNow).TotalSeconds;
|
||||||
string status = GetStatusMessage(GetTimespan(seconds));
|
string status = GetStatusMessage(GetTimespan(seconds));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user