public bool UninscribeItem(uint idItem, Character pUser) { DbItem dbItem = Database.Items.FetchByIdentity(idItem); if (dbItem == null) { return(false); } TotemPoleType pType = GetArsenalType(Calculations.GetItemPosition(dbItem.Type)); if (pType == TotemPoleType.TOTEM_NONE) { return(false); } Totem pPole; if (!Poles.ContainsKey(pType) || !Poles[pType].Items.TryGetValue(idItem, out pPole)) { return(false); } return(UninscribeItem(pPole.Item, pUser)); }
public bool InscribeItem(Item pItem, Character pUser) { TotemPoleType pType = GetArsenalType(pItem); if (pType == TotemPoleType.TOTEM_NONE) // invalid item { return(false); } if (!Poles.ContainsKey(pType)) // arsenal probably closed { return(false); } if (!pUser.Inventory.Items.ContainsKey(pItem.Identity)) // item should be in the user inventory { return(false); } if (pItem.GetQuality() < 8 || pItem.IsArrowSort()) { return(false); } if (Poles[pType].Items.ContainsKey(pItem.Identity)) // already inscribed { return(false); } int nTotal = Poles[pType].Items.Values.Count(x => x.PlayerIdentity == pUser.Identity); if (nTotal >= MaxPerType(pUser)) // inscribed max items { return(false); } var totem = new Totem(pItem, pUser); if (!Poles[pType].Items.TryAdd(pItem.Identity, totem)) { return(false); } uint dwOldBp = BattlePower; pItem.Inscribed = true; pUser.Send(pItem.InformationPacket(true)); totem.Save(); UpdatePoles(); pUser.SyndicateMember.ArsenalDonation += totem.Donation(); if (dwOldBp != BattlePower) { SendBattlePower(); } SendArsenal(pUser); return(true); }
public void AddTotemPole(TotemPoleType type, uint dwBp, uint dwBoost, uint dwTotalDonation, bool isOpen) { int offset = (int)(24 + (TotemAmount * 24)); TotemAmount += 1; WriteUInt((uint)type, offset); WriteUInt(dwBp, offset + 4); WriteUInt(dwBoost, offset + 8); WriteUInt(dwTotalDonation, offset + 12); WriteBoolean(isOpen, offset + 20); }
public bool UnlockArsenal(TotemPoleType pType, Character pUser) { if (pUser.SyndicateMember == null || pUser.Syndicate == null || pUser.Syndicate != Owner || (pUser.SyndicateMember.Position != SyndicateRank.GUILD_LEADER && pUser.SyndicateMember.Position != SyndicateRank.LEADER_SPOUSE && pUser.SyndicateMember.Position != SyndicateRank.DEPUTY_LEADER && pUser.SyndicateMember.Position != SyndicateRank.HONORARY_DEPUTY_LEADER)) { pUser.Send("You don`t have permission to open arsenals."); return(false); } if (pType == TotemPoleType.TOTEM_NONE) { pUser.Send("Invalid arsenal type."); return(false); } if (Poles.ContainsKey(pType)) { pUser.Send("This arsenal is already open."); return(false); } uint dwPrice = UnlockValue(); if (Owner.SilverDonation < dwPrice) { pUser.Send("Not enough funds."); return(false); } if (uint.Parse(DateTime.Now.ToString("yyyyMMdd")) <= Owner.LastTotemOpen) { pUser.Send("Your guild already oppened an arsenal today."); return(false); } if (!Owner.ChangeFunds((int)UnlockValue() * -1)) { return(false); } OpenArsenal(pType); SendArsenal(pUser); pUser.SyndicateMember.SendSyndicate(); return(true); }
public static void HandleWeaponsInfo(Character pUser, MsgWeaponsInfo pMsg) { TotemPoleType pType = (TotemPoleType)pMsg.ArsenalType; if (pType == TotemPoleType.TOTEM_NONE) { pType = TotemPoleType.TOTEM_HEADGEAR; } TotemPole pPole; if (!pUser.Syndicate.Arsenal.Poles.TryGetValue(pType, out pPole)) { return; } uint beginAt = pMsg.BeginAt - 1; uint length = (uint)pPole.Items.Count; length = Math.Min(length, 8); int nAmount = 0; foreach (var item in pPole.Items.Values.OrderByDescending(x => x.Donation())) { if (nAmount < beginAt) { nAmount++; continue; } if (nAmount > beginAt + length) { break; } pMsg.AppendItem(item.Identity, (uint)nAmount, item.PlayerName, item.Itemtype, (byte)(item.Itemtype % 10), item.Item.Plus, (byte)item.Item.SocketOne, (byte)item.Item.SocketTwo, (uint)item.Item.CalculateItemBattlePower(), item.Donation()); nAmount++; } pMsg.EndAt = length + pMsg.BeginAt - 1; pMsg.Donation = (uint)pPole.Donation; pMsg.Enchantment = 0; // todo pMsg.EnchantmentExpire = 0; // todo pMsg.SharedBattlePower = pPole.BattlePower; pMsg.TotalInscribed = (uint)pPole.Items.Count; pUser.Send(pMsg); }
private bool OpenArsenal(TotemPoleType pType) { Owner.LastTotemOpen = uint.Parse(DateTime.Now.ToString("yyyyMMdd")); switch (pType) { case TotemPoleType.TOTEM_HEADGEAR: Owner.HeadgearTotem = true; break; case TotemPoleType.TOTEM_NECKLACE: Owner.NecklaceTotem = true; break; case TotemPoleType.TOTEM_RING: Owner.RingTotem = true; break; case TotemPoleType.TOTEM_WEAPON: Owner.WeaponTotem = true; break; case TotemPoleType.TOTEM_ARMOR: Owner.ArmorTotem = true; break; case TotemPoleType.TOTEM_BOOTS: Owner.BootsTotem = true; break; case TotemPoleType.TOTEM_FAN: Owner.HeavenFanTotem = true; break; case TotemPoleType.TOTEM_TOWER: Owner.StarTowerTotem = true; break; } return(Poles.TryAdd(pType, new TotemPole(pType) { Locked = false })); }
public bool UninscribeItem(Item pItem, Character pUser) { TotemPoleType pType = GetArsenalType(pItem); if (pType == TotemPoleType.TOTEM_NONE) // shit happens { return(false); } if (!Poles.ContainsKey(pType)) { return(false); } if (!Poles[pType].Items.ContainsKey(pItem.Identity)) { return(false); } uint dwOldBp = BattlePower; Totem pTotem; if (!Poles[pType].Items.TryRemove(pItem.Identity, out pTotem)) { return(false); } pTotem.Delete(); pItem.Inscribed = false; pUser.Send(pItem.InformationPacket(true)); UpdatePoles(); if (dwOldBp != BattlePower) { SendBattlePower(); } SendArsenal(pUser); return(true); }
/// <summary> /// Used to add items to the totem pole on the server startup. /// </summary> /// <param name="item">The item that will be inserted into the arsenal.</param> /// <param name="totem">The totem object.</param> /// <returns>If the item has been inscribed successfully.</returns> public bool AddItem(Item item, Totem totem) { TotemPoleType type = GetArsenalType(item); if (type == TotemPoleType.TOTEM_NONE) { return(false); } if (!Poles.ContainsKey(type)) { return(false); // doesn't contain the required type } if (Poles[type].Locked) { return(false); } if (item.GetQuality() < 8 || item.IsArrowSort()) { return(false); } if (Poles[type].Items.ContainsKey(item.Identity)) { return(false); // that item is already inscribed? } if (!Poles[type].Items.TryAdd(item.Identity, totem)) { return(false); } item.Inscribed = true; item.Save(); return(true); }
public TotemPole(TotemPoleType type) { Type = type; Items = new ConcurrentDictionary <uint, Totem>(); }
public void SendArsenal(Character pUser) { var pMsg = new MsgTotemPoleInfo(); UpdatePoles(); var orderedTotem = Poles.Values.OrderByDescending(x => x.Donation).ToList(); for (TotemPoleType i = TotemPoleType.TOTEM_HEADGEAR; i < TotemPoleType.TOTEM_NONE; i++) { TotemPole totem = orderedTotem.FirstOrDefault(x => x.Type == i); if (totem == null) { pMsg.AddTotemPole(i, 0, 0, 0, false); continue; } pMsg.AddTotemPole(totem.Type, totem.BattlePower, 0, (uint)totem.Donation, true); //switch (totem.Type) //{ // case TotemPoleType.TOTEM_HEADGEAR: // pMsg.HearwearIdentity = (uint)totem.Type; // pMsg.TotemHeadwearIsOpen = pUser.Syndicate.HeadgearTotem; // pMsg.HeadwearBattlePower = totem.BattlePower; // pMsg.HeadwearTotalDonation = (uint)totem.Donation; // break; // case TotemPoleType.TOTEM_NECKLACE: // pMsg.NecklaceIdentity = (uint)totem.Type; // pMsg.TotemNecklaceIsOpen = pUser.Syndicate.NecklaceTotem; // pMsg.NecklaceBattlePower = totem.BattlePower; // pMsg.NecklaceTotalDonation = (uint)totem.Donation; // break; // case TotemPoleType.TOTEM_RING: // pMsg.RingIdentity = (uint)totem.Type; // pMsg.TotemRingIsOpen = pUser.Syndicate.RingTotem; // pMsg.RingBattlePower = totem.BattlePower; // pMsg.RingTotalDonation = (uint)totem.Donation; // break; // case TotemPoleType.TOTEM_WEAPON: // pMsg.WeaponIdentity = (uint)totem.Type; // pMsg.TotemWeaponIsOpen = pUser.Syndicate.WeaponTotem; // pMsg.WeaponBattlePower = totem.BattlePower; // pMsg.WeaponTotalDonation = (uint)totem.Donation; // break; // case TotemPoleType.TOTEM_ARMOR: // pMsg.ArmorIdentity = (uint)totem.Type; // pMsg.TotemArmorIsOpen = pUser.Syndicate.ArmorTotem; // pMsg.ArmorBattlePower = totem.BattlePower; // pMsg.ArmorTotalDonation = (uint)totem.Donation; // break; // case TotemPoleType.TOTEM_BOOTS: // pMsg.BootsIdentity = (uint)totem.Type; // pMsg.TotemBootsIsOpen = pUser.Syndicate.BootsTotem; // pMsg.BootsBattlePower = totem.BattlePower; // pMsg.BootsTotalDonation = (uint)totem.Donation; // break; // case TotemPoleType.TOTEM_FAN: // pMsg.FanIdentity = (uint)totem.Type; // pMsg.TotemFanIsOpen = pUser.Syndicate.HeavenFanTotem; // pMsg.FanBattlePower = totem.BattlePower; // pMsg.FanTotalDonation = (uint)totem.Donation; // break; // case TotemPoleType.TOTEM_TOWER: // pMsg.TowerIdentity = (uint)totem.Type; // pMsg.TotemTowerIsOpen = pUser.Syndicate.StarTowerTotem; // pMsg.TowerBattlePower = totem.BattlePower; // pMsg.TowerTotalDonation = (uint)totem.Donation; // break; //} } pMsg.SharedBattlePower = BattlePower; pMsg.BattlePower = SharedBattlePower(pUser.SyndicateMember.Position); pMsg.TotemDonation = pUser.SyndicateMember.ArsenalDonation; if (pUser.Syndicate.Arsenal != null) { pUser.UpdateClient(ClientUpdateType.GUILD_BATTLEPOWER, pUser.Syndicate.Arsenal.SharedBattlePower(pUser)); } pUser.Send(pMsg); }