private void ParseCrafting(IList<string> lines) { for (int i = 0; i < lines.Count; i++) { if (!lines[i].ToUpper().StartsWith(RecipeKey)) continue; while (++i < lines.Count) { if (lines[i].StartsWith("[")) return; if (String.IsNullOrEmpty(lines[i])) continue; var data = lines[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); ItemInfo info = Envir.GetItemInfo(data[0]); if (info == null) continue; RecipeInfo recipe = Envir.RecipeInfoList.SingleOrDefault(x => x.MatchItem(info.Index)); if (recipe == null) { MessageQueue.Enqueue(string.Format("Could not find recipe: {0}, File: {1}", lines[i], FileName)); continue; } if (recipe.Ingredients.Count == 0) { MessageQueue.Enqueue(string.Format("Could not find ingredients: {0}, File: {1}", lines[i], FileName)); continue; } CraftGoods.Add(recipe); } } }
public QuestItemTask ParseItem(string line) { if (line.Length < 1) { return(null); } string[] split = line.Split(' '); uint count = 1; string message = ""; ItemInfo mInfo = Envir.GetItemInfo(split[0]); if (split.Length > 1) { uint.TryParse(split[1], out count); } var match = _regexMessage.Match(line); if (match.Success) { message = match.Groups[1].Captures[0].Value; } //if (mInfo.StackSize <= 1) //{ // //recursively add item if cant stack??? //} return(mInfo == null ? null : new QuestItemTask { Item = mInfo, Count = count, Message = message }); }
private void ParseGoods(IList<string> lines) { for (int i = 0; i < lines.Count; i++) { if (!lines[i].ToUpper().StartsWith(TradeKey)) continue; while (++i < lines.Count) { if (lines[i].StartsWith("[")) return; if (String.IsNullOrEmpty(lines[i])) continue; var data = lines[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); ItemInfo info = Envir.GetItemInfo(data[0]); if (info == null) continue; UserItem goods = Envir.CreateShopItem(info, (uint)i); if (goods == null || Goods.Contains(goods)) { MessageQueue.Enqueue(string.Format("Could not find Item: {0}, File: {1}", lines[i], FileName)); continue; } ushort count = 1; if (data.Length == 2) ushort.TryParse(data[1], out count); goods.Count = count; Goods.Add(goods); } } }
public override Packet GetInfo() { sbyte tmpSByte = 0; if (Item != null) { ItemInfo tmp = Envir.GetItemInfo(Item.ItemIndex); if (tmp != null) { switch (Item.Info.Grade) { default: case ItemGrade.None: tmpSByte = 0; break; case ItemGrade.Common: tmpSByte = 1; break; case ItemGrade.Rare: tmpSByte = 2; break; case ItemGrade.Legendary: tmpSByte = 3; break; case ItemGrade.Mythical: tmpSByte = 4; break; case ItemGrade.Quest: tmpSByte = 5; break; } } // Code after for overriding the grade effect if (Item.IsAdded) { tmpSByte = 6; } return(new S.ObjectItem { ObjectID = ObjectID, Name = Item.Count > 1 ? string.Format("{0} ({1})", Name, Item.Count) : Name, NameColour = NameColour, Location = CurrentLocation, Image = Item.Image, floorColor = tmpSByte }); } return(new S.ObjectGold { ObjectID = ObjectID, Gold = Gold, Location = CurrentLocation, }); }
public static DropInfo FromLine(string s) { string[] parts = s.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length < 2) { return(null); } DropInfo info = new DropInfo(); if (!int.TryParse(parts[0].Substring(2), out info.Chance)) { return(null); } if (string.Compare(parts[1], "Gold", StringComparison.OrdinalIgnoreCase) == 0) { if (parts.Length < 3) { return(null); } if (!uint.TryParse(parts[2], out info.Gold) || info.Gold == 0) { return(null); } } else if (parts[1].ToUpper().StartsWith("GROUP")) { info.GroupedDrop = new GroupDropInfo { Random = parts[1].EndsWith("*"), First = parts[1].EndsWith("^") }; } else { info.Item = Envir.GetItemInfo(parts[1]); if (info.Item == null) { return(null); } if (parts.Length > 2) { string dropRequirement = parts[2]; if (dropRequirement.ToUpper() == "Q") { info.QuestRequired = true; } } } return(info); }
public RecipeInfo(string name) { ItemInfo itemInfo = Envir.GetItemInfo(name); if (itemInfo == null) { MessageQueue.Enqueue(string.Format("Could not find Item: {0}", name)); return; } Item = Envir.CreateShopItem(itemInfo); LoadIngredients(name); }
public RecipeInfo(string name) { ItemInfo itemInfo = Envir.GetItemInfo(name); if (itemInfo == null) { MessageQueue.Enqueue(string.Format("找不到物品合成配方: {0}", name)); return; } Item = Envir.CreateShopItem(itemInfo, ++Envir.NextRecipeID); LoadIngredients(name); }
private void ParseGoods(IList <string> lines) { for (int i = 0; i < lines.Count; i++) { if (!lines[i].ToUpper().StartsWith(TradeKey)) { continue; } while (++i < lines.Count) { if (lines[i].StartsWith("[")) { return; } if (String.IsNullOrEmpty(lines[i])) { continue; } var data = lines[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); ItemInfo info = Envir.GetItemInfo(data[0]); if (info == null) { continue; } UserItem goods = new UserItem(info) { CurrentDura = info.Durability, MaxDura = info.Durability }; if (goods == null || Goods.Contains(goods)) { MessageQueue.Enqueue(string.Format("Could not find Item: {0}, File: {1}", lines[i], FileName)); continue; } uint count = 1; if (data.Length == 2) { uint.TryParse(data[1], out count); } goods.Count = count; goods.UniqueID = (ulong)i; Goods.Add(goods); } } }
public void ParseReward(List <QuestItemReward> list, string line) { if (line.Length < 1) { return; } string[] split = line.Split(' '); uint count = 1; if (split.Length > 1) { uint.TryParse(split[1], out count); } ItemInfo mInfo = Envir.GetItemInfo(split[0]); if (mInfo == null) { mInfo = Envir.GetItemInfo(split[0] + "(M)"); if (mInfo != null) { list.Add(new QuestItemReward() { Item = mInfo, Count = count }); } mInfo = Envir.GetItemInfo(split[0] + "(F)"); if (mInfo != null) { list.Add(new QuestItemReward() { Item = mInfo, Count = count }); } } else { list.Add(new QuestItemReward() { Item = mInfo, Count = count }); } }
public static DropInfo FromLine(string s) { string[] parts = s.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); DropInfo info = new DropInfo(); if (!int.TryParse(parts[0].Substring(2), out info.Chance)) { return(null); } if (string.Compare(parts[1], "金币", StringComparison.OrdinalIgnoreCase) == 0) { if (parts.Length < 4) { return(null); } if (!uint.TryParse(parts[2], out info.Gold) || info.Gold == 0) { return(null); } if (!byte.TryParse(parts[3], out info.level)) { return(null); } } else { if (parts.Length < 3) { return(null); } info.Item = Envir.GetItemInfo(parts[1]); if (info.Item == null) { return(null); } if (!byte.TryParse(parts[2], out info.level)) { return(null); } } return(info); }
protected virtual void GetItemInfo() { UserItem item; for (int i = 0; i < Info.Inventory.Length; i++) { item = Info.Inventory[i]; if (item == null) { continue; } Owner.CheckItem(item); } for (int i = 0; i < Info.Equipment.Length; i++) { item = Info.Equipment[i]; if (item == null) { continue; } Owner.CheckItem(item); } if (HPItemIndex > 0) { Owner.CheckItemInfo(Envir.GetItemInfo(HPItemIndex)); } if (MPItemIndex > 0) { Owner.CheckItemInfo(Envir.GetItemInfo(MPItemIndex)); } }
private void LoadIngredients(string recipe) { List <string> lines = File.ReadAllLines(Path.Combine(Settings.RecipePath, recipe + ".txt")).ToList(); Tools = new List <UserItem>(); Ingredients = new List <UserItem>(); var mode = "ingredients"; for (int i = 0; i < lines.Count; i++) { if (String.IsNullOrEmpty(lines[i])) { continue; } if (lines[i].StartsWith("[")) { mode = lines[i].Substring(1, lines[i].Length - 2).ToLower(); continue; } switch (mode) { case "recipe": { var data = lines[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (data.Length < 2) { continue; } switch (data[0].ToLower()) { case "amount": Item.Count = uint.Parse(data[1]); break; case "chance": Chance = byte.Parse(data[1]); if (Chance > 100) { Chance = 100; } break; case "gold": Gold = uint.Parse(data[1]); break; default: break; } } break; case "tools": { var data = lines[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); ItemInfo info = Envir.GetItemInfo(data[0]); if (info == null) { MessageQueue.Enqueue(string.Format("Could not find Tool: {0}, Recipe: {1}", lines[i], recipe)); continue; } UserItem tool = Envir.CreateShopItem(info); Tools.Add(tool); } break; case "ingredients": { var data = lines[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); ItemInfo info = Envir.GetItemInfo(data[0]); if (info == null) { MessageQueue.Enqueue(string.Format("Could not find Ingredient: {0}, Recipe: {1}", lines[i], recipe)); continue; } UserItem ingredient = Envir.CreateShopItem(info); uint count = 1; if (data.Length >= 2) { uint.TryParse(data[1], out count); } if (data.Length >= 3) { ushort.TryParse(data[2], out ingredient.CurrentDura); } ingredient.Count = count > info.StackSize ? info.StackSize : count; Ingredients.Add(ingredient); } break; case "criteria": { var data = lines[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (data.Length < 2) { continue; } try { switch (data[0].ToLower()) { case "level": RequiredLevel = ushort.Parse(data[1]); break; case "class": if (Enum.TryParse <MirClass>(data[1], true, out MirClass cls)) { RequiredClass.Add(cls); } else { RequiredClass.Add((MirClass)byte.Parse(data[1])); } break; case "gender": if (Enum.TryParse <MirGender>(data[1], true, out MirGender gender)) { RequiredGender = gender; } else { RequiredGender = (MirGender)byte.Parse(data[1]); } break; case "flag": RequiredFlag.Add(int.Parse(data[1])); break; case "quest": RequiredQuest.Add(int.Parse(data[1])); break; } } catch { MessageQueue.Enqueue(string.Format("Could not parse option: {0}, Value: {1}", data[0], data[1])); continue; } } break; } } }
public void End_Match(bool foundWinner = false) { bool failed = false; string matchResult = ""; if (foundWinner) { LMS_Rank lmsRank = null; PlayerObject winningPlayer = null; for (int i = 0; i < CurrentMap.Players.Count; i++) { PlayerObject player = CurrentMap.Players[i]; if (player == null || player.Dead) { continue; } for (int x = 0; x < PlayerRanks.Count; x++) { if (player.Name == PlayerRanks[x].Player.Name && winningPlayer == null && lmsRank == null) { winningPlayer = player; lmsRank = PlayerRanks[x]; } } } if (winningPlayer != null && lmsRank != null) { // TODO Reward players (send by mail) matchResult = string.Format("{0} is the Victor of the match!", winningPlayer.Name); winningPlayer.Teleport(Envir.GetMap(winningPlayer.BindMapIndex), winningPlayer.BindLocation, true, 0); winningPlayer.InLMSBR = false; List <LMS_RewardInfo> rewards = CreateRewards(1, winningPlayer); if (rewards != null && rewards.Count > 0) { winningPlayer.ReceiveChat(string.Format("Victory is yours! Prize(s) will be sent via mail!"), ChatType.Hint); List <UserItem> items = new List <UserItem>(); for (int i = 0; i < rewards.Count; i++) { if (rewards[i].ItemReward == null) { SMain.EnqueueDebugging(string.Format("Null reward")); continue; } ItemInfo iInfo = Envir.GetItemInfo(rewards[i].ItemReward.Index); if (iInfo == null) { SMain.EnqueueDebugging(string.Format("Null item info")); continue; } UserItem item = Envir.CreateFreshItem(iInfo); if (item != null) { items.Add(item); } } MailInfo mail = new MailInfo(winningPlayer.Info.Index) { Items = items, Message = string.Format("Congratulations on winning the match! here is your prize(s)"), Sender = string.Format("LMS"), MailID = ++Envir.NextMailID }; mail.Send(); } SMain.EnqueueDebugging(string.Format("[LMS BR] Map {0} {1} wins the Match, made {2} kills.", CurrentMap.Info.Title, winningPlayer.Name, lmsRank.Kills)); } else { failed = true; } } if ((failed && foundWinner) || !foundWinner) { if (CurrentMap.Players.Count > 0) { string[] finalPlayers = new string[CurrentMap.Players.Count]; if (finalPlayers.Length >= 1) { int index = 0; for (int i = 0; i < CurrentMap.Players.Count; i++) { PlayerObject player = CurrentMap.Players[i]; if (player.Dead || player.IsGM) { continue; } finalPlayers[index] = player.Name; player.Teleport(Envir.GetMap(player.BindMapIndex), player.BindLocation); player.InLMSBR = failed; index++; } Array.Resize(ref finalPlayers, index); } matchResult = "Stalemate, Players "; for (int i = 0; i < finalPlayers.Length; i++) { matchResult += string.Format("{0}{1} ", finalPlayers[i], i - 1 <= finalPlayers.Length ? "," : " have drawn the match!"); } } } if (matchResult.Length > 0) { Envir.Broadcast(new ServerPackets.Chat { Message = matchResult, Type = ChatType.Announcement }); } StartTime = 0; EndTime = 0; SignedupPlayers = new List <PlayerObject>(); CircleLocations = new List <Point>(); PlayerRanks = new List <LMS_Rank>(); StartingLocation = Info.StartingLocation; Stage = 0; Finished = false; Started = false; }
private void LoadIngredients(string recipe) { List <string> lines = File.ReadAllLines(Path.Combine(Settings.RecipePath, recipe + ".txt")).ToList(); Ingredients = new List <UserItem>(); var mode = "ingredients"; for (int i = 0; i < lines.Count; i++) { if (String.IsNullOrEmpty(lines[i])) { continue; } if (lines[i].StartsWith("[")) { mode = lines[i].Substring(1, lines[i].Length - 2).ToLower(); continue; } switch (mode) { case "ingredients": { var data = lines[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); ItemInfo info = Envir.GetItemInfo(data[0]); if (info == null) { MessageQueue.Enqueue(string.Format("Could not find Item: {0}, Recipe: {1}", lines[i], recipe)); continue; } uint count = 1; if (data.Length == 2) { uint.TryParse(data[1], out count); } UserItem ingredient = Envir.CreateShopItem(info); ingredient.Count = count > info.StackSize ? info.StackSize : count; Ingredients.Add(ingredient); } break; case "criteria": { var data = lines[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (data.Length < 2) { continue; } try { switch (data[0].ToLower()) { case "level": RequiredLevel = ushort.Parse(data[1]); break; case "class": RequiredClass.Add((MirClass)byte.Parse(data[1])); break; case "gender": RequiredGender = (MirGender)byte.Parse(data[1]); break; case "flag": RequiredFlag.Add(int.Parse(data[1])); break; case "quest": RequiredQuest.Add(int.Parse(data[1])); break; } } catch { MessageQueue.Enqueue(string.Format("Could not parse option: {0}, Value: {1}", data[0], data[1])); continue; } } break; } } }