コード例 #1
0
        /// <summary>
        /// Get a reward list for missions
        /// </summary>
        /// <param name="db"></param>
        /// <param name="misLevelRequire"></param>
        /// <param name="m"></param>
        internal static Items GetRewardForMis(RecommendLevel misLevelRequire, Machines m)
        {
            int probability = MachineLogic.CalculateMachineLuck(m);

            using (DataContext db = new DataContext())
            {
                if (misLevelRequire == 0)
                {
                    Items Reward = GetItemsForRewards(10, 20, probability, db);
                    return(Reward);
                }
                else if (misLevelRequire == (RecommendLevel)1)
                {
                    Items Reward = GetItemsForRewards(11, 25, probability, db);
                    return(Reward);
                }
                else if (misLevelRequire == (RecommendLevel)2)
                {
                    Items Reward = GetItemsForRewards(12, 30, probability, db);
                    return(Reward);
                }
                else if (misLevelRequire == (RecommendLevel)3)
                {
                    Items Reward = GetItemsForRewards(13, 35, probability, db);
                    return(Reward);
                }
                else
                {
                    return(null);
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Delete Item from the User Inventory
 /// </summary>
 /// <param name="UserID"></param>
 /// <param name="ItemID"></param>
 /// <returns></returns>
 public static bool DeleteItemFromUserInv(int UserID, int ItemID)
 {
     using (DataContext db = new DataContext())
     {
         InventoryItem invitem = db.InventoryItem.Where(x => x.UserId == UserID && x.ItemId == ItemID).FirstOrDefault();
         if (invitem.Quantity > 1)
         {
             invitem.Quantity = invitem.Quantity - 1;
             db.SaveChanges();
             return(true);
         }
         else
         {
             if (!MachineLogic.CheckInstalledParts(UserID, ItemID, db))
             {
                 db.InventoryItem.Remove(invitem);
                 db.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
 }