Example #1
0
        private DeliveryCompletion DoDelivery(PlayerWitch p, DeliverySpell del)
        {
            if (!p.CanDeliver(del.Recipe))
            {
                throw new GameException("Not enough ingredients for order " + del.Id);
            }
            for (int i = 0; i < INGREDIENT_TYPE_COUNT; ++i)
            {
                p.Inventory.Add(i, del.Recipe.Delta[i]);
            }
            DeliveryCompletion delCompletion = new DeliveryCompletion(del, _deliveries.IndexOf(del), GetScoreOf(del));

            _delivered.Add(delCompletion);
            p.AddDelivery();
            p.AddScore(GetScoreOf(del));

            EventData e = new EventData();

            e.Type      = EventData.DELIVERY;
            e.PlayerIdx = p.Index;
            e.SpellId   = del.Id;
            _viewerEvents.Add(e);
            return(delCompletion);
        }