コード例 #1
0
    protected void LoadPropertyData()
    {
        if (playerInfo != null)
        {
            foreach (Prop stat in statsToDisplay)
            {
                if (stat != null && stat.key != null && stat.key.Length > 0 && playerInfo.attributes.ContainsKey(stat.key))
                {
                    Roar.DomainObjects.PlayerAttribute userStat = playerInfo.attributes[stat.key];
                    stat.UserStat = userStat;
                    if (stat.valueFormat.Length > 0)
                    {
                        stat.Value = string.Format("{0:" + stat.valueFormat + "}", userStat != null ? userStat.value : "null");
                    }
                    else
                    {
                        stat.Value = userStat != null ? userStat.value : null;
                    }

                    if (stat.title == null || stat.title.Length == 0)
                    {
                        stat.title = userStat != null ? userStat.label : "UNKNOWN";
                    }
                }
            }
        }
    }
コード例 #2
0
    protected void LoadPropertyData()
    {
        if (properties != null)
        {
            foreach (Stat stat in statsToDisplay)
            {
                if (stat != null && stat.key != null && stat.key.Length > 0)
                {
                    Roar.DomainObjects.PlayerAttribute userStat = properties.GetProperty(stat.key);
                    stat.UserStat = userStat;

                    if (stat.valueFormat.Length > 0)
                    {
                        stat.Value = string.Format("{0:" + stat.valueFormat + "}", userStat != null ? userStat.value : "null");
                    }
                    //stat.Value = string.Format("{0:"+stat.valueFormat+"}", properties.GetValue(stat.key));
                    else
                    {
                        stat.Value = userStat != null ? userStat.value : null;
                    }
                    //stat.Value = properties.GetValue(stat.key);

                    if (stat.title == null || stat.title.Length == 0)
                    {
                        stat.title = userStat != null ? userStat.label : "UNKNOWN";

                        /*
                         * object statProperty = properties.GetProperty(stat.key);
                         * if (statProperty is Hashtable)
                         * {
                         *      Hashtable property = (Hashtable)statProperty;
                         *      if (property.ContainsKey("label"))
                         *      {
                         *              stat.title = (string)property["label"];
                         *      }
                         * }
                         */
                    }
                    else
                    {
                        //TODO: Why was this here?
                        //userStat.Title = stat.title;
                    }
                }
            }
        }
    }
コード例 #3
0
    public void testGetProperty()
    {
        //returns null on no data from server
        Assert.IsNull(properties.GetProperty("stamina"));

        mockFetch(userView, null);

        //returns Hashtable of property if exists
        Roar.DomainObjects.PlayerAttribute staminaProperty = properties.GetProperty("stamina");
        Assert.IsNotNull(staminaProperty);
        StringAssert.IsMatch("5", staminaProperty.value);
        StringAssert.IsMatch("resource", staminaProperty.type);
        StringAssert.IsMatch("123", staminaProperty.max);
        StringAssert.IsMatch("0", staminaProperty.min);
        StringAssert.IsMatch("1000", staminaProperty.regen_every);
        StringAssert.IsMatch("Stamina", staminaProperty.label);

        //returns null on property not existing
        Assert.IsNull(properties.GetProperty("doesnotexist"));
    }