public IList <VisForBookOffer> GenerateBuyBookOffers(MagusTradingDesires otherDesires) { List <VisForBookOffer> bookTradeOffers = new List <VisForBookOffer>(); if (BookDesires.Any() && otherDesires.BooksForTrade.Any()) { // they have books, we want books foreach (BookForTrade bookForTrade in otherDesires.BooksForTrade) { // if we're interested in the topic of this book and it's of sufficient level if (BookDesires.ContainsKey(bookForTrade.Book.Topic) && BookDesires[bookForTrade.Book.Topic].CurrentLevel < bookForTrade.Book.Level && Mage.ValidToRead(bookForTrade.Book)) { // evaluate the value of the book to us double bookVisValue = Mage.RateLifetimeBookValue(bookForTrade.Book); // TODO: improve pricing mechanics double price = bookVisValue + bookForTrade.MinimumPrice / 2; var visOffers = GenerateVisOffer(price, otherDesires.VisDesires, VisDesires); if (visOffers != null) { // we can offer this sort of vis for the book bookTradeOffers.Add(new VisForBookOffer(otherDesires.Mage, visOffers, price, bookForTrade.Book)); } } } } return(bookTradeOffers); }
public IList <BookTradeOffer> GenerateBookTradeOffers(MagusTradingDesires tradeDesires) { List <BookTradeOffer> tradeList = new List <BookTradeOffer>(); foreach (BookForTrade book in BooksForTrade) { if (tradeDesires.BookDesires.ContainsKey(book.Book.Topic) && tradeDesires.Mage.ValidToRead(book.Book)) { // we have a book they want, see if they have a book we want foreach (BookForTrade theirBook in tradeDesires.BooksForTrade) { if (BookDesires.ContainsKey(theirBook.Book.Topic) && Mage.ValidToRead(theirBook.Book) && theirBook.Book.Quality == book.Book.Quality && theirBook.Book.Level <= book.Book.Level + 1.0 && theirBook.Book.Level >= book.Book.Level - 1.0) { tradeList.Add(new BookTradeOffer(tradeDesires.Mage, book.Book, theirBook.Book)); } } } } return(tradeList); }