public override async Task <ActionResult> HandleAsync([FromBody] CreateStaircaseRequest request, CancellationToken cancellationToken = default) { var Staircase = new Staircase { Id = Guid.NewGuid(), BuildingId = request.BuildingId, CarpetId = request.CarpetId, IsCurved = request.IsCurved, StairCount = request.StairCount, Stairs = new List <Stair>(), Total = request.Total }; for (int i = 0; i < request.StairCount; i++) { Staircase.Stairs.Add(new Stair { StaircaseId = Staircase.Id, CarpetId = request.CarpetId, Height = request.StairHeight, Width = request.StairWidth, Length = request.StairLength, Price = (request.Total / request.StairCount) }); } await _repo.AddAsync(Staircase); await _repo.SaveAsync(); return(Ok(Staircase)); }
private void MovePlayerToLocation_Internal(Staircase sendingStairs, DungeonLocation location, bool suppressMovementEvents) { if (location == null) { location = sendingStairs.Destination; } // Make sure that this dungeon branch does in fact exist. if (DungeonBranches.Contains(location.Branch)) { SetCurrentBranch(location.Branch, suppressMovementEvents); if (!CurrentBranch.DungeonLevelExists(location.DungeonBranchLevel)) { CurrentBranch.CreateNewLevel(location.DungeonBranchLevel); if (sendingStairs != null) { // The map position shoud be populated on the staircase now. location = sendingStairs.Destination; } } CurrentMapState = CurrentBranch.GetDungeonLevel(location.DungeonBranchLevel); Game.Current.Player.Position = location.MapPosition; // Update the dungeon level. CurrentDungeonLevel = _dungeonBranches[CurrentBranch] + CurrentMapState.DungeonBranchIndex; } else { throw new InvalidOperationException(string.Format(ErrorMessages.DungeonBranchNotFound, location.Branch.Name)); } }
static void Main(string[] args) { // IAlgorithm a; // IAlgorithm algorithm=new ReverseString(); // IAlgorithm algorithm=new Palindrome(); // IAlgorithm algorithm=new RemoveDuplicateChar(); // IAlgorithm algorithm=new HighestOccuredChar(); // IAlgorithm algorithm=new FindHighestInArray(); // IAlgorithm algorithm=new AbstractClassTest(); // IAlgorithm algorithm=new ArrayLeftRotation(); // IAlgorithm algorithm=new TriesContact(); IAlgorithm algorithm = new Staircase(); algorithm.Run(); Console.ReadLine(); // int i=10; // Console.WriteLine(++i); // int j=15; // Console.WriteLine(j++); // Console.WriteLine(j); }
public void StaircaseTests() { // Case One (Correct) var inputCaseOne = 4; var exercise = new Staircase(inputCaseOne); var expectedOutputCaseOne = new string[4] { " #", " ##", " ###", "####" }; var resultCaseOne = exercise.Execute(); CollectionAssert.AreEqual(expectedOutputCaseOne, resultCaseOne); // Case Two (Check Constraints) var inputCaseTwo = 500; Assert.ThrowsException <ConstraintException>( () => new Staircase(inputCaseTwo)); }
public void StairCaseProblem3Memo() { int[] paths = new int[6]; Array.Clear(paths, 0, paths.Length); var result = new Staircase().StairCase3Memo(5, paths); Assert.AreEqual(13, result); }
public void GenerateStaircaseBaseFloor_Returns_BaseFloorWithLengthEqualN(int n) { var staircase = new Staircase(); var baseFloor = staircase.CreateStaircaseFloor(n); Assert.AreEqual(n, baseFloor.Length); }
private Dictionary <Vector2, Block> ErrorRoom() { Dictionary <Vector2, Block> dic = new Dictionary <Vector2, Block>(); Vector2 vec = new Vector2(0); dic[vec] = new Staircase(vec, true); return(dic); }
static void Main(string[] args) { //================================================================// //================================================================// //WarmUP MODULE // //================================================================// //================================================================// #region [===== WarmUP MODULE =====] //Console.WriteLine("================ TEST 01 ==============="); //var test01 = new SolveMeFirst(); //test01.Start(); Console.WriteLine("================ TEST 02 ==============="); var test02 = new SimpleArraySum(); test02.Start(); Console.WriteLine("================ TEST 03 ==============="); var test03 = new CompareTheTriplets(); test03.Start(); Console.WriteLine("================ TEST 04 ==============="); var test04 = new AVeryBigSum(); test04.Start(); Console.WriteLine("================ TEST 05 ==============="); var test05 = new DiagonalDifference(); test05.Start(); Console.WriteLine("================ TEST 06 ==============="); var test06 = new PlusMinus(); test06.Start(); Console.WriteLine("================ TEST 07 ==============="); var test07 = new MiniMaxSum(); test07.Start(); Console.WriteLine("================ TEST 08 ==============="); var test08 = new Staircase(); test08.Start(); Console.WriteLine("================ TEST 09 ==============="); var test09 = new BirthdayCakeCandles(); test09.Start(); Console.WriteLine("================ TEST 10 ==============="); var test10 = new TimeConversion(); test10.Start(); Console.WriteLine("================ TEST 11 ==============="); #endregion }
public void StaircasePrint() { var result = Staircase.Stair(6); Assert.AreEqual(" #", result[0]); Assert.AreEqual(" ##", result[1]); Assert.AreEqual(" ###", result[2]); Assert.AreEqual(" ####", result[3]); Assert.AreEqual(" #####", result[4]); Assert.AreEqual("######", result[5]); }
public void staircaseTest() { int stairs = 6; List <string> expected = new List <string>() { " #", " ##", " ###", " ####", " #####", "######" }; List <string> result = Staircase.staircase(stairs); CollectionAssert.AreEqual(expected, result); }
public void TestStaircaseDeegres1() { // arrange Staircase TestStairs = new Staircase(20, 20); Map TestMap = new Map(); TestStairs.StepHeight = 17; TestStairs.StepWidth = 20; // act TestStairs.GetFlowRate(); }
public MapState(IMap map) { this.Map = map; this.Player = Game.Current.Player; Staircase upStairs = Map.UpStairs.FirstOrDefault(); DungeonBranchIndex = -1; _monsters = new List <IMonster>(); MonsterGenerator = Game.Current.Services.GetService <MonsterGenerationService>(); }
public void TestStaircaseDeegres2() { // arrange Staircase TestStairs = new Staircase(20, 20); TestStairs.StepHeight = 7; TestStairs.StepWidth = 11; // act TestStairs.GetFlowRate(); // assert Assert.IsTrue(TestStairs.K > 1.06 && TestStairs.K < 1.08); }
public void TestStaircaseDeegres3() { // arrange Staircase TestStairs = new Staircase(20, 20); TestStairs.StepHeight = 7.5; TestStairs.StepWidth = 10; // act TestStairs.GetFlowRate(); // assert Assert.IsTrue(TestStairs.K > 0.99 && TestStairs.K < 1.01); }
public void TestStaircaseDeegres5() { // arrange Staircase TestStairs = new Staircase(20, 20); TestStairs.StepHeight = 6.5; TestStairs.StepWidth = 14; // act TestStairs.GetFlowRate(); // assert Assert.IsTrue(TestStairs.K > 1.22 && TestStairs.K < 1.24); }
public void TestStaircaseDeegres6() { // arrange Staircase TestStairs = new Staircase(20, 20); TestStairs.StepHeight = 6.5; TestStairs.StepWidth = 17; // act TestStairs.GetFlowRate(); // assert Assert.AreEqual(1.23, TestStairs.K); }
public AuditoryModel() { this._base = .50; this._step = .30; this._minFq = 500; this._maxFq = 5000; this._lBeat = 25.0; this._lStim = 8; this._lIntStim = 10; this._lIntSignal = 20; this._nBufferSize = 20; this._attenuationSequencer = 0; this._attenuationRandom = 6; this._rule = Staircase.One_One; }
public bool MoveUpStairs() { Position playerPosition = Game.Current.Player.Position; Staircase upStairs = Dungeon.CurrentMapState.Map.UpStairs.Where(s => s.Location.MapPosition.Equals(playerPosition)).FirstOrDefault(); if (upStairs != null) { UseStaircase(upStairs); return(true); } else { Game.Current.Messages.AddMessage(ErrorMessages.MoveUpNotOnStairs); return(false); } }
public void Copy(AuditoryModel tmp) { if (tmp == null) { return; } this._base = tmp._base; this._step = tmp._step; this._rule = tmp._rule; this._minFq = tmp._minFq; this._maxFq = tmp._maxFq; this._lBeat = tmp._lBeat; this._lStim = tmp._lStim; this._lIntStim = tmp._lIntStim; this._lIntSignal = tmp._lIntSignal; this._nBufferSize = tmp._nBufferSize; this._attenuationSequencer = tmp._attenuationSequencer; this._attenuationRandom = tmp._attenuationRandom; }
/// <summary> /// Create a static policeman that looks around /// </summary> /// <param name="map"></param> /// <param name="position"></param> public Policeman(Map map, Vector position, bool gunAlwaysUp, bool lockLeft, bool lockRight) : base(map, 1.6, 2.3) // Look around { Position = position; StartX = position.X; CurrentStrategy = OriginalStrategy = Strategy.LookAround; Facing = Map.Random.Next(2) == 1 ? Direction.Left : Direction.Right; if (lockLeft) { Facing = Direction.Left; Locked = true; } else if (lockRight) { Facing = Direction.Right; Locked = true; } LookTime = Map.Random.Next(300); GoalStaircase = null; GunAlwaysUp = gunAlwaysUp; }
public static Block[,] Entrance(Random rng, Orientation[] orientations) { //Creates the object and all the walls with doors Block[,] blocks = Walls(); //Making all the floor blocks randomising if they are regular floor or carpet for (int x = 1; x < 20; ++x) { for (int y = 1; y < 12; ++y) { if (rng.Next(0, 2) != 1) { blocks[x, y] = new Ground(new Vector2(x, y)); } else { blocks[x, y] = new Carpet(new Vector2(x, y)); } } } blocks[10, 6] = new Staircase(new Vector2(10, 6), true); return(blocks); }
public void MakeExit() { blocks[10, 6] = new Staircase(new Vector2(10, 6), false); }
public override void Update() { if (ForceGun > 0) ForceGun--; if (CheckPlayerVisibility()) { if ((GetCenter() - Map.PlayerEntity.GetCenter()).Length < 20) { // in shooting position if (GunAlwaysUp || ShootingTimer++ >= 10) { Resources.Audio.GunShot.CreateInstance().Play(); Map.PlayerEntity.Kill(); ForceGun = 45; } } else { CurrentStrategy = Strategy.Check; CheckX = Map.PlayerEntity.GetCenter().X; ShootingTimer = 0; TimeSpentChecking = 0; } } else { ShootingTimer = 0; } if (CurrentStrategy == Strategy.Check) { TimeSpentChecking++; if (TimeSpentChecking >= 500) CurrentStrategy = OriginalStrategy; if (WalkTo(CheckX, RunSpeed)) { LookTime--; if (LookTime <= 0) { LookTime = 200 + Map.Random.Next(100); Facing = (Direction)(1 - (int)Facing); } DistanceWalked = 0; } } else if (GoalStaircase != null) { if (WalkTo(GoalStaircase.GetCenter().X, RunSpeed)) { Position = new Vector( GoalStaircase.Other.Location.X + Staircase.Width / 2 - Width / 2, GoalStaircase.Other.Location.Y + Staircase.Height - Height); CurrentStrategy = OriginalStrategy = Strategy.LookAround; StartX = GetCenter().X + Map.Random.NextDouble() * 4 - 2; LookTime = 40 + Map.Random.Next(20); GoalStaircase = null; } } else if (CurrentStrategy == Strategy.Patrol) { if (Facing == Direction.Left && WalkTo(PatrolXLeft, MoveSpeed)) Facing = Direction.Right; else if (Facing == Direction.Right && WalkTo(PatrolXRight, MoveSpeed)) Facing = Direction.Left; } else if (CurrentStrategy == Strategy.LookAround) { if (WalkTo(StartX, MoveSpeed)) { DistanceWalked = 0; LookTime--; if (LookTime <= 0) { LookTime = 200 + Map.Random.Next(100); if(!Locked) Facing = (Direction)(1 - (int)Facing); } } } MoveVertical(0.5); }
public override void CallFromStaircase(Staircase s) { if(CurrentStrategy != Strategy.Check && CanSeeLocation(s.GetCenter())) GoalStaircase = s; }
public virtual void CallFromStaircase(Staircase s) { }
protected void PlaceNewLevelStairs(MapState mapState, int mapIndex) { IMap map = mapState.Map; // Map generatos might try to place stairs, but they're not correct. if (map.Stairs.Count() > 0) { map.RemoveAllStairs(); } // We need a list of staircases we have resolved, since we can't resolve them in this loop. List <Staircase> resolvedStaircases = new List <Staircase>(); // Grab any unresolved stairs that are pointed at this level. foreach (Staircase unresolvedStair in Game.Current.UnresolvedStaircases.Where(s => s.Destination.Branch == this && s.Destination.DungeonBranchLevel == mapIndex)) { // Create a new staircase that links to the unresolved staircase. Staircase newStair = CreateStaircase(mapState, mapIndex, unresolvedStair.Direction == Staircase.StaircaseDirection.Down ? Staircase.StaircaseDirection.Up : Staircase.StaircaseDirection.Down); unresolvedStair.Destination = newStair.Location; resolvedStaircases.Add(unresolvedStair); newStair.Destination = unresolvedStair.Location; mapState.Map.AddStaircase(newStair); } // Now mark them all as resolved. foreach (Staircase resolvedStair in resolvedStaircases) { Game.Current.ResolveStaircaseDestination(resolvedStair); } // See if there are any dungeon connections we need to create. foreach (var connection in BranchConnections.Where(c => !c.StaircaseCreated && mapIndex >= c.EarliestIndex && mapIndex <= c.LatestIndex)) { if (ShouldCreateConnectionStaircase(connection.EarliestIndex, connection.LatestIndex, mapIndex)) { Staircase branchStair = CreateStaircase(mapState, mapIndex, connection.StairDirection); int destinationLevel = Game.Current.RNG.Next(connection.MinimumDestinationIndex, connection.MaximumDestinationIndex + 1); branchStair.Destination = new DungeonLocation(connection.DestinationBranch, destinationLevel, null); Game.Current.AddUnresolvedStaircase(branchStair); mapState.Map.AddStaircase(branchStair); if (!connection.DestinationBranch.PositionFinalized) { connection.DestinationBranch.FinalizeBranchDungeonPosition(this, mapIndex, destinationLevel, connection.StairDirection); } connection.StaircaseCreated = true; } } // If this isn't the bottom level, and no downstairs have been created yet, we need some down stairs. if (mapIndex < ActualLevels - 1 && map.DownStairs.Where(s => s.Destination.Branch == this).Count() <= 0) { Staircase downStair = CreateStaircase(mapState, mapIndex, Staircase.StaircaseDirection.Down); downStair.Destination = new DungeonLocation(this, mapIndex + 1, null); Game.Current.AddUnresolvedStaircase(downStair); map.AddStaircase(downStair); } // If this isn't the top level, and no upstairs have been created yet, we need some up stairs. if (mapIndex > 0 && map.UpStairs.Where(s => s.Destination.Branch == this).Count() <= 0) { Staircase upStair = CreateStaircase(mapState, mapIndex, Staircase.StaircaseDirection.Up); upStair.Destination = new DungeonLocation(this, mapIndex - 1, null); Game.Current.AddUnresolvedStaircase(upStair); map.AddStaircase(upStair); } }
private void UseStaircase(Staircase stairs) { Dungeon.MovePlayerToLocation(stairs); }
public void StairCaseProblem3I_MinPath() { var result = new Staircase().StairCase3I_MinPath(5); Assert.AreEqual(2, result); }
public void StairCaseProblem3I() { var result = new Staircase().StairCase3I(5); Assert.AreEqual(13, result); }
public virtual void SetUp() { _challenge = new Staircase(); }
public void StairCaseProblem2() { var result = new Staircase().StairCase2(6); Assert.AreEqual(6, result); }
public void StairCaseProblem() { var result = new Staircase().Solution(4); Assert.AreEqual(result, 5); }
public void Initialize() { _staircase = new Staircase(); }
public void MovePlayerToLocation(Staircase sendingStairs, bool suppressMovementEvents = false) { MovePlayerToLocation_Internal(sendingStairs, null, suppressMovementEvents); }