GetUserCurrency() private method

private GetUserCurrency ( UUID agentId ) : WhiteCore.Modules.Currency.UserCurrency
agentId UUID
return WhiteCore.Modules.Currency.UserCurrency
Beispiel #1
0
        public XmlRpcResponse PreflightBuyLandPrepFunc(XmlRpcRequest request, IPEndPoint ep)
        {
            Hashtable      requestData = (Hashtable)request.Params [0];
            XmlRpcResponse ret         = new XmlRpcResponse();
            Hashtable      retparam    = new Hashtable();

            Hashtable membershiplevels = new Hashtable();

            membershiplevels.Add("levels", membershiplevels);

            Hashtable landuse = new Hashtable();

            Hashtable level = new Hashtable {
                { "id", "00000000-0000-0000-0000-000000000000" },
                { m_connector.GetConfig().UpgradeMembershipUri, "Premium Membership" }
            };

            if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy"))
            {
                UUID agentId;
                UUID.TryParse((string)requestData ["agentId"], out agentId);
                UserCurrency     currency = m_connector.GetUserCurrency(agentId);
                IUserProfileInfo profile  =
                    Framework.Utilities.DataManager.RequestPlugin <IProfileConnector> ("IProfileConnector").GetUserProfile(agentId);
                OSDMap   replyData = null;
                bool     response  = false;
                UserInfo user      = m_agentInfoService.GetUserInfo(agentId.ToString());
                if (user == null)
                {
                    landuse.Add("action", false);

                    retparam.Add("success", false);
                    retparam.Add("currency", currency);
                    retparam.Add("membership", level);
                    retparam.Add("landuse", landuse);
                    retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf");
                    ret.Value = retparam;
                }
                else
                {
                    OSDMap map = new OSDMap();
                    map ["Method"]  = "GetLandData";
                    map ["AgentID"] = agentId;
                    m_syncMessagePoster.Get(user.CurrentRegionURI, map, (o) => {
                        replyData = o;
                        response  = true;
                    });
                    while (!response)
                    {
                        Thread.Sleep(10);
                    }
                    if (replyData == null || replyData ["Success"] == false)
                    {
                        landuse.Add("action", false);

                        retparam.Add("success", false);
                        retparam.Add("currency", currency);
                        retparam.Add("membership", level);
                        retparam.Add("landuse", landuse);
                        retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf");
                        ret.Value = retparam;
                    }
                    else
                    {
                        if (replyData.ContainsKey("SalePrice"))
                        {
                            int  landTierNeeded = (int)(currency.LandInUse + replyData ["Area"].AsInteger());
                            bool needsUpgrade   = false;
                            switch (profile.MembershipGroup)
                            {
                            case "Premium":
                            case "":
                                needsUpgrade = landTierNeeded >= currency.Tier;
                                break;

                            case "Banned":
                                needsUpgrade = true;
                                break;
                            }
                            landuse.Add("action", needsUpgrade);
                            retparam.Add("success", true);
                            retparam.Add("currency", currency);
                            retparam.Add("membership", level);
                            retparam.Add("landuse", landuse);
                            retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf");
                            ret.Value = retparam;
                        }
                    }
                }
            }

            return(ret);
        }
Beispiel #2
0
 public int Balance(UUID agentID)
 {
     return((int)m_connector.GetUserCurrency(agentID).Amount);
 }