mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-26 06:43:25 -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
|
||||
or implied. See the Licenses for the specific language governing
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
*/
|
||||
using System.Collections.Generic;
|
||||
using MCGalaxy.Games;
|
||||
|
||||
@ -31,16 +31,16 @@ namespace MCGalaxy.Commands {
|
||||
public CmdBounties() { }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
Dictionary<string, BountyData> bounties = Server.zombie.Bounties;
|
||||
if (bounties.Count == 0) {
|
||||
Player.Message(p, "There are no active bounties.");
|
||||
} else {
|
||||
foreach (var pair in bounties) {
|
||||
Player pl = PlayerInfo.FindExact(pair.Key);
|
||||
if (pl == null) continue;
|
||||
Player.Message(p, "Bounty for " + pl.ColoredName + " %Sis &a"
|
||||
+ pair.Value.Amount + "%S" + Server.moneys + ".");
|
||||
}
|
||||
BountyData[] bounties = Server.zombie.Bounties.Items;
|
||||
if (bounties.Length == 0) {
|
||||
Player.Message(p, "There are no active bounties."); return;
|
||||
}
|
||||
|
||||
foreach (BountyData bounty in bounties) {
|
||||
Player pl = PlayerInfo.FindExact(bounty.Target);
|
||||
if (pl == null) continue;
|
||||
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;
|
||||
}
|
||||
|
||||
BountyData old;
|
||||
if (Server.zombie.Bounties.TryGetValue(who.name, out old) && old.Amount >= amount) {
|
||||
BountyData old = Server.zombie.FindBounty(who.name);
|
||||
if (old != null && old.Amount >= amount) {
|
||||
Player.Message(p, "There is already a larger active bounty for " + who.name + "."); return;
|
||||
}
|
||||
|
||||
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.",
|
||||
who.ColoredName, amount, Server.moneys);
|
||||
who.ColoredName, amount, Server.moneys);
|
||||
} else {
|
||||
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) {
|
||||
|
@ -268,13 +268,18 @@ namespace MCGalaxy.Games {
|
||||
}
|
||||
|
||||
void CheckBounty(Player pAlive, Player pKiller) {
|
||||
BountyData bounty;
|
||||
if (Bounties.TryGetValue(pAlive.name, out bounty))
|
||||
Bounties.Remove(pAlive.name);
|
||||
if (bounty != null) {
|
||||
BountyData bounty = FindBounty(pAlive.name);
|
||||
if (bounty == null) return;
|
||||
Bounties.Remove(bounty);
|
||||
|
||||
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" +
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -304,7 +309,6 @@ namespace MCGalaxy.Games {
|
||||
RoundInProgress = false;
|
||||
RoundStart = DateTime.MinValue;
|
||||
RoundEnd = DateTime.MinValue;
|
||||
Bounties.Clear();
|
||||
|
||||
if (!Running) return;
|
||||
Rewards.HandOut(this);
|
||||
|
@ -97,10 +97,23 @@ namespace MCGalaxy.Games {
|
||||
Alive.Remove(p);
|
||||
Infected.Remove(p);
|
||||
p.Game.Infected = false;
|
||||
RemoveBounties(p);
|
||||
|
||||
AssignFirstZombie();
|
||||
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) {
|
||||
if (!Running || ZombieGameProps.SetMainLevel) return;
|
||||
Player.Message(p, "Zombie Survival is running! Type %T/g " + CurLevelName + " %Sto join.");
|
||||
|
@ -24,11 +24,11 @@ using MCGalaxy.Config;
|
||||
namespace MCGalaxy.Games {
|
||||
|
||||
public class BountyData {
|
||||
public Player Origin;
|
||||
public string Origin, Target;
|
||||
public int Amount;
|
||||
|
||||
public BountyData(Player origin, int amount) {
|
||||
Origin = origin; Amount = amount;
|
||||
public BountyData(string origin, string target, int amount) {
|
||||
Origin = origin; Target = target; Amount = amount;
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,7 +90,8 @@ namespace MCGalaxy.Games {
|
||||
string lastPlayerToInfect = "";
|
||||
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>
|
||||
public VolatileArray<string> Lottery = new VolatileArray<string>(false);
|
||||
|
@ -186,6 +186,15 @@ namespace MCGalaxy.Games {
|
||||
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) {
|
||||
int seconds = (int)(RoundEnd - DateTime.UtcNow).TotalSeconds;
|
||||
string status = GetStatusMessage(GetTimespan(seconds));
|
||||
|
Loading…
x
Reference in New Issue
Block a user