Example #1
0
        public async Task <IActionResult> AddItemToFishTank(AddItemToFishTank model)
        {
            // Find fish tank
            FishTank tank = await _context.FishTank.FirstOrDefaultAsync(t => t.Id == model.Id);

            if (tank == null)
            {
                return(BadRequest($"Fish tank with Id {model.Id} not found"));
            }


            // check if it is a fish or an item and get its size
            int newItemSize = model.Fish != null ? model.Fish.Size : model.Item.Size;

            // check if the fish tank has the capacity to hold it
            if (tank.AvailableCapacity < newItemSize)
            {
                return(BadRequest($"Fish tank with Id {model.Id} cannot fit the new item"));
            }

            // add the new item
            if (model.Fish != null)
            {
                tank.AddFish(model.Fish);
            }
            else
            {
                tank.AddItem(model.Item);
            }

            await _context.SaveChangesAsync();

            return(Ok(tank));
        }
Example #2
0
 static FishTankApplication()
 {
     Window.AddEventListener("load", delegate(ElementEvent e) {
         FishTank fishtank = new FishTank();
         fishtank.Run();
     }, /* useCapture */ false);
 }
        public void Jellyfish_TrackJellyfish_TrackTest()
        {
            int            initialPositionX  = 0;
            int            initialPositionY  = 0;
            string         instructionString = "";
            string         direction         = "";
            FishTank       fishTank          = new FishTank();
            IRemoteControl remote            = new RemoteControl();

            fishTank.SetTankSize(5, 3);
            initialPositionX  = 3;
            initialPositionY  = 2;
            instructionString = "FRRFLLFFRRFLL";
            direction         = "N";

            remote.SetJellyfishOrigin(initialPositionX, initialPositionY, direction);
            string val = remote.GetJellyfishFinalPosition(fishTank, instructionString);

            initialPositionX  = 0;
            initialPositionY  = 3;
            instructionString = "LLFFFLFLFL";
            direction         = "W";


            remote.SetJellyfishOrigin(initialPositionX, initialPositionY, direction);

            Assert.AreEqual("2 3 S", remote.GetJellyfishFinalPosition(fishTank, instructionString));
        }
 static FishTankApplication()
 {
     Window.AddEventListener("load", delegate(ElementEvent e) {
         FishTank fishtank = new FishTank();
         fishtank.Run();
     }, /* useCapture */ false);
 }
Example #5
0
    void Start()
    {
        //aiManager = FindObjectOfType<FishTank> ();

        aiManager = transform.parent.GetComponentInParent <FishTank> ();
        animator  = GetComponent <Animator> ();
        //SetUpNPC ();
    }
Example #6
0
        public void CreatingFishTank_HasNoFishInTank()
        {
            //Arrange / Act
            var fishTank = new FishTank();

            //Assert
            Assert.That(fishTank.Fish.Count, Is.EqualTo(0));
        }
Example #7
0
        public void Setup()
        {
            _fishTank = new FishTank();

            _goldFish  = new GoldFish(0.1f);
            _angelFish = new AngelFish(0.2f);
            _babelFish = new BabelFish(0.3f);
            _fakeFish  = new FakeFish(0.7f);
        }
Example #8
0
        public void AddingGoldFish_AddsFishToTank()
        {
            //Arrange / Act
            var fishTank = new FishTank();

            fishTank.AddFish(new GoldFish("Goldy"));

            //Assert
            Assert.That(fishTank.Fish.Count, Is.EqualTo(1));
            Assert.That(fishTank.Fish.ElementAt(0).Name, Is.EqualTo("Goldy"));
        }
Example #9
0
        public async Task <IActionResult> GetFishTankById([FromBody] GetFishTank model)
        {
            // Find fish tank
            FishTank tank = await _context.FishTank.FirstOrDefaultAsync(t => t.Id == model.Id);

            if (tank == null)
            {
                return(BadRequest($"Fish tank with Id {model.Id} not found"));
            }

            return(Ok(tank));
        }
Example #10
0
        public void AddingGoldFishAndBabelFishAndAngelFish_UpdatesFishInTank()
        {
            //Arrange / Act
            var fishTank = new FishTank();

            fishTank.AddFish(new GoldFish("Neil"));
            fishTank.AddFish(new BabelFish("Zaphod"));
            fishTank.AddFish(new AngelFish("Charlies"));

            //Assert
            Assert.That(fishTank.Fish.Count, Is.EqualTo(3));
        }
Example #11
0
        public async Task <IActionResult> AddFishTank([FromBody] CreateFishTankModel model)
        {
            FishTank tank = new FishTank();

            tank.Capacity          = model.Capacity;
            tank.AvailableCapacity = model.Capacity;

            await _context.FishTank.AddAsync(tank);

            await _context.SaveChangesAsync();

            return(Ok(tank));
        }
Example #12
0
        public void LoadingXmlWithOneFishPutsFishInTank()
        {
            //Arrange / Act
            var fishTank = new FishTank();

            fishTank.AddFish(new GoldFish("Neil"));
            fishTank.AddFish(new GoldFish("Boris"));
            fishTank.AddFish(new BabelFish("Zaphod"));
            fishTank.AddFish(new AngelFish("Charlies"));

            //Assert
            Assert.That(fishTank.Feed, Is.EqualTo(0.7));
        }
Example #13
0
        public void Feed_CalculatesTotalFishFoodForAllFishInTank()
        {
            //Arrange / Act
            var fishTank = new FishTank();

            fishTank.AddFish(new GoldFish("Neil"));
            fishTank.AddFish(new GoldFish("Boris"));
            fishTank.AddFish(new BabelFish("Zaphod"));
            fishTank.AddFish(new AngelFish("Charlies"));

            //Assert
            Assert.That(fishTank.Feed, Is.EqualTo(0.7));
        }
Example #14
0
        public async Task <IActionResult> DeleteFish(RemoveFishModel model)
        {
            FishTank tank = await _context.FishTank.FirstOrDefaultAsync(t => t.Id == model.Id);

            if (tank == null)
            {
                return(BadRequest("No Tank found with Id"));
            }

            tank.RemoveFish(model.Fish.Id);

            await _context.SaveChangesAsync();

            return(Ok(tank));
        }
Example #15
0
        public async Task <IActionResult> AddToNextAvailable(AddItemModel model)
        {
            FishTank tank = await NextAvailableFishTankWithCapacity(model.Decoration.Size);

            if (tank == null)
            {
                return(BadRequest("No Tank found that can hold this fish, please add a new tank"));
            }

            tank.AddItem(model.Decoration);

            await _context.SaveChangesAsync();

            return(Ok(tank));
        }
Example #16
0
        public void FishTankXml_ThrowsException_IfFishTankIsNull()
        {
            //Arrange
            FishTank fishTank = null;

            //Act / Assert
            try
            {
                var fishXml = new FishTankXml(fishTank);
                Assert.Fail();
            }
            catch (ArgumentException ex)
            {
                Assert.That(ex.Message, Is.EqualTo("Fish Tank cannot be null"));
            }
        }
Example #17
0
    private void SetupFishTank()
    {
        this.m_FishTank = null;
        int     num  = Physics.RaycastNonAlloc(new Ray(this.m_FloatPos + Vector3.up * 0.1f, Vector3.down), FishingRod.s_RaycastHitsTmp);
        Vector3 zero = Vector3.zero;

        for (int i = 0; i < num; i++)
        {
            FishTank component = FishingRod.s_RaycastHitsTmp[i].collider.gameObject.GetComponent <FishTank>();
            if (component)
            {
                this.m_FishTank = component;
                return;
            }
        }
    }
Example #18
0
        public void GenerateFishTankXml_CreatesXmlDocumentWithNoFish_IfNoFishInTank()
        {
            //Arrange
            var fishTank = new FishTank();

            var fishXml = new FishTankXml(fishTank);

            //Act
            var fishXmlDocument = fishXml.GenerateFishTankXml();


            //Assert
            double totalFeed = Convert.ToDouble(fishXmlDocument.Root.Element("TotalFeed").Value);

            Assert.That(totalFeed, Is.EqualTo(0));
            Assert.That(fishXmlDocument.Root.Element("Fishes").IsEmpty, Is.True);
        }
Example #19
0
        static void Main(string[] args)
        {
            var angelFish = new AngelFish(0.3f);
            var babelFish = new BabelFish(0.5f);
            var goldFish  = new GoldFish(1.0f);

            var eviesFishTank = new FishTank();

            eviesFishTank.AddFish(angelFish);
            eviesFishTank.AddFish(babelFish);
            eviesFishTank.AddFish(goldFish);

            var feedingTimeMessage = eviesFishTank.Feed();

            Console.WriteLine("Hello my sweet fishies!");
            Console.BackgroundColor = ConsoleColor.DarkBlue;
            Console.WriteLine(feedingTimeMessage);
        }
Example #20
0
        public void ImportFishTankXmlToFishTank_AddsFishesToFishTank()
        {
            //Arrange
            string    fishXml  = @"<?xml version=""1.0"" encoding=""utf-8""?>
<FishTank>
  <TotalFeed>0.7</TotalFeed>
  <Fishes>
    <Fish FishType=""FishTank.GoldFish, FishTank, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"">
      <Name>Neil</Name>
      <FoodRequired>0.1</FoodRequired>
    </Fish>
    <Fish FishType=""FishTank.GoldFish, FishTank, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"">
      <Name>Boris</Name>
      <FoodRequired>0.1</FoodRequired>
    </Fish>
    <Fish FishType=""FishTank.BabelFish, FishTank, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"">
      <Name>Zaphod</Name>
      <FoodRequired>0.3</FoodRequired>
    </Fish>
    <Fish FishType=""FishTank.AngelFish, FishTank, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"">
      <Name>Charlie</Name>
      <FoodRequired>0.2</FoodRequired>
    </Fish>
  </Fishes>
</FishTank>";
            XDocument fishXDoc = XDocument.Parse(fishXml);

            FishTank    fishTank    = new FishTank();
            FishTankXml fishTankXml = new FishTankXml();


            //act
            fishTank = fishTankXml.ImportFishTankXmlToFishTank(fishXDoc);

            //assert
            Assert.That(fishTank.Fish.Count, Is.EqualTo(4));
            Assert.That(fishTank.Feed, Is.EqualTo(0.7));
        }
Example #21
0
        public async Task <IActionResult> ReplaceFishTank([FromBody] UpdateFishTankCapacityModel model)
        {
            // Find fish tank
            FishTank tank = await _context.FishTank.FirstOrDefaultAsync(t => t.Id == model.Id);

            if (tank == null)
            {
                return(BadRequest($"Fish tank with Id {model.Id} not found"));
            }

            // Check if the old fish can fit in the new capacity
            if (tank.Fishes != null && tank.Fishes.Count() > 0)
            {
                // Find the size of all the fishes
                int fishSize = tank.Fishes.ToList().Select(f => f.Size).Aggregate((sum, val) => sum + val);
                if (fishSize > model.Capacity)
                {
                    return(BadRequest($"Fish tank with Id {model.Id} not big enough to hold the fishes of the old tank"));
                }
            }


            // The new tank to replace the old
            FishTank newTank = new FishTank();

            // deocaration and plants are discarded when replacing the fish tank
            newTank.Capacity = model.Capacity;
            newTank.AddFish(tank.Fishes);

            // remove the old fishes from the old tank
            tank.RemoveFish(tank.Fishes.Select(f => f.Id));
            // add and save the new fish tank
            await _context.FishTank.AddAsync(newTank);

            await _context.SaveChangesAsync();

            return(Ok(newTank));
        }
Example #22
0
    private void SetupHookInWaterPos()
    {
        Ray ray = new Ray(this.m_FloatPos + Vector3.up * 0.1f, Vector3.down);

        RaycastHit[]      collection = Physics.RaycastAll(ray);
        List <RaycastHit> list       = new List <RaycastHit>(collection);
        FishTank          fishTank   = null;
        Vector3           vector     = Vector3.zero;

        foreach (RaycastHit raycastHit in list)
        {
            fishTank = raycastHit.collider.gameObject.GetComponent <FishTank>();
            if (fishTank)
            {
                vector = raycastHit.point;
                break;
            }
        }
        float terrainY = MainLevel.GetTerrainY(this.m_FloatPos);

        if (terrainY >= this.m_FloatPos.y)
        {
            DebugUtils.Assert("[FishingRod:OnEnterState] Float is under terrain!", true, DebugUtils.AssertType.Info);
        }
        Vector3 floatPos = this.m_FloatPos;

        if (fishTank)
        {
            floatPos.y = vector.y - fishTank.m_BoxCollider.size.y * 0.5f;
        }
        if (floatPos.y < terrainY + 0.2f)
        {
            floatPos.y = terrainY + 0.2f;
        }
        floatPos.y = Mathf.Min(floatPos.y, this.m_FloatPos.y);
        this.m_Hook.transform.position = floatPos;
    }
Example #23
0
        public async Task <IActionResult> DeleteEmptyFishTank([FromBody] DeleteFishTankModel model)
        {
            // Find fish tank
            FishTank tank = await _context.FishTank.FirstOrDefaultAsync(t => t.Id == model.Id);

            if (tank == null)
            {
                return(BadRequest($"Fish tank with Id {model.Id} not found"));
            }

            // check how many items are in the tank (all fishes, decoration and plant)
            int itemsCount = tank.Fishes.ToList().Count + tank.Items.ToList().Count;

            if (itemsCount != 0)
            {
                return(BadRequest($"Fish tank with Id {model.Id} is not empty"));
            }

            // remove and save the changes
            _context.FishTank.Remove(tank);
            await _context.SaveChangesAsync();

            return(NoContent());
        }
 void Start()
 {
     currentSpeed = Random.Range(minSpeed, maxSpeed);
     tank         = GetComponentInParent <FishTank>();
 }
Example #25
0
 public override string GetInteractionName(IActor a, FishTank target, InteractionObjectPair interaction)
 {
     return(Common.Localize("StockAny:MenuName"));
 }
Example #26
0
        static void Main(string[] args)
        {
            int            initialPositionX  = 0;
            int            initialPositionY  = 0;
            string         instructionString = "";
            string         direction         = "";
            Validations    validate          = new Validations();
            IRemoteControl remote            = new RemoteControl();
            FishTank       fishTank          = new FishTank();

starting:
            Console.WriteLine("Please Enter the Upper-Right Corner Coordinates of Tank.");
            string inputTankSize = Console.ReadLine();

            try
            {
                fishTank.SetTankSize(Convert.ToInt32(inputTankSize.Substring(0, inputTankSize.IndexOf(" "))), Convert.ToInt32(inputTankSize.Substring(inputTankSize.IndexOf(" ") + 1)));
            }
            catch (Exception e)
            {
                Console.WriteLine("Error-Wrong input Format.Try again.\n");
                goto starting;
            }

            if (!validate.MaxCoordinatesOK(fishTank.Width, fishTank.Height))
            {
                goto starting;
            }



enterPosition:
            Console.WriteLine("\nPlease Enter JellyFish Position and Instructions:-");
            string inputLine = Console.ReadLine();

            try
            {
                string[] subStr = inputLine.Split(" ");
                initialPositionX  = Convert.ToInt32(subStr[0]);
                initialPositionY  = Convert.ToInt32(subStr[1]);
                direction         = subStr[2];
                instructionString = subStr[3];
            }
            catch (Exception e)
            {
                Console.WriteLine("Error-Wrong input Format.Try again.");
                goto enterPosition;
            }


            if (!validate.InstructionsOK(instructionString))
            {
                goto enterPosition;
            }
            if (!validate.MaxCoordinatesOK(initialPositionX, initialPositionY))
            {
                goto enterPosition;
            }


            remote.SetJellyfishOrigin(initialPositionX, initialPositionY, direction);

            Console.WriteLine(remote.GetJellyfishFinalPosition(fishTank, instructionString));

            goto enterPosition;
        }
Example #27
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            bool success = false;

            List <IFishContainer> bowls = new List <IFishContainer>();

            foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
            {
                bowls.AddRange(lot.GetObjects <IFishContainer>());
            }

            List <GameObject> inventory = GetInventory(Sim);

            Dictionary <FishType, Fish> perfect = new Dictionary <FishType, Fish>();

            foreach (Fish fish in inventory)
            {
                if (fish == null)
                {
                    continue;
                }

                if (fish.GetQuality() == Sims3.Gameplay.Objects.Quality.Perfect)
                {
                    if (perfect.ContainsKey(fish.Type))
                    {
                        continue;
                    }

                    perfect.Add(fish.Type, fish);
                }
            }

            foreach (Fish fish in inventory)
            {
                if (fish == null)
                {
                    continue;
                }

                if (fish.GetQuality() == Sims3.Gameplay.Objects.Quality.Perfect)
                {
                    bool moved = false;

                    foreach (IFishContainer obj in bowls)
                    {
                        FishBowlBase bowl = obj as FishBowlBase;
                        if (bowl != null)
                        {
                            if (bowl.HasFish())
                            {
                                continue;
                            }

                            Inventories.ParentInventory(fish).TryToRemove(fish);

                            bowl.SetFishInBowl(fish);

                            bowl.StartFishFx();
                            bowl.FishFed();

                            EventTracker.SendEvent(EventTypeId.kPutFishInFishbowl, Sim.CreatedSim, bowl);

                            IncStat("Stored in Bowl");
                            moved = true;
                            break;
                        }
                        else
                        {
                            FishTank tank = obj as FishTank;
                            if (tank != null)
                            {
                                if (tank.Inventory == null)
                                {
                                    continue;
                                }

                                if (tank.Inventory.IsFull())
                                {
                                    continue;
                                }

                                tank.Inventory.TryToMove(fish);

                                IncStat("Stored in Tank");
                                moved = true;
                                break;
                            }
                        }
                    }

                    if (perfect[fish.Type] == fish)
                    {
                        moved = true;

                        IncStat("Perfect Retained");
                    }

                    if (moved)
                    {
                        continue;
                    }
                }

                int value = Money.Sell(Sim, fish);
                mFunds += value;

                AddStat("Sold", value);
                success = true;
            }

            return(success);
        }
 public void Setup()
 {
     tank = new FishTank();
 }
Example #29
0
 void Start()
 {
     fishTankScript = head.GetComponent<FishTank>();
 }