示例#1
0
        private void HandlePutMailTransactionEnd(IEventData eventData, SendParameters sendParameters)
        {
            PUTInventoryItemTransactionEnd endTransaction = new PUTInventoryItemTransactionEnd(eventData);

            switch ((TransactionSource)endTransaction.transactionSource)
            {
            case TransactionSource.Inaps: {
                application.inaps.putTransactionPool.HandleTransaction(endTransaction);
            }
            break;
            }
        }
示例#2
0
        public void HandleTransaction(PUTInventoryItemTransactionEnd end)
        {
            string id = end.gameRefID;

            lock (syncRoot) {
                foreach (var pClient in this)
                {
                    if (pClient.Value.id == id)
                    {
                        pClient.Value.putPool.HandleTransaction(end);
                        break;
                    }
                }
            }
        }
示例#3
0
        private void HandlePUTInventoryTransactionEnd(IEventData eventData, SendParameters sendParameters)
        {
            PUTInventoryItemTransactionEnd end = new PUTInventoryItemTransactionEnd(eventData);

            switch ((TransactionSource)end.transactionSource)
            {
            case TransactionSource.Store:
            {
                log.InfoFormat("Handle PUT Inventory transaction end with Store source");
                application.Stores.inventoryPUTPool.HandleTransaction(end);
                break;
            }

            case TransactionSource.Mail:
            {
                log.InfoFormat("Handle PUT Inventory transaction end with MAIL source");
                application.Mail.inventoryPUTPool.HandleTransaction(end);
                break;
            }

            case TransactionSource.Bank:
            {
                log.InfoFormat("handle put bank transaction returned");
                application.Clients.HandleTransaction(end);
                break;
            }

            case TransactionSource.PvpStore:
            {
                application.pvpStore.putTransactionPool.HandleTransaction(end);
                log.InfoFormat("transaction handled for buy pvp store item [red]");
            }
            break;

            default:
            {
                log.ErrorFormat("Unsopprted PUT transaction source = {0}", (TransactionSource)end.transactionSource);
                break;
            }
            }
        }
示例#4
0
        public bool HandleTransaction(PUTInventoryItemTransactionStart transactionStart, PUTInventoryItemTransactionEnd transactionEnd)
        {
            if (transactionEnd.success)
            {
                PlayerStore store;
                if (!mPlayerStoreCache.TryGetValue(transactionEnd.characterID, out store))
                {
                    return(false);
                }

                switch ((PostTransactionAction)transactionStart.postTransactionAction)
                {
                case PostTransactionAction.BuyStoreItem:
                {
                    int price = (int)transactionStart.tag;
                    if (store.RemoveCredits(price))
                    {
                        SendConsumablePurchaseStatus(transactionStart.gameRefID, true);
                        return(true);
                    }
                    SendConsumablePurchaseStatus(transactionStart.gameRefID, false);
                    return(false);
                }

                default:
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
 public bool HandleTransaction(PUTInventoryItemTransactionStart transactionStart, PUTInventoryItemTransactionEnd transactionEnd)
 {
     if (transactionEnd.success)
     {
         //after putting item to station remove item from bank
         if (transactionStart.postTransactionAction == (byte)PostTransactionAction.WithdrawFromBank)
         {
             if (bank != null)
             {
                 bank.RemoveItem(transactionStart.itemID, transactionStart.count);
                 SendBankUpdate();
                 return(true);
             }
         }
     }
     return(false);
 }
示例#6
0
    private void HandlePUTInventoryItemStart(IEventData eventData, SendParameters sendParameters)
    {
        //log.Info("HandlePUTInventoryItemStart: PUT inventory item event received");
        PUTInventoryItemTransactionStart start = new PUTInventoryItemTransactionStart(eventData);

        try {
            MmoActor player;
            if (!m_App.serverActors.TryGetValue(start.gameRefID, out player))
            {
                log.InfoFormat("HandlePUTInventoryItemStart: player = {0} not founded on server", start.gameRefID);
                return;
            }

            PUTInventoryItemTransactionEnd end = new PUTInventoryItemTransactionEnd {
                characterID            = start.characterID,
                gameRefID              = start.gameRefID,
                inventoryType          = start.inventoryType,
                itemID                 = start.itemID,
                count                  = start.count,
                transactionID          = start.transactionID,
                transactionSource      = start.transactionSource,
                transactionStartServer = start.transactionStartServer,
                transactionEndServer   = start.transactionEndServer
            };

            InventoryType invType = (InventoryType)start.inventoryType;
            if (invType == InventoryType.ship || invType == InventoryType.station)
            {
                var inventory  = (invType == InventoryType.ship) ? player.Inventory : player.Station.StationInventory;
                int count      = 0;
                var itemObject = InventoryUtils.Create(start.targetObject as Hashtable, out count);
                count = start.count;

                if (!inventory.EnoughSpace(new Dictionary <string, InventoryObjectType> {
                    { itemObject.Id, itemObject.Type }
                }))
                {
                    end.success = false; end.result = 1; end.returnCode = (short)ReturnCode.NotEnoughInventorySpace;
                }
                else
                {
                    if (!inventory.Add(itemObject, count))
                    {
                        end.success = false; end.result = 1; end.returnCode = (short)ReturnCode.ErrorAddingToInventory;
                    }
                    else
                    {
                        end.success = true; end.result = 0; end.returnCode = (short)ReturnCode.Ok;
                    }
                    player.EventOnInventoryUpdated();
                    player.EventOnStationHoldUpdated();
                }
            }

            EventData evt = new EventData((byte)S2SEventCode.PUTInventoryItemEnd, end);
            SendEvent(evt, sendParameters);
            log.InfoFormat("HandlePUTInventoryItemStart: transaction end sended with success = {0}", end.success);
        } catch (Exception exception) {
            log.Info("exception");
            log.Info(exception.Message);
            log.Info(exception.StackTrace);
        }
    }