public static GameAction CreateMoveAction( GameActions actionType, GameAction parent, int newX, int newY, int originCellHalite, bool dropoff) { int moveCost = GameMechanicsHelper.HaliteToMoveCost(originCellHalite); if (moveCost > parent.Ship.Halite) { return(null); } if (dropoff) { return(new GameAction( actionType, parent.Player.WithHalite(parent.Player.Halite + parent.Ship.Halite - moveCost), new ShipActor(newX, newY, 0), originCellHalite, GameMapGeometry.CellIndex(parent.Ship.X, parent.Ship.Y))); } else { return(new GameAction( actionType, parent.Player, new ShipActor(newX, newY, parent.Ship.Halite - moveCost), originCellHalite, GameMapGeometry.CellIndex(parent.Ship.X, parent.Ship.Y))); } }
public static GameAction CreateStayStillAction(GameAction parent, int cellHalite, bool dropoff) { int newShipHalite = Math.Min( parent.Ship.Halite + GameMechanicsHelper.HaliteToCollect(cellHalite), Constants.MaxHalite); int haliteCollected = newShipHalite - parent.Ship.Halite; int cellIndex = GameMapGeometry.CellIndex(parent.Ship.X, parent.Ship.Y); if (dropoff) { return(new GameAction( GameActions.STAY_STILL, parent.Player.WithHalite(parent.Player.Halite + newShipHalite), parent.Ship.WithHalite(0), cellHalite - haliteCollected, cellIndex)); } else { return(new GameAction( GameActions.STAY_STILL, parent.Player, parent.Ship.WithHalite(newShipHalite), cellHalite - haliteCollected, cellIndex)); } }