public static void SearchWarp(User user, string searchKey) { using (var db = new LiteDatabase(@"GB.db")) { var warps = db.GetCollection <WarpPoint>("warps"); var resultName = warps.Find(x => x.WarpName.Contains(searchKey)); var resultCreator = warps.Find(x => x.Creator.Contains(searchKey)); if (resultName != null || resultCreator != null) { var searchResult = new StringBuilder().AppendLine(TextLoc.HeaderLocStr("Suchergebnis:")); if (resultName != null) { searchResult.AppendLine(resultName.Select(x => $"{x.WarpName} - {x.Creator}").NewlineList()); } if (resultCreator != null) { searchResult.AppendLine(resultCreator.Select(x => $"{x.WarpName} - {x.Creator}").NewlineList()); } ChatManager.ServerMessageToPlayer(new LocString(searchResult.ToString()), user, false); } else { ChatManager.ServerMessageToPlayer(new LocString("<color=red>Es konnten keine Warps gefunden werden!"), user, false, DefaultChatTags.Notifications, ChatCategory.Info); } } }
// Die Methode gibt einen String zurück der im Spiel in einem Infofenster angezeigt wird public static string ShowPremiumUser() { using (var db = new LiteDatabase(@"GBSpender.db")) { var spenderUsers = db.GetCollection <SpenderUser>("SpenderUser"); var result = spenderUsers.FindAll().OrderBy(x => x.Username); string einruecken = "\t"; var premiumUserList = new StringBuilder().AppendLine(TextLoc.InfoLocStr("Name" + einruecken + "Mitglied bis:" + einruecken + "Patreon:")); premiumUserList.AppendLine(); foreach (SpenderUser spenderUser in result) { string datumString; if (spenderUser.EndDate >= DateTime.Now) { datumString = "<color=green>" + spenderUser.EndDate.ToShortDateString() + "</color>"; } else { datumString = "<color=red>" + spenderUser.EndDate.ToShortDateString() + "</color>"; } premiumUserList.AppendLine(TextLoc.InfoLocStr("<color=white>" + spenderUser.Username + "</color>" + einruecken + datumString + einruecken + spenderUser.Patreon.ToString())); } ; return(premiumUserList.ToString()); } }
public static string WarpTrackerString() { using (var db = new LiteDatabase(@"GB.db")) { var warpTrackerCol = db.GetCollection <WarpTracker>("warptracker"); var warpTracker = warpTrackerCol.FindAll().OrderBy(x => x.UserName); string einruecken = "\t"; var warpTrackerList = new StringBuilder().AppendLine(TextLoc.InfoLocStr("User Name" + einruecken + "WarpAmount")); warpTrackerList.AppendLine(); foreach (WarpTracker warptracker in warpTracker) { warpTrackerList.AppendLine(warptracker.UserName + einruecken + warptracker.WarpAmount); } return(warpTrackerList.ToString()); } }
private TextBlock GetTextWithLoc(int col, int row, TextLoc textLoc) { BoardSpace space = GetSpace(col, row); if (space == null) { return(null); } foreach (Tile tile in space.MyTiles) { if (tile is TextBlock && (tile as TextBlock).MyTextLoc == textLoc) { return(tile as TextBlock); } } return(null); // Nah, didn't find one. }
// Gibt einen string zurück der alle bisher gespeicherten Warppunkte in einem Infofenster auflistet public static string ShowWarps() //User user { using (var db = new LiteDatabase(@"GB.db")) { var warps = db.GetCollection <WarpPoint>("warps"); var result = warps.FindAll().OrderBy(x => x.WarpName); string einruecken = "\t"; var warpList = new StringBuilder().AppendLine(TextLoc.InfoLocStr("Name" + einruecken + "Ersteller" + einruecken + "Koordinaten")); warpList.AppendLine(); foreach (WarpPoint warppoint in result) { double posX = Math.Round(Convert.ToDouble(warppoint.WarpPosX)); double posY = Math.Round(Convert.ToDouble(warppoint.WarpPosY)); double posZ = Math.Round(Convert.ToDouble(warppoint.WarpPosZ)); warpList.AppendLine(TextLoc.InfoLocStr("<color=white>" + warppoint.WarpName + einruecken + warppoint.Creator + einruecken + posX.ToString() + " , " + posY.ToString() + " , " + posZ.ToString())); } ; return(warpList.ToString()); } }
public string GetEcopediaData(Player player, EcopediaPage page) { var cur = ConstitutionManager.Obj.Current; var valToOverthrow = Text.StyledNum(CivicsPlugin.Obj.Config.ValueAdditionToOverthrow); var curVal = Text.StyledNum(cur?.RoomValue.Get ?? 0f); var newVal = Text.StyledNum(ConstitutionManager.Obj.Current?.RoomValue.Get ?? 0); var sb = new StringBuilder(); sb.AppendLine(TextLoc.HeaderLocStr("World Settings")); sb.AppendLineLoc($"Constitutions can be overthrown when their value is exceeded by {valToOverthrow}%."); sb.AppendLocStr("Current constituion:"); sb.Append(" "); if (cur == null) { sb.AppendLine(TextLoc.BoldLocStr("None.")); } else { sb.AppendLineLoc($"{cur.UILink()} with room value {curVal}"); } return(sb.ToString()); }
// Die Methode gibt einen String zurück, der dann in einem Infofenster im Spiel angezeigt wird. public static string ShowAuktionen() { using (var db = new LiteDatabase(@"GB.db")) { var auktionen = db.GetCollection <AuktionsAngebot>("Auktionen"); var result = auktionen.FindAll(); string einruecken = "\t"; string color = "white"; float restZeit; var auktionenListe = new StringBuilder().AppendLine(TextLoc.InfoLocStr("Id" + einruecken + "Name" + einruecken + "Höchstgebot" + einruecken + "Endet in")); auktionenListe.AppendLine(); foreach (AuktionsAngebot auktionsAngebot in result) { restZeit = auktionsAngebot.Endzeit.Subtract(DateTime.Now).Minutes; if (restZeit <= 30) { color = "red"; } else if (restZeit <= 120) { color = "orange"; } if (restZeit <= 0) { auktionenListe.AppendLine(TextLoc.InfoLocStr("<color=" + color + ">" + auktionsAngebot.ID + einruecken + auktionsAngebot.AngebotsItem.Item.DisplayName + einruecken + auktionsAngebot.Gebot + einruecken + " Beendet")); } else { auktionenListe.AppendLine(TextLoc.InfoLocStr("<color=" + color + ">" + auktionsAngebot.ID + einruecken + auktionsAngebot.AngebotsItem.Item.DisplayName + einruecken + auktionsAngebot.Gebot + einruecken + restZeit + " Minuten")); } } ; return(auktionenListe.ToString()); } }
protected override void Execute(WorldRange selection) { selection = selection.FixXZ(Shared.Voxel.World.VoxelSize); Dictionary <object, long> blocks = new Dictionary <object, long>(); long emptyBlocks = 0; foreach (Vector3i pos in selection.XYZIterInc()) { Block block = Eco.World.World.GetBlock(pos); Type blockType = null; switch (block) { case PlantBlock _: case TreeBlock _: Plant plant = EcoSim.PlantSim.GetPlant(pos); if (plant != null && plant.Position.Equals(pos)) { blockType = plant.Species.GetType(); } break; case WorldObjectBlock worldObjectBlock: WorldObject worldObject = worldObjectBlock.WorldObjectHandle.Object; if (worldObject.Position3i.Equals(pos)) { blockType = worldObject.GetType(); } break; default: if (BlockContainerManager.Obj.IsBlockContained(pos)) { WorldObject obj = ServiceHolder <IWorldObjectManager> .Obj.All.Where(x => x.Position3i.Equals(pos)).FirstOrDefault(); if (obj != null) { blockType = obj.GetType(); } } else { blockType = block.GetType(); } break; } if (blockType != null) { if (blockType == typeof(EmptyBlock)) { emptyBlocks++; continue; } if (this.outputType.Equals("brief")) { string name = this.GetBlockFancyName(blockType); blocks.TryGetValue(name, out long count); blocks[name] = count + 1; } else { blocks.TryGetValue(blockType, out long count); blocks[blockType] = count + 1; } } } decimal totalBlocks = blocks.Values.Sum(); // (vectors.Higher.X - vectors.Lower.X) * (vectors.Higher.Y - vectors.Lower.Y) * (vectors.Higher.Z - vectors.Lower.Z); StringBuilder sb = new StringBuilder(); sb.AppendLine(TextLoc.Header(Localizer.DoStr("Selection Info"))); sb.AppendLineLoc($"Region: {Text.Location(this.UserSession.Selection.min)} - {Text.Location(this.UserSession.Selection.max)}"); sb.Append(Localizer.DoStr("Width:").ToString().PadRight(8)).AppendLine(Text.PluralLocStr("block", "blocks", selection.WidthInc)); sb.Append(Localizer.DoStr("Height:").ToString().PadRight(8)).AppendLine(Text.PluralLocStr("block", "blocks", selection.HeightInc)); sb.Append(Localizer.DoStr("Length:").ToString().PadRight(8)).AppendLine(Text.PluralLocStr("block", "blocks", selection.LengthInc)); sb.Append(Localizer.DoStr("Volume:").ToString().PadRight(8)).AppendLine(Text.PluralLocStr("block", "blocks", selection.VolumeInc)); sb.Append(Localizer.DoStr("Area:").ToString().PadRight(8)).AppendLine(Text.PluralLocStr("block", "blocks", selection.WidthInc * selection.LengthInc)); sb.AppendLocStr("Empty blocks:"); sb.AppendLine($" {emptyBlocks,8}"); sb.AppendLocStr("Total blocks:"); sb.AppendLine($" {totalBlocks,8}"); sb.AppendLine().AppendLine(TextLoc.Header(Localizer.DoStr("Block List"))); foreach (KeyValuePair <object, long> entry in blocks) { decimal percent = Math.Round((entry.Value / totalBlocks) * 100, 2); sb.Append(this.outputType.Equals("detail") ? this.GetBlockFancyName((Type)entry.Key) : (string)entry.Key); sb.Append(Text.Pos(400, Text.Info(Text.Int(entry.Value)))); sb.Append($"({percent}%)".PadLeft(10)); if (this.outputType.Equals("detail")) { sb.Append(Text.Pos(500, $"[{Localizer.DoStr(((Type)entry.Key).Name)}]")); } sb.AppendLine(); } if (!string.IsNullOrEmpty(this.fileName)) { this.OutputToFile(sb.ToString()); this.UserSession.Player.MsgLoc($"Report saved into file with name <{WorldEditManager.SanitizeFileName(this.fileName)}.txt>"); } this.UserSession.Player.OpenInfoPanel(Localizer.Do($"WorldEdit Blocks Report"), sb.ToString(), "WorldEditDistr"); }