Esempio n. 1
0
 private void FinalScore()
 {
     Words.CurrentTime = DateTime.Now;
     if (Words.Score == 0)
     {
         Log.Info(tag, "You can do better than that");
     }
     else if (Words.Score > 0)
     {
         // add score to the database
         db.AddItem();
         Log.Info(tag, "Data added to Database");
     }
 }
Esempio n. 2
0
        public bool TrySplit(int amount, out Item splitItem)
        {
            if (Amount <= amount)
            {
                splitItem = null;
                return(false);
            }

            splitItem        = new Item(this);
            Amount          -= amount;
            splitItem.Amount = amount;
            splitItem.Slot   = -1;
            splitItem.Uid    = DatabaseManager.AddItem(this);
            return(true);
        }
Esempio n. 3
0
 public Item(int id)
 {
     Id = id;
     SetMetadataValues(id);
     Level                 = ItemMetadataStorage.GetLevel(id);
     ItemSlot              = ItemMetadataStorage.GetSlot(id);
     Rarity                = ItemMetadataStorage.GetRarity(id);
     PlayCount             = ItemMetadataStorage.GetPlayCount(id);
     Color                 = ItemMetadataStorage.GetEquipColor(id);
     CreationTime          = DateTimeOffset.Now.ToUnixTimeSeconds();
     RemainingGlamorForges = ItemExtractionMetadataStorage.GetExtractionCount(id);
     Slot         = -1;
     Amount       = 1;
     Score        = new MusicScore();
     Stats        = new ItemStats(id, Rarity, Level, IsTwoHand);
     CanRepackage = true; // If false, item becomes untradable
     Uid          = DatabaseManager.AddItem(this);
 }
Esempio n. 4
0
        private void OnBtnAddClick(object sender, EventArgs e)
        {
            Log.Info(tag, "OnBtnAddClick");

            //if you forget to add a name remind the person
            if (txtAddName.Text == "")
            {
                Toast.MakeText(this, "Please add Your Name and ty again. ", ToastLength.Long).Show();
                //get abusive
                txtAddName.Text = "Anonymous Coward";
                return;
            }

            //if all the fields have something in them might be redundant with other checks
            if (txtAddName.Text != "" && Words.Score.ToString() != "" && Words.Word != "")
            {
                Words.Name = txtAddName.Text;
                db.AddItem();
                Toast.MakeText(this, "Score Added", ToastLength.Long).Show();
                this.Finish();
                StartActivity(typeof(Scores));
            }
            Toast.MakeText(this, "Borked! Name = " + Words.Name + " Score = " + Words.Score + " Word = " + Words.Word, ToastLength.Long).Show();
        }
        // Adds item
        public static void Add(GameSession session, Item item, bool isNew)
        {
            // Checks if item is stackable or not
            if (item.StackLimit > 1)
            {
                foreach (Item i in session.Player.Inventory.Items.Values)
                {
                    // Checks to see if item exists in database (dictionary)
                    if (i.Id != item.Id || i.Amount >= i.StackLimit)
                    {
                        continue;
                    }
                    // Updates inventory for item amount overflow
                    if ((i.Amount + item.Amount) > i.StackLimit)
                    {
                        int added = i.StackLimit - i.Amount;
                        item.Amount -= added;
                        i.Amount     = i.StackLimit;
                        session.Send(ItemInventoryPacket.Update(i.Uid, i.Amount));
                        session.Send(ItemInventoryPacket.MarkItemNew(i, added));
                    }
                    // Updates item amount
                    else
                    {
                        i.Amount += item.Amount;
                        session.Send(ItemInventoryPacket.Update(i.Uid, i.Amount));
                        session.Send(ItemInventoryPacket.MarkItemNew(i, item.Amount));
                        return;
                    }
                }

                if (!session.Player.Inventory.Add(item)) // Adds item into internal database
                {
                    return;
                }
                session.Send(ItemInventoryPacket.Add(item)); // Sends packet to add item clientside
                if (isNew)
                {
                    session.Send(ItemInventoryPacket.MarkItemNew(item, item.Amount)); // Marks Item as New
                }
                return;
            }

            if (item.Amount == 1)
            {
                if (!session.Player.Inventory.Add(item))
                {
                    return;
                }

                session.Send(ItemInventoryPacket.Add(item));
                if (isNew)
                {
                    session.Send(ItemInventoryPacket.MarkItemNew(item, item.Amount));
                }
                return;
            }

            for (int i = 0; i < item.Amount; i++)
            {
                Item newItem = new Item(item)
                {
                    Amount = 1,
                    Slot   = (short)(session.Player.Inventory.SlotTaken(item, item.Slot) ? -1 : item.Slot),
                    Uid    = 0
                };
                newItem.Uid = DatabaseManager.AddItem(newItem);

                if (!session.Player.Inventory.Add(newItem))
                {
                    continue;
                }

                session.Send(ItemInventoryPacket.Add(item));
                if (isNew)
                {
                    session.Send(ItemInventoryPacket.MarkItemNew(item, item.Amount));
                }
            }
        }