private static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net_server.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; Database = new Database(); GameData = new XmlData(); InstanceId = Guid.NewGuid().ToString(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; if (RunPreCheck(port)) { listener = new HttpListener(); listener.Prefixes.Add($"http://*:{port}/"); listener.Start(); listener.BeginGetContext(ListenerCallback, null); Logger.Info($"Listening at port {port}..."); } else Logger.Error($"Port {port} is occupied"); while (Console.ReadKey(true).Key != ConsoleKey.Escape) ; Logger.Info("Terminating..."); while (currentRequests.Count > 0) ; listener?.Stop(); }
public static Char CreateCharacter(XmlData dat, ushort type, int chrId) { XElement cls = dat.ObjectTypeToElement[type]; if (cls == null) return null; return new Char() { ObjectType = type, CharacterId = chrId, Level = 1, Exp = 0, CurrentFame = 0, _Equipment = cls.Element("Equipment").Value, MaxHitPoints = int.Parse(cls.Element("MaxHitPoints").Value), HitPoints = int.Parse(cls.Element("MaxHitPoints").Value), MaxMagicPoints = int.Parse(cls.Element("MaxMagicPoints").Value), MagicPoints = int.Parse(cls.Element("MaxMagicPoints").Value), Attack = int.Parse(cls.Element("Attack").Value), Defense = int.Parse(cls.Element("Defense").Value), Speed = int.Parse(cls.Element("Speed").Value), Dexterity = int.Parse(cls.Element("Dexterity").Value), HpRegen = int.Parse(cls.Element("HpRegen").Value), MpRegen = int.Parse(cls.Element("MpRegen").Value), Tex1 = 0, Tex2 = 0, Dead = false, PCStats = "", FameStats = new FameStats(), Pet = -1 }; }
public List<NewsItem> GetNews(XmlData dat, Account acc) { var cmd = CreateQuery(); cmd.CommandText = "SELECT icon, title, text, link, date FROM news ORDER BY date LIMIT 10;"; List<NewsItem> ret = new List<NewsItem>(); using (var rdr = cmd.ExecuteReader()) { while (rdr.Read()) ret.Add(new NewsItem() { Icon = rdr.GetString("icon"), Title = rdr.GetString("title"), TagLine = rdr.GetString("text"), Link = rdr.GetString("link"), Date = DateTimeToUnixTimestamp(rdr.GetDateTime("date")), }); } if (acc != null) { cmd.CommandText = @"SELECT charId, characters.charType, level, death.totalFame, time FROM characters, death WHERE dead = TRUE AND characters.accId=@accId AND death.accId=@accId AND characters.charId=death.chrId;"; cmd.Parameters.AddWithValue("@accId", acc.AccountId); using (var rdr = cmd.ExecuteReader()) { while (rdr.Read()) ret.Add(new NewsItem() { Icon = "fame", Title = string.Format("Your {0} died at level {1}", dat.ObjectTypeToId[(ushort)rdr.GetInt32("charType")], rdr.GetInt32("level")), TagLine = string.Format("You earned {0} glorious Fame", rdr.GetInt32("totalFame")), Link = "fame:" + rdr.GetInt32("charId"), Date = DateTimeToUnixTimestamp(rdr.GetDateTime("time")), }); } } ret.Sort((a, b) => -Comparer<int>.Default.Compare(a.Date, b.Date)); return ret.Take(10).ToList(); }
static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; using (Settings = new SimpleSettings("server")) { GameData = new XmlData(); int port = Settings.GetValue<int>("port", "8888"); listener = new HttpListener(); listener.Prefixes.Add("http://*:" + port + "/"); listener.Start(); listener.BeginGetContext(ListenerCallback, null); for (var i = 0; i < workers.Length; i++) { workers[i] = new Thread(Worker) { Name = "Worker " + i }; workers[i].Start(); } Console.CancelKeyPress += (sender, e) => e.Cancel = true; log.Info("Listening at port " + port + "..."); while (Console.ReadKey(true).Key != ConsoleKey.Escape) ; log.Info("Terminating..."); terminating = true; listener.Stop(); queueReady.Set(); GameData.Dispose(); while (contextQueue.Count > 0) Thread.Sleep(100); } }
public void Death(XmlData dat, Account acc, Char chr, string killer) //Save first { var cmd = CreateQuery(); cmd.CommandText = @"UPDATE characters SET dead=TRUE, deathTime=NOW() WHERE accId=@accId AND charId=@charId;"; cmd.Parameters.AddWithValue("@accId", acc.AccountId); cmd.Parameters.AddWithValue("@charId", chr.CharacterId); cmd.ExecuteNonQuery(); bool firstBorn; var finalFame = chr.FameStats.CalculateTotal(dat, acc, chr, chr.CurrentFame, out firstBorn); cmd = CreateQuery(); cmd.CommandText = @"UPDATE stats SET fame=fame+@amount, totalFame=totalFame+@amount WHERE accId=@accId;"; cmd.Parameters.AddWithValue("@accId", acc.AccountId); cmd.Parameters.AddWithValue("@amount", finalFame); cmd.ExecuteNonQuery(); cmd = CreateQuery(); cmd.CommandText = @"INSERT INTO death(accId, chrId, name, charType, tex1, tex2, items, fame, fameStats, totalFame, firstBorn, killer) VALUES(@accId, @chrId, @name, @objType, @tex1, @tex2, @items, @fame, @fameStats, @totalFame, @firstBorn, @killer);"; cmd.Parameters.AddWithValue("@accId", acc.AccountId); cmd.Parameters.AddWithValue("@chrId", chr.CharacterId); cmd.Parameters.AddWithValue("@name", acc.Name); cmd.Parameters.AddWithValue("@objType", chr.ObjectType); cmd.Parameters.AddWithValue("@tex1", chr.Tex1); cmd.Parameters.AddWithValue("@tex2", chr.Tex2); cmd.Parameters.AddWithValue("@items", chr._Equipment); cmd.Parameters.AddWithValue("@fame", chr.CurrentFame); cmd.Parameters.AddWithValue("@fameStats", chr.PCStats); cmd.Parameters.AddWithValue("@totalFame", finalFame); cmd.Parameters.AddWithValue("@firstBorn", firstBorn); cmd.Parameters.AddWithValue("@killer", killer); cmd.ExecuteNonQuery(); }
private void SerializeBonus(XmlData data, XmlDocument doc, Account acc, Char chr, int baseFame, bool firstBorn) { double bonus = 0; if (chr.CharacterId < 2) //Ancestor { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.Ancestor"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.AncestorDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor(((baseFame + Math.Floor(bonus)) * 0.1) + 20)).ToString(); bonus = Math.Floor(bonus) + ((baseFame + Math.Floor(bonus)) * 0.1) + 20; doc.DocumentElement.AppendChild(x); } //Legacy Builder??? if (ShotsThatDamage == 0) //Pacifist { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.Pacifist"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.PacifistDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.25)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.25; doc.DocumentElement.AppendChild(x); } if (PotionsDrunk == 0) //Thirsty { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.Thirsty"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.ThirstyDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.25)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.25; doc.DocumentElement.AppendChild(x); } if (SpecialAbilityUses == 0) //Mundane { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.Mundane"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.MundaneDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.25)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.25; doc.DocumentElement.AppendChild(x); } if (Teleports == 0) //Boots on the Ground { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.BootsOnGround"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.BootsOnGroundDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.25)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.25; doc.DocumentElement.AppendChild(x); } if (PirateCavesCompleted > 0 && UndeadLairsCompleted > 0 && AbyssOfDemonsCompleted > 0 && SnakePitsCompleted > 0 && SpiderDensCompleted > 0 && SpriteWorldsCompleted > 0 && TombsCompleted > 0 && TrenchesCompleted > 0 && JunglesCompleted > 0 && ManorsCompleted > 0) //Tunnel Rat { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.TunnelRat"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.TunnelRatDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } if ((double)GodKills / (GodKills + MonsterKills) > 0.1) //Enemy of the Gods { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.GodEnemy"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.GodEnemyDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } if ((double)GodKills / (GodKills + MonsterKills) > 0.5) //Slayer of the Gods { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.GodSlayer"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.GodSlayerDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } if (OryxKills > 0) //Oryx Slayer { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.OryxSlayer"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.OryxSlayerDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } if ((double)ShotsThatDamage / Shots > 0.25) //Accurate { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.Accurate"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.AccurateDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } if ((double)ShotsThatDamage / Shots > 0.5) //Sharpshooter { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.SharpShooter"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.SharpShooterDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } if ((double)ShotsThatDamage / Shots > 0.75) //Sniper { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.Sniper"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.SniperDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } if (TilesUncovered > 1000000) //Explorer { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.Explorer"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.ExplorerDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.05)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.05; doc.DocumentElement.AppendChild(x); } if (TilesUncovered > 4000000) //Cartographer { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.Cartographer"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.CartographerDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.05)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.05; doc.DocumentElement.AppendChild(x); } if (LevelUpAssists > 100) //Team Player { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.TeamPlayer"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.TeamPlayerDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } if (LevelUpAssists > 1000) //Leader of Men { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.LeaderOfMen"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.LeaderOfMenDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } if (QuestsCompleted > 1000) //Doer of Deeds { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.DoerOfDeeds"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.DoerOfDeedsDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } if (CubeKills == 0) //Friend of the Cubes { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.CubeFriend"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.CubeFriendDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } double bo = 0; for (int i = 0; i < 4; i++) //Well Equipped { if (chr.Equipment[i] == -1) { continue; } int b = data.Items[(ushort)chr.Equipment[i]].FameBonus; if (b > 0) { bo += (baseFame + Math.Floor(bonus)) * b / 100; } } if (bo > 0) { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.WellEquipped"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.WellEquippedDescription"; x.Attributes.Append(descAttr); x.InnerText = ((int)bo).ToString(); bonus = Math.Floor(bonus) + Math.Floor(bo); doc.DocumentElement.AppendChild(x); } if (firstBorn) { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.FirstBorn"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.FirstBornDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } }
public int CalculateTotal(XmlData data, Account acc, Char chr, int baseFame, out bool firstBorn) { double bonus = 0; if (chr.CharacterId < 2) //Ancestor { bonus = Math.Floor(bonus) + ((baseFame + Math.Floor(bonus)) * 0.1) + 20; } //Legacy Builder??? if (ShotsThatDamage == 0) //Pacifist { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.25; } if (PotionsDrunk == 0) //Thirsty { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.25; } if (SpecialAbilityUses == 0) //Mundane { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.25; } if (Teleports == 0) //Boots on the Ground { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.25; } if (PirateCavesCompleted > 0 && UndeadLairsCompleted > 0 && AbyssOfDemonsCompleted > 0 && SnakePitsCompleted > 0 && SpiderDensCompleted > 0 && SpriteWorldsCompleted > 0 && TombsCompleted > 0 && TrenchesCompleted > 0 && JunglesCompleted > 0 && ManorsCompleted > 0) //Tunnel Rat { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; } if ((double)GodKills / (GodKills + MonsterKills) > 0.1) //Enemy of the Gods { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; } if ((double)GodKills / (GodKills + MonsterKills) > 0.5) //Slayer of the Gods { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; } if (OryxKills > 0) //Oryx Slayer { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; } if ((double)ShotsThatDamage / Shots > 0.25) //Accurate { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; } if ((double)ShotsThatDamage / Shots > 0.5) //Sharpshooter { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; } if ((double)ShotsThatDamage / Shots > 0.75) //Sniper { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; } if (TilesUncovered > 1000000) //Explorer { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.05; } if (TilesUncovered > 4000000) //Cartographer { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.05; } if (LevelUpAssists > 100) //Team Player { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; } if (LevelUpAssists > 1000) //Leader of Men { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; } if (QuestsCompleted > 1000) //Doer of Deeds { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; } if (CubeKills == 0) //Friend of the Cubes { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; } double eq = 0; for (int i = 0; i < 4; i++) //Well Equipped { if (chr.Equipment[i] == -1) { continue; } var b = data.Items[(ushort)chr.Equipment[i]].FameBonus; if (b > 0) { eq += (baseFame + Math.Floor(bonus)) * b / 100; } } bonus = Math.Floor(bonus) + Math.Floor(eq); if (baseFame + Math.Floor(bonus) > acc.Stats.BestCharFame) //First Born { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; firstBorn = true; } else { firstBorn = false; } return((int)(baseFame + Math.Floor(bonus))); }
public static void InitMerchantLists(XmlData data) { log.Info("Loading merchant lists..."); /* Price Lists */ var accessoryDyeList = new List<int>(); var clothingDyeList = new List<int>(); var accessoryClothList = new List<int>(); var clothingClothList = new List<int>(); var petGeneratorList = new List<int>(); var materialList = new List<int>(); var keyList = new List<int>(); var weaponList = new List<int>(); var abilityList = new List<int>(); var armorList = new List<int>(); var ringList = new List<int>(); var noDiscountList = new List<int>(); foreach (KeyValuePair<ushort, Item> item in data.Items) { if (item.Value.Texture1 != 0 && item.Value.ObjectId.Contains("Clothing") && item.Value.Class == "Dye") { prices.Add(item.Value.ObjectType, new Tuple<int, CurrencyType>(150, CurrencyType.Gold)); clothingDyeList.Add(item.Value.ObjectType); } if (item.Value.Texture2 != 0 && item.Value.ObjectId.Contains("Accessory") && item.Value.Class == "Dye") { prices.Add(item.Value.ObjectType, new Tuple<int, CurrencyType>(150, CurrencyType.Gold)); accessoryDyeList.Add(item.Value.ObjectType); } if (item.Value.Texture1 != 0 && item.Value.ObjectId.Contains("Cloth") && item.Value.ObjectId.Contains("Large")) { prices.Add(item.Value.ObjectType, new Tuple<int, CurrencyType>(500, CurrencyType.Gold)); clothingClothList.Add(item.Value.ObjectType); } if (item.Value.Texture2 != 0 && item.Value.ObjectId.Contains("Cloth") && item.Value.ObjectId.Contains("Small")) { prices.Add(item.Value.ObjectType, new Tuple<int, CurrencyType>(500, CurrencyType.Gold)); accessoryClothList.Add(item.Value.ObjectType); } if (item.Value.ObjectId.EndsWith("Generator")) { prices.Add(item.Value.ObjectType, new Tuple<int, CurrencyType>(500, CurrencyType.Fame)); petGeneratorList.Add(item.Value.ObjectType); } if (item.Value.Material && item.Value.Price > 0) { prices.Add(item.Value.ObjectType, new Tuple<int, CurrencyType>(item.Value.Price, CurrencyType.Souls)); materialList.Add(item.Value.ObjectType); noDiscountList.Add(item.Value.ObjectType); } if (item.Value.ObjectId.EndsWith("Key") && item.Value.Class == "Equipment" && item.Value.Consumable && item.Value.Soulbound) { prices.Add(item.Value.ObjectType, new Tuple<int, CurrencyType>(item.Value.Price != 0 ? item.Value.Price : 1500, CurrencyType.Gold)); keyList.Add(item.Value.ObjectType); noDiscountList.Add(item.Value.ObjectType); } if (item.Value.Class == "Equipment" && (item.Value.SlotType == 1 || item.Value.SlotType == 2 || item.Value.SlotType == 3 || item.Value.SlotType == 8 || item.Value.SlotType == 17 || item.Value.SlotType == 24) && !item.Value.AdminOnly) { switch (item.Value.Tier) { case 8: prices.Add(item.Value.ObjectType, new Tuple<int, CurrencyType>(500, CurrencyType.Gold)); weaponList.Add(item.Value.ObjectType); break; case 9: prices.Add(item.Value.ObjectType, new Tuple<int, CurrencyType>(750, CurrencyType.Gold)); weaponList.Add(item.Value.ObjectType); break; } } if (item.Value.Class == "Equipment" && (item.Value.SlotType == 4 || item.Value.SlotType == 5 || item.Value.SlotType == 11 || item.Value.SlotType == 12 || item.Value.SlotType == 13 || item.Value.SlotType == 15 || item.Value.SlotType == 16 || item.Value.SlotType == 18 || item.Value.SlotType == 19 || item.Value.SlotType == 20 || item.Value.SlotType == 21 || item.Value.SlotType == 22 || item.Value.SlotType == 23 || item.Value.SlotType == 25) && !item.Value.AdminOnly) { switch (item.Value.Tier) { case 4: prices.Add(item.Value.ObjectType, new Tuple<int, CurrencyType>(500, CurrencyType.Gold)); abilityList.Add(item.Value.ObjectType); break; } } if (item.Value.Class == "Equipment" && (item.Value.SlotType == 6 || item.Value.SlotType == 7 || item.Value.SlotType == 14) && !item.Value.AdminOnly) { switch (item.Value.Tier) { case 9: prices.Add(item.Value.ObjectType, new Tuple<int, CurrencyType>(500, CurrencyType.Gold)); armorList.Add(item.Value.ObjectType); break; case 10: prices.Add(item.Value.ObjectType, new Tuple<int, CurrencyType>(750, CurrencyType.Gold)); armorList.Add(item.Value.ObjectType); break; } } if (item.Value.Class == "Equipment" && item.Value.ObjectId.Contains("Ring") && (item.Value.SlotType == 9) && !item.Value.AdminOnly) { switch (item.Value.Tier) { case 4: prices.Add(item.Value.ObjectType, new Tuple<int, CurrencyType>(500, CurrencyType.Gold)); ringList.Add(item.Value.ObjectType); break; } } } ClothingDyeList = clothingDyeList.ToArray(); ClothingClothList = clothingClothList.ToArray(); AccessoryClothList = accessoryClothList.ToArray(); AccessoryDyeList = accessoryDyeList.ToArray(); PetGeneratorList = petGeneratorList.ToArray(); MaterialList = materialList.ToArray(); KeyList = keyList.ToArray(); WeaponList = weaponList.ToArray(); AbilityList = abilityList.ToArray(); ArmorList = armorList.ToArray(); RingList = ringList.ToArray(); noDiscountList.Add(0xc5e); noDiscountList.Add(0xc5d); NoDiscountList = noDiscountList.ToArray(); log.Info("Merchat lists added."); }
public Account GetAccount(XmlData data) { using (var db = new Database()) return(db.GetAccount(accId, data)); }
public JsonMap(XmlData dat) { this.dat = dat; }
public void Initialize() { log.Info("Initializing Realm Manager..."); GameData = new XmlData(); Behaviors = new BehaviorDb(this); MerchantLists.InitMerchantLists(GameData); AddWorld(World.NEXUS_ID, Worlds[0] = new Nexus()); Monitor = new RealmPortalMonitor(this); AddWorld(World.TUT_ID, new Tutorial(true)); AddWorld(World.NEXUS_LIMBO, new NexusLimbo()); AddWorld(World.VAULT_ID, new Vault(true)); AddWorld(World.TEST_ID, new Test()); AddWorld(World.RAND_REALM, new RandomRealm()); AddWorld(World.PVP, new PVPArena()); AddWorld(World.SHOP_ID, new Shop()); if (Program.Settings.GetValue<bool>("hasRealm")) AddWorld(GameWorld.AutoName(1, true)); Chat = new ChatManager(this); Commands = new CommandManager(); UnusualEffects.Init(); log.Info("Realm Manager initialized."); }