public static bool CheckTimesKarmaTypeHasBeenUsedRecently(KarmaType karmaType) { // if they have max event setting off always return false if (!ToolkitSettings.MaxEvents) { return(false); } switch (karmaType) { case KarmaType.Bad: return(component.KarmaTypesInLogOf(karmaType) >= ToolkitSettings.MaxBadEventsPerInterval); case KarmaType.Good: return(component.KarmaTypesInLogOf(karmaType) >= ToolkitSettings.MaxGoodEventsPerInterval); case KarmaType.Neutral: return(component.KarmaTypesInLogOf(karmaType) >= ToolkitSettings.MaxNeutralEventsPerInterval); case KarmaType.Doom: return(component.KarmaTypesInLogOf(karmaType) >= ToolkitSettings.MaxBadEventsPerInterval); } return(false); }
public void CalculateNewKarma(KarmaType karmaType, int price) { int old = this.GetViewerKarma(); int newKarma = Karma.CalculateNewKarma(old, karmaType, price); SetViewerKarma(newKarma); Store_Logger.LogKarmaChange(username, old, newKarma); }
public void AdjustKarma(Guid userId, Guid subId, KarmaType karmaType, int change) { if (change == 0) { return; } EnsureStatementsReady(); _session.Execute(_adjustStatement.Bind((long)change, userId, subId + "-" + karmaType).SetConsistencyLevel(ConsistencyLevel.All)); }
public static void Charge([NotNull] this Viewer viewer, int cost, KarmaType karmaType) { if (!ToolkitSettings.UnlimitedCoins) { viewer.TakeViewerCoins(cost); } viewer.CalculateNewKarma(karmaType, cost); }
/// <summary> /// Save the object's XML to the XmlWriter. /// </summary> /// <param name="objWriter">XmlTextWriter to write with.</param> public void Save(XmlTextWriter objWriter) { objWriter.WriteStartElement("undo"); objWriter.WriteElementString("karmatype", KarmaType.ToString()); objWriter.WriteElementString("nuyentype", NuyenType.ToString()); objWriter.WriteElementString("objectid", _strObjectId); objWriter.WriteElementString("qty", _decQty.ToString(GlobalOptions.InvariantCultureInfo)); objWriter.WriteElementString("extra", _strExtra); objWriter.WriteEndElement(); }
public Product(int id, int type, string name, string abr, KarmaType karmatype, int amount, int evtId, int maxEvents) { this.id = id; this.type = type; this.name = name; this.abr = abr; this.karmatype = karmatype; this.amount = amount; this.evtId = evtId; this.evt = Products.defaultEvents[this.evtId]; this.maxEvents = maxEvents; }
public static bool CheckIfKarmaTypeIsMaxed(KarmaType karmaType, string username, bool separateChannel = false) { bool maxed = CheckTimesKarmaTypeHasBeenUsedRecently(karmaType); if (maxed) { Log.Message("KarmaType " + karmaType + " event cap has been reached"); client.SendMessage($"@{username} " + "TwitchToolkitMaxEvents".Translate(), separateChannel); } return(maxed); }
/// <summary> /// Save the object's XML to the XmlWriter. /// </summary> /// <param name="objWriter">XmlTextWriter to write with.</param> public void Save(XmlWriter objWriter) { if (objWriter == null) { return; } objWriter.WriteStartElement("undo"); objWriter.WriteElementString("karmatype", KarmaType.ToString()); objWriter.WriteElementString("nuyentype", NuyenType.ToString()); objWriter.WriteElementString("objectid", _strObjectId); objWriter.WriteElementString("qty", _decQty.ToString(GlobalSettings.InvariantCultureInfo)); objWriter.WriteElementString("extra", _strExtra); objWriter.WriteEndElement(); }
public async Task <KarmaAkashicRecord> KarmaLost(KarmaType karmaType, KarmaSourceType karmaSourceType, string karamSourceTitle, string karmaSourceDesc, bool autoSave = true) { KarmaAkashicRecord record = new KarmaAkashicRecord { KarmaEarntOrLost = KarmaEarntOrLost.Lost, Date = DateTime.Now, Karma = GetKarmaForType(karmaType), KarmaSource = karmaSourceType, KarmaSourceTitle = karamSourceTitle, KarmaSourceDesc = karmaSourceDesc, KarmaType = karmaType, UserId = UserId, Provider = ProviderManager.CurrentStorageProviderType }; this.Karma -= GetKarmaForType(karmaType); this.KarmaAkashicRecords.Add(record); if (autoSave) { await Save(); } return(record); }
private int GetKarmaForType(KarmaType karmaType) { switch (karmaType) { case KarmaType.ContributingTowardsAGoodCauseAdministrator: return(3); case KarmaType.ContributingTowardsAGoodCauseSpeaker: return(8); case KarmaType.ContributingTowardsAGoodCauseContributor: return(5); case KarmaType.ContributingTowardsAGoodCauseCreatorOrganiser: return(10); case KarmaType.ContributingTowardsAGoodCauseFunder: return(8); case KarmaType.ContributingTowardsAGoodCausePeacefulProtesterActivist: return(5); case KarmaType.ContributingTowardsAGoodCauseSharer: return(3); case KarmaType.HelpingAnimals: return(5); case KarmaType.HelpingTheEnvironment: return(5); case KarmaType.Other: return(2); case KarmaType.OurWorld: return(5); case KarmaType.SelfHelpImprovement: return(2); default: return(0); } }
public static int CalculateNewKarma(int karma, KarmaType karmatype, int calculatedprice = 0) { float tier = ((float)karma / ((float)ToolkitSettings.KarmaCap)); Helper.Log($"Calculating new karma with {karma}, and karma type {karmatype} for {calculatedprice} with curve {CalculateForCurve()} tier {tier}"); double newkarma = 0; int maxkarma = 0; if (karmatype == KarmaType.Doom) { newkarma = (double)karma - (Convert.ToDouble((double)calculatedprice / (double)ToolkitSettings.DoomBonus) * (ToolkitSettings.KarmaCap / 100)); //possibly ban? if (tier < 0.061) { //ban viewer maxkarma = 0; } } else { if (tier > 0.55) { switch (karmatype) { //small bonus for good case KarmaType.Good: newkarma = (double)karma + (Convert.ToDouble((double)calculatedprice / (double)ToolkitSettings.TierOneGoodBonus) * CalculateForCurve()); break; //minute bonus for neutral case KarmaType.Neutral: newkarma = (double)karma + (Convert.ToDouble((double)calculatedprice / (double)ToolkitSettings.TierOneNeutralBonus) * CalculateForCurve()); break; //small punishment for bad case KarmaType.Bad: newkarma = (double)karma - (Convert.ToDouble((double)calculatedprice / (double)ToolkitSettings.TierOneBadBonus) * CalculateForCurve()); break; } } else if (tier > 0.36) { switch (karmatype) { //medium bonus for good case KarmaType.Good: newkarma = (double)karma + (Convert.ToDouble((double)calculatedprice / (double)ToolkitSettings.TierTwoGoodBonus) * CalculateForCurve()); break; //minute bonus for neutral case KarmaType.Neutral: Helper.Log($"{(double)karma} + ( ({(double)calculatedprice} / {(double)ToolkitSettings.TierTwoNeutralBonus}) * ({CalculateForCurve()}))"); newkarma = (double)karma + (Convert.ToDouble((double)calculatedprice / (double)ToolkitSettings.TierTwoNeutralBonus) * CalculateForCurve()); break; //medium punishment for bad case KarmaType.Bad: newkarma = (double)karma - (Convert.ToDouble((double)calculatedprice / (double)ToolkitSettings.TierTwoBadBonus) * CalculateForCurve()); break; } } else if (tier > 0.06) { switch (karmatype) { //small bonus for good case KarmaType.Good: newkarma = (double)karma + (Convert.ToDouble((double)calculatedprice / (double)ToolkitSettings.TierThreeGoodBonus) * CalculateForCurve()); break; //small bonus for neutral case KarmaType.Neutral: newkarma = (double)karma + (Convert.ToDouble((double)calculatedprice / (double)ToolkitSettings.TierThreeNeutralBonus) * CalculateForCurve()); break; //big punishment for bad case KarmaType.Bad: newkarma = (double)karma - (Convert.ToDouble((double)calculatedprice / (double)ToolkitSettings.TierThreeBadBonus) * CalculateForCurve()); break; } } else { switch (karmatype) { //medium bonus for good case KarmaType.Good: newkarma = (double)karma + (Convert.ToDouble((double)calculatedprice / (double)ToolkitSettings.TierFourGoodBonus) * CalculateForCurve()); break; //small bonus for neutral case KarmaType.Neutral: newkarma = (double)karma + (Convert.ToDouble((double)calculatedprice / (double)ToolkitSettings.TierFourNeutralBonus) * CalculateForCurve()); break; //banned for bad case KarmaType.Bad: newkarma = (double)karma - (Convert.ToDouble((double)calculatedprice / ((double)ToolkitSettings.TierFourBadBonus > 0 ? ToolkitSettings.TierFourBadBonus : 66)) * CalculateForCurve()); break; } } } if (newkarma < 1 && ToolkitSettings.BanViewersWhoPurchaseAlwaysBad) { newkarma = 1; } if (newkarma < ToolkitSettings.KarmaMinimum) { newkarma = ToolkitSettings.KarmaMinimum; } maxkarma = Convert.ToInt32(Math.Ceiling(newkarma)) > ToolkitSettings.KarmaCap ? ToolkitSettings.KarmaCap : Convert.ToInt32(Math.Ceiling(newkarma)); return(maxkarma); }
public void Draw(Rect canvas) { (Rect label, Rect field) = canvas.Split(0.75f); UiHelper.Label(label, _karmaTypeLabel); if (Widgets.ButtonText(field, _karmaType.ToString())) { Find.WindowStack.Add(new FloatMenu(Data.KarmaTypes.Values.Select(i => new FloatMenuOption(i.ToString(), () => _karmaType = i)).ToList())); } }
public void DecreaseKarma(Guid userId, Guid subId, KarmaType karmaType) { AdjustKarma(userId, subId, karmaType, -1); }
public Task <KarmaAkashicRecord> AddKarmaToProfileAsync(API.Core.IProfile profile, KarmaType karmaType, KarmaSourceType karmaSourceType, string karamSourceTitle, string karmaSourceDesc) { return(profile.KarmaEarnt(karmaType, karmaSourceType, karamSourceTitle, karmaSourceDesc)); }
public KarmaReportKey(Guid subId, KarmaType type) { _subId = subId; _type = type; }
public override void ExposeData() { base.ExposeData(); Scribe_Values.Look(ref Channel, "Channel", "", true); Scribe_Values.Look(ref Username, "Username", "", true); Scribe_Values.Look(ref OAuth, "OAuth", "", true); Scribe_Values.Look(ref ChannelID, "ChannelID", "", true); Scribe_Values.Look(ref ChatroomUUID, "ChatroomUUID", "", true); Scribe_Values.Look(ref VoteTime, "VoteTime", 1, true); Scribe_Values.Look(ref VoteOptions, "VoteOptions", 3, true); Scribe_Values.Look(ref VoteEnabled, "VoteEnabled", false, true); Scribe_Values.Look(ref AutoConnect, "AutoConnect", false, true); Scribe_Values.Look(ref OtherStorytellersEnabled, "OtherStorytellersEnabled", false, true); Scribe_Values.Look(ref CommandsModsEnabled, "CommandsModsEnabled", true, true); Scribe_Values.Look(ref CommandsAliveEnabled, "CommandsAliveEnabled", true, true); Scribe_Values.Look(ref QuotesEnabled, "QuotesEnabled", true, true); Scribe_Values.Look(ref CoinInterval, "CoinInterval", 2, true); Scribe_Values.Look(ref CoinAmount, "CoinAmount", 30, true); Scribe_Values.Look(ref KarmaCap, "KarmaCap", 140, true); Scribe_Values.Look(ref MinimumPurchasePrice, "MinimumPurchasePrice", 60, true); Scribe_Values.Look(ref EventCooldownInterval, "EventCooldownInterval", 15, true); Scribe_Values.Look(ref StartingBalance, "StartingBalance", 150, true); Scribe_Values.Look(ref StartingKarma, "StartingKarma", 100, true); Scribe_Values.Look(ref CustomPricingSheetLink, "CustomPricingSheetLink", "https://bit.ly/2GT5daR", true); Scribe_Values.Look(ref EarningCoins, "EarningCoins", true, true); Scribe_Values.Look(ref StoreOpen, "StoreOpen", false, true); Scribe_Values.Look(ref GiftingCoins, "GiftingCoins", false, true); Scribe_Values.Look(ref WhisperCmdsAllowed, "WhisperCmdsAllowed", true, true); Scribe_Values.Look(ref WhisperCmdsOnly, "WhisperCmdsOnly", false, true); Scribe_Values.Look(ref PurchaseConfirmations, "PurchaseConfirmations", true, true); Scribe_Values.Look(ref JWTToken, "JWTToken", "", true); Scribe_Values.Look(ref AccountID, "AccountID", "", true); Scribe_Values.Look(ref MinifiableBuildings, "MinifiableBuildings", false, true); Scribe_Values.Look(ref UnlimitedCoins, "UnlimitedCoins", false, true); Scribe_Values.Look(ref EventsHaveCooldowns, "EventsHaveCooldowns", true, true); Scribe_Values.Look(ref RepeatViewerNames, "RepeatViewerNames", false, true); Scribe_Values.Look(ref LargeVotingWindow, "LargeVotingWindow", false, true); Scribe_Values.Look(ref BalanceCmd, "BalanceCmd", "!bal", true); Scribe_Values.Look(ref BuyeventCmd, "BuyeventCmd", "!buyevent", true); Scribe_Values.Look(ref BuyitemCmd, "BuyitemCmd", "!buyitem", true); Scribe_Values.Look(ref InstructionsCmd, "InstructionsCmd", "!instructions", true); Scribe_Values.Look(ref PurchaselistCmd, "PurchaselistCmd", "!purchaselist", true); Scribe_Values.Look(ref ModinfoCmd, "ModinfoCmd", "!modinfo", true); Scribe_Values.Look(ref ModsettingsCmd, "ModsettingsCmd", "!modsettings", true); Scribe_Values.Look(ref KarmaCmd, "KarmaCmd", "!whatiskarma", true); Scribe_Values.Look(ref GiftCmd, "GiftCmd", "!giftcoins", true); Scribe_Values.Look(ref CommandHelpCmd, "CommandHelpCmd", "!toolkitcmds", true); Scribe_Values.Look(ref VoteInterval, "VoteInterval", 5, true); Scribe_Collections.Look(ref ViewerIds, "ViewerIds", LookMode.Value, LookMode.Value); Scribe_Collections.Look(ref ViewerCoins, "ViewerCoins", LookMode.Value, LookMode.Value); Scribe_Collections.Look(ref ViewerKarma, "ViewerKarma", LookMode.Value, LookMode.Value); Scribe_Collections.Look(ref ViewerModerators, "ViewerModerators", LookMode.Value, LookMode.Value); Scribe_Collections.Look(ref ItemIds, "ItemIds", LookMode.Value, LookMode.Value); Scribe_Collections.Look(ref ItemPrices, "ItemPrices", LookMode.Value, LookMode.Value); Scribe_Collections.Look(ref ItemDefnames, "ItemDefnames", LookMode.Value, LookMode.Value); Scribe_Collections.Look(ref ItemStuffnames, "ItemStuffnames", LookMode.Value, LookMode.Value); Scribe_Collections.Look(ref ProductIds, "ProductIds", LookMode.Value, LookMode.Value); Scribe_Collections.Look(ref ProductTypes, "ProductTypes", LookMode.Value, LookMode.Value); Scribe_Collections.Look(ref ProductNames, "ProductNames", LookMode.Value, LookMode.Value); Scribe_Collections.Look(ref ProductKarmaTypes, "ProductKarmaTypes", LookMode.Value, LookMode.Value); Scribe_Collections.Look(ref ProductAmounts, "ProductAmounts", LookMode.Value, LookMode.Value); Scribe_Collections.Look(ref ProductEventIds, "ProductEventIds", LookMode.Value, LookMode.Value); Scribe_Collections.Look(ref ProductMaxEvents, "ProductMaxEvents", LookMode.Value, LookMode.Value); Scribe_Collections.Look(ref CategoryWeights, "CategoryWeights", LookMode.Value); if (ViewerIds == null) { ViewerIds = new Dictionary <string, int>(); ViewerCoins = new Dictionary <int, int>(); ViewerKarma = new Dictionary <int, int>(); } if (CategoryWeights == null) { CategoryWeights = Enumerable.Repeat <int>(100, _Categories.Count).ToList(); } Scribe_Collections.Look(ref EventWeights, "EventWeights", LookMode.Value); if (EventWeights == null) { EventWeights = Events.GetEvents().ToDictionary(e => e.Id, e => 100); } if (listOfViewers == null) { listOfViewers = new List <Viewer>(); foreach (KeyValuePair <string, int> viewer in ViewerIds) { int viewerkarma = ViewerKarma[viewer.Value]; int viewercoins = ViewerCoins[viewer.Value]; Viewer newviewer = new Viewer(viewer.Key, viewer.Value); listOfViewers.Add(newviewer); } } if (products == null) { if (ProductIds == null || ProductMaxEvents == null) { Helper.Log("Ressetting Products"); ResetProductData(); this.Write(); } else { Helper.Log("Loading Product Settings"); products = new List <Product>(); // load products from settings, then load them into settings class foreach (KeyValuePair <string, int> product in ProductIds) { int id = product.Value; string abr = product.Key; int type = ProductTypes[id]; string name = ProductNames[id]; KarmaType karmatype = (KarmaType)ProductKarmaTypes[id]; int amount = ProductAmounts[id]; int evtId = ProductEventIds[id]; int maxEvents = ProductMaxEvents[id]; products.Add(new Product(id, type, name, abr, karmatype, amount, evtId, maxEvents)); } } } if (items == null) { if (ItemIds == null) { Helper.Log("Creating all items"); ResetItemData(); this.Write(); } else { Helper.Log("Loading items from settings"); items = new List <Item>(); foreach (KeyValuePair <string, int> item in ItemIds) { int id = item.Value; string abr = item.Key; int price = ItemPrices[id]; string defname = ItemDefnames[id]; string stuffname = ItemStuffnames[id]; items.Add(new Item(price, abr, defname, id, stuffname)); } } } }
private void SetKarma(KarmaType karma) { _karmaType = karma; Dirty.Set(true); }
public KarmaReportKey(Guid subId, KarmaType type) { _subId = subId; _type = type; }
public static int CalculateNewKarma(int karma, KarmaType karmatype, int calculatedprice = 0) { Helper.Log($"Calculating new karma with {karma}, and karma type {karmatype}"); double newkarma = 0; int maxkarma; if (calculatedprice > 0) { newkarma = (double)karma + (calculatedprice / 25); maxkarma = Convert.ToInt32(Math.Round(newkarma)) > Settings.KarmaCap ? Settings.KarmaCap : Convert.ToInt32(Math.Round(newkarma)); return(maxkarma); } switch (karmatype) { //bad event case KarmaType.Bad: if (karma >= 100) { newkarma = (double)karma * 0.5d; } else if (karma >= 80 && karma < 100) { newkarma = (double)karma * 0.3d; } else if (karma >= 60 && karma < 80) { newkarma = (double)karma * 0.35d; } else if (karma >= 40 && karma < 60) { newkarma = (double)karma * 0.4d; } else if (karma >= 20 && karma < 40) { newkarma = (double)karma * 0.45d; } else { newkarma = (double)karma * 0.5d; } break; //good event case KarmaType.Good: if (karma >= 100) { newkarma = (double)karma * 1.05d; } else if (karma >= 82 && karma < 100) { // hard stop at 100 karma. newkarma = karma * 1.18; if (karma > 100) { newkarma = 100; } } else if (karma >= 67 && karma < 82) { newkarma = (double)karma * 1.22d; } else if (karma >= 50 && karma < 67) { newkarma = (double)karma * 1.34d; } else if (karma >= 6 && karma < 50) { newkarma = (double)karma * 1.38d; } else { newkarma = (double)karma * 1.45d; } break; //neutral event case KarmaType.Neutral: newkarma = karma * 1.02; break; //doom event case KarmaType.Doom: newkarma = karma - 80; break; default: break; } Helper.Log($"New Karma is {Convert.ToInt32(Math.Round(newkarma))}"); maxkarma = Convert.ToInt32(Math.Round(newkarma)) > Settings.KarmaCap ? Settings.KarmaCap : Convert.ToInt32(Math.Round(newkarma)); return(maxkarma); }
public async Task <KarmaAkashicRecord> RemoveKarmaFromProfileAsync(IProfile profile, KarmaType karmaType, KarmaSourceType karmaSourceType, string karamSourceTitle, string karmaSourceDesc, ProviderType provider = ProviderType.Default) { if (provider != ProviderType.Default) { return(await((IOASISStorage)ProviderManager.GetAndActivateProvider(provider)).SubtractKarmaFromProfileAsync(profile, karmaType, karmaSourceType, karamSourceTitle, karmaSourceDesc)); } return(await ProviderManager.CurrentStorageProvider.SubtractKarmaFromProfileAsync(profile, karmaType, karmaSourceType, karamSourceTitle, karmaSourceDesc)); }
public static void Charge([NotNull] this Viewer viewer, int cost, float weight, KarmaType karmaType) { if (!ToolkitSettings.UnlimitedCoins) { viewer.TakeViewerCoins(cost); } viewer.CalculateNewKarma(karmaType, Mathf.CeilToInt(cost * weight)); }
public void AdjustKarma(Guid userId, Guid subId, KarmaType karmaType, int change) { if (change == 0) return; EnsureStatementsReady(); _session.Execute(_adjustStatement.Bind((long)change, userId, subId + "-" + karmaType).SetConsistencyLevel(ConsistencyLevel.All)); }
public void IncreaseKarma(Guid userId, Guid subId, KarmaType karmaType) { AdjustKarma(userId, subId, karmaType, 1); }
public Task <KarmaAkashicRecord> SubtractKarmaFromProfileAsync(API.Core.IProfile profile, KarmaType karmaType, KarmaSourceType karmaSourceType, string karamSourceTitle, string karmaSourceDesc) { return(profile.KarmaLost(karmaType, karmaSourceType, karamSourceTitle, karmaSourceDesc)); }
public int KarmaTypesInLogOf(KarmaType karmaType) { return(karmaHistory.Where(pair => pair.Value == karmaType.ToString()).Count()); }
private static bool Prefix(KarmaType karmaType) => !TkSettings.TrueNeutral || karmaType != KarmaType.Neutral;