Esempio n. 1
0
 public void UpdateFailures(Bounty bounty)
 {
     try
     {
         _db.Query("UPDATE Bounties SET Failures = @0 WHERE Name = @1", String.Join(", ", bounty.failures), bounty.name);
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
     }
 }
Esempio n. 2
0
 public void DeleteBounty(Bounty bounty)
 {
     try
     {
         _db.Query("DELETE FROM Bounties WHERE Name = @0", bounty.name);
         BH.bounties.Remove(bounty);
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
     }
 }
Esempio n. 3
0
 public void AddNewBounty(Bounty bounty)
 {
     try
     {
         _db.Query("INSERT INTO Bounties (Name, Contractor, Target, Rewards, Hunters, Failures)"
             + " VALUES (@0, @1, @2, @3, @4, @5)",
             bounty.name, bounty.contractor, bounty.target, Utils.TurnRewardsToString(bounty.reward), "", "");
         if (!BH.bounties.Contains(bounty))
             BH.bounties.Add(bounty);
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
     }
 }
Esempio n. 4
0
 public void AddNewBounty(Bounty bounty)
 {
     try
     {
         _db.Query("INSERT INTO Bounties (Name, Contractor, Target, Rewards, Hunters, Failures)"
                   + " VALUES (@0, @1, @2, @3, @4, @5)",
                   bounty.name, bounty.contractor, bounty.target, Utils.TurnRewardsToString(bounty.reward), "", "");
         if (!BH.bounties.Contains(bounty))
         {
             BH.bounties.Add(bounty);
         }
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
     }
 }
Esempio n. 5
0
 public void DeleteBounty(Bounty bounty)
 {
     try
     {
         _db.Query("DELETE FROM Bounties WHERE Name = @0", bounty.name);
         BH.bounties.Remove(bounty);
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
     }
 }
Esempio n. 6
0
 public void UpdateHunters(Bounty bounty)
 {
     try
     {
         _db.Query("UPDATE Bounties SET Hunters = @0 WHERE Name = @1", String.Join(", ", bounty.hunter), bounty.name);
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
     }
 }
Esempio n. 7
0
        private void GenBounty(CommandArgs args)
        {
            var player = Utils.GetPlayer(args.Player.Index);

            if (args.Parameters.Count < 1)
            {
                Utils.InvalidGenBountyUsage(args.Player);
                return;
            }
            if (args.Parameters[0].ToLower() == "-list")
            {
                int page;
                if (!PaginationTools.TryParsePageNumber(args.Parameters, 1, args.Player, out page))
                {
                    return;
                }

                List <string> allBty = new List <string>();
                foreach (Bounty bty in bounties)
                {
                    allBty.Add(bty.name);
                }
                PaginationTools.SendPage(args.Player, page, PaginationTools.BuildLinesFromTerms(allBty),
                                         new PaginationTools.Settings
                {
                    HeaderFormat           = "Bounties ({0}/{1}):",
                    FooterFormat           = "Type /bty -list {0} for more.",
                    NothingToDisplayString = "There are currently no bounties listed!"
                });
                return;
            }
            if (args.Parameters.Count < 2)
            {
                Utils.InvalidGenBountyUsage(args.Player);
                return;
            }
            if (!Utils.CheckBountyNameExists(args.Parameters[1]))
            {
                args.Player.SendErrorMessage("Invalid bounty!");
                return;
            }
            for (int i = 0; i < bounties.Count; i++)
            {
                if (args.Parameters[1].ToLower() == bounties[i].name.ToLower())
                {
                    var subcmd = args.Parameters[0].ToLower();

                    switch (subcmd)
                    {
                    case "-info":
                        args.Player.SendInfoMessage("Bounty ({0}) was listed by {1} targeting {2}",
                                                    bounties[i].name,
                                                    bounties[i].contractor,
                                                    bounties[i].target);
                        args.Player.SendInfoMessage("with rewards ({0}).", Utils.ItemListToRewardsString(bounties[i].reward));
                        return;

                    case "-accept":
                        if (bounties[i].hunter.Contains(args.Player.Name))
                        {
                            args.Player.SendErrorMessage("You have already accepted this bounty!");
                            return;
                        }
                        if (bounties[i].failures.Contains(args.Player.Name))
                        {
                            args.Player.SendErrorMessage("You have failed this bounty already!");
                            args.Player.SendErrorMessage("You can no longer accept this bounty.");
                            return;
                        }
                        if (config.MaxHuntersPerBounty != 0 && bounties[i].hunter.Count >= config.MaxHuntersPerBounty)
                        {
                            args.Player.SendErrorMessage("The maximum number of hunters have accepted this bounty!");
                            args.Player.SendErrorMessage("Please try again later.");
                            return;
                        }
                        if (config.MaxBountiesPerHunter != 0 && player.activeBounties.Count >= config.MaxBountiesPerHunter)
                        {
                            args.Player.SendErrorMessage("You have taken the maximum number of bounties!");
                            args.Player.SendErrorMessage("Abandon another bounty to accept this bounty.");
                            return;
                        }
                        player.activeBounties.Add(bounties[i], 0);
                        bounties[i].hunter.Add(args.Player.Name);
                        dbManager.UpdateHunters(bounties[i]);
                        args.Player.SendSuccessMessage("You have accepted \"{0}.\" Your target is \"{1}.\"", bounties[i].name, bounties[i].target);
                        return;

                    case "-abandon":
                        Bounty btyToRemove = null;
                        foreach (Bounty bounty in player.activeBounties.Keys)
                        {
                            if (bounty.name == bounties[i].name)
                            {
                                btyToRemove = bounty;
                            }
                        }
                        if (btyToRemove != null)
                        {
                            player.activeBounties.Remove(btyToRemove);
                        }
                        bounties[i].hunter.Remove(args.Player.Name);
                        dbManager.UpdateHunters(bounties[i]);
                        args.Player.SendInfoMessage("You have abandoned \"{0}.\"", bounties[i].name);
                        return;

                    default:
                        Utils.InvalidGenBountyUsage(args.Player);
                        return;
                    }
                }
            }
        }