コード例 #1
0
        public void Simple_downgrade_trade(int rank, int expected, int missing, bool sameGroup)
        {
            var group  = Group.Alloys;
            var alloys = entries.Where(e => e.Group == group)
                         .OrderBy(e => e.Rarity)
                         .ToList();

            var   firstGrade = alloys[rank];
            Entry secondGrade;

            if (sameGroup)
            {
                secondGrade = new Entry(alloys[0]);
            }
            else
            {
                secondGrade = new Entry(entries.First(e => e.Group != group && e.Rarity.Rank() == 1 && e.Subkind == firstGrade.Subkind && e.Kind == firstGrade.Kind));
            }

            cargo.IncrementCargo(firstGrade.Name, expected * 2);

            var missingIngredients = new Dictionary <Entry, int>
            {
                [secondGrade] = missing
            };

            var trades = MaterialTrader.FindPossibleTrades(cargo, missingIngredients, new Dictionary <EntryData, int>()).ToList();

            Check.That(trades.Count).IsEqualTo(1);

            var trade = trades[0];

            Check.That(trade.Traded.Data).IsEqualTo(firstGrade);
            Check.That(trade.TradedNeeded).IsEqualTo(expected);
        }
コード例 #2
0
        public void Simple_upgrade_trade(int rank, int expected)
        {
            var group  = Group.Alloys;
            var alloys = entries.Where(e => e.Group == group)
                         .OrderBy(e => e.Rarity)
                         .ToList();

            var firstGrade  = alloys[0];
            var secondGrade = new Entry(alloys[rank]);

            cargo.IncrementCargo(firstGrade.Name, expected * 2);

            var missingIngredients = new Dictionary <Entry, int>
            {
                [secondGrade] = 1
            };

            var trades = MaterialTrader.FindPossibleTrades(cargo, missingIngredients, new Dictionary <EntryData, int>()).ToList();

            Check.That(trades.Count).IsEqualTo(1);

            var trade = trades[0];

            Check.That(trade.Traded.Data).IsEqualTo(firstGrade);
            Check.That(trade.TradedNeeded).IsEqualTo(expected);
        }