Пример #1
0
 private void Initialize()
 {
     Stage = UpgradeMode.IsMultistage() ? UpgradeStage.Upgrading : UpgradeStage.Final;
     Hints = new SetSlim <UpgradeHint>();
     RecycledDefinitions = new List <RecycledDefinition>();
     Services            = new UpgradeServiceAccessor();
 }
Пример #2
0
        internal static string ToSerializedValue(this UpgradeMode value)
        {
            switch (value)
            {
            case UpgradeMode.Automatic:
                return("Automatic");

            case UpgradeMode.Manual:
                return("Manual");
            }
            return(null);
        }
        public override void ExecuteCmdlet()
        {
            var patchRequest = new ClusterUpdateParameters();

            if (UpgradeMode == ClusterUpgradeMode.Manual)
            {
                patchRequest.ClusterCodeVersion = this.Version;
            }

            patchRequest.UpgradeMode = UpgradeMode.ToString();

            if (ShouldProcess(target: this.Name, action: string.Format("Set fabric upgrade type to {0} ", this.UpgradeMode)))
            {
                var cluster = SendPatchRequest(patchRequest);
                WriteObject(cluster, true);
            }
        }
Пример #4
0
        void OnGUI()
        {
            m_UpgradeMode = (UpgradeMode)EditorGUILayout.EnumPopup("Mode", m_UpgradeMode);
            if (m_UpgradeMode == UpgradeMode.MoveFiles)
            {
                m_RuntimeDirectory = EditorGUILayout.TextField("Runtime Directory", m_RuntimeDirectory);
                m_EditorDirectory  = EditorGUILayout.TextField("Editor Directory", m_EditorDirectory);
            }

            m_RuntimeAssemblyName = EditorGUILayout.TextField("Runtime Assembly Name", m_RuntimeAssemblyName);
            m_EditorAssemblyName  = EditorGUILayout.TextField("Editor Assembly Name", m_EditorAssemblyName);
            m_SearchRootDirectory = EditorGUILayout.TextField("Search Root Directory", m_SearchRootDirectory);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Preview"))
            {
                GenerateUpgradeSteps();
            }
            if (GUILayout.Button("Upgrade"))
            {
            }
            GUILayout.EndHorizontal();

            if (m_CreatedAsmdefs.Count > 0 || m_MovedAssets.Count > 0)
            {
                m_ScrollPos = EditorGUILayout.BeginScrollView(m_ScrollPos, EditorStyles.helpBox);
                EditorGUILayout.LabelField("Created Asmdefs:", EditorStyles.boldLabel);
                foreach (var createdAsmdef in m_CreatedAsmdefs)
                {
                    createdAsmdef.foldout = EditorGUILayout.Foldout(createdAsmdef.foldout, createdAsmdef.asmdef.name);
                    if (createdAsmdef.foldout)
                    {
                        EditorGUILayout.LabelField(createdAsmdef.path);
                        EditorGUILayout.LabelField("References:");
                        foreach (var asmdefReference in createdAsmdef.asmdef.references)
                        {
                            EditorGUILayout.LabelField(asmdefReference);
                        }
                    }
                }
                EditorGUILayout.EndScrollView();
            }
        }
Пример #5
0
        /// <summary>
        /// Upgrades the given deployment with the package contents.
        /// </summary>
        public async Task UpgradeAsync(
            Uri packageUrl,
            DeploymentType deploymentType,
            string roleToUpgrade = null,
            UpgradeMode mode     = UpgradeMode.Auto)
        {
            Contract.Requires(Parent != null);
            Contract.Requires(packageUrl != null);
            Contract.Requires(!string.IsNullOrWhiteSpace(Label));
            Contract.Requires(Configuration != null);

            var ns      = XmlNamespaces.WindowsAzure;
            var content = new XElement(ns + "UpgradeDeployment",
                                       new XElement(ns + "Mode", mode.ToString()),
                                       new XElement(ns + "PackageUrl", packageUrl.ToString()),
                                       new XElement(ns + "Configuration", Configuration.ToXml().ToString().ToBase64String()),
                                       new XElement(ns + "Label", Label.ToBase64String()),
                                       new XElement(ns + "RoleToUpgrade", roleToUpgrade),
                                       new XElement(ns + "Force", deploymentType == DeploymentType.Forced));
            // With the deployments endpoint, you need a forward slash separating the URI from the query string!
            HttpResponseMessage response = await GetRestClient(Parent, "/?comp=upgrade").PostAsync(content);

            await Parent.Subscription.WaitForOperationCompletionAsync(response);
        }
 public static string ToSerialString(this UpgradeMode value) => value switch
 {
        public void UpgradeItem(ClientSession Session, UpgradeMode mode, UpgradeProtection protection, bool isCommand = false)
        {
            if (this.Upgrade < 10)
            {
                short[] upsuccess = { 100, 100, 100, 95, 80, 60, 40, 5, 3, 1 };
                short[] upfix     = { 0, 0, 10, 15, 20, 20, 20, 80, 95, 99 };

                // short itempricevnum1 = 0;
                // short itempricevnum2 = 0;
                int[]   goldprice = { 500, 1500, 3000, 10000, 30000, 80000, 150000, 400000, 700000, 1000000 };
                short[] cella     = { 20, 50, 80, 120, 160, 220, 280, 380, 480, 600 };
                short[] gem       = { 1, 1, 2, 2, 3, 1, 1, 2, 2, 3 };

                short  cellaVnum          = 1014;
                short  gemVnum            = 1015;
                short  gemFullVnum        = 1016;
                double reducedpricefactor = 0.5;
                short  normalScrollVnum   = 1218;
                short  goldScrollVnum     = 5369;

                if (this.IsFixed)
                {
                    Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ITEM_IS_FIXED"), 10));
                    Session.SendPacket("shop_end 1");
                    return;
                }
                switch (mode)
                {
                case UpgradeMode.Free:
                    break;

                case UpgradeMode.Reduced:

                    // TODO: Reduced Item Amount
                    if (Session.Character.Gold < goldprice[this.Upgrade] * reducedpricefactor)
                    {
                        return;
                    }
                    Session.Character.Gold = Session.Character.Gold - (long)(goldprice[this.Upgrade] * reducedpricefactor);
                    if (Session.Character.InventoryList.CountItem(cellaVnum) < cella[this.Upgrade] * reducedpricefactor)
                    {
                        return;
                    }
                    Session.Character.InventoryList.RemoveItemAmount(cellaVnum, (int)(cella[this.Upgrade] * reducedpricefactor));
                    if (this.Upgrade <= 5)
                    {
                        if (Session.Character.InventoryList.CountItem(gemVnum) < gem[this.Upgrade] * reducedpricefactor)
                        {
                            return;
                        }
                        Session.Character.InventoryList.RemoveItemAmount(gemVnum, (int)(gem[this.Upgrade] * reducedpricefactor));
                    }
                    else
                    {
                        if (Session.Character.InventoryList.CountItem(gemFullVnum) < gem[this.Upgrade] * reducedpricefactor)
                        {
                            return;
                        }
                        Session.Character.InventoryList.RemoveItemAmount(gemFullVnum, (int)(gem[this.Upgrade] * reducedpricefactor));
                    }

                    if (protection == UpgradeProtection.Protected && !isCommand)
                    {
                        if (Session.Character.InventoryList.CountItem(goldScrollVnum) < 1)
                        {
                            return;
                        }
                        Session.Character.InventoryList.RemoveItemAmount(goldScrollVnum);
                        Session.SendPacket("shop_end 2");
                    }
                    Session.SendPacket(Session.Character.GenerateGold());
                    break;

                case UpgradeMode.Normal:

                    // TODO: Normal Item Amount
                    if (Session.Character.Gold < goldprice[this.Upgrade])
                    {
                        return;
                    }
                    Session.Character.Gold = Session.Character.Gold - goldprice[this.Upgrade];
                    if (Session.Character.InventoryList.CountItem(cellaVnum) < cella[this.Upgrade])
                    {
                        return;
                    }
                    Session.Character.InventoryList.RemoveItemAmount(cellaVnum, (cella[this.Upgrade]));
                    if (this.Upgrade < 5)
                    {
                        if (Session.Character.InventoryList.CountItem(gemVnum) < gem[this.Upgrade])
                        {
                            return;
                        }
                        Session.Character.InventoryList.RemoveItemAmount(gemVnum, (gem[this.Upgrade]));
                    }
                    else
                    {
                        if (Session.Character.InventoryList.CountItem(gemFullVnum) < gem[this.Upgrade])
                        {
                            return;
                        }
                        Session.Character.InventoryList.RemoveItemAmount(gemFullVnum, (gem[this.Upgrade]));
                    }
                    if (protection == UpgradeProtection.Protected && !isCommand)
                    {
                        if (Session.Character.InventoryList.CountItem(normalScrollVnum) < 1)
                        {
                            return;
                        }
                        Session.Character.InventoryList.RemoveItemAmount(normalScrollVnum);
                        Session.SendPacket("shop_end 2");
                    }
                    Session.SendPacket(Session.Character.GenerateGold());
                    break;
                }
                WearableInstance wearable  = Session.Character.InventoryList.LoadByItemInstance <WearableInstance>(this.Id);
                Inventory        inventory = Session.Character.InventoryList.GetInventoryByItemInstanceId(this.Id);

                int rnd = _random.Next(100);
                if (rnd <= upfix[this.Upgrade])
                {
                    ServerManager.Instance.Broadcast(Session, Session.Character.GenerateEff(3004), ReceiverType.All);
                    wearable.IsFixed = true;
                    Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 11));
                    Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 0));
                }
                else if (rnd <= upsuccess[this.Upgrade])
                {
                    ServerManager.Instance.Broadcast(Session, Session.Character.GenerateEff(3005), ReceiverType.All);
                    Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 12));
                    Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 0));
                    wearable.Upgrade++;
                    Session.SendPacket(Session.Character.GenerateInventoryAdd(this.ItemVNum, 1, inventory.Type, inventory.Slot, this.Rare, 0, this.Upgrade, 0));
                }
                else
                {
                    if (protection == UpgradeProtection.Protected)
                    {
                        if (protection == UpgradeProtection.Protected)
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 11));
                        }
                        Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 0));
                    }
                    else
                    {
                        ServerManager.Instance.Broadcast(Session, Session.Character.GenerateEff(3004), ReceiverType.All);
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SCROLL_PROTECT_USED"), 11));
                        Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0));
                    }
                }
            }
            else
            {
                ServerManager.Instance.Broadcast(Session, Session.Character.GenerateEff(3004), ReceiverType.All);
                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SCROLL_PROTECT_USED"), 11));
                Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0));
            }
            Session.SendPacket("shop_end 1");
        }
Пример #8
0
        public void UpgradeItem(ClientSession Session, UpgradeMode mode, UpgradeProtection protection, bool isCommand = false)
        {
            if (this.Upgrade < 10)
            {
                short[] upsuccess;
                short[] upfix;
                int[]   goldprice;
                short[] cella;
                short[] gem;

                if (this.Rare == 8)
                {
                    upsuccess = new short[] { 50, 50, 45, 30, 20, 10, 5, 3, 2, 1 };
                    upfix     = new short[] { 0, 0, 10, 15, 20, 20, 20, 20, 15, 10 };
                    goldprice = new int[] { 5000, 15000, 30000, 100000, 300000, 800000, 1500000, 4000000, 7000000, 10000000 };
                    cella     = new short[] { 40, 100, 160, 240, 320, 440, 560, 760, 960, 1200 };
                    gem       = new short[] { 2, 2, 4, 4, 6, 2, 2, 4, 4, 6 };
                }
                else
                {
                    upsuccess = new short[] { 100, 100, 100, 95, 80, 60, 40, 30, 20, 11 };
                    upfix     = new short[] { 0, 0, 10, 15, 20, 20, 20, 20, 15, 10 };
                    goldprice = new int[] { 500, 1500, 3000, 10000, 30000, 80000, 150000, 400000, 700000, 1000000 };
                    cella     = new short[] { 20, 50, 80, 120, 160, 220, 280, 380, 480, 600 };
                    gem       = new short[] { 1, 1, 2, 2, 3, 1, 1, 2, 2, 3 };
                }

                short  cellaVnum          = 1014;
                short  gemVnum            = 1015;
                short  gemFullVnum        = 1016;
                double reducedpricefactor = 0.5;
                short  normalScrollVnum   = 1218;
                short  goldScrollVnum     = 5369;

                if (this.IsFixed)
                {
                    Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ITEM_IS_FIXED"), 10));
                    Session.SendPacket("shop_end 1");
                    return;
                }
                switch (mode)
                {
                case UpgradeMode.Free:
                    break;

                case UpgradeMode.Reduced:

                    // TODO: Reduced Item Amount
                    if (Session.Character.Gold < (long)(goldprice[this.Upgrade] * reducedpricefactor))
                    {
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                        return;
                    }
                    if (Session.Character.Inventory.CountItem(cellaVnum) < cella[this.Upgrade] * reducedpricefactor)
                    {
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(cellaVnum).Name, cella[this.Upgrade] * reducedpricefactor)), 10));
                        return;
                    }
                    if (protection == UpgradeProtection.Protected && !isCommand && Session.Character.Inventory.CountItem(goldScrollVnum) < 1)
                    {
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(goldScrollVnum).Name, cella[this.Upgrade] * reducedpricefactor)), 10));
                        return;
                    }
                    if (this.Upgrade < 5)
                    {
                        if (Session.Character.Inventory.CountItem(gemVnum) < gem[this.Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(gemVnum).Name, gem[this.Upgrade])), 10));
                            return;
                        }
                        Session.Character.Inventory.RemoveItemAmount(gemVnum, gem[this.Upgrade]);
                    }
                    else
                    {
                        if (Session.Character.Inventory.CountItem(gemFullVnum) < gem[this.Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(gemFullVnum).Name, gem[this.Upgrade])), 10));
                            return;
                        }
                        Session.Character.Inventory.RemoveItemAmount(gemFullVnum, gem[this.Upgrade]);
                    }
                    if (protection == UpgradeProtection.Protected && !isCommand)
                    {
                        Session.Character.Inventory.RemoveItemAmount(goldScrollVnum);
                        Session.SendPacket("shop_end 2");
                    }
                    Session.Character.Gold -= (long)(goldprice[this.Upgrade] * reducedpricefactor);
                    Session.Character.Inventory.RemoveItemAmount(cellaVnum, (int)(cella[this.Upgrade] * reducedpricefactor));
                    Session.SendPacket(Session.Character.GenerateGold());
                    break;

                case UpgradeMode.Normal:

                    // TODO: Normal Item Amount
                    if (Session.Character.Inventory.CountItem(cellaVnum) < cella[this.Upgrade])
                    {
                        return;
                    }
                    if (Session.Character.Gold < goldprice[this.Upgrade])
                    {
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                        return;
                    }
                    if (protection == UpgradeProtection.Protected && !isCommand && Session.Character.Inventory.CountItem(normalScrollVnum) < 1)
                    {
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(normalScrollVnum).Name, 1)), 10));
                        return;
                    }
                    if (this.Upgrade < 5)
                    {
                        if (Session.Character.Inventory.CountItem(gemVnum) < gem[this.Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(gemVnum).Name, gem[this.Upgrade])), 10));
                            return;
                        }
                        Session.Character.Inventory.RemoveItemAmount(gemVnum, (gem[this.Upgrade]));
                    }
                    else
                    {
                        if (Session.Character.Inventory.CountItem(gemFullVnum) < gem[this.Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(gemFullVnum).Name, gem[this.Upgrade])), 10));
                            return;
                        }
                        Session.Character.Inventory.RemoveItemAmount(gemFullVnum, (gem[this.Upgrade]));
                    }
                    if (protection == UpgradeProtection.Protected && !isCommand)
                    {
                        Session.Character.Inventory.RemoveItemAmount(normalScrollVnum);
                        Session.SendPacket("shop_end 2");
                    }
                    Session.Character.Inventory.RemoveItemAmount(cellaVnum, (cella[this.Upgrade]));
                    Session.Character.Gold -= goldprice[this.Upgrade];
                    Session.SendPacket(Session.Character.GenerateGold());
                    break;
                }
                WearableInstance wearable  = Session.Character.Inventory.LoadByItemInstance <WearableInstance>(this.Id);
                ItemInstance     inventory = Session.Character.Inventory.GetItemInstanceById(this.Id);

                int rnd = _random.Next(1, 100);

                if (this.Rare == 8)
                {
                    if (rnd <= upsuccess[this.Upgrade])
                    {
                        Session.CurrentMap.Broadcast(Session.Character.GenerateEff(3005), Session.Character.MapX, Session.Character.MapY);
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 12));
                        Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 0));
                        wearable.Upgrade++;
                        Session.SendPacket(Session.Character.GenerateInventoryAdd(this.ItemVNum, 1, inventory.Type, inventory.Slot, wearable.Rare, 0, wearable.Upgrade, 0));
                    }
                    else if (rnd <= upfix[this.Upgrade])
                    {
                        Session.CurrentMap.Broadcast(Session.Character.GenerateEff(3004), Session.Character.MapX, Session.Character.MapY);
                        wearable.IsFixed = true;
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 11));
                        Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 0));
                    }
                    else
                    {
                        if (protection == UpgradeProtection.None)
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 11));
                            Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 0));
                            Session.Character.DeleteItemByItemInstanceId(this.Id);
                        }
                        else
                        {
                            Session.CurrentMap.Broadcast(Session.Character.GenerateEff(3004), Session.Character.MapX, Session.Character.MapY);
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SCROLL_PROTECT_USED"), 11));
                            Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0));
                        }
                    }
                }
                else
                {
                    if (rnd <= upfix[this.Upgrade])
                    {
                        Session.CurrentMap.Broadcast(Session.Character.GenerateEff(3004), Session.Character.MapX, Session.Character.MapY);
                        wearable.IsFixed = true;
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 11));
                        Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 0));
                    }
                    else if (rnd <= upsuccess[this.Upgrade])
                    {
                        Session.CurrentMap.Broadcast(Session.Character.GenerateEff(3005), Session.Character.MapX, Session.Character.MapY);
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 12));
                        Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 0));
                        wearable.Upgrade++;
                        Session.SendPacket(Session.Character.GenerateInventoryAdd(this.ItemVNum, 1, inventory.Type, inventory.Slot, wearable.Rare, 0, wearable.Upgrade, 0));
                    }
                    else
                    {
                        if (protection == UpgradeProtection.None)
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 11));
                            Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 0));
                            Session.Character.DeleteItemByItemInstanceId(this.Id);
                        }
                        else
                        {
                            Session.CurrentMap.Broadcast(Session.Character.GenerateEff(3004), Session.Character.MapX, Session.Character.MapY);
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SCROLL_PROTECT_USED"), 11));
                            Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0));
                        }
                    }
                }
            }
            else
            {
                Session.CurrentMap.Broadcast(Session.Character.GenerateEff(3004), Session.Character.MapX, Session.Character.MapY);
                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SCROLL_PROTECT_USED"), 11));
                Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0));
            }
            Session.SendPacket("shop_end 1");
        }
Пример #9
0
        public void UpgradeItem(ClientSession session, UpgradeMode mode, UpgradeProtection protection, bool isCommand = false)
        {
            if (!session.HasCurrentMap)
            {
                return;
            }
            if (Upgrade < 10)
            {
                short[] upsuccess;
                short[] upfix;
                int[] goldprice;
                short[] cella;
                short[] gem;

                if (Rare == 8)
                {
                    upsuccess = new short[] { 50, 50, 45, 30, 20, 10, 5, 3, 2, 1 };
                    upfix = new short[] { 0, 0, 10, 15, 20, 20, 20, 20, 15, 10 };
                    goldprice = new[] { 5000, 15000, 30000, 100000, 300000, 800000, 1500000, 4000000, 7000000, 10000000 };
                    cella = new short[] { 40, 100, 160, 240, 320, 440, 560, 760, 960, 1200 };
                    gem = new short[] { 2, 2, 4, 4, 6, 2, 2, 4, 4, 6 };
                }
                else
                {
                    upsuccess = new short[] { 100, 100, 100, 95, 80, 60, 40, 30, 20, 11 };
                    upfix = new short[] { 0, 0, 10, 15, 20, 20, 20, 20, 15, 10 };
                    goldprice = new[] { 500, 1500, 3000, 10000, 30000, 80000, 150000, 400000, 700000, 1000000 };
                    cella = new short[] { 20, 50, 80, 120, 160, 220, 280, 380, 480, 600 };
                    gem = new short[] { 1, 1, 2, 2, 3, 1, 1, 2, 2, 3 };
                }

                short cellaVnum = 1014;
                short gemVnum = 1015;
                short gemFullVnum = 1016;
                double reducedpricefactor = 0.5;
                short normalScrollVnum = 1218;
                short goldScrollVnum = 5369;

                if (IsFixed)
                {
                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ITEM_IS_FIXED"), 10));
                    session.SendPacket("shop_end 1");
                    return;
                }
                switch (mode)
                {
                    case UpgradeMode.Free:
                        break;

                    case UpgradeMode.Reduced:

                        // TODO: Reduced Item Amount
                        if (session.Character.Gold < (long)(goldprice[Upgrade] * reducedpricefactor))
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                            return;
                        }
                        if (session.Character.Inventory.CountItem(cellaVnum) < cella[Upgrade] * reducedpricefactor)
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(cellaVnum).Name, cella[Upgrade] * reducedpricefactor)), 10));
                            return;
                        }
                        if (protection == UpgradeProtection.Protected && !isCommand && session.Character.Inventory.CountItem(goldScrollVnum) < 1)
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(goldScrollVnum).Name, cella[Upgrade] * reducedpricefactor)), 10));
                            return;
                        }
                        if (Upgrade < 5)
                        {
                            if (session.Character.Inventory.CountItem(gemVnum) < gem[Upgrade])
                            {
                                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(gemVnum).Name, gem[Upgrade])), 10));
                                return;
                            }
                            session.Character.Inventory.RemoveItemAmount(gemVnum, gem[Upgrade]);
                        }
                        else
                        {
                            if (session.Character.Inventory.CountItem(gemFullVnum) < gem[Upgrade])
                            {
                                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(gemFullVnum).Name, gem[Upgrade])), 10));
                                return;
                            }
                            session.Character.Inventory.RemoveItemAmount(gemFullVnum, gem[Upgrade]);
                        }
                        if (protection == UpgradeProtection.Protected && !isCommand)
                        {
                            session.Character.Inventory.RemoveItemAmount(goldScrollVnum);
                            session.SendPacket("shop_end 2");
                        }
                        session.Character.Gold -= (long)(goldprice[Upgrade] * reducedpricefactor);
                        session.Character.Inventory.RemoveItemAmount(cellaVnum, (int)(cella[Upgrade] * reducedpricefactor));
                        session.SendPacket(session.Character.GenerateGold());
                        break;

                    case UpgradeMode.Normal:

                        // TODO: Normal Item Amount
                        if (session.Character.Inventory.CountItem(cellaVnum) < cella[Upgrade])
                        {
                            return;
                        }
                        if (session.Character.Gold < goldprice[Upgrade])
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                            return;
                        }
                        if (protection == UpgradeProtection.Protected && !isCommand && session.Character.Inventory.CountItem(normalScrollVnum) < 1)
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(normalScrollVnum).Name, 1)), 10));
                            return;
                        }
                        if (Upgrade < 5)
                        {
                            if (session.Character.Inventory.CountItem(gemVnum) < gem[Upgrade])
                            {
                                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(gemVnum).Name, gem[Upgrade])), 10));
                                return;
                            }
                            session.Character.Inventory.RemoveItemAmount(gemVnum, (gem[Upgrade]));
                        }
                        else
                        {
                            if (session.Character.Inventory.CountItem(gemFullVnum) < gem[Upgrade])
                            {
                                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(gemFullVnum).Name, gem[Upgrade])), 10));
                                return;
                            }
                            session.Character.Inventory.RemoveItemAmount(gemFullVnum, (gem[Upgrade]));
                        }
                        if (protection == UpgradeProtection.Protected && !isCommand)
                        {
                            session.Character.Inventory.RemoveItemAmount(normalScrollVnum);
                            session.SendPacket("shop_end 2");
                        }
                        session.Character.Inventory.RemoveItemAmount(cellaVnum, (cella[Upgrade]));
                        session.Character.Gold -= goldprice[Upgrade];
                        session.SendPacket(session.Character.GenerateGold());
                        break;
                }
                WearableInstance wearable = session.Character.Inventory.LoadByItemInstance<WearableInstance>(Id);
                ItemInstance inventory = session.Character.Inventory.GetItemInstanceById(Id);

                int rnd = _random.Next(1, 100);

                if (Rare == 8)
                {
                    if (rnd <= upsuccess[Upgrade])
                    {
                        session.CurrentMap.Broadcast(session.Character.GenerateEff(3005), session.Character.MapX, session.Character.MapY);
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 12));
                        session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 0));
                        wearable.Upgrade++;
                        session.SendPacket(session.Character.GenerateInventoryAdd(ItemVNum, 1, inventory.Type, inventory.Slot, wearable.Rare, 0, wearable.Upgrade, 0));
                    }
                    else if (rnd <= upfix[Upgrade])
                    {
                        session.CurrentMap.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY);
                        wearable.IsFixed = true;
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 11));
                        session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 0));
                    }
                    else
                    {
                        if (protection == UpgradeProtection.None)
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 11));
                            session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 0));
                            session.Character.DeleteItemByItemInstanceId(Id);
                        }
                        else
                        {
                            session.CurrentMap.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY);
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SCROLL_PROTECT_USED"), 11));
                            session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0));
                        }
                    }
                }
                else
                {
                    if (rnd <= upfix[Upgrade])
                    {
                        session.CurrentMap.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY);
                        wearable.IsFixed = true;
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 11));
                        session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 0));
                    }
                    else if (rnd <= upsuccess[Upgrade])
                    {
                        session.CurrentMap.Broadcast(session.Character.GenerateEff(3005), session.Character.MapX, session.Character.MapY);
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 12));
                        session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 0));
                        wearable.Upgrade++;
                        session.SendPacket(session.Character.GenerateInventoryAdd(ItemVNum, 1, inventory.Type, inventory.Slot, wearable.Rare, 0, wearable.Upgrade, 0));
                    }
                    else
                    {
                        if (protection == UpgradeProtection.None)
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 11));
                            session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 0));
                            session.Character.DeleteItemByItemInstanceId(Id);
                        }
                        else
                        {
                            session.CurrentMap.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY);
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SCROLL_PROTECT_USED"), 11));
                            session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0));
                        }
                    }
                }
            }
            else
            {
                session.CurrentMap.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY);
                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SCROLL_PROTECT_USED"), 11));
                session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0));
            }
            session.SendPacket("shop_end 1");
        }
Пример #10
0
        public void UpgradeItem(ClientSession session, UpgradeMode mode, UpgradeProtection protection, bool isCommand = false)
        {
            if (!session.HasCurrentMapInstance)
            {
                return;
            }
            if (Upgrade < 10)
            {
                short[] upfail;
                short[] upfix;
                int[]   goldprice;
                short[] cella;
                short[] gem;

                if (Rare >= 8)
                {
                    upfix  = new short[] { 50, 40, 70, 65, 80, 90, 95, 97, 98, 99 };
                    upfail = new short[] { 50, 40, 60, 50, 60, 70, 75, 77, 83, 89 };

                    goldprice = new[] { 5000, 15000, 30000, 100000, 300000, 800000, 1500000, 4000000, 7000000, 10000000 };
                    cella     = new short[] { 40, 100, 160, 240, 320, 440, 560, 760, 960, 1200 };
                    gem       = new short[] { 2, 2, 4, 4, 6, 2, 2, 4, 4, 6 };
                }
                else
                {
                    upfix  = new short[] { 0, 0, 10, 15, 20, 20, 20, 20, 15, 14 };
                    upfail = new short[] { 0, 0, 0, 5, 20, 40, 60, 70, 80, 85 };

                    goldprice = new[] { 500, 1500, 3000, 10000, 30000, 80000, 150000, 400000, 700000, 1000000 };
                    cella     = new short[] { 20, 50, 80, 120, 160, 220, 280, 380, 480, 600 };
                    gem       = new short[] { 1, 1, 2, 2, 3, 1, 1, 2, 2, 3 };
                }

                const short  cellaVnum          = 1014;
                const short  gemVnum            = 1015;
                const short  gemFullVnum        = 1016;
                const double reducedpricefactor = 0.5;
                const short  normalScrollVnum   = 1218;
                const short  goldScrollVnum     = 5369;

                if (IsFixed)
                {
                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ITEM_IS_FIXED"), 10));
                    session.SendPacket("shop_end 1");
                    return;
                }
                switch (mode)
                {
                case UpgradeMode.Free:
                    break;

                case UpgradeMode.Reduced:

                    // TODO: Reduced Item Amount
                    if (session.Character.Gold < (long)(goldprice[Upgrade] * reducedpricefactor))
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                        return;
                    }
                    if (session.Character.Inventory.CountItem(cellaVnum) < cella[Upgrade] * reducedpricefactor)
                    {
                        session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(cellaVnum).Name, cella[Upgrade] * reducedpricefactor), 10));
                        return;
                    }
                    if (protection == UpgradeProtection.Protected && !isCommand && session.Character.Inventory.CountItem(goldScrollVnum) < 1)
                    {
                        session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(goldScrollVnum).Name, cella[Upgrade] * reducedpricefactor), 10));
                        return;
                    }
                    if (Upgrade < 5)
                    {
                        if (session.Character.Inventory.CountItem(gemVnum) < gem[Upgrade])
                        {
                            session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(gemVnum).Name, gem[Upgrade]), 10));
                            return;
                        }
                        session.Character.Inventory.RemoveItemAmount(gemVnum, gem[Upgrade]);
                    }
                    else
                    {
                        if (session.Character.Inventory.CountItem(gemFullVnum) < gem[Upgrade])
                        {
                            session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(gemFullVnum).Name, gem[Upgrade]), 10));
                            return;
                        }
                        session.Character.Inventory.RemoveItemAmount(gemFullVnum, gem[Upgrade]);
                    }
                    if (protection == UpgradeProtection.Protected && !isCommand)
                    {
                        session.Character.Inventory.RemoveItemAmount(goldScrollVnum);
                        session.SendPacket("shop_end 2");
                    }
                    session.Character.Gold -= (long)(goldprice[Upgrade] * reducedpricefactor);
                    session.Character.Inventory.RemoveItemAmount(cellaVnum, (int)(cella[Upgrade] * reducedpricefactor));
                    session.SendPacket(session.Character.GenerateGold());
                    break;

                case UpgradeMode.Normal:

                    // TODO: Normal Item Amount
                    if (session.Character.Inventory.CountItem(cellaVnum) < cella[Upgrade])
                    {
                        return;
                    }
                    if (session.Character.Gold < goldprice[Upgrade])
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                        return;
                    }
                    if (protection == UpgradeProtection.Protected && !isCommand && session.Character.Inventory.CountItem(normalScrollVnum) < 1)
                    {
                        session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(normalScrollVnum).Name, 1), 10));
                        return;
                    }
                    if (Upgrade < 5)
                    {
                        if (session.Character.Inventory.CountItem(gemVnum) < gem[Upgrade])
                        {
                            session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(gemVnum).Name, gem[Upgrade]), 10));
                            return;
                        }
                        session.Character.Inventory.RemoveItemAmount(gemVnum, gem[Upgrade]);
                    }
                    else
                    {
                        if (session.Character.Inventory.CountItem(gemFullVnum) < gem[Upgrade])
                        {
                            session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(gemFullVnum).Name, gem[Upgrade]), 10));
                            return;
                        }
                        session.Character.Inventory.RemoveItemAmount(gemFullVnum, gem[Upgrade]);
                    }
                    if (protection == UpgradeProtection.Protected && !isCommand)
                    {
                        session.Character.Inventory.RemoveItemAmount(normalScrollVnum);
                        session.SendPacket("shop_end 2");
                    }
                    session.Character.Inventory.RemoveItemAmount(cellaVnum, cella[Upgrade]);
                    session.Character.Gold -= goldprice[Upgrade];
                    session.SendPacket(session.Character.GenerateGold());
                    break;
                }
                WearableInstance wearable  = session.Character.Inventory.LoadByItemInstance <WearableInstance>(Id);
                ItemInstance     inventory = session.Character.Inventory.GetItemInstanceById(Id);

                int rnd = ServerManager.Instance.RandomNumber();
                if (Rare == 8)
                {
                    if (rnd < upfail[Upgrade])
                    {
                        if (protection == UpgradeProtection.None)
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 11));
                            session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 0));
                            session.Character.DeleteItemByItemInstanceId(Id);
                        }
                        else
                        {
                            session.CurrentMapInstance.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY);
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SCROLL_PROTECT_USED"), 11));
                            session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0));
                        }
                    }
                    else if (rnd < upfix[Upgrade])
                    {
                        session.CurrentMapInstance.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY);
                        wearable.IsFixed = true;
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 11));
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 0));
                    }
                    else
                    {
                        session.CurrentMapInstance.Broadcast(session.Character.GenerateEff(3005), session.Character.MapX, session.Character.MapY);
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 12));
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 0));
                        wearable.Upgrade++;
                        if (wearable.Upgrade > 4)
                        {
                            session.Character.Family?.InsertFamilyLog(FamilyLogType.ItemUpgraded, session.Character.Name, itemVNum: wearable.ItemVNum, upgrade: wearable.Upgrade);
                        }
                        session.SendPacket(wearable.GenerateInventoryAdd());
                    }
                }
                else
                {
                    if (rnd < upfix[Upgrade])
                    {
                        session.CurrentMapInstance.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY);
                        wearable.IsFixed = true;
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 11));
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 0));
                    }
                    else if (rnd < upfail[Upgrade] + upfix[Upgrade])
                    {
                        if (protection == UpgradeProtection.None)
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 11));
                            session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 0));
                            session.Character.DeleteItemByItemInstanceId(Id);
                        }
                        else
                        {
                            session.CurrentMapInstance.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY);
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SCROLL_PROTECT_USED"), 11));
                            session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0));
                        }
                    }
                    else
                    {
                        session.CurrentMapInstance.Broadcast(session.Character.GenerateEff(3005), session.Character.MapX, session.Character.MapY);
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 12));
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 0));
                        wearable.Upgrade++;
                        if (wearable.Upgrade > 4)
                        {
                            session.Character.Family?.InsertFamilyLog(FamilyLogType.ItemUpgraded, session.Character.Name, itemVNum: wearable.ItemVNum, upgrade: wearable.Upgrade);
                        }
                        session.SendPacket(wearable.GenerateInventoryAdd());
                    }
                }
                session.SendPacket("shop_end 1");
            }
        }
Пример #11
0
 /// <summary>
 /// Upgrades the given deployment with the package contents.
 /// </summary>
 public Task UpgradeAsync(Uri packageUrl, string roleToUpgrade = null, UpgradeMode mode = UpgradeMode.Auto)
 {
     return(UpgradeAsync(packageUrl, DeploymentType.Standard, roleToUpgrade, mode));
 }
Пример #12
0
        public void UpgradeItem(ClientSession Session, UpgradeMode mode, UpgradeProtection protection)
        {
            if (this.Upgrade < 10)
            {
                short[] upsuccess = { 100, 100, 100, 95, 80, 60, 40, 30, 20, 11 };
                short[] upfix     = { 0, 0, 10, 15, 20, 20, 20, 20, 15, 10 };

                //short itempricevnum1 = 0;
                //short itempricevnum2 = 0;
                int[]   goldprice = { 500, 1500, 3000, 10000, 30000, 80000, 150000, 400000, 700000, 1000000 };
                short[] cella     = { 20, 50, 80, 120, 160, 220, 280, 380, 480, 600 };
                short[] gem       = { 1, 1, 2, 2, 3, 3, 1, 2, 2, 3 };

                int    cellaVnum          = 1014;
                int    gemVnum            = 1015;
                int    gemFullVnum        = 1016;
                double reducedpricefactor = 0.5;

                if (this.IsFixed)
                {
                    Session.Client.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ITEM_IS_FIXED"), 10));

                    Session.Character.GenerateStartupInventory();
                    Session.Client.SendPacket("shop_end 1");
                    return;
                }
                switch (mode)
                {
                case UpgradeMode.Free:
                    break;

                case UpgradeMode.Reduced:
                    // TODO: Reduced Item Amount
                    if (Session.Character.Gold < goldprice[this.Upgrade] * reducedpricefactor)
                    {
                        return;
                    }
                    Session.Character.Gold = Session.Character.Gold - (long)(goldprice[this.Upgrade] * reducedpricefactor);
                    if (Session.Character.InventoryList.CountItem(cellaVnum) < cella[this.Upgrade] * reducedpricefactor)
                    {
                        return;
                    }
                    Session.Character.InventoryList.RemoveItemAmount(cellaVnum, (int)(cella[this.Upgrade] * reducedpricefactor));
                    if (this.Upgrade <= 5)
                    {
                        if (Session.Character.InventoryList.CountItem(gemVnum) < gem[this.Upgrade] * reducedpricefactor)
                        {
                            return;
                        }
                        Session.Character.InventoryList.RemoveItemAmount(gemVnum, (int)(gem[this.Upgrade] * reducedpricefactor));
                    }
                    else
                    {
                        if (Session.Character.InventoryList.CountItem(gemFullVnum) < gem[this.Upgrade] * reducedpricefactor)
                        {
                            return;
                        }
                        Session.Character.InventoryList.RemoveItemAmount(gemFullVnum, (int)(gem[this.Upgrade] * reducedpricefactor));
                    }
                    Session.Client.SendPacket(Session.Character.GenerateGold());
                    break;

                case UpgradeMode.Normal:
                    // TODO: Normal Item Amount
                    if (Session.Character.Gold < goldprice[this.Upgrade])
                    {
                        return;
                    }
                    Session.Character.Gold = Session.Character.Gold - goldprice[this.Upgrade];
                    if (Session.Character.InventoryList.CountItem(cellaVnum) < cella[this.Upgrade])
                    {
                        return;
                    }
                    Session.Character.InventoryList.RemoveItemAmount(cellaVnum, (cella[this.Upgrade]));
                    if (this.Upgrade < 5)
                    {
                        if (Session.Character.InventoryList.CountItem(gemVnum) < gem[this.Upgrade])
                        {
                            return;
                        }
                        Session.Character.InventoryList.RemoveItemAmount(gemVnum, (gem[this.Upgrade]));
                    }
                    else
                    {
                        if (Session.Character.InventoryList.CountItem(gemFullVnum) < gem[this.Upgrade])
                        {
                            return;
                        }
                        Session.Character.InventoryList.RemoveItemAmount(gemFullVnum, (gem[this.Upgrade]));
                    }
                    Session.Client.SendPacket(Session.Character.GenerateGold());
                    break;
                }

                Random r   = new Random();
                int    rnd = r.Next(100);
                if (rnd <= upfix[this.Upgrade])
                {
                    ServerManager.Instance.Broadcast(Session, Session.Character.GenerateEff(3004), ReceiverType.All);
                    Session.Character.InventoryList.LoadByItemInstance <WearableInstance>(this.ItemInstanceId).IsFixed = true;
                    Session.Client.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 11));
                    Session.Client.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 0));
                }
                else if (rnd <= upsuccess[this.Upgrade])
                {
                    ServerManager.Instance.Broadcast(Session, Session.Character.GenerateEff(3005), ReceiverType.All);
                    Session.Client.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 12));
                    Session.Client.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 0));
                    Session.Character.InventoryList.LoadByItemInstance <WearableInstance>(this.ItemInstanceId).Upgrade++;
                }
                else
                {
                    if (protection == UpgradeProtection.None)
                    {
                        Session.Client.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 11));
                        Session.Client.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 0));
                        Session.Character.DeleteItemByItemInstanceId(this.ItemInstanceId);
                    }
                    else
                    {
                        ServerManager.Instance.Broadcast(Session, Session.Character.GenerateEff(3004), ReceiverType.All);
                        Session.Client.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SCROLL_PROTECT_USED"), 11));
                        Session.Client.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0));
                    }
                }
            }
            else
            {
                ServerManager.Instance.Broadcast(Session, Session.Character.GenerateEff(3004), ReceiverType.All);
                Session.Client.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SCROLL_PROTECT_USED"), 11));
                Session.Client.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0));
            }
            Session.Character.GenerateStartupInventory();
            Session.Client.SendPacket("shop_end 1");
        }
Пример #13
0
 /// <summary>
 /// Upgrades the given deployment with the package contents.
 /// </summary>
 public async Task UpgradeAsync(
     Uri packageUrl,
     DeploymentType deploymentType,
     string roleToUpgrade = null,
     UpgradeMode mode = UpgradeMode.Auto)
 {
     Contract.Requires(Parent != null);
     Contract.Requires(packageUrl != null);
     Contract.Requires(!string.IsNullOrWhiteSpace(Label));
     Contract.Requires(Configuration != null);
     
     var ns = XmlNamespaces.WindowsAzure;
     var content = new XElement(ns + "UpgradeDeployment",
         new XElement(ns + "Mode", mode.ToString()),
         new XElement(ns + "PackageUrl", packageUrl.ToString()),
         new XElement(ns + "Configuration", Configuration.ToXml().ToString().ToBase64String()),
         new XElement(ns + "Label", Label.ToBase64String()),
         new XElement(ns + "RoleToUpgrade", roleToUpgrade),
         new XElement(ns + "Force", deploymentType == DeploymentType.Forced));
     // With the deployments endpoint, you need a forward slash separating the URI from the query string!
     HttpResponseMessage response = await GetRestClient(Parent, "/?comp=upgrade").PostAsync(content);
     await Parent.Subscription.WaitForOperationCompletionAsync(response);
 }
Пример #14
0
 /// <summary>
 /// Upgrades the given deployment with the package contents.
 /// </summary>
 public Task UpgradeAsync(Uri packageUrl, string roleToUpgrade = null, UpgradeMode mode = UpgradeMode.Auto)
 {
     return UpgradeAsync(packageUrl, DeploymentType.Standard, roleToUpgrade, mode);
 }