Пример #1
0
        private void YoloTeamAction(Offset offset)
        {
            var nextPosition = _yoloTeam.Position + offset;

            var nextTile = _room.Tiles[nextPosition.X, nextPosition.Y];

            if (nextTile.Type == TileType.Wall)
            {
                return;
            }

            if (_room.MonsterOccupiesPosition(nextPosition))
            {
                var monsterToAttack = _room.Monsters.FirstOrDefault(monster => Equals(monster.Position, nextPosition));
                _yoloTeam.Attack(monsterToAttack);
                _logger.LogFight(_yoloTeam, monsterToAttack);

                return;
            }

            if (nextTile.Type == TileType.Door)
            {
                EnterNextRoom(nextTile);
                return;
            }

            if (nextTile.HasShrine)
            {
                var hitpointsBeforeHeal = _yoloTeam.Hitpoints;
                nextTile.Shrine.Heal(_yoloTeam);
                _logger.LogHeal(_yoloTeam, hitpointsBeforeHeal);
            }

            _yoloTeam.Move(offset);
        }
Пример #2
0
        public void ShouldMoveInRoomWhenPossible()
        {
            // given
            var room = RoomFactory.CreateEmptyRoom(new Size(4, 4), new Position(1, 1));

            var team = new YoloTeam(room.StartingPosition);

            // when
            team.Move(MovementOffsets.RightDown);

            // then
            Assert.That(team.Position, Is.EqualTo(new Position(2, 2)));
        }