Exemplo n.º 1
0
 private void SwitchPlayer()
 {
     _currentPlayer.ResetActions();
     _currentPlayer = GetOpponentOf(_currentPlayer);
     LogCurrentPlayer();
     _actionExecutor = null;
 }
Exemplo n.º 2
0
        public ActionExecutor(AvailableOptions[] availableOptions, DragonX dragon, GameEngine game)
        {
            _availableOptions = availableOptions;
            _dragon           = dragon;
            _game             = game;

            _nextOptionToPick = 0;
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
0
        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;
        }
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
0
 private bool CanDealFullDamageTo(DragonX target)
 {
     return(target.Occupies(_fullDamageLocation));
 }
Exemplo n.º 7
0
 public DragonAction(DragonX dragon, GameEngine game)
 {
     Dragon     = dragon;
     GameEngine = game;
 }
Exemplo n.º 8
0
 public ConsumeWaterAction(DragonX dragon, GameEngine game) : base(dragon, game)
 {
 }
Exemplo n.º 9
0
 public ExpelWaterAction(DragonX dragon, GameEngine game) : base(dragon, game)
 {
 }
Exemplo n.º 10
0
        public AvailableOptions[] GetAvailableOptions(DragonX dragon, GameEngine game)
        {
            var availableOptions = GetAvailableOptions(dragon.Direction);

            return(availableOptions);
        }
Exemplo n.º 11
0
 public DragonX GetOpponentOf(DragonX dragon)
 {
     return(dragon == _whiteDragon
         ? _blackDragon
         : _whiteDragon);
 }
Exemplo n.º 12
0
 public Move(DragonX dragon, Direction direction, GameEngine game) : base(dragon, game)
 {
     Direction = direction;
     _target   = Dragon.Location + direction;
 }
Exemplo n.º 13
0
 public BiteAction(DragonX dragon, GameEngine game) : base(dragon, game)
 {
 }
Exemplo n.º 14
0
        public bool CanExecuteAction(DragonX dragon, GameEngine board)
        {
            var firstMove = GetAvailableOptions(dragon, board)[0];

            return(firstMove.For(dragon).Any());
        }
Exemplo n.º 15
0
 public void Execute(DragonX dragon)
 {
     _actionFinder(dragon).Execute();
 }
Exemplo n.º 16
0
 public bool CanExecute(DragonX dragon)
 {
     return(_actionFinder(dragon).CanExecute());
 }
Exemplo n.º 17
0
 public DoNothing(DragonX dragon, GameEngine game) : base(dragon, game)
 {
 }
Exemplo n.º 18
0
 private bool CanDealPartialDamageTo(DragonX target)
 {
     return(GameEngine.IsFreeSpace(_fullDamageLocation) &&
            _partialDamageLocations.Any(location => target.Occupies(location)) ||
            target.Occupies(_noDistanceDamageLocation) && GameEngine.IsFreeSpace(_partialDamageLocations[0]));
 }
Exemplo n.º 19
0
        public void DeliverDamage(Damage damage, DragonX dragon)
        {
            var waterChange = dragon.TakeDamage(damage);

            _waterPool.Add(waterChange);
        }
Exemplo n.º 20
0
 public Option[] For(DragonX dragon)
 {
     return(_options.Where(o => o.CanExecute(dragon)).ToArray());
 }
Exemplo n.º 21
0
 public ExpelFireAction(DragonX dragon, GameEngine game) : base(dragon, game)
 {
 }