Esempio n. 1
0
 public static string EquipItem(string ReqAccount, string ReqChar, string Account, string Character, string Tag, int InventorySlot)
 {
     try
     {
         string wrURI = baseServerTarget + "equipitem";
         string msg = new EquipRequest(ReqChar, ReqAccount, Character, Account, Tag, InventorySlot, SessionId).ToString();
         WebRequest wreq = WebRequest.Create(wrURI + "?message=" + msg);
         wreq.Method = "POST";
         wreq.ContentLength = 0;
         WebResponse wresp = wreq.GetResponse();
         using (TextReader sr = new StreamReader(wresp.GetResponseStream()))
         {
             XmlSerializer xml = new XmlSerializer(typeof(string), StringNamespace);
             string resp = (string)xml.Deserialize(sr);
             return resp;
         }
     }
     catch { }
     return String.Empty;
 }
Esempio n. 2
0
        public string EquipItem(string message)
        {
            string ret = String.Empty;
            EquipRequest req = new EquipRequest(message);
            Account acct = Account.LoadAccount(req.RequestingAccount);
            if (acct == null)
            {
                return "Error: invalid account";
            }

            string ip = (OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty).Address;
            if (acct.SessionId != req.SessionId || acct.Address != ip)
            {
                return "Error: incorrect address or session Id";
            }

            acct.KeepAlive();
            Character ch = acct.LoadCharacter(req.RequestingCharacter);
            if(ch == null)
            {
                return "Error: invalid character";
            }

            if(!ch.IsDM)
            {
                if(ch.EquipItem(req.InventorySlot, req.Identifier))
                {
                    if(req.InventorySlot == (int)InventorySlot.Chest)
                    {
                        if (Map.LoadedMaps.ContainsKey(ch.Map))
                        {
                            Map.LoadedMaps[ch.Map].ChangeCharacterAppearance(ch);
                        }
                    }
                    return ch.ToString();
                }
                else
                {
                    return "Error: cannot equip item";
                }
            }
            else
            {
                Account tgAcct = Account.LoadAccount(req.ChangedAccount);
                if(tgAcct == null)
                {
                    return "Error: invalid account";
                }
                Character tgCh = tgAcct.LoadCharacter(req.ChangedCharacter);
                if(tgCh == null)
                {
                    return "Error: invalid character";
                }
                if(tgCh.EquipItem(req.InventorySlot, req.Identifier))
                {
                    return ch.ToString();
                }
                else
                {
                    return "Error: cannot equip item";
                }
            }
        }