public override AuctionLists checkStock() { var excess = new Dictionary <string, int>(); var deficit = new Dictionary <string, int>(); if (inventory["Tools"] > toolThreshold) { excess.Add("Tools", inventory["Tools"] - toolThreshold); } if (inventory["Food"] < foodThreshold) { deficit.Add("Food", foodThreshold - inventory["Food"]); } if (inventory["Metal"] < metalThreshold) { deficit.Add("Metal", metalThreshold - inventory["Metal"]); } var auctions = new AuctionLists { excessList = excess, deficitList = deficit }; return(auctions); }
public void generateOffers(List <Trade> tradeList) { AuctionLists auctionLists = role.checkStock(); /* * if (auctionLists.excessList.ContainsKey("Food")) * { * Debug.Log(auctionLists.excessList["Food"]); * } */ //ADDME: logic determining price and quantity of ask if (auctionLists.deficitList.Count > 0) { foreach (KeyValuePair <string, int> kvp in auctionLists.excessList) { //FIXME: currently placing an ask for exactly the excess amount and a random price. no logic applied int cost = pseudoRandom.Next(2, 6); int quant = kvp.Value; Trade newAsk = new Trade("ask", kvp.Key, quant, cost); tradeList.Add(newAsk); } } if (auctionLists.excessList.Count > 0) { foreach (KeyValuePair <string, int> kvp in auctionLists.deficitList) { //FIXME: currently trying to place a bid for exactly the deficit amount and a random price. int cost = pseudoRandom.Next(2, 6); int quant = kvp.Value; if (cost * quant > inventory["Coin"]) { //cant afford at cost specified. do nothing if broke, otherwise ask at price of 1; if (inventory["Coin"] < 1) { return; } cost = 1; quant = inventory["Coin"] / cost; } Trade newBid = new Trade("bid", kvp.Key, quant, cost); tradeList.Add(newBid); } } }