Пример #1
0
        public int CreateItem(string name, string description, float attackBoost, float defenseBoost)
        {
            int result = 0;

            try
            {
                result = InventoryAccessor.AddItem(name, description, attackBoost, defenseBoost);
            }
            catch (Exception ex)
            {
                throw new ApplicationException("There was a problem connecting to the server.", ex);
            }

            return(result);
        }
 public void EndExplorer(int[] inventoryIds, LogExplorerType result)
 {
     if (result == LogExplorerType.Start)
     {
         throw new Exception("Invalid exploration end state");
     }
     if (result == LogExplorerType.FinishImpact)
     {
         if (inventoryIds.Length > 10)
         {
             throw new Exception("The number of selected items must not exceed 100");
         }
         foreach (var id in inventoryIds)
         {
             _inventory.AddItem(id, _explorer.State.Inventory[id]);
         }
     }
     _battle.State.Data = null;
     LogicLog.SetExplorer(_explorer.State.StageId, result);
     _explorerLogic.FinishExplorer(result == LogExplorerType.FinishImpact);
 }
Пример #3
0
        public void Drop(IDropItem drop)
        {
            var value = (int)_formula.Calculate(drop.Value);

            switch (drop.Item.Type)
            {
            case DropType.Inventory:
                _inventory.AddItem(drop.Item.ItemId, value);
                break;

            case DropType.Money:
                var data1 = _scorers.Static.MoneyTypes[drop.Item.MoneyId];
                var dict  = _scorers.State.Values;
                dict.TryGetValue(data1.ScorerId, out var oldValue);
                dict[data1.ScorerId] = oldValue + value;
                if (data1.AchievScorerId != 0)
                {
                    if (!dict.ContainsKey(data1.AchievScorerId))
                    {
                        dict[data1.AchievScorerId] = 0;
                    }
                    dict[data1.AchievScorerId] += value;
                }
                break;

            case DropType.Shard:
                _units.AddUnitShard(drop.Item.UnitId, value);
                var data = _units.State.Units.FirstOrDefault(x => x.Id == drop.Item.UnitId);
                if (data != null)
                {
                    TryUpdateNullRarity(data);
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }