public static void BuyBack(GameContext context, GameEntity company, GameEntity seller, int amountOfShares) { // TODO BUYBACK var sellerInvestorId = seller.shareholder.Id; var bid = GetSharesCost(context, company, seller, amountOfShares); Debug.Log($"Buy Back! {amountOfShares} shares of {company.company.Name} for ${bid}"); var cost = bid; if (!IsEnoughResources(company, cost)) { return; } Debug.Log($"Seller: {GetInvestorName(seller)}"); var b = company.shareholders.Shareholders[sellerInvestorId]; //.amount -= amountOfShares; b.amount -= amountOfShares; company.shareholders.Shareholders[sellerInvestorId] = b; if (b.amount <= 0) { RemoveShareholder(company, context, seller); } Companies.Pay(company, cost, "Buy back"); Companies.AddResources(seller, bid, "Buy back"); }
public static void AddMoneyToInvestor(GameContext context, int investorId, long sum) { var investor = GetInvestorById(context, investorId); Companies.AddResources(investor, sum); }