Exemplo n.º 1
0
 public SpecialStat(StatAttribute attribute, float value, StatAttributeType type) : base(attribute, type, value)
 {
 }
Exemplo n.º 2
0
 protected ItemStat(StatAttribute attribute, StatAttributeType type, float value)
 {
     ItemAttribute = attribute;
     AttributeType = type;
     SetValue(value);
 }
Exemplo n.º 3
0
    private static List <ParserSpecialStat> ParseSpecialStat(StatAttribute attribute, XmlNode node, StatAttributeType type)
    {
        List <ParserSpecialStat> values = new();

        for (int i = 2; i <= 17; i++)
        {
            values.Add(new(attribute, float.Parse(node.Attributes[$"idx{i}"].Value), type));
        }

        return(values);
    }
 public ParserSpecialStat(StatAttribute attribute, float value, StatAttributeType type)
 {
     Attribute     = attribute;
     Value         = value;
     AttributeType = type;
 }
Exemplo n.º 5
0
    public override void Execute(GameCommandTrigger trigger)
    {
        string equipSlot      = trigger.Get <string>("equipSlot");
        string newAttributeId = trigger.Get <string>("newAttributeId");
        float  value          = trigger.Get <float>("value");
        byte   isPercentage   = trigger.Get <byte>("isPercentage");
        byte   category       = trigger.Get <byte>("category");

        if (string.IsNullOrEmpty(equipSlot))
        {
            trigger.Session.SendNotice($"Type '/info {Aliases.First()}' for more details.");
            return;
        }

        if (!Enum.TryParse(equipSlot, ignoreCase: true, out ItemSlot itemSlot) || itemSlot == ItemSlot.NONE)
        {
            trigger.Session.SendNotice($"{equipSlot} is not a valid equip slot.");
            string slots = "";
            foreach (object slot in Enum.GetValues(typeof(ItemSlot)))
            {
                slots += $"{slot} - {((ItemSlot) slot).GetEnumDescription()}, ";
            }

            trigger.Session.SendNotice($"Available slots: {slots.TrimEnd(',', ' ')}");
            return;
        }

        if (!Enum.TryParse(newAttributeId, ignoreCase: true, out StatAttribute newAttribute))
        {
            trigger.Session.SendNotice($"{newAttributeId} is not a valid attribute. Check StatAttribute.cs");
            return;
        }

        Player player = trigger.Session.Player;

        if (!player.Inventory.Equips.TryGetValue(itemSlot, out Item item))
        {
            trigger.Session.SendNotice($"You don't have an item in slot {itemSlot}.");
            return;
        }

        ItemStat          itemStat;
        StatAttributeType attributeType = isPercentage == 1 ? StatAttributeType.Rate : StatAttributeType.Flat;

        if ((int)newAttribute > 11000)
        {
            itemStat = new SpecialStat(newAttribute, value, attributeType);
        }
        else
        {
            itemStat = new BasicStat(newAttribute, value, attributeType);
        }

        if (category == 0)
        {
            if (value == 0)
            {
                item.Stats.Constants.Remove(newAttribute);
            }
            else
            {
                item.Stats.Constants[newAttribute] = itemStat;
            }
        }
        else if (category == 1)
        {
            if (value == 0)
            {
                item.Stats.Statics.Remove(newAttribute);
            }
            else
            {
                item.Stats.Statics[newAttribute] = itemStat;
            }
        }
        else if (category == 2)
        {
            if (value == 0)
            {
                item.Stats.Randoms.Remove(newAttribute);
            }
            else
            {
                item.Stats.Randoms[newAttribute] = itemStat;
            }
        }

        trigger.Session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(player.FieldPlayer, item, itemSlot));

        player.FieldPlayer.ComputeStats();

        DatabaseManager.Items.Update(item);
    }