public async Task <Food> AcquireFoodAsync(Type type, int weaponAccuracy, User dbUser = null) { if (type != typeof(Meat) && type != typeof(Fish)) { throw new Exception("Invalid food type."); } if (CryptoRandom.Roll() <= weaponAccuracy) { int cumulative = 0; int sum = type == typeof(Meat) ? Data.MeatAcquireOdds : Data.FishAcquireOdds; int roll = CryptoRandom.Next(1, sum + 1); foreach (var item in type == typeof(Meat) ? (Food[])Data.Meat : Data.Fish) { cumulative += item.AcquireOdds; if (roll < cumulative) { if (dbUser != null) { await ModifyInventoryAsync(dbUser, item.Name); } return(item); } } return(null); } else { return(null); } }
public async Task <Item> OpenCrateAsync(Crate crate, User dbUser = null) { int cumulative = 0; int roll = CryptoRandom.Next(1, Data.CrateItemOdds); if (crate.ItemOdds >= CryptoRandom.Roll()) { foreach (var item in Data.CrateItems) { cumulative += item.CrateOdds; if (roll < cumulative) { if (dbUser != null) { await ModifyInventoryAsync(dbUser, crate.Name, -1); await ModifyInventoryAsync(dbUser, item.Name); } return(item); } } } else { if (dbUser != null) { await ModifyInventoryAsync(dbUser, crate.Name, -1); await ModifyInventoryAsync(dbUser, "Bullet"); } return(Data.Items.First(x => x.Name == "Bullet")); } return(null); }
public async Task Rob(IGuildUser user, decimal resources) { if (user.Id == Context.User.Id) { ReplyError("Only the *retards* try to rob themselves. Are you a retard?"); } else if (resources < Config.MinResources) { ReplyError($"The minimum amount of money to spend on resources for a robbery is {Config.MinResources.USD()}."); } else if (Context.Cash < resources) { ReplyError($"You don't have enough money. Balance: {Context.Cash.USD()}."); } var raidedDbUser = await _userRepo.GetUserAsync(user); if (resources > Math.Round(raidedDbUser.Cash * Config.RobCap / 2, 2)) { ReplyError($"You are overkilling it. You only need {(raidedDbUser.Cash * Config.RobCap / 2).USD()} " + $"to rob {Config.RobCap.ToString("P")} of their cash, that is {(raidedDbUser.Cash * Config.RobCap).USD()}."); } var stolen = resources * 2; int roll = CryptoRandom.Roll(); var successOdds = await _gangRepo.InGangAsync(Context.GUser) ? Config.RobOdds - 5 : Config.RobOdds; if (successOdds > roll) { await _userRepo.EditCashAsync(user, Context.DbGuild, raidedDbUser, -stolen); await _userRepo.EditCashAsync(Context, stolen); await user.Id.TryDMAsync(Context.Client, $"{Context.User} just robbed you and managed to walk away with {stolen.USD()}."); await ReplyAsync($"With a {successOdds}.00% chance of success, you successfully stole {stolen.USD()}. Balance: {Context.Cash.USD()}."); } else { await _userRepo.EditCashAsync(Context, -resources); await user.Id.TryDMAsync(Context.Client, $"{Context.User} tried to rob your sweet cash, but the n***a slipped on a banana peel and got arrested :joy: :joy: :joy:."); await ReplyAsync($"With a {successOdds}.00% chance of success, you failed to steal {stolen.USD()} " + $"and lost all resources in the process. Balance: {Context.Cash.USD()}."); } _cooldownService.TryAdd(new CommandCooldown(Context.User.Id, Context.Guild.Id, "Rob", Config.RobCooldown)); }
public async Task Raid(string gangName, decimal resources) { if (resources < Config.MinResources) { ReplyError($"The minimum amount of money to spend on resources for a raid is {Config.MinResources.USD()}."); } else if (Context.Gang.Wealth < resources) { ReplyError($"Your gang does not have enough money. {Context.Gang.Name}'s Wealth {Context.Gang.Wealth.USD()}."); } var raidedGang = await _gangRepo.GetGangAsync(gangName, Context.Guild.Id); if (raidedGang == null) { ReplyError("This gang does not exist."); } else if (Math.Round(resources, 2) > Math.Round(raidedGang.Wealth * Config.RaidCap / 2, 2)) { ReplyError($"You are overkilling it. You only need {(raidedGang.Wealth * Config.RaidCap / 2).USD()} " + $"to steal {Config.RaidCap.ToString("P")} of their cash, that is {(raidedGang.Wealth * Config.RaidCap).USD()}."); } var stolen = resources * 2; int roll = CryptoRandom.Roll(); var membersDeduction = raidedGang.Members.Length * 5; if (Config.RaidOdds - membersDeduction > roll) { await _gangRepo.ModifyGangAsync(gangName, Context.Guild.Id, x => x.Wealth = raidedGang.Wealth - stolen); await _gangRepo.ModifyAsync(Context.Gang, x => x.Wealth = Context.Gang.Wealth + stolen); await raidedGang.LeaderId.TryDMAsync(Context.Client, $"{Context.Gang.Name} just raided your gang's wealth and managed to walk away with {stolen.USD()}."); await ReplyAsync($"With a {Config.RaidOdds}.00% chance of success, you successfully stole {stolen.USD()}. " + $"{Context.Gang.Name}'s Wealth {Context.Gang.Wealth.USD()}."); } else { await _gangRepo.ModifyAsync(Context.Gang, x => x.Wealth = Context.Gang.Wealth - resources); await raidedGang.LeaderId.TryDMAsync(Context.Client, $"{Context.Gang.Name} tried to raid your gang's stash, but one of your loyal sicarios gunned them out."); await ReplyAsync($"With a {Config.RaidOdds}.00% chance of success, you failed to steal {stolen.USD()} " + $"and lost all resources in the process."); } _cooldownService.TryAdd(new CommandCooldown(Context.User.Id, Context.Guild.Id, "Raid", Config.RaidCooldown)); }
public async Task Shoot(IGuildUser userToShoot, [Own][Remainder] Gun gun) { if (userToShoot.Id == Context.User.Id) { ReplyError("Hey, look at that retard! He's trying to shoot himself l0l."); } var dbUser = await _userRepo.GetUserAsync(userToShoot); if (CryptoRandom.Roll() < gun.Accuracy) { var invData = _gameService.InventoryData(dbUser); var damage = invData.Any(x => x is Armour) ? (int)(gun.Damage * 0.8) : gun.Damage; //TODO: Rework armour. await _userRepo.ModifyAsync(dbUser, x => x.Health -= damage); await _gameService.ModifyInventoryAsync(Context.DbUser, "Bullet", -1); if (dbUser.Health <= 0) { foreach (var item in dbUser.Inventory.Elements) { await _gameService.ModifyInventoryAsync(Context.DbUser, item.Name, item.Value.AsInt32); } await _userRepo.DeleteAsync(dbUser); await userToShoot.TryDMAsync($"Unfortunately, you were killed by {Context.User.Boldify()}. All your data has been reset."); await _userRepo.EditCashAsync(Context, dbUser.Bounty); await ReplyAsync($"Woah, you just killed {userToShoot.Boldify()}. You just earned {dbUser.Bounty.USD()} **AND** their inventory, congrats."); } else { await ReplyAsync($"Nice shot, you just dealt {damage} damage to {userToShoot.Boldify()}."); await userToShoot.TryDMAsync($"{Context.User} tried to kill you, but n***a you *AH, HA, HA, HA, STAYIN' ALIVE*. -{damage} health. Current Health: {dbUser.Health}"); } } else { await ReplyAsync($"The n***a f*****g dodged the bullet, literally. What in the sac of nuts."); } await _gameService.ModifyInventoryAsync(Context.DbUser, "Bullet", -1); _cooldownService.TryAdd(new CommandCooldown(Context.User.Id, Context.Guild.Id, "Shoot", Config.ShootCooldown)); }
public async Task Jump() { if (CryptoRandom.Roll() > Config.JumpOdds) { await _userRepo.EditCashAsync(Context, -Config.JumpFine); await ReplyAsync($"Turns out the n***a was a black belt, whooped your ass, and brought you in. " + $"Court's final ruling was a {Config.JumpFine.USD()} fine. Balance: {Context.Cash.USD()}."); } else { decimal moneyJumped = CryptoRandom.NextDecimal(Config.MinJump, Config.MaxJump); await _userRepo.EditCashAsync(Context, moneyJumped); await ReplyAsync($"You jump some random n***a on the streets and manage to get {moneyJumped.USD()}. Balance: {Context.Cash.USD()}."); } _cooldownService.TryAdd(new CommandCooldown(Context.User.Id, Context.Guild.Id, "Jump", Config.JumpCooldown)); }
public async Task W***e() { if (CryptoRandom.Roll() > Config.WhoreOdds) { await _userRepo.EditCashAsync(Context, -Config.WhoreFine); await ReplyAsync($"What are the f*****g odds that one of your main clients was a cop... " + $"You are lucky you only got a {Config.WhoreFine.USD()} fine. Balance: {Context.Cash.USD()}."); } else { decimal moneyWhored = CryptoRandom.NextDecimal(Config.MinWhore, Config.MaxWhore); await _userRepo.EditCashAsync(Context, moneyWhored); await ReplyAsync($"You whip it out and manage to rake in {moneyWhored.USD()}. Balance: {Context.Cash.USD()}."); } _cooldownService.TryAdd(new CommandCooldown(Context.User.Id, Context.Guild.Id, "W***e", Config.WhoreCooldown)); }
public async Task Stab(IGuildUser userToStab, [Own][Remainder] Knife knife) { if (userToStab.Id == Context.User.Id) { ReplyError("Hey, look at that retard! He's trying to stab himself lmfao."); } var dbUser = await _userRepo.GetUserAsync(userToStab); if (CryptoRandom.Roll() < knife.Accuracy) { var invData = _gameService.InventoryData(dbUser); var damage = invData.Any(x => x is Armour) ? (int)(knife.Damage * 0.8) : knife.Damage; //TODO: Rework armour. await _userRepo.ModifyAsync(dbUser, x => x.Health -= damage); if (dbUser.Health <= 0) { foreach (var item in dbUser.Inventory.Elements) { await _gameService.ModifyInventoryAsync(Context.DbUser, item.Name, item.Value.AsInt32); } await _userRepo.DeleteAsync(dbUser); await userToStab.TryDMAsync($"Unfortunately, you were killed by {Context.User.Boldify()}. All your data has been reset."); await _userRepo.EditCashAsync(Context, dbUser.Bounty); await ReplyAsync($"Woah, you just killed {userToStab.Boldify()}. You just earned {dbUser.Bounty.USD()} **AND** their inventory, congrats."); } else { await userToStab.TryDMAsync($"{Context.User} tried to kill you, but n***a *AH, HA, HA, HA, STAYIN' ALIVE*. -{damage} health. Current Health: {dbUser.Health}"); await ReplyAsync($"Just stabbed that n***a in the heart, you just dealt {damage} damage to {userToStab.Boldify()}."); } } else { await ReplyAsync($"This n***a actually did some acrobatics shit and bounced out of the way before you stabbed him."); } _cooldownService.TryAdd(new CommandCooldown(Context.User.Id, Context.Guild.Id, "Stab", Config.StabCooldown)); }
public async Task Steal() { if (CryptoRandom.Roll() > Config.StealOdds) { await _userRepo.EditCashAsync(Context, -Config.StealFine); await ReplyAsync($"You were on your way out with the cash, but then some hot chick asked you if you " + $"wanted to bust a nut. Turns out she was a cop, and raped you before turning you in. Since she passed on some " + $"nice words to the judge about you not resisting arrest, you managed to walk away with only a " + $"{Config.StealFine.USD()} fine. Balance: {Context.Cash.USD()}."); } else { decimal moneyStolen = CryptoRandom.NextDecimal(Config.MinSteal, Config.MaxSteal); await _userRepo.EditCashAsync(Context, moneyStolen); string randomStore = Config.Stores[CryptoRandom.Next(Config.Stores.Length)]; await ReplyAsync($"You walk in to your local {randomStore}, point a fake gun at the clerk, and manage to walk away " + $"with {moneyStolen.USD()}. Balance: {Context.Cash.USD()}."); } _cooldownService.TryAdd(new CommandCooldown(Context.User.Id, Context.Guild.Id, "Steal", Config.StealCooldown)); }
public async Task Enslave(IGuildUser userToEnslave, [Own][Remainder] Weapon weapon) { var user = await _userRepo.GetUserAsync(userToEnslave); if (userToEnslave.Id == Context.User.Id) { ReplyError("Hey good buddies, look at that retard, trying to enslave himself."); } else if (Context.DbUser.SlaveOf != 0) { ReplyError("You cannot enslave someone if you are a slave."); } else if (user.SlaveOf != 0) { ReplyError("This user is already a slave."); } else if (user.Health > Config.MaxEnslaveHealth) { ReplyError($"The user must be under {Config.MaxEnslaveHealth} health to enslave."); } if (weapon.Accuracy >= CryptoRandom.Roll()) { await _userRepo.ModifyAsync(user, x => x.SlaveOf = Context.User.Id); await ReplyAsync($"You have successfully enslaved {userToEnslave.Boldify()}. {Config.SlaveCollection.ToString("P")} of all cash earned by all your slaves will go straight to you when you use `{Context.DbGuild.Prefix}Collect`."); await userToEnslave.TryDMAsync($"AH SHIT N***A! Looks like {Context.User.Boldify()} got you enslaved. The only way out is `{Context.DbGuild.Prefix}suicide`."); } else { await ReplyAsync("YOU GOT SLAMMED RIGHT IN THE C**T BY A N***A! :joy: :joy: :joy: Only took him 10 seconds to get you to the ground LMFAO."); await userToEnslave.TryDMAsync($"{Context.User.Boldify()} tried to enslave you but accidentally got pregnant and now he can't move :joy: :joy: :joy:."); } _cooldownService.TryAdd(new CommandCooldown(Context.User.Id, Context.Guild.Id, "Enslave", Config.EnslaveCooldown)); }