protected virtual void InternalIncreaseInventory(InventoryStateModel stateModel, int quantity, bool decreaseSold) { if (quantity < 0) { throw new DaprException("Quantity should not be less than 0."); } if (decreaseSold && stateModel.Sold - quantity < 0) { throw new DaprException("Target Sold cannot be less than 0."); } stateModel.Inventory = checked (stateModel.Inventory + quantity); if (decreaseSold) { stateModel.Sold -= quantity; } }
protected virtual void InternalReduceInventory(InventoryStateModel stateModel, int quantity, bool increaseSold) { if (quantity < 0) { throw new DaprException("Quantity should not be less than 0."); } if (quantity > stateModel.Inventory) { throw new DaprException("Insufficient inventory."); } if (increaseSold) { stateModel.Sold = checked (stateModel.Sold + quantity); } stateModel.Inventory -= quantity; }
public InventoryState(GameStateModel model, GameStateView view) : base(model, view) { _webService = GameController.Instance.WebService; _view = View as InventoryStateView; _model = Model as InventoryStateModel; }
protected virtual async Task SetInventoryStateAsync(InventoryStateModel state) { await StateManager.SetStateAsync(InventoryStateName, state); }