Ejemplo n.º 1
0
        private void BuildTree()
        {
            var rootGuid = EditorUtils.GetScriptOutput("studio.project.workspace.masterEventFolder.id");

            rootFolder      = new FolderEntry();
            rootFolder.guid = rootGuid;
            BuildTreeItem(rootFolder);
            wantsMouseMove = true;
            banks          = new List <BankEntry>();

            EditorUtils.GetScriptOutput("children = \"\";");
            EditorUtils.GetScriptOutput("func = function(val) {{ children += \",\" + val.id + val.name; }};");
            EditorUtils.GetScriptOutput("studio.project.workspace.masterBankFolder.items.forEach(func, this); ");
            string bankList = EditorUtils.GetScriptOutput("children;");

            string[] bankListSplit = bankList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var bank in bankListSplit)
            {
                var entry = new BankEntry();
                entry.guid = bank.Substring(0, 38);
                entry.name = bank.Substring(38);
                banks.Add(entry);
            }

            banks.Sort((a, b) => a.name.CompareTo(b.name));
        }
        public BankDataSheet TransformTsv(FileInfo file)
        {
            BankDataSheet sheet = new BankDataSheet();

            string account = this.GetAccount(file);

            string[] lines = File.ReadAllLines(file.FullName);

            foreach (string line in lines)
            {
                string[] data = line.Split('\t', StringSplitOptions.RemoveEmptyEntries);

                BankEntry entry = new BankEntry()
                {
                    Account     = account,
                    Date        = this.GetDate(data),
                    Amount      = this.GetAmount(data),
                    Balance     = 0,
                    Currency    = this.GetCurrency(data),
                    FullDetails = this.GetDescription(data),
                    PaymentType = this.mapper.Map("Płatność kartą"),
                };

                entry.Payer     = this.mapper.Map(this.GetPayer(entry));
                entry.Recipient = this.mapper.Map(this.GetRecipient(data, entry));
                entry.Note      = this.mapper.Map(this.GetDescription(data));
                sheet.Entries.Add(entry);
            }

            return(sheet);
        }
Ejemplo n.º 3
0
        private List <Myorder> FindRefundEntries(BankEntry entry, ref List <Offer> offersMatchingPrice, List <Myorder> allegroEntries)
        {
            List <Myorder> dateFilteredEntries;

            //if it's a refund, then we have one more chance of finding the right one
            //the refund must have happened AFTER the purchase
            dateFilteredEntries = allegroEntries.Where(x => x.payment.endDate.Date < entry.Date).ToList();

            if (dateFilteredEntries.Count != 1)
            {
                //so now we have a potentially long list of entries purchased at the same price (e.g. 9.99),
                //so we cannot figure out which one was actually refunded.
                //too bad there is no refund note or reference
                offersMatchingPrice = dateFilteredEntries
                                      .SelectMany(x => x.offers.Where(x =>
                                                                      this.converter.ToDecimal(x.offerPrice.amount) == this.converter.ToDecimal(entry.Amount.ToString().Trim('-')))
                                                  ).ToList();

                return(null);
            }
            else
            {
                return(dateFilteredEntries);
            }
        }
        public BankDataSheet TransformXml(XDocument xDocument, string accountName)
        {
            BankDataSheet sheet = new BankDataSheet();

            foreach (XElement operation in xDocument.Descendants("Transaction"))
            {
                BankEntry entry = new BankEntry()
                {
                    Account     = accountName,
                    Date        = this.GetDate(operation),
                    Amount      = this.GetAmount(operation),
                    Balance     = 0,
                    Currency    = "PLN",
                    Note        = this.GetDescription(operation)?.Replace("  ", ""),
                    FullDetails = this.GetDescription(operation),
                    PaymentType = this.mapper.Map(this.GetPaymentType(operation)),
                };

                entry.Payer     = this.mapper.Map(this.GetPayer(entry, operation));
                entry.Recipient = this.mapper.Map(this.GetRecipient(entry, operation));
                sheet.Entries.Add(entry);
            }

            return(sheet);
        }
Ejemplo n.º 5
0
        private void HandlePartialRefunds(BankEntry entry, List <BankEntry> updatedEntries, Myorder order,
                                          AllegroDataContainer container)
        {
            List <Offer> offersWithProperPrice =
                order.offers.Where(x => this.converter.ToDecimal(x.offerPrice.amount) == entry.Amount).ToList();

            if (offersWithProperPrice.Any())
            {
                if (offersWithProperPrice.Count == 1)
                {
                    Offer     offer    = offersWithProperPrice.First();
                    BankEntry newEntry = BankEntry.Clone(entry);

                    newEntry.Note = $"ZWROT: {offer.title} (Ilość sztuk: {offer.quantity}, Oferta {offer.id})";

                    newEntry.Payer        = "allegro.pl - " + order.seller.login;
                    newEntry.Recipient    = container.ServiceUserName;
                    newEntry.FullDetails += $"\r\nPłatność Allegro: {order.payment.id}.\r\n URL: {offer.friendlyUrl}";
                    updatedEntries.Add(newEntry);
                }
                else
                {
                    BankEntry newEntry = BankEntry.Clone(entry);

                    newEntry.Note = "ZWROT pasujący do jednej z ofert: " +
                                    string.Join("\r\n", offersWithProperPrice.Select(x => x.title));

                    newEntry.Payer        = "allegro.pl - " + order.seller.login;
                    newEntry.Recipient    = container.ServiceUserName;
                    newEntry.FullDetails += $"\r\nPłatność Allegro: {order.payment.id}.\r\n{newEntry.Note}";
                    updatedEntries.Add(newEntry);
                }
            }
        }
Ejemplo n.º 6
0
    private void doTimeOver()
    {
        if (!gameOver)
        {
            hideScoreAndTime();

            //Stop character
            m_Character.m_MoveSpeedMultiplier = 0;
            m_Character.m_AnimSpeedMultiplier = 0;

            //Change text
            gameOverUI.GetComponentInChildren <Text>().text = "Times Up!";

            //Show game over screen
            Animator gameOverAnim = gameOverUI.GetComponent <Animator>();
            gameOverAnim.SetTrigger("game_over");

            BankEntry be = new BankEntry(ScoreText.runnerScore, "Earned", DateTime.Now);

            GameManager.instance.getPlayerData().addBankEntry(be);
            GameManager.instance.saveGame();

            gameOver = true;
        }
    }
        public BankDataSheet TransformXml(XDocument xDocument)
        {
            BankDataSheet sheet = new BankDataSheet();

            string account = this.GetAccount(xDocument);

            foreach (XElement operation in xDocument.Descendants("operation"))
            {
                BankEntry entry = new BankEntry()
                {
                    Account     = account,
                    Date        = this.GetDate(operation),
                    Amount      = this.GetAmount(operation),
                    Balance     = this.GetBalance(operation),
                    Currency    = this.GetCurrency(operation),
                    FullDetails = this.GetDescription(operation),
                    PaymentType = this.mapper.Map(this.GetPaymentType(operation)),
                };

                entry.Payer     = this.mapper.Map(this.GetPayer(entry, operation));
                entry.Recipient = this.mapper.Map(this.GetRecipient(entry, operation));
                entry.Note      = this.mapper.Map(this.GetNote(entry, operation));
                MakeSureRecipientNotEmpty(entry);
                sheet.Entries.Add(entry);
            }

            return(sheet);
        }
Ejemplo n.º 8
0
        private List <Myorder> GetAllegroEntries(BankEntry entry, AllegroData model, out List <Offer> offersMatchingPrice)
        {
            offersMatchingPrice = null;
            List <Myorder> allegroOrders = FindOrdersWhichMatchEntryPriceFullyOrPartially(entry, model);

            if (allegroOrders.Count == 0)
            {
                return(null);
            }
            if (allegroOrders.Count == 1)
            {
                return(allegroOrders);
            }
            else
            {
                List <Myorder> dateFilteredEntries = allegroOrders.Where(x => x.payment.endDate.Date == entry.Date.Date).ToList();
                if (dateFilteredEntries.Count < 1)
                {
                    return(FindRefundEntries(entry, ref offersMatchingPrice, allegroOrders));
                }
                else
                {
                    return(FindProperEntriesBasedOnDateTime(entry, dateFilteredEntries));
                }
            }
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Edit([FromBody] BankEntry pModel)
        {
            // Validation
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (Validate(pModel, true) == false)
            {
                return(BadRequest(ModelState));
            }
            else
            {
                // Execution of concrete process
                SQLResult result = new SQLResult();
                result = await _repo.Edit(pModel);

                if (result.ErrorNo > 0)
                {
                    return(BadRequest(result));
                }
                else
                {
                    return(Ok(result));
                }
            }
        }
Ejemplo n.º 10
0
    private void buyItem1()
    {
        BankEntry bought = new BankEntry(-price1, "Bought first upgrade", DateTime.Now);

        player.addBankEntry(bought);
        player.setUpgradeIndex(0);
    }
Ejemplo n.º 11
0
 private bool Validate(BankEntry pModel, bool isUpdateValidation)
 {
     if (isUpdateValidation == true)
     {
         if (pModel.BankId <= 0)
         {
             ModelState.AddModelError("", Messages.Blank("Bank entry"));
             return(false);
         }
     }
     if (pModel.Bank.Trim().Length == 0)
     {
         ModelState.AddModelError("", Messages.Blank("Bank"));
         return(false);
     }
     if (pModel.BankReferenceNo.Trim().Length == 0)
     {
         ModelState.AddModelError("", Messages.Blank("Bank reference number"));
         return(false);
     }
     if (pModel.BankClearingNo.Trim().Length == 0)
     {
         ModelState.AddModelError("", Messages.Blank("Bank clearing number"));
         return(false);
     }
     return(true);
 }
Ejemplo n.º 12
0
    private void buyItem2()
    {
        BankEntry bought = new BankEntry(-price2, "Bought second upgrade", DateTime.Now);

        player.addBankEntry(bought);
        player.setUpgradeIndex(1);
    }
Ejemplo n.º 13
0
    private void buyItem3()
    {
        BankEntry bought = new BankEntry(-price3, "Bought third upgrade", DateTime.Now);

        player.addBankEntry(bought);
        player.setUpgradeIndex(2);
    }
Ejemplo n.º 14
0
        public void EnrichAllegroEntry(BankEntry entry, List <AllegroDataContainer> allData, List <BankEntry> updatedEntries, out decimal discount)
        {
            discount = 0;
            List <Myorder> relevantOrders = this.GetRelevantOrders(entry, allData, out AllegroDataContainer container,
                                                                   out List <Offer> potentiallyRelatedOfferIds);

            if (relevantOrders != null && relevantOrders.Any())
            {
                foreach (Myorder order in relevantOrders)
                {
                    if (entry.Amount == order.GetAmount(converter))
                    {
                        for (int offerIndex = 0; offerIndex < order.offers.Length; offerIndex++)
                        {
                            BankEntry newEntry = PrepareNewBankEntryForOffer(order, offerIndex, entry, container);

                            updatedEntries.Add(newEntry);
                        }
                    }
                    else
                    {
                        HandlePartialRefunds(entry, updatedEntries, order, container);
                    }
                }
            }
            else
            {
                //that's either not Allegro entry or not entry of this person, but needs to be preserved on the list
                EnrichUnrecognizedAllegroOffer(entry, container, potentiallyRelatedOfferIds);
                updatedEntries.Add(entry);
            }
        }
Ejemplo n.º 15
0
        public void EnrichAllegroEntry(BankEntry entry, List <AllegroDataContainer> allData, List <BankEntry> updatedEntries, out decimal buyerPaidAmount)
        {
            buyerPaidAmount = 0;
            List <Myorder> relevantOrders = this.GetRelevantOrders(entry, allData, out AllegroDataContainer container);



            if (relevantOrders != null && relevantOrders.Any())
            {
                buyerPaidAmount = this.CalculateTotalAmount(relevantOrders);
                //multiple orders can be covered by a single payment
                foreach (Myorder order in relevantOrders)
                {
                    for (int offerIndex = 0; offerIndex < order.offers.Length; offerIndex++)
                    {
                        BankEntry newEntry = PrepareNewBankEntryForOffer(order, offerIndex, entry, container);
                        updatedEntries.Add(newEntry);
                    }
                    AddDeliveryCost(entry, updatedEntries, order, container);
                }
            }
            else
            {
                //that's either not Allegro entry or not entry of this person, but needs to be preserved on the list
                EnrichUnrecognizedAllegroOffer(entry);
                updatedEntries.Add(entry);
            }
        }
Ejemplo n.º 16
0
        private void AddDeliveryCost(BankEntry entry, List <BankEntry> updatedEntries, Myorder allegroEntry,
                                     AllegroDataContainer container)
        {
            if (allegroEntry.delivery.cost.amount != "0.00")
            {
                //lets add a delivery cost as a separate entry, but assign it a category etc. of the most expensive item
                Offer mostExpensive =
                    allegroEntry.offers.OrderByDescending(x => this.converter.ToDecimal(x.offerPrice.amount)).First();

                BankEntry deliveryEntry = BankEntry.Clone(entry);
                deliveryEntry.Amount = this.converter.ToDecimal(allegroEntry.delivery.cost.amount) * -1;
                deliveryEntry.Note   =
                    $"DOSTAWA: {mostExpensive.title} (Oferta {mostExpensive.id}, Suma zamówień: {allegroEntry.offers.Length})";
                deliveryEntry.Recipient = "allegro.pl - " + allegroEntry.seller.login;
                deliveryEntry.Tags.Add("dostawa");
                if (string.IsNullOrEmpty(deliveryEntry.Payer))
                {
                    deliveryEntry.Payer = container.ServiceUserName;
                }

                deliveryEntry.FullDetails +=
                    $"\r\nPłatność Allegro: {allegroEntry.payment.id}.\r\n URL: {mostExpensive.friendlyUrl}";
                updatedEntries.Add(deliveryEntry);
            }
        }
Ejemplo n.º 17
0
        private static List <Myorder> FindProperEntriesBasedOnDateTime(BankEntry entry, List <Myorder> dateFilteredEntries)
        {
            string paymentId = dateFilteredEntries.First().payment.id;

            if (dateFilteredEntries.All(x => paymentId == x.payment.id))
            {
                //that's all the orders from the same payment, so it's one big purchase
                return(dateFilteredEntries);
            }
            else
            {
                //we have multiple purchases for the same amount on the same date - lets try finding matching timestamp (if timestamp is available)
                DateTime       entryTimeUtc        = entry.Date.ToUniversalTime();
                List <Myorder> timeMatchingEntries = dateFilteredEntries
                                                     .Where(x => x.payment.endDate > entryTimeUtc && x.payment.startDate < entryTimeUtc).ToList();

                if (timeMatchingEntries.Count == 1)
                {
                    return(timeMatchingEntries);
                }
                else
                {
                    var orderedByTime = timeMatchingEntries.OrderBy(x => x.payment.endDate);
                    return(orderedByTime.Take(1).ToList());
                }
            }
        }
Ejemplo n.º 18
0
    public void payBill(int billIndex)
    {
        Bill      theBill  = player.getBillList()[billIndex];
        BankEntry newEntry = new BankEntry(-theBill.getAmount(), theBill.getDescription(), DateTime.Now);

        player.getBillList()[billIndex].payBill();
        addBankEntry(newEntry);
    }
 private string GetRecipient(string[] line, BankEntry entry)
 {
     if (entry.PaymentType == "Spłata należności - Dziękujemy")
     {
         return(this.mapper.Map(entry.Account));
     }
     return(line[1] + ", " + line[2]);
 }
Ejemplo n.º 20
0
    private void buyItem4()
    {
        BankEntry bought = new BankEntry(-price4, "Upgrade4", DateTime.Now);

        player.addBankEntry(bought);
        player.setUpgradeIndex(3);
        chosenUpgrade4();
    }
        private string GetPayer(BankEntry entry)
        {
            if (entry.PaymentType == "Płatność kartą" ||
                entry.PaymentType == "Spłata należności - Dziękujemy")
            {
                return(this.mapper.Map(entry.Account));
            }

            return("");
        }
Ejemplo n.º 22
0
 private static void EnrichUnrecognizedAllegroOffer(BankEntry entry)
 {
     if (entry.Note == entry.FullDetails)
     {
         entry.Note = AllegroBankDataEnricher.UnrecognizedEntry;
     }
     else
     {
         entry.Note = AllegroBankDataEnricher.UnrecognizedEntry + " - " + entry.Note;
     }
 }
 private static void MakeSureRecipientNotEmpty(BankEntry entry)
 {
     if (string.IsNullOrEmpty(entry.Recipient) && entry.PaymentType == "Płatność kartą")
     {
         entry.Recipient = entry.Note;
     }
     if (string.IsNullOrEmpty(entry.Recipient) && entry.Amount > 0)
     {
         entry.Recipient = entry.Account;
     }
 }
Ejemplo n.º 24
0
    private void addMoneyOnClick(int i, float tempMoney)
    {
        Debug.Log("added Money: " + tempMoney);
        BankEntry tempEntry = new BankEntry(tempMoney, "Reward", true);                 //create a temporary entry to add,set isReward to true

        GameManager.instance.getPlayerData().addBankEntry(tempEntry);                   //add the temp entry to the player BankEntry
        GameManager.instance.getPlayerData().setRewardsClaimed(i, true);                //set the rewardsClaimed[i] to true;
        ribbons[i / 3].GetComponent <Button>().onClick.RemoveListener(() => something());
        ribbons[i / 3].GetComponent <Button>().interactable = false;                    //disable the button
        StartCoroutine(ShowPopup("you just got $" + tempMoney + " as a reward", 3));
        GameManager.instance.saveGame();
    }
Ejemplo n.º 25
0
        public async Task <SQLResult> Create(BankEntry pModel)
        {
            SQLResult result = new SQLResult();

            _Context.Database.BeginTransaction();
            try
            {
                string csql = @" EXEC spmBankInsert
                    @pi_Bank
                    , @pi_BankReferenceNo
                    , @pi_BankClearingNo
                    , @pi_CashAccount
                    , @pi_UserId
                    , @pi_HostName
                    , @pi_IPAddress
                    , @pi_DeviceType
                    , @pi_MACAddress
                    , @pi_typ_mBankDetail";
                List <SqlParameter> sqlparam = new List <SqlParameter>()
                {
                    new SqlParameter("@pi_Bank", pModel.Bank),
                    new SqlParameter("@pi_BankReferenceNo", pModel.BankReferenceNo),
                    new SqlParameter("@pi_BankClearingNo", pModel.BankClearingNo),
                    new SqlParameter("@pi_CashAccount", pModel.CashAccount),
                    new SqlParameter("@pi_UserId", pModel.AuditColumns.UserId),
                    new SqlParameter("@pi_HostName", pModel.AuditColumns.HostName),
                    new SqlParameter("@pi_IPAddress", pModel.AuditColumns.IPAddress),
                    new SqlParameter("@pi_DeviceType", pModel.AuditColumns.DeviceType),
                    new SqlParameter("@pi_MACAddress", pModel.AuditColumns.MACAddress),
                    new SqlParameter("@pi_typ_mBankDetail", pModel.BankDetailEntry),
                };
                result = await _Context.DBResult.FromSql(csql, sqlparam.ToArray()).SingleOrDefaultAsync();

                if (result.ErrorNo != 0)
                {
                    _Context.Database.RollbackTransaction();
                }
                else
                {
                    _Context.Database.CommitTransaction();
                }
            }
            catch (Exception ex)
            {
                _Context.Database.RollbackTransaction();
                result.ErrorNo         = 9999999999;
                result.ErrorMessage    = ex.Message.ToString();
                result.SQLErrorNumber  = ex.HResult;
                result.SQLErrorMessage = ex.Source.ToString();
            }
            return(result);
        }
Ejemplo n.º 26
0
        private void AssignIncomeCategories(BankEntry bankEntry)
        {
            bool isAssigned = false;

            foreach (CategoryMap category in this.incomeCategories)
            {
                foreach (SubcategoryMap subcategory in category.Subcategories)
                {
                    foreach (string keyword in subcategory.MapFrom)
                    {
                        try
                        {
                            if (bankEntry.Payer.ContainsNationalUnaware(keyword) ||
                                bankEntry.PaymentType.ContainsNationalUnaware(keyword) ||
                                bankEntry.Note.ContainsNationalUnaware(keyword))
                            {
                                bankEntry.Subcategory = subcategory.Name;
                                bankEntry.Category    = category.Name;
                                isAssigned            = true;
                                break;
                            }
                        }
                        catch (Exception e)
                        {
                            this.logger.Debug(e.ToString());
                        }
                    }
                }

                if (!isAssigned)
                {
                    foreach (string keyword in category.MapFrom)
                    {
                        try
                        {
                            if (bankEntry.Payer.ContainsNationalUnaware(keyword) ||
                                bankEntry.PaymentType.ContainsNationalUnaware(keyword) ||
                                bankEntry.Note.ContainsNationalUnaware(keyword))
                            {
                                bankEntry.Category = category.Name;
                                break;
                            }
                        }
                        catch (Exception e)
                        {
                            this.logger.Debug(e.ToString());
                        }
                    }
                }
            }
        }
Ejemplo n.º 27
0
        private BankEntry PrepareNewBankEntryForOffer(Myorder allegroEntry, int offerIndex, BankEntry entry,
                                                      AllegroDataContainer container)
        {
            Offer     offer    = allegroEntry.offers[offerIndex];
            BankEntry newEntry = BankEntry.Clone(entry);

            newEntry.Amount = this.converter.ToDecimal(offer.offerPrice.amount);

            newEntry.Note = $"ZWROT: {offer.title} (Ilość sztuk: {offer.quantity}, Oferta {offer.id}, Pozycja {offerIndex + 1}/{allegroEntry.offers.Length})";

            newEntry.Payer        = "allegro.pl - " + allegroEntry.seller.login;
            newEntry.Recipient    = container.ServiceUserName;
            newEntry.FullDetails += $"\r\nPłatność Allegro: {allegroEntry.payment.id}.\r\n URL: {offer.friendlyUrl}";
            return(newEntry);
        }
        private string GetRecipient(BankEntry entry, XElement operation)
        {
            string   recipient = "";
            XElement element   = operation.Element("description");

            if (element != null)
            {
                // When you own multiple accounts, your better bet at figuring out tha payer is by checking the account number
                // because the 'nazwa odbiorcy' will be same person for multiple sources
                // However, when you send money to a stranger, you better figure out who its from by the name, not a number
                // Therefore, a quick win is to try mapping account number, and if not, then go with the regular flow
                recipient = this.descriptionDataExtractor.GetRecipientFromAccount(element.Value);
                if (recipient != null)
                {
                    var mapped = this.mapper.Map(recipient);
                    if (!string.IsNullOrEmpty(mapped) && mapped != recipient)
                    {
                        return(mapped);
                    }
                }
                recipient = this.descriptionDataExtractor.GetRecipient(element.Value);
            }

            if (!string.IsNullOrEmpty(recipient))
            {
                return(recipient);
            }

            if (entry.PaymentType == "Przelew na rachunek" || entry.PaymentType == "Zwrot w terminalu" || entry.PaymentType == "Spłata należności - Dziękujemy")
            {
                return(this.mapper.Map(entry.Account));
            }
            if (entry.PaymentType == "Wypłata z bankomatu" || entry.PaymentType == "Wypłata w bankomacie")
            {
                return(entry.Payer);
            }
            if (entry.PaymentType == "Prowizja" ||
                entry.PaymentType == "Opłata")
            {
                return("Bank");
            }



            return("");
        }
        private static bool IsAllegro(BankEntry entry)
        {
            bool value = entry.Recipient.Contains("allegro.pl", StringComparison.OrdinalIgnoreCase) ||
                         entry.Recipient.Contains("PAYU*ALLEGRO", StringComparison.OrdinalIgnoreCase) ||
                         (entry.Recipient.Contains("PAYPRO", StringComparison.OrdinalIgnoreCase) && entry.Note != null && entry.Note.Contains("allegro", StringComparison.OrdinalIgnoreCase)) ||
                         (entry.Recipient.Contains("PAYU", StringComparison.OrdinalIgnoreCase) && entry.Note != null && entry.Note.Contains("allegro", StringComparison.OrdinalIgnoreCase))
            ;

            if (value)
            {
                return(true);
            }

            value = entry.Note?.Contains("allegro", StringComparison.OrdinalIgnoreCase) ?? false;

            return(value);
        }
        private string GetRecipient(BankEntry entry, XElement operation)
        {
            if (entry.PaymentType == PaymentType_splataNależności ||
                entry.PaymentType == PaymentType_oplataZaKartę)
            {
                return("Bank");
            }

            string   recipient = "";
            XElement element   = operation.Element("description");

            if (!string.IsNullOrEmpty(element?.Value))
            {
                recipient = this.descriptionDataExtractor.GetRecipient(element.Value);
            }

            return(recipient);
        }
Ejemplo n.º 31
0
        private void BuildTree()
        {
            var rootGuid = EditorUtils.GetScriptOutput("studio.project.workspace.masterEventFolder.id");
            rootFolder = new FolderEntry();
            rootFolder.guid = rootGuid;
            BuildTreeItem(rootFolder);
            wantsMouseMove = true;
            banks = new List<BankEntry>();

            EditorUtils.GetScriptOutput("children = \"\";");
            EditorUtils.GetScriptOutput("func = function(val) {{ children += \",\" + val.id + val.name; }};");
            EditorUtils.GetScriptOutput("studio.project.workspace.masterBankFolder.items.forEach(func, this); ");
            string bankList = EditorUtils.GetScriptOutput("children;");
            string[] bankListSplit = bankList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            foreach(var bank in bankListSplit)
            {
                var entry = new BankEntry();
                entry.guid = bank.Substring(0, 38);
                entry.name = bank.Substring(38);
                banks.Add(entry);
            }

            banks.Sort((a, b) => a.name.CompareTo(b.name));
        }
Ejemplo n.º 32
0
        private static void WriteBankEntry(BinaryWriter bw, BankEntry entry, ByteOrder Endian)
        {
            if (entry.Parts.Count < 3)
                throw new FormatException("Bank entry has an invalid part count. Parts.Count = " + entry.Parts.Count);

            bw.Write(entry.TypeId);

            switch (entry.TypeId)
            {
                case 1:
                case 2:
                    break;
                default:
                    throw new FormatException("Bank entry to be written has an invalid Type ID.  TypeId = " + entry.TypeId);
            }

            for (int i = 0; i < 3; i++)
                WriteBankString(bw, entry.Parts[i], Endian);

            UInt32 grade = (UInt16)entry.Quality + (UInt16)entry.Level * (UInt32)65536;

            Write(bw, (Int32)grade, Endian);

            for (int i = 3; i < entry.Parts.Count; i++)
                WriteBankString(bw, entry.Parts[i], Endian);

            // see ReadBankItem for notes about the footer bytes
            Byte[] Footer = new Byte[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
            Footer[8] = entry.Equipped;
            bw.Write(Footer);

            switch (entry.TypeId)
            {
                case 1: // weapon
                    Write(bw, entry.AmmoOrQuantity, Endian);
                    break;
                case 2: // item
                    bw.Write((Byte)entry.AmmoOrQuantity);
                    break;
                default:
                    throw new FormatException("Bank entry to be written has an invalid Type ID.  TypeId = " + entry.TypeId);
            }
        }
Ejemplo n.º 33
0
        private static BankEntry ReadBankEntry(BinaryReader br, ByteOrder endian)
        {
            BankEntry entry = new BankEntry();
            int partCount;

            entry.TypeId = br.ReadByte();

            switch (entry.TypeId)
            {
                case 1:
                case 2:
                    break;
                default:
                    throw new FormatException("Bank entry to be written has invalid Type ID.  TypeId = " + entry.TypeId);
            }

            for (int i = 0; i < 3; i++)
                entry.Parts.Add(ReadBankString(br, endian));

            UInt32 temp = (UInt32)ReadInt32(br, endian);
            entry.Quality = (Int16)(temp % (UInt32)65536);
            entry.Level = (Int16)(temp / (UInt32)65536);

            switch (entry.TypeId)
            {
                case 1:
                    partCount = 14;
                    break;
                case 2:
                    partCount = 9;
                    break;
                default:
                    partCount = 0;
                    break;
            }

            for (int i = 3; i < partCount; i++)
                entry.Parts.Add(ReadBankString(br, endian));

            byte[] Footer = br.ReadBytes(10);
            // da_fileserver's investigation has led him to believe the footer bytes are:
            // (Int)GameStage - default 0
            // (Int)AwesomeLevel - default 0
            // (Byte)Equipped - default 0
            // (Byte)DropOnDeath - default 1 (this is whether an npc would drop it when it dies not you)
            // (Byte)ShopsHaveInfiniteQuantity - default 0
            // matt911 - It seems apparent that this table is used for more than just the bank inventory
            // in the game.  None of the values are stored in the inventory part of the savegame
            // except Equipped and even that will be updated immediately when you take the item
            // out of the bank.  I've never seen any of these with anything except the default value
            // in the bank except Equipped so I will store that in case it is not what we think it
            // is and it is important, but I am doubtful that it is.
            for (int i = 0; i < 7; i++)
                System.Diagnostics.Debug.Assert(Footer[i] == 0);
            System.Diagnostics.Debug.Assert(Footer[9] == 1); // This might be 1 for a health pack
            entry.Equipped = Footer[8];

            switch (entry.TypeId)
            {
                case 1: // weapon
                    entry.AmmoOrQuantity = ReadInt32(br, endian);
                    break;
                case 2: // item
                    entry.AmmoOrQuantity = (int)br.ReadByte();
                    break;
                default:
                    entry.AmmoOrQuantity = 0;
                    break;
            }
            return entry;
        }