private void SwitchPlayer() { _currentPlayer.ResetActions(); _currentPlayer = GetOpponentOf(_currentPlayer); LogCurrentPlayer(); _actionExecutor = null; }
public ActionExecutor(AvailableOptions[] availableOptions, DragonX dragon, GameEngine game) { _availableOptions = availableOptions; _dragon = dragon; _game = game; _nextOptionToPick = 0; }
public bool HasAValidMove(DragonX player, GameEngine game) { var dropOffLocations = _elements.Select(DetermineActionFor).Distinct().ToList(); // TODO more accurate calculation of can execute option // First calculate available moves? return(dropOffLocations .Select(action => action.GetAvailableOptions(player, game).Any()) .Any(x => x)); }
public void Reset() { _baGuaWheel = new BaGuaWheel(); _whiteDragon = DragonX.CreateWhite(new Location.Location(0, 6), this); _blackDragon = DragonX.CreateBlack(new Location.Location(6, 0), this); _firePool = FirePool.Instantiate(); _waterPool = WaterPool.Instantiate(); _actionExecutor = null; _currentPlayer = _whiteDragon; }
protected ExpelElementAction(DragonX dragon, GameEngine game) : base(dragon, game) { _fullDamageLocation = Dragon.Location + Dragon.Direction; _partialDamageLocations = new[] { _fullDamageLocation + Dragon.Direction, _fullDamageLocation + Dragon.Direction.TurnLeft(), _fullDamageLocation + Dragon.Direction.TurnRight(), }; _noDistanceDamageLocation = _fullDamageLocation + Dragon.Direction + Dragon.Direction; }
private bool CanDealFullDamageTo(DragonX target) { return(target.Occupies(_fullDamageLocation)); }
public DragonAction(DragonX dragon, GameEngine game) { Dragon = dragon; GameEngine = game; }
public ConsumeWaterAction(DragonX dragon, GameEngine game) : base(dragon, game) { }
public ExpelWaterAction(DragonX dragon, GameEngine game) : base(dragon, game) { }
public AvailableOptions[] GetAvailableOptions(DragonX dragon, GameEngine game) { var availableOptions = GetAvailableOptions(dragon.Direction); return(availableOptions); }
public DragonX GetOpponentOf(DragonX dragon) { return(dragon == _whiteDragon ? _blackDragon : _whiteDragon); }
public Move(DragonX dragon, Direction direction, GameEngine game) : base(dragon, game) { Direction = direction; _target = Dragon.Location + direction; }
public BiteAction(DragonX dragon, GameEngine game) : base(dragon, game) { }
public bool CanExecuteAction(DragonX dragon, GameEngine board) { var firstMove = GetAvailableOptions(dragon, board)[0]; return(firstMove.For(dragon).Any()); }
public void Execute(DragonX dragon) { _actionFinder(dragon).Execute(); }
public bool CanExecute(DragonX dragon) { return(_actionFinder(dragon).CanExecute()); }
public DoNothing(DragonX dragon, GameEngine game) : base(dragon, game) { }
private bool CanDealPartialDamageTo(DragonX target) { return(GameEngine.IsFreeSpace(_fullDamageLocation) && _partialDamageLocations.Any(location => target.Occupies(location)) || target.Occupies(_noDistanceDamageLocation) && GameEngine.IsFreeSpace(_partialDamageLocations[0])); }
public void DeliverDamage(Damage damage, DragonX dragon) { var waterChange = dragon.TakeDamage(damage); _waterPool.Add(waterChange); }
public Option[] For(DragonX dragon) { return(_options.Where(o => o.CanExecute(dragon)).ToArray()); }
public ExpelFireAction(DragonX dragon, GameEngine game) : base(dragon, game) { }