public static void SaveRoleMap() { string json = JsonConvert.SerializeObject(RoleMap, Formatting.Indented); File.WriteAllText(DataFileNames.RoleSelectMapFile, json); KLog.Info("Role Map Saved."); }
static void AddMenu() { // add a menu in the mainmenu. KLog.Dbg("[ModLoaderLite] adding config menu option..."); var mainMenu = Traverse.Create(Wnd_GameMain.Instance).Field <PopupMenu>("MainMenu").Value; mainMenu?.AddItem("MLL设置", () => Config.Configuration.Show()); }
public static void FullSave() { KLog.Info("Beginning full save...\n---------------"); SaveUserData(); SaveUserSettings(); UserInventoryManager.SaveInventories(); KLog.Info("---------------"); }
public static void ResetWeekly() { foreach (ulong key in UserData.Keys) { UserData[key].WeeklyScore = 0; } KLog.Info("Reset weekly message scores"); }
public static void LoadNodeMap() { string json = FileManager.ReadFullFile(DataFileNames.TitleListFile); NodeMap = JsonConvert.DeserializeObject <Dictionary <int, TitleNode> >(json) ?? new Dictionary <int, TitleNode>(); KLog.Info($"Title node map {(Loaded ? "Reloaded":"Loaded")}"); Loaded = true; }
/// <summary> /// 던전을 클리어 했다. /// </summary> /// <param name="dungeonKey"></param> public static void ClearDungeon(string dungeonKey) { if (!UserData.clearedDungeon.Contains(dungeonKey)) { UserData.clearedDungeon.Add(dungeonKey); } KLog.Log("Clear Dungeon. " + dungeonKey); }
/// <summary> /// Generates the base for a user entry. Does not generate the strike, only columns A through C /// </summary> /// <param name="pos">Row in the spreadsheet</param> /// <param name="target">Target user for entry</param> private static void GenUserStrike(int pos, SocketUser target, int strikes = 1) { KLog.Info($"User {BotUtils.GetFullUsername(target)} doesn't have a strike entry, creating one..."); List <string[]> entry = new List <string[]>(); entry.Add(new string[] { target.Id.ToString(), BotUtils.GetFullUsername(target), strikes.ToString() }); StrikeLog.Workbook.Worksheets[StrikeLogPage].Cells[$"A{pos}:C{pos}"].LoadFromArrays(entry); }
void FixedUpdate() { duration += Time.fixedDeltaTime; if (duration > 1f) { duration = 0f; KLog.Log(KLogLevel.Debug, $"test success!"); } }
private static void GenUserStrike(int pos, ulong target, string username = "", int strikes = 1) { KLog.Info($"User {(string.IsNullOrEmpty(username) ? target.ToString() : username)} doesn't have a strike entry, creating one..."); List <string[]> entry = new List <string[]>(); entry.Add(new string[] { target.ToString(), username, strikes.ToString() }); StrikeLog.Workbook.Worksheets[StrikeLogPage].Cells[$"A{pos}:C{pos}"].LoadFromArrays(entry); }
/// <summary> /// 키를 언락한다. 중복으로 넣어도 알아서 처리됨 /// </summary> public static void UnlockKey(string key) { if (!UserData.unlocks.Contains(key)) { UserData.unlocks.Add(key); UserData.UpdateData(); KLog.LogWarning(string.Format("[{0}] Unlock Key", key)); } }
private void Awake() { // 에러체크 if (this.detailView == null) { KLog.LogError("QuestDetailView is null", this); } (this.detailView.transform as RectTransform).anchoredPosition3D = Vector3.zero; }
/// <summary> /// Query Kiroku Storage for a single KLOG. /// </summary> /// <param name="req"></param> /// <returns></returns> public static OkObjectResult Execute(HttpRequest req) { using (KLog klog = new KLog($"KQueryManager,Execute")) { if (!_configOnline) { klog.Error("Config failed to load."); return(new OkObjectResult("")); } if (req == null) { klog.Warning("Request was empty."); return(new OkObjectResult("")); } string id = req?.Query["id"]; try { Guid checkId = new Guid(id); byte[] doc = Storage.GetLog(id); var payload = Encoding.UTF8.GetString(doc, 0, doc.Length); if (!string.IsNullOrEmpty(payload)) { payload = payload.Replace("#KLOG_INSTANCE_STATUS#", ""); payload = payload.Replace("}", "},"); payload = "[" + payload + "]"; payload = payload.Replace("},\r\n$", "}]"); payload = JValue.Parse(payload).ToString(Formatting.Indented); } if (doc == null) { klog.Error($"Document is null. Id: {id}"); } return(doc == null ? new OkObjectResult($"404") : new OkObjectResult(payload)); } catch (Exception ex) { klog.Error($"EXCEPTION : {ex.ToString()}"); return(new OkObjectResult("")); } } }
public override void OnInit() { base.OnInit(); this.metalon = this.unit as Metalon; if (!this.metalon.isMini && this.centerTransform == null) { KLog.LogError("Metalon은 센터위치를 지정해 줘야함. ", this); } }
private void Awake() { if (this.root == null) { KLog.Log("root is null", this); } // 선택지로 사용할 버튼들 캐싱 + 비활성화 this.elements = this.root.GetComponentsInChildren <SelectionUI_Element>(); InactiveAllElement(); }
// will be called each time a game is loaded. public static void Load() { KLog.Dbg("[ModLoaderLite] game loading..."); AddMenu(); DoLoad(); foreach (var asm in assemblies) { Utilities.Util.Call(asm, "OnLoad"); } Config.Configuration.Load(); }
public int Main() { KLog.Dbg("Start Sala"); GlobalSet.SetSchoolMaxNpcAsOne(); SalaEvents salaEvents = new SalaEvents(); salaEvents.InitEventRegister(); return(0); }
public static void Execute() { // Blob retention using (KLog blobRetention = new KLog("BlobFileRetention-BlobRetention")) { try { IEnumerable <BlobFileModel> retentionFileCollection = BlobFileCollection.CurrentRetentionCount(); blobRetention.Info($"Retention Count: {retentionFileCollection.Count()}"); foreach (BlobFileModel blobFile in retentionFileCollection) { // for each file, confim check one more blobRetention.Info($"Retention => File Name: {blobFile.CloudFile}"); string cloudFile = blobFile.CloudFile; try { BlobClient.DeleteBlobFile(cloudFile); blobRetention.Info($"File Deleted => File Name: {blobFile.CloudFile}"); } catch (Exception ex) { blobRetention.Error($"Delete Failure: {blobFile.CloudFile} Exception: {ex}"); } } } catch (Exception ex) { blobRetention.Error($"BlobFileRetention Exception: {ex.ToString()}"); } } // SQL Retention using (KLog sqlRetention = new KLog("BlobFileRetention-SQLRetention")) { try { SQLResponseModel checkRetention = DataAccessor.Retention(Configuration.RetentionDays); if (!checkRetention.Success) { sqlRetention.Error($"SQL Expection on [BlobFileRetention].[Retention] - Message: {checkRetention.Message}"); } } catch (Exception ex) { sqlRetention.Error($"BlobFileRetention Exception: {ex.ToString()}"); } } }
public static void ResetRep() { foreach (ulong key in UserData.Keys) { UserData[key].ReputationToGive = Math.Max(UserData[key].MaxReputation, UserData[key].ReputationToGive); } SaveUserData(); KLog.Info("Reset giveable reputation stats"); }
public async Task Send_GetWithReportWithResponseBody_returns_true() { var request = new KRequest(HttpMethod.Get, new Uri(_uri)); var client = new KClient(); string reportFile = Path.Combine(Directory.GetCurrentDirectory(), $"KReport_{DateTime.Today:yyyy-MM-dd}__{Guid.NewGuid()}.csv"); var results = await client.SendAsync(request); await KLog.ReportAsync(results, reportFile); Assert.True(File.Exists(reportFile)); }
/// <summary> /// Counts the number of items (or the number of a specific item) in the inventory. /// </summary> /// <param name="item">The ID of the item to get the count of</param> /// <returns>The count of the specified item, or the total number of items if no item is specified</returns> public int ItemCount(uint?item = null) { // check if an item was specified if (item == null) { // if it wasn't, get the total count of all items int t = 0; // variable to store item total bool cleanup = false; // bool for cleanup so if it foreach (uint k in Items.Keys) { int i = Items[k]; // check to make sure the items don't have bizarre counts if (i <= 0) { KLog.Debug($"[UIN] Item [{k}] had count {i}, and was removed."); cleanup = true; // if so, make sure to clean up the inventory at the end of the method continue; // and skip the item } t += i; // add it to the total } if (cleanup) { // if the inventory needs cleaning, do so. ParseInventory(); } return(t); // return the total } else { // The item was specified, so count it uint i = item.Value; if (!Items.ContainsKey(i)) { // error checks return(0); } if (Items[i] <= 0) { // Fix broken inventories ParseInventory(); return(0); } return(Items[i]); } }
public static void ResetKamtrokenEarns() { foreach (ulong key in UserData.Keys) { UserData[key].KamtrokensEarned = 0; UserData[key].KamtrokenEarnProgress = 0; } SaveUserData(); KLog.Info("Reset daily earned kamtrokens"); }
/// <summary> /// Test method for dynamic KLOG creation. /// </summary> /// <param name="instanceIteration"></param> public static void DynamicLog(string instanceIteration) { using (KLog klog = new KLog($"Dynamic KFlow -- Primary Node -- {instanceIteration}")) { klog.Info("Testing primary block"); using (KLog nestedKLog = new KLog($"Dynamic KFlow -- Nested Node -- {instanceIteration}", klog)) { nestedKLog.Info("Testing nested block"); } } }
/// <summary> /// Adds a strike to a user /// </summary> /// <param name="target"></param> /// <param name="strike"></param> /// <returns>The number of strikes the user has.</returns> public static int AddStrike(SocketUser target, StrikeDataNode strike) { ulong targetId = target.Id; int pos = GetEntryPos(targetId); ExcelRange cells = StrikeLog.Workbook.Worksheets[StrikeLogPage].Cells; if (!IsRowNew(pos)) { // Add the srike to this row. // First, check the username. if (cells["B" + pos].Text != BotUtils.GetFullUsername(target)) { // if it doesn't check out, update it. cells["B" + pos].Value = BotUtils.GetFullUsername(target); } // now for the strike address. This will be based off of the number of strikes. // This is in column C int strikes = cells["C" + pos].GetValue <int>(); if (strikes == 2) { return(4); // 4 is the signal } // now to get the column. Fun ascii math. // 68 = ASCII for capital D. string range = char.ConvertFromUtf32(68 + strikes * 3) + pos + ":" + char.ConvertFromUtf32(70 + strikes * 3) + pos; cells[range].LoadFromArrays(strike.GetStrikeForExcel()); cells[$"C:{pos}"].Value = (Convert.ToInt32(cells[$"C{pos}"].Text) + 1).ToString(); StrikeLog.Save(); KLog.Info($"Added strike {cells[$"C:{pos}"].Value.ToString()} for {BotUtils.GetFullUsername(target)} in cell range {range}"); return(Convert.ToInt32(cells[$"C{pos}"].Text)); } // The user doesn't have an entry. So make one. GenUserStrike(pos, target); // Now add the strike ExcelRange er = cells[$"D{pos}:F{pos}"]; er.LoadFromArrays(strike.GetStrikeForExcel()); // Set auto fit cells[StrikeLog.Workbook.Worksheets[StrikeLogPage].Dimension.Address].AutoFitColumns(); StrikeLog.Save(); KLog.Info($"Added strike for {BotUtils.GetFullUsername(target)} in cell range D{pos}:F{pos}"); return(1); }
/// <summary> /// Happens when a user is unbanned from a server the bot is in. /// </summary> /// <param name="user">The user that was unbanned</param> /// <param name="server">The server they were unbanned from</param> /// <returns></returns> public async Task OnMemberUnban(SocketUser user, SocketGuild server) { if(CrossBan == null) { CrossBan = new Dictionary<ulong, CrossBanDataNode>(); SaveList(); } if (CrossBan.ContainsKey(user.Id) && server.Id == ServerData.Server.Id) { CrossBan.Remove(user.Id); KLog.Info($"Removed user {BotUtils.GetFullUsername(user)} from cross-ban list"); SaveList(); } }
/// <summary> /// Saves the user data to it's file. /// </summary> public static void SaveUserData() { if (!Saving && !BotUtils.SaveInProgress) { Saving = true; BotUtils.WriteToJson(UserData, DataFileNames.UserDataFile); Saving = false; } else { KLog.Warning("Tried to save user data, but couldn't becuase it was already being saved!"); } }
static void replaceMenu(PopupMenu ___MainMenu) { KLog.Dbg("[AmzHardCoreSaver] add buttons v1"); var i = 0; var t1 = -1; var t2 = -1; foreach (var gObject in ___MainMenu._list.GetChildren()) { if (gObject.asButton.title == TFMgr.Get("存档并返回")) { t1 = i; } else if (gObject.asButton.title == TFMgr.Get("存档并退出")) { t2 = i; } i++; } if (t1 >= 0) { var name = ___MainMenu.GetItemName(t1); KLog.Dbg("[AmzHardCoreSaver] remove {0} {1}", t1, name); if (___MainMenu.RemoveItem(name)) { ___MainMenu.AddItem(TFMgr.Get("存档"), (EventCallback0)(() => Wnd_Save.Instance.ShowSaveWnd(0))); } } else { // ___MainMenu.AddItem(TFMgr.Get("存档"), // (EventCallback0) (() => Wnd_Save.Instance.ShowSaveWnd(0))); } if (t2 >= 0) { if (___MainMenu.RemoveItem(___MainMenu.GetItemName(t2))) { ___MainMenu.AddItem(TFMgr.Get("读档"), (EventCallback0)(() => Wnd_Save.Instance.ShowSaveWnd(1))); } } else { // ___MainMenu.AddItem(TFMgr.Get("读档"), // (EventCallback0) (() => Wnd_Save.Instance.ShowSaveWnd(1))); } }
private async Task StrikeUser(SocketUser user) { // First, the classic null check if (BotUtils.GetGUser(Context) == null) { await Context.Channel.SendMessageAsync(BotUtils.KamtroText("That user does not exist!")); KLog.Info($"User {BotUtils.GetFullUsername(Context.User)} attempted to strike non-existant member {BotUtils.GetFullUsername(user)}"); return; } // Flavor text for trying to strike yourself if (user.Id == Context.User.Id) { await Context.Channel.SendMessageAsync(BotUtils.KamtroText("We would like to save the strikes for those that deserve it.")); return; } // next, check to see if Kamtro has perms to ban the user if (!BotUtils.HighestUser(BotUtils.GetGUser(Context.Client.CurrentUser.Id), BotUtils.GetGUser(user.Id))) { await Context.Channel.SendMessageAsync(BotUtils.KamtroText("The user is higher than me, so I cannot strike them.")); KLog.Info($"User {BotUtils.GetFullUsername(Context.User)} attempted to strike member {BotUtils.GetFullUsername(user)} of higher status than bot"); return; } // next, check if the caller can ban the user if (!ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.ADMIN)) { if (BotUtils.HighestUser(BotUtils.GetGUser(user.Id), BotUtils.GetGUser(Context), true)) { await Context.Channel.SendMessageAsync(BotUtils.KamtroText("This user is higher or equal than you, and as such, you cannot strike them.")); KLog.Info($"User {BotUtils.GetFullUsername(Context.User)} attempted to strike member {BotUtils.GetFullUsername(user)} of higher status than caller"); return; } } if (AdminDataManager.GetStrikes(user) >= 2) { await BanUser(user); return; } StrikeEmbed se = new StrikeEmbed(Context, user); await se.Display(); }
public CrossBanDataNode(int server, string reason = "") { if (server >= Servers.Length) { KLog.Warning($"Cross-ban entry for a user had an invalid index! ({server})"); Server = 0; } else { Server = server; } Reason = reason; }
/// <summary> /// Crafts the item. No checks in method /// </summary> /// <param name="item">The item to craft</param> private void Craft(uint itemId) { Item item = ItemManager.GetItem(itemId); foreach (uint k in item.GetRecipe().Keys) { LoseItem(k, item.GetRecipe()[k]); } AddItem(itemId); KLog.Info($"User {BotUtils.GetFullUsername(BotUtils.GetGUser(UserDataManager.UserData.FirstOrDefault(x => x.Value.Inventory == this).Key))} crafted item {item.Name} (ID: {itemId})"); ParseInventory(); }
/// <summary> /// 선택지는 최대 4개까지 지원한다. /// </summary> public void Init(SelectionData[] list, UnityAction <int> onComplete) { if (list.Length >= 4) { KLog.Log("선택지는 최대 4개까지 지원함"); } InactiveAllElement(); for (int i = 0; i < list.Length; i++) { this.elements[i].gameObject.SetActive(true); this.elements[i].Init(this, list[i]); } this.onComplete = onComplete; }