public IEnumerable <User> BulkGive(Guid currencyID, [FromBody] IEnumerable <GiveUserCurrency> giveDatas) { if (!ChannelSession.Settings.Currencies.ContainsKey(currencyID)) { var resp = new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new ObjectContent <Error>(new Error { Message = $"Unable to find currency: {currencyID.ToString()}." }, new JsonMediaTypeFormatter(), "application/json"), ReasonPhrase = "Currency ID not found" }; throw new HttpResponseException(resp); } if (giveDatas == null) { var resp = new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new ObjectContent <Error>(new Error { Message = $"Unable to parse array of give data from POST body." }, new JsonMediaTypeFormatter(), "application/json"), ReasonPhrase = "Invalid POST Body" }; throw new HttpResponseException(resp); } UserCurrencyViewModel currency = ChannelSession.Settings.Currencies[currencyID]; List <User> users = new List <User>(); foreach (var giveData in giveDatas) { UserDataViewModel user = null; if (uint.TryParse(giveData.UsernameOrID, out uint userID)) { user = ChannelSession.Settings.UserData[userID]; } if (user == null) { user = ChannelSession.Settings.UserData.Values.FirstOrDefault(u => u.UserName.Equals(giveData.UsernameOrID, StringComparison.InvariantCultureIgnoreCase)); } if (user != null && giveData.Amount > 0) { user.AddCurrencyAmount(currency, giveData.Amount); users.Add(UserController.UserFromUserDataViewModel(user)); } } return(users); }
private User AdjustCurrency(UserDataViewModel user, Guid currencyID, [FromBody] AdjustCurrency currencyUpdate) { if (!ChannelSession.Settings.Currencies.ContainsKey(currencyID)) { var resp = new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new ObjectContent <Error>(new Error { Message = $"Unable to find currency: {currencyID.ToString()}." }, new JsonMediaTypeFormatter(), "application/json"), ReasonPhrase = "Currency ID not found" }; throw new HttpResponseException(resp); } if (currencyUpdate == null) { var resp = new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new ObjectContent <Error>(new Error { Message = "Unable to parse currency adjustment from POST body." }, new JsonMediaTypeFormatter(), "application/json"), ReasonPhrase = "Invalid POST Body" }; throw new HttpResponseException(resp); } UserCurrencyViewModel currency = ChannelSession.Settings.Currencies[currencyID]; if (currencyUpdate.Amount < 0) { int quantityToRemove = currencyUpdate.Amount * -1; if (!user.HasCurrencyAmount(currency, quantityToRemove)) { var resp = new HttpResponseMessage(HttpStatusCode.Forbidden) { Content = new ObjectContent <Error>(new Error { Message = "User does not have enough currency to remove" }, new JsonMediaTypeFormatter(), "application/json"), ReasonPhrase = "Not Enough Currency" }; throw new HttpResponseException(resp); } user.SubtractCurrencyAmount(currency, quantityToRemove); } else if (currencyUpdate.Amount > 0) { user.AddCurrencyAmount(currency, currencyUpdate.Amount); } return(UserFromUserDataViewModel(user)); }
public CurrencyWindow(UserCurrencyViewModel currency) { this.currency = currency; this.rankChangedCommand = this.currency.RankChangedCommand; InitializeComponent(); this.RetroactivelyGivePointsButton.IsEnabled = true; this.ExportToFileButton.IsEnabled = true; this.ImportFromFileButton.IsEnabled = true; this.Initialize(this.StatusBar); }
protected override Task OnLoaded() { if (this.existingCommand != null) { this.CommandDetailsControl.SetDefaultValues(this.existingCommand); this.CommandDetailsControl.SetDefaultValues(this.existingCommand); this.MinimumParticipantsTextBox.Text = this.existingCommand.MinimumParticipants.ToString(); this.TimeLimitTextBox.Text = this.existingCommand.TimeLimit.ToString(); this.HitmanTimeLimitTextBox.Text = this.existingCommand.HitmanTimeLimit.ToString(); this.startedCommand = this.existingCommand.StartedCommand; this.userJoinCommand = this.existingCommand.UserJoinCommand; this.hitmanApproachingCommand = this.existingCommand.HitmanApproachingCommand; this.hitmanAppearsCommand = this.existingCommand.HitmanAppearsCommand; this.userSuccessCommand = this.existingCommand.UserSuccessOutcome.Command; this.userFailCommand = this.existingCommand.UserFailOutcome.Command; this.CustomHitmanNamesFilePathTextBox.Text = this.existingCommand.CustomWordsFilePath; } else { this.CommandDetailsControl.SetDefaultValues("Hitman", "hitman", CurrencyRequirementTypeEnum.MinimumAndMaximum, 10, 1000); UserCurrencyViewModel currency = ChannelSession.Settings.Currencies.Values.FirstOrDefault(); this.MinimumParticipantsTextBox.Text = "2"; this.TimeLimitTextBox.Text = "30"; this.HitmanTimeLimitTextBox.Text = "10"; this.startedCommand = this.CreateBasicChatCommand("@$username has started a game of hitman! Type !hitman in chat to play!"); this.userJoinCommand = this.CreateBasicChatCommand("You assemble with everyone else, patiently waiting for the hitman to appear...", whisper: true); this.hitmanApproachingCommand = this.CreateBasicChatCommand("You can feel the presence of the hitman approaching. Get ready..."); this.hitmanAppearsCommand = this.CreateBasicChatCommand("It's hitman $gamehitmanname! Quick, type $gamehitmanname in chat!"); this.userSuccessCommand = this.CreateBasicChatCommand("$gamewinners got hitman $gamehitmanname and walked away with a bounty of $gamepayout " + currency.Name + "!"); this.userFailCommand = this.CreateBasicChatCommand("No one was quick enough to get hitman $gamehitmanname! Better luck next time..."); } this.GameStartCommandButtonsControl.DataContext = this.startedCommand; this.UserJoinedCommandButtonsControl.DataContext = this.userJoinCommand; this.HitmanApproachingCommandButtonsControl.DataContext = this.hitmanApproachingCommand; this.HitmanAppearsCommandButtonsControl.DataContext = this.hitmanAppearsCommand; this.SuccessOutcomeCommandButtonsControl.DataContext = this.userSuccessCommand; this.FailOutcomeCommandButtonsControl.DataContext = this.userFailCommand; return(base.OnLoaded()); }
public TreasureDefenseGameEditorControlViewModel(UserCurrencyViewModel currency) { this.StartedCommand = this.CreateBasicChatCommand("@$username has started a game of Treasure Defense with a $gamebet " + currency.Name + " entry fee! Type !treasure to join in!"); this.UserJoinCommand = this.CreateBasicChatCommand("You've joined in to the defense of the treasure! Let's see what role you're assigned...", whisper: true); this.NotEnoughPlayersCommand = this.CreateBasicChatCommand("@$username couldn't get enough users to join in..."); this.KnightUserCommand = this.CreateBasicChatCommand("You've been selected as a Knight; convince the King to pick you so can protect the treasure!", whisper: true); this.ThiefUserCommand = this.CreateBasicChatCommand("You've been selected as a Thief; convince the King you are a Knight so you can steal the treasure!", whisper: true); this.KingUserCommand = this.CreateBasicChatCommand("King @$username has discovered the treasure! They must type \"!treasure <PLAYER>\" in chat to pick who will defend the treasure"); this.KnightSelectedCommand = this.CreateBasicChatCommand("King @$username picked @$targetusername to defend the treasure...and they were a Knight! They defended the treasure, giving the King & Knights $gamepayout " + currency.Name + " each!"); this.ThiefSelectedCommand = this.CreateBasicChatCommand("King @$username picked @$targetusername to defend the treasure...and they were a Thief! They stole the treasure, giving all Thieves $gamepayout " + currency.Name + " each!"); }
public BetGameEditorControlViewModel(UserCurrencyViewModel currency) : this() { this.StartedCommand = this.CreateBasic2ChatCommand("@$username has started a bet on...SOMETHING! Type !bet <OPTION #> <AMOUNT> in chat to participate!", "Options: $gamebetoptions"); this.UserJoinedCommand = this.CreateBasicChatCommand("Your bet option has been selected!", whisper: true); this.NotEnoughPlayersCommand = this.CreateBasicChatCommand("@$username couldn't get enough users to join in..."); this.BetsClosedCommand = this.CreateBasicChatCommand("All bets are now closed! Let's wait and see what the result is..."); this.UserFailCommand = this.CreateBasicChatCommand("Lady luck wasn't with you today, better luck next time...", whisper: true); this.GameCompleteCommand = this.CreateBasicChatCommand("$gamebetwinningoption was the winning choice!"); this.Options.Add(new BetOutcome("Win Match", this.CreateBasicChatCommand("We both won! Which mean you won $gamepayout " + currency.Name + "!", whisper: true), 200)); this.Options.Add(new BetOutcome("Lose Match", this.CreateBasicChatCommand("Well, I lose and you won $gamepayout " + currency.Name + ", so there's something at least...", whisper: true), 200)); }
public HitmanGameEditorControlViewModel(UserCurrencyViewModel currency) : this() { this.StartedCommand = this.CreateBasicChatCommand("@$username has started a game of hitman! Type !hitman in chat to play!"); this.UserJoinCommand = this.CreateBasicChatCommand("You assemble with everyone else, patiently waiting for the hitman to appear...", whisper: true); this.NotEnoughPlayersCommand = this.CreateBasicChatCommand("@$username couldn't get enough users to join in..."); this.HitmanApproachingCommand = this.CreateBasicChatCommand("You can feel the presence of the hitman approaching. Get ready..."); this.HitmanAppearsCommand = this.CreateBasicChatCommand("It's hitman $gamehitmanname! Quick, type $gamehitmanname in chat!"); this.UserSuccessCommand = this.CreateBasicChatCommand("$gamewinners got hitman $gamehitmanname and walked away with a bounty of $gamepayout " + currency.Name + "!"); this.UserFailCommand = this.CreateBasicChatCommand("No one was quick enough to get hitman $gamehitmanname! Better luck next time..."); }
public VolcanoGameEditorControlViewModel(UserCurrencyViewModel currency) { this.Stage1DepositCommand = this.CreateBasicChatCommand("After a few seconds, @$username hears a faint clunk as their " + currency.Name + " hit the bottom of the volcano"); this.Stage1StatusCommand = this.CreateBasicChatCommand("Peering in, you can hardly see anything inside. Total Amount: $gametotalamount"); this.Stage2DepositCommand = this.CreateBasicChatCommand("@$username hears a loud shuffling of " + currency.Name + " as their deposit goes in to the volcano"); this.Stage2StatusCommand = this.CreateBasicChatCommand("Peering in, you see the opening filled up over halfway inside the Volcano. Total Amount: $gametotalamount"); this.Stage3DepositCommand = this.CreateBasicChatCommand("@$username carefully places their " + currency.Name + " into the volcano, trying not to knock over the overflowing amount already in it."); this.Stage3StatusCommand = this.CreateBasicChatCommand("The " + currency.Name + " are starting to overflow from the top of the Volcano. Total Amount: $gametotalamount"); this.PayoutCommand = this.CreateBasic2ChatCommand("As @$username drops their " + currency.Name + " into the Volcano, a loud eruption occurs and $gamepayout " + currency.Name + " land on top of them!", "The Volcano is exploding out coins! Quick, type \"!volcano collect\" in chat in the next 30 seconds!"); this.CollectCommand = this.CreateBasicChatCommand("@$username after scavenging the aftermath, you walk away with $gamepayout " + currency.Name + "!", whisper: true); }
public NewCurrencyRankCommandsDialogControl(UserCurrencyViewModel currency, IEnumerable <NewCurrencyRankCommand> commands) { this.DataContext = this.currency = currency; InitializeComponent(); this.NewCommandsItemsControl.ItemsSource = this.commands; foreach (NewCurrencyRankCommand command in commands) { this.commands.Add(command); } this.Loaded += NewCurrencyRankCommandsDialogControl_Loaded; }
private async void CommandButtons_DeleteClicked(object sender, RoutedEventArgs e) { await this.RunAsyncOperation(async() => { CommandButtonsControl commandButtonsControl = (CommandButtonsControl)sender; CustomCommand command = commandButtonsControl.GetCommandFromCommandButtons <CustomCommand>(sender); if (command != null) { this.currency = null; await ChannelSession.SaveSettings(); this.UpdateRankChangedCommand(); } }); }
public WordScrambleGameEditorControlViewModel(UserCurrencyViewModel currency) : this() { this.StartedCommand = this.CreateBasicChatCommand("@$username has started a game of word scramble! Type !scramble in chat to play!"); this.UserJoinCommand = this.CreateBasicChatCommand("You assemble with everyone else arond the table...", whisper: true); this.NotEnoughPlayersCommand = this.CreateBasicChatCommand("@$username couldn't get enough users to join in..."); this.WordScramblePrepareCommand = this.CreateBasicChatCommand("Everyone is gathered patiently with their pencils in hand. Get ready..."); this.WordScrambleBeginCommand = this.CreateBasicChatCommand("The scrambled word is \"$gamewordscrambleword\"; solve it and be the first to type it in chat!"); this.UserSuccessCommand = this.CreateBasicChatCommand("$gamewinners correctly guessed the word \"$gamewordscrambleanswer\" and walked away with a bounty of $gamepayout " + currency.Name + "!"); this.UserFailCommand = this.CreateBasicChatCommand("No one was able the guess the word \"$gamewordscrambleanswer\"! Better luck next time..."); }
public override ActionBase GetAction() { if (this.CurrencyTypeComboBox.SelectedIndex >= 0 && this.CurrencyActionTypeComboBox.SelectedIndex >= 0) { UserCurrencyViewModel currency = this.GetSelectedCurrency(); UserInventoryViewModel inventory = this.GetSelectedInventory(); CurrencyActionTypeEnum actionType = EnumHelper.GetEnumValueFromString <CurrencyActionTypeEnum>((string)this.CurrencyActionTypeComboBox.SelectedItem); if (actionType == CurrencyActionTypeEnum.ResetForAllUsers || actionType == CurrencyActionTypeEnum.ResetForUser || !string.IsNullOrEmpty(this.CurrencyAmountTextBox.Text)) { if (actionType == CurrencyActionTypeEnum.AddToSpecificUser) { if (string.IsNullOrEmpty(this.CurrencyUsernameTextBox.Text)) { return(null); } } MixerRoleEnum roleRequirement = MixerRoleEnum.User; if (actionType == CurrencyActionTypeEnum.AddToAllChatUsers || actionType == CurrencyActionTypeEnum.SubtractFromAllChatUsers) { if (this.CurrencyPermissionsAllowedComboBox.SelectedIndex < 0) { return(null); } roleRequirement = EnumHelper.GetEnumValueFromString <MixerRoleEnum>((string)this.CurrencyPermissionsAllowedComboBox.SelectedItem); } if (currency != null) { return(new CurrencyAction(currency, actionType, this.CurrencyAmountTextBox.Text, username: this.CurrencyUsernameTextBox.Text, roleRequirement: roleRequirement, deductFromUser: this.DeductFromUserToggleButton.IsChecked.GetValueOrDefault())); } else if (inventory != null) { if (actionType == CurrencyActionTypeEnum.ResetForAllUsers || actionType == CurrencyActionTypeEnum.ResetForUser) { return(new CurrencyAction(inventory, actionType)); } else if (!string.IsNullOrEmpty(this.InventoryItemNameComboBox.Text)) { return(new CurrencyAction(inventory, actionType, this.InventoryItemNameComboBox.Text, this.CurrencyAmountTextBox.Text, username: this.CurrencyUsernameTextBox.Text, roleRequirement: roleRequirement, deductFromUser: this.DeductFromUserToggleButton.IsChecked.GetValueOrDefault())); } } } } return(null); }
private SlotMachineGameEditorControlViewModel() { this.AddOutcomeCommand = this.CreateCommand((parameter) => { UserCurrencyViewModel currency = (UserCurrencyViewModel)parameter; this.Outcomes.Add(new SlotMachineOutcome(null, null, null, this.CreateBasicChatCommand("Result: $gameslotsoutcome - @$username walks away with $gamepayout " + currency.Name + "!"))); return(Task.FromResult(0)); }); this.DeleteOutcomeCommand = this.CreateCommand((parameter) => { this.Outcomes.Remove((SlotMachineOutcome)parameter); return(Task.FromResult(0)); }); }
public HeistGameEditorControlViewModel(UserCurrencyViewModel currency) { this.StartedCommand = this.CreateBasicChatCommand("@$username has started a game of Heist! Type !heist <AMOUNT> to join in!"); this.UserJoinCommand = this.CreateBasicChatCommand("You've joined in the heist! Let's see how it turns out...", whisper: true); this.NotEnoughPlayersCommand = this.CreateBasicChatCommand("@$username couldn't get enough users to join in..."); this.UserSuccessCommand = this.CreateBasicChatCommand("Congrats, you made out with $gamepayout " + currency.Name + "!", whisper: true); this.UserFailCommand = this.CreateBasicChatCommand("The cops caught you before you could make it out! Better luck next time...", whisper: true); this.AllSucceedCommand = this.CreateBasic2ChatCommand("What a steal! Everyone made it out and cleaned the bank out dry! Total Amount: $gameallpayout " + currency.Name + "!", "Winners: $gamewinners"); this.TopThirdsSucceedCommand = this.CreateBasic2ChatCommand("The cops showed up at the last second and snagged a few of you, but most made it out with the good! Total Amount: $gameallpayout " + currency.Name + "!", "Winners: $gamewinners"); this.MiddleThirdsSucceedCommand = this.CreateBasic2ChatCommand("As you started to leave the bank, the cops were ready for you and got almost half of you! Total Amount: $gameallpayout " + currency.Name + "!", "Winners: $gamewinners"); this.LowThirdsSucceedCommand = this.CreateBasic2ChatCommand("A heated battle took place inside the bank and almost everyone got caught by the cops! Total Amount: $gameallpayout " + currency.Name + "!", "Winners: $gamewinners"); this.NoneSucceedCommand = this.CreateBasicChatCommand("Someone was a spy! The cops were waiting for you as soon as you showed up and got everyone!"); }
public IEnumerable <User> Get(Guid currencyID, int count = 10) { if (!ChannelSession.Settings.Currencies.ContainsKey(currencyID)) { var resp = new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new ObjectContent <Error>(new Error { Message = $"Unable to find currency: {currencyID.ToString()}." }, new JsonMediaTypeFormatter(), "application/json"), ReasonPhrase = "Currency ID not found" }; throw new HttpResponseException(resp); } if (count < 1) { // TODO: Consider checking or a max # too? (100?) var resp = new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new ObjectContent <Error>(new Error { Message = $"Count must be greater than 0." }, new JsonMediaTypeFormatter(), "application/json"), ReasonPhrase = "Count too low" }; throw new HttpResponseException(resp); } UserCurrencyViewModel currency = ChannelSession.Settings.Currencies[currencyID]; Dictionary <uint, UserDataViewModel> allUsersDictionary = ChannelSession.Settings.UserData.ToDictionary(); allUsersDictionary.Remove(ChannelSession.Channel.user.id); IEnumerable <UserDataViewModel> allUsers = allUsersDictionary.Select(kvp => kvp.Value); allUsers = allUsers.Where(u => !u.IsCurrencyRankExempt); List <User> currencyUserList = new List <User>(); foreach (UserDataViewModel currencyUser in allUsers.OrderByDescending(u => u.GetCurrencyAmount(currency)).Take(count)) { currencyUserList.Add(UserController.UserFromUserDataViewModel(currencyUser)); } return(currencyUserList); }
protected override Task OnLoaded() { if (this.existingCommand != null) { this.CommandDetailsControl.SetDefaultValues(this.existingCommand); this.MinimumParticipantsTextBox.Text = this.existingCommand.MinimumParticipants.ToString(); this.TimeLimitTextBox.Text = this.existingCommand.TimeLimit.ToString(); this.MaxWinnersTextBox.Text = this.existingCommand.MaxWinners.ToString(); this.startedCommand = this.existingCommand.StartedCommand; this.userJoinCommand = this.existingCommand.UserJoinCommand; this.userSuccessCommand = this.existingCommand.UserSuccessOutcome.Command; this.userFailCommand = this.existingCommand.UserFailOutcome.Command; this.gameCompleteCommand = this.existingCommand.GameCompleteCommand; } else { this.CommandDetailsControl.SetDefaultValues("Russian Roulette", "rr russian", CurrencyRequirementTypeEnum.MinimumAndMaximum, 10, 1000); UserCurrencyViewModel currency = ChannelSession.Settings.Currencies.Values.FirstOrDefault(); this.MinimumParticipantsTextBox.Text = "2"; this.TimeLimitTextBox.Text = "30"; this.MaxWinnersTextBox.Text = "1"; this.startedCommand = this.CreateBasicChatCommand("@$username has started a game of Russian Roulette with a $gamebet " + currency.Name + " entry fee! Type !rr to join in!"); this.userJoinCommand = this.CreateBasicChatCommand("You've joined in the russian roulette match! Let's see who walks away the winner...", whisper: true); this.userSuccessCommand = this.CreateBasicChatCommand("You survived and walked away with $gamepayout " + currency.Name + "!", whisper: true); this.userFailCommand = this.CreateBasicChatCommand("Looks like luck was not on your side. Better luck next time...", whisper: true); this.gameCompleteCommand = this.CreateBasicChatCommand("The dust settles after a grueling match-up and...It's $gamewinners! Total Amount Per Winner: $gameallpayout " + currency.Name + "!"); } this.GameStartCommandButtonsControl.DataContext = this.startedCommand; this.UserJoinedCommandButtonsControl.DataContext = this.userJoinCommand; this.SuccessOutcomeCommandButtonsControl.DataContext = this.userSuccessCommand; this.FailOutcomeCommandButtonsControl.DataContext = this.userFailCommand; this.GameCompleteCommandButtonsControl.DataContext = this.gameCompleteCommand; return(base.OnLoaded()); }
private void AddOutcomeButton_Click(object sender, RoutedEventArgs e) { UserCurrencyViewModel currency = null; RequirementViewModel requirements = this.CommandDetailsControl.GetRequirements(); if (requirements.Currency != null) { currency = requirements.Currency.GetCurrency(); } if (currency == null) { currency = ChannelSession.Settings.Currencies.Values.FirstOrDefault(); } this.outcomes.Add(new SlotMachineOutcome(null, null, null, this.CreateBasicChatCommand("Result: $gameslotsoutcome - @$username walks away with $gamepayout " + currency.Name + "!"))); }
public VendingMachineGameEditorControlViewModel(UserCurrencyViewModel currency) : this() { this.Outcomes.Add(new VendingMachineOutcome("Nothing", this.CreateBasicChatCommand("@$username opened their capsule and found nothing..."), 40, 40, 40)); CustomCommand currencyCommand = this.CreateBasicChatCommand("@$username opened their capsule and found 50 " + currency.Name + "!"); currencyCommand.Actions.Add(new CurrencyAction(currency, CurrencyActionTypeEnum.AddToUser, 50.ToString())); this.Outcomes.Add(new VendingMachineOutcome("50", currencyCommand, 30, 30, 30)); CustomCommand overlayCommand = this.CreateBasicChatCommand("@$username opened their capsule and found a dancing Carlton!"); OverlayImageItemModel overlayImage = new OverlayImageItemModel("https://78.media.tumblr.com/1921bcd13e12643771410200a322cb0e/tumblr_ogs5bcHWUc1udh5n8o1_500.gif", 500, 500); overlayImage.Position = new OverlayItemPositionModel(OverlayItemPositionType.Percentage, 50, 50, 0); overlayImage.Effects = new OverlayItemEffectsModel(OverlayItemEffectEntranceAnimationTypeEnum.FadeIn, OverlayItemEffectVisibleAnimationTypeEnum.None, OverlayItemEffectExitAnimationTypeEnum.FadeOut, 3); overlayCommand.Actions.Add(new OverlayAction(ChannelSession.Services.OverlayServers.DefaultOverlayName, overlayImage)); this.Outcomes.Add(new VendingMachineOutcome("Dancing Carlton", overlayCommand, 30, 30, 30)); }
public bool TrySubtractAmount(UserDataViewModel userData, int amount) { if (this.DoesMeetCurrencyRequirement(amount)) { UserCurrencyViewModel currency = this.GetCurrency(); if (currency == null) { return(false); } if (!userData.HasCurrencyAmount(currency, amount)) { return(false); } userData.SubtractCurrencyAmount(currency, amount); return(true); } return(false); }
protected override Task OnLoaded() { if (this.existingCommand != null) { this.CommandDetailsControl.SetDefaultValues(this.existingCommand); this.CombinationLengthTextBox.Text = this.existingCommand.CombinationLength.ToString(); this.InitialAmountTextBox.Text = this.existingCommand.InitialAmount.ToString(); this.failedGuessCommand = this.existingCommand.FailedGuessCommand; this.successfulGuessCommand = this.existingCommand.SuccessfulGuessCommand; this.StatusArgumentTextBox.Text = this.existingCommand.StatusArgument; this.statusCommand = this.existingCommand.StatusCommand; this.InspectionArgumentTextBox.Text = this.existingCommand.InspectionArgument; this.InspectionCostTextBox.Text = this.existingCommand.InspectionCost.ToString(); this.inspectionCommand = this.existingCommand.InspectionCommand; } else { this.CommandDetailsControl.SetDefaultValues("Lock Box", "lockbox", CurrencyRequirementTypeEnum.RequiredAmount, 10); UserCurrencyViewModel currency = ChannelSession.Settings.Currencies.Values.FirstOrDefault(); this.CombinationLengthTextBox.Text = "3"; this.InitialAmountTextBox.Text = "500"; this.failedGuessCommand = this.CreateBasicChatCommand("@$username drops their coins into and try their combo...but the box doesn't unlock. Their guess was too $gamelockboxhint."); this.successfulGuessCommand = this.CreateBasicChatCommand("@$username drops their coins into and try their combo...and unlocks the box! They quickly run off with the $gamepayout " + currency.Name + " inside it!"); this.StatusArgumentTextBox.Text = "status"; this.statusCommand = this.CreateBasicChatCommand("After shaking the box for a bit, you guess there's about $gametotalamount " + currency.Name + " inside it."); this.InspectionArgumentTextBox.Text = "inspect"; this.InspectionCostTextBox.Text = "10"; this.inspectionCommand = this.CreateBasicChatCommand("After inspecting the box for a bit, you surmise that one of the numbers is a $gamelockboxinspection."); } this.FailedGuessCommandButtonsControl.DataContext = this.failedGuessCommand; this.SuccessfulGuessCommandButtonsControl.DataContext = this.successfulGuessCommand; this.StatusCommandButtonsControl.DataContext = this.statusCommand; this.InspectionCommandButtonsControl.DataContext = this.inspectionCommand; return(base.OnLoaded()); }
public override ActionBase GetAction() { if (this.CurrencyTypeComboBox.SelectedIndex >= 0 && this.CurrencyActionTypeComboBox.SelectedIndex >= 0 && !string.IsNullOrEmpty(this.CurrencyAmountTextBox.Text)) { UserCurrencyViewModel currency = (UserCurrencyViewModel)this.CurrencyTypeComboBox.SelectedItem; CurrencyActionTypeEnum actionType = EnumHelper.GetEnumValueFromString <CurrencyActionTypeEnum>((string)this.CurrencyActionTypeComboBox.SelectedItem); if (actionType == CurrencyActionTypeEnum.GiveToSpecificUser) { if (string.IsNullOrEmpty(this.CurrencyUsernameTextBox.Text)) { return(null); } } return(new CurrencyAction(currency, actionType, this.CurrencyAmountTextBox.Text, this.CurrencyUsernameTextBox.Text, this.DeductFromUserToggleButton.IsChecked.GetValueOrDefault())); } return(null); }
protected override Task OnLoaded() { this.CommandDetailsControl.SetAsMinimumOnly(); this.GameStartRoleComboBox.ItemsSource = RoleRequirementViewModel.AdvancedUserRoleAllowedValues; this.GameStartRoleComboBox.SelectedItem = EnumHelper.GetEnumName(MixerRoleEnum.Mod); if (this.existingCommand != null) { this.CommandDetailsControl.SetDefaultValues(this.existingCommand); this.CommandDetailsControl.SetDefaultValues(this.existingCommand); this.MinimumParticipantsTextBox.Text = this.existingCommand.MinimumParticipants.ToString(); this.TimeLimitTextBox.Text = this.existingCommand.TimeLimit.ToString(); this.GameStartRoleComboBox.SelectedItem = this.existingCommand.GameStarterRequirement.RoleNameString; this.startedCommand = this.existingCommand.StartedCommand; this.userJoinCommand = this.existingCommand.UserJoinCommand; this.gameCompleteCommand = this.existingCommand.GameCompleteCommand; } else { this.CommandDetailsControl.SetDefaultValues("Bid", "bid", CurrencyRequirementTypeEnum.MinimumOnly, 10); UserCurrencyViewModel currency = ChannelSession.Settings.Currencies.Values.FirstOrDefault(); this.MinimumParticipantsTextBox.Text = "2"; this.TimeLimitTextBox.Text = "30"; this.startedCommand = this.CreateBasicChatCommand("@$username has started a bidding war starting at $gamebet " + currency.Name + " for...SOMETHING! Type !bid <AMOUNT> in chat to outbid them!"); this.userJoinCommand = this.CreateBasicChatCommand("@$username has become the top bidder with $gamebet " + currency.Name + "! Type !bid <AMOUNT> in chat to outbid them!"); this.gameCompleteCommand = this.CreateBasicChatCommand("$gamewinners won the bidding war with a bid of $gamebet " + currency.Name + "! Listen closely for how to claim your prize..."); } this.GameStartCommandButtonsControl.DataContext = this.startedCommand; this.UserJoinedCommandButtonsControl.DataContext = this.userJoinCommand; this.GameCompleteCommandButtonsControl.DataContext = this.gameCompleteCommand; return(base.OnLoaded()); }
public bool DoesMeetCurrencyRequirement(UserDataViewModel userData) { UserCurrencyViewModel currency = this.GetCurrency(); if (currency == null) { return(false); } UserRankViewModel rank = this.RequiredRank; if (rank == null) { return(false); } UserCurrencyDataViewModel userCurrencyData = userData.GetCurrency(currency); return(this.DoesMeetCurrencyRequirement(userCurrencyData.Amount)); }
public bool TrySubtractAmount(UserDataViewModel userData, int amount) { if (this.DoesMeetCurrencyRequirement(amount)) { UserCurrencyViewModel currency = this.GetCurrency(); if (currency == null) { return(false); } UserCurrencyDataViewModel userCurrencyData = userData.GetCurrency(currency); if (userCurrencyData.Amount < amount) { return(false); } userCurrencyData.Amount -= amount; return(true); } return(false); }
protected override Task OnLoaded() { if (this.existingCommand != null) { this.CommandDetailsControl.SetDefaultValues(this.existingCommand); this.CommandDetailsControl.SetDefaultValues(this.existingCommand); this.MinimumAmountForPayoutTextBox.Text = this.existingCommand.MinimumAmountForPayout.ToString(); this.PayoutProbabilityTextBox.Text = this.existingCommand.PayoutProbability.ToString(); this.PayoutPercentageMinimumLimitTextBox.Text = (this.existingCommand.PayoutPercentageMinimum * 100).ToString(); this.PayoutPercentageMaximumLimitTextBox.Text = (this.existingCommand.PayoutPercentageMaximum * 100).ToString(); this.noPayoutCommand = this.existingCommand.NoPayoutCommand; this.payoutCommand = this.existingCommand.PayoutCommand; this.StatusArgumentTextBox.Text = this.existingCommand.StatusArgument; this.statusCommand = this.existingCommand.StatusCommand; } else { this.CommandDetailsControl.SetDefaultValues("Coin Pusher", "pusher", CurrencyRequirementTypeEnum.MinimumAndMaximum, 10, 1000); UserCurrencyViewModel currency = ChannelSession.Settings.Currencies.Values.FirstOrDefault(); this.MinimumAmountForPayoutTextBox.Text = "2500"; this.PayoutProbabilityTextBox.Text = "10"; this.PayoutPercentageMinimumLimitTextBox.Text = "30"; this.PayoutPercentageMaximumLimitTextBox.Text = "70"; this.noPayoutCommand = this.CreateBasicChatCommand("@$username drops their coins into the machine...and nothing happens. All $gametotalamount " + currency.Name + " stares back at you."); this.payoutCommand = this.CreateBasicChatCommand("@$username drops their coins into the machine...and hits the jackpot, walking away with $gamepayout " + currency.Name + "!"); this.StatusArgumentTextBox.Text = "status"; this.statusCommand = this.CreateBasicChatCommand("After spending a few minutes, you count $gametotalamount " + currency.Name + " inside the machine."); } this.NoPayoutCommandButtonsControl.DataContext = this.noPayoutCommand; this.PayoutCommandButtonsControl.DataContext = this.payoutCommand; this.StatusCommandButtonsControl.DataContext = this.statusCommand; return(base.OnLoaded()); }
public IEnumerable <User> BulkGive(Guid currencyID, [FromBody] IEnumerable <GiveUserCurrency> giveDatas) { if (!ChannelSession.Settings.Currencies.ContainsKey(currencyID)) { throw new HttpResponseException(HttpStatusCode.NotFound); } if (giveDatas == null) { throw new HttpResponseException(HttpStatusCode.BadRequest); } UserCurrencyViewModel currency = ChannelSession.Settings.Currencies[currencyID]; List <User> users = new List <User>(); foreach (var giveData in giveDatas) { UserDataViewModel user = null; if (uint.TryParse(giveData.UsernameOrID, out uint userID)) { user = ChannelSession.Settings.UserData[userID]; } if (user == null) { user = ChannelSession.Settings.UserData.Values.FirstOrDefault(u => u.UserName.Equals(giveData.UsernameOrID, StringComparison.InvariantCultureIgnoreCase)); } if (user != null && giveData.Amount > 0) { user.AddCurrencyAmount(currency, giveData.Amount); users.Add(UserController.UserFromUserDataViewModel(user)); } } return(users); }
public SpinWheelGameCommand(UserCurrencyViewModel currency) : base("Spin Wheel", new List <string>() { "spin" }, UserRole.User, 15, new UserCurrencyRequirementViewModel(currency, 1, 100), CurrencyRequirementTypeEnum.MinimumAndMaximum, new List <GameOutcome>(), new List <GameOutcomeGroup>(), null) { this.Outcomes.Add(new GameOutcome("Win", PreMadeGameCommandHelper.CreateCustomChatCommand("@$username won $gamepayout $gamecurrencyname!"))); GameOutcomeGroup userGroup = new GameOutcomeGroup(UserRole.User); userGroup.Probabilities.Add(new GameOutcomeProbability(50, 25, "Win")); this.Groups.Add(userGroup); GameOutcomeGroup subscriberGroup = new GameOutcomeGroup(UserRole.Subscriber); subscriberGroup.Probabilities.Add(new GameOutcomeProbability(50, 25, "Win")); this.Groups.Add(subscriberGroup); GameOutcomeGroup modGroup = new GameOutcomeGroup(UserRole.Mod); modGroup.Probabilities.Add(new GameOutcomeProbability(50, 25, "Win")); this.Groups.Add(modGroup); this.LoseLeftoverCommand = PreMadeGameCommandHelper.CreateCustomChatCommand("Sorry @$username, you lost the spin!"); }
public override ActionBase GetAction() { if (this.CurrencyTypeComboBox.SelectedIndex >= 0 && !string.IsNullOrEmpty(this.CurrencyAmountTextBox.Text) && this.GiveToComboBox.SelectedIndex >= 0) { CurrencyGiveToTypeEnum giveTo = EnumHelper.GetEnumValueFromString <CurrencyGiveToTypeEnum>((string)this.GiveToComboBox.SelectedItem); if (giveTo == CurrencyGiveToTypeEnum.SpecificUser) { if (string.IsNullOrEmpty(this.CurrencyUsernameTextBox.Text)) { return(null); } } else { this.CurrencyUsernameTextBox.Text = null; } UserCurrencyViewModel currency = (UserCurrencyViewModel)this.CurrencyTypeComboBox.SelectedItem; return(new CurrencyAction(currency, this.CurrencyUsernameTextBox.Text, (giveTo == CurrencyGiveToTypeEnum.AllChatUsers), this.CurrencyAmountTextBox.Text, this.DeductFromUserToggleButton.IsChecked.GetValueOrDefault(), this.CurrencyMessageTextBox.Text, this.CurrencyWhisperToggleButton.IsChecked.GetValueOrDefault())); } return(null); }
protected override Task OnLoaded() { this.OutcomesItemsControl.ItemsSource = this.outcomes; if (this.existingCommand != null) { this.CommandDetailsControl.SetDefaultValues(this.existingCommand); foreach (GameOutcome outcome in this.existingCommand.Outcomes) { this.outcomes.Add(new SpinOutcome(outcome)); } } else { this.CommandDetailsControl.SetDefaultValues("Spin", "spin", CurrencyRequirementTypeEnum.MinimumAndMaximum, 10, 1000); UserCurrencyViewModel currency = ChannelSession.Settings.Currencies.Values.FirstOrDefault(); this.outcomes.Add(new SpinOutcome("Lose", this.CreateBasicChatCommand("Sorry @$username, you lost the spin!"), 0, 70, 70, 70)); this.outcomes.Add(new SpinOutcome("Win", this.CreateBasicChatCommand("Congrats @$username, you won $gamepayout " + currency.Name + "!"), 200, 30, 30, 30)); } return(base.OnLoaded()); }
private static string ReplaceSpecialIdentifiersVersion4(string text, UserCurrencyViewModel currency, UserCurrencyViewModel rank) { if (!string.IsNullOrEmpty(text)) { text = text.Replace("$userrank ", "$userrankname - $userrankpoints "); if (currency != null) { text = text.Replace("$usercurrency", "$" + currency.UserAmountSpecialIdentifier); } if (rank != null) { text = text.Replace("$userrankpoints", "$" + rank.UserAmountSpecialIdentifier); text = text.Replace("$userrankname", "$" + rank.UserRankNameSpecialIdentifier); } for (int i = 0; i < 10; i++) { text = text.Replace("$arg" + i + "string", "$arg" + i + "text"); text = text.Replace("$arg" + i + "userrank", "$arg" + i + "userrankname - " + "$arg" + i + "userrankpoints"); if (currency != null) { text = text.Replace("$arg" + i + "usercurrency", "$arg" + i + currency.UserAmountSpecialIdentifier); } if (rank != null) { text = text.Replace("$arg" + i + "userrankpoints", "$arg" + i + rank.UserAmountSpecialIdentifier); text = text.Replace("$arg" + i + "userrankname", "$arg" + i + rank.UserRankNameSpecialIdentifier); } } } return(text); }