mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-26 14:54:12 -04:00
Add /bounties, start work for /bounty.
This commit is contained in:
parent
0f2d42301a
commit
2752a9e018
51
Commands/Fun/CmdBounties.cs
Normal file
51
Commands/Fun/CmdBounties.cs
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
Copyright 2015 MCGalaxy
|
||||
|
||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||
not use this file except in compliance with the Licenses. You may
|
||||
obtain a copy of the Licenses at
|
||||
|
||||
http://www.opensource.org/licenses/ecl2.php
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the Licenses are distributed on an "AS IS"
|
||||
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;
|
||||
|
||||
namespace MCGalaxy.Commands {
|
||||
|
||||
public sealed class CmdBounties : Command {
|
||||
|
||||
public override string name { get { return "bounties"; } }
|
||||
public override string shortcut { get { return ""; } }
|
||||
public override string type { get { return CommandTypes.Games; } }
|
||||
public override bool museumUsable { get { return true; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
|
||||
public override bool Enabled { get { return Server.ZombieModeOn; } }
|
||||
public CmdBounties() { }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
Dictionary<string, BountyData> bounties = Server.zombie.Bounties;
|
||||
if (bounties.Count == 0) {
|
||||
Player.SendMessage(p, "There are no active bounties.");
|
||||
} else {
|
||||
foreach (var pair in bounties) {
|
||||
Player pl = PlayerInfo.FindExact(pair.Key);
|
||||
if (pl == null) continue;
|
||||
Player.SendMessage(p, "Bounty for " + pl.FullName + " %Sis &a"
|
||||
+ pair.Value.Amount + "%S" + Server.moneys + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.SendMessage(p, "%T/bounties");
|
||||
Player.SendMessage(p, "%HOutputs a list of all active bounties on players.");
|
||||
}
|
||||
}
|
||||
}
|
58
Commands/Fun/CmdBounty.cs
Normal file
58
Commands/Fun/CmdBounty.cs
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
Copyright 2015 MCGalaxy
|
||||
|
||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||
not use this file except in compliance with the Licenses. You may
|
||||
obtain a copy of the Licenses at
|
||||
|
||||
http://www.opensource.org/licenses/ecl2.php
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the Licenses are distributed on an "AS IS"
|
||||
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.
|
||||
*/
|
||||
namespace MCGalaxy.Commands {
|
||||
|
||||
public sealed class CmdBounty : Command {
|
||||
|
||||
public override string name { get { return "bounty"; } }
|
||||
public override string shortcut { get { return ""; } }
|
||||
public override string type { get { return CommandTypes.Games; } }
|
||||
public override bool museumUsable { get { return true; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
|
||||
public override bool Enabled { get { return Server.ZombieModeOn; } }
|
||||
public CmdBounty() { }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
string[] args = message.Split(' ');
|
||||
if (args.Length < 2) { Help(p); return; }
|
||||
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
if (who == null) return;
|
||||
byte amount = 0;
|
||||
if (!byte.TryParse(args[1], out amount)) {
|
||||
Player.SendMessage(p, "The bounty amount must be an positive integer less than 256."); return;
|
||||
}
|
||||
if (p.money < amount) {
|
||||
Player.SendMessage(p, "You do not have enough " + Server.moneys + " to place such a large bountry."); return;
|
||||
}
|
||||
|
||||
BountyData data;
|
||||
if (Server.zombie.Bounties.TryGetValue(who.name, out data) && data.Amount >= amount) {
|
||||
Player.SendMessage(p, "There is already a larger active bounty for " + who.name + "."); return;
|
||||
}
|
||||
// TODO here - actually announce the bounty and place it
|
||||
// "Looks like someone wants the brain of <name>! An bounty for x <money> was placed on them.
|
||||
// "<name> is popular! The bounty on them was increased from <old> to <new> money.
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.SendMessage(p, "%T/bounty [name] [amount]");
|
||||
Player.SendMessage(p, "%HSets a bounty on the given player.");
|
||||
}
|
||||
}
|
||||
}
|
@ -24,8 +24,17 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Timers;
|
||||
|
||||
namespace MCGalaxy
|
||||
{
|
||||
namespace MCGalaxy {
|
||||
|
||||
public class BountyData {
|
||||
public Player Origin;
|
||||
public int Amount;
|
||||
|
||||
public BountyData(Player origin, int amount) {
|
||||
Origin = origin; Amount = amount;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed partial class ZombieGame
|
||||
{
|
||||
public int amountOfRounds = 0;
|
||||
@ -55,6 +64,7 @@ namespace MCGalaxy
|
||||
|
||||
string lastPlayerToInfect = "";
|
||||
int infectCombo = 0;
|
||||
public Dictionary<string, BountyData> Bounties = new Dictionary<string, BountyData>();
|
||||
|
||||
public void StartGame(int status, int amount)
|
||||
{
|
||||
|
@ -175,6 +175,8 @@
|
||||
<Compile Include="Commands\Fun\Cmd8Ball.cs" />
|
||||
<Compile Include="Commands\Fun\CmdAka.cs" />
|
||||
<Compile Include="Commands\Fun\CmdAlive.cs" />
|
||||
<Compile Include="Commands\Fun\CmdBounties.cs" />
|
||||
<Compile Include="Commands\Fun\CmdBounty.cs" />
|
||||
<Compile Include="Commands\Fun\CmdCountdown.cs" />
|
||||
<Compile Include="Commands\Fun\CmdCtf.cs" />
|
||||
<Compile Include="Commands\Fun\CmdDisinfect.cs" />
|
||||
|
@ -1509,6 +1509,10 @@ return;
|
||||
if (!group.CanExecute(command)) {
|
||||
SendMessage("You are not allowed to use \"" + cmd + "\"."); return;
|
||||
}
|
||||
if (!command.Enabled) {
|
||||
SendMessage("The game associated with this game is not running, " +
|
||||
"so this command is disabled."); return;
|
||||
}
|
||||
if (cmd != "repeat") lastCMD = cmd + " " + message;
|
||||
|
||||
if (level.IsMuseum && !command.museumUsable ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user