Esempio n. 1
0
        public static Cups Create(IEnumerable <int> values, int size = 9)
        {
            var cups  = new Cups(size);
            var done  = 1;
            var first = new Cup(values.First());

            cups.search[first.Value] = first;
            var prev = first;

            foreach (var val in values.Skip(1))
            {
                var curr = new Cup(val);
                cups.search[val] = curr;
                prev.Next        = curr;
                prev             = curr;
                done++;
            }
            while (++done <= size)
            {
                var curr = new Cup(done);
                cups.search[done] = curr;
                prev.Next         = curr;
                prev = curr;
            }
            prev.Next = first;
            cups.Curr = first;
            return(cups);
        }
Esempio n. 2
0
        public virtual void SetUp()
        {
            randomizer = Substitute.For <IRandomizer>();
            var cup = new Cup(2, randomizer);

            game = new Game(10, cup);
        }
Esempio n. 3
0
        private static Cup Initialize(IEnumerable <int> values, Dictionary <int, Cup> cache)
        {
            Cup head = null;
            Cup prev = null;

            foreach (int value in values)
            {
                var current = new Cup(value);

                if (head == null)
                {
                    head = current;
                }

                if (prev != null)
                {
                    current.AttachAfter(prev);
                }

                prev = current;

                if (cache != null)
                {
                    cache.Add(value, current);
                }
            }

            if (prev != null)
            {
                head.AttachAfter(prev);
            }

            return(head);
        }
Esempio n. 4
0
        private void PlayNMoves(CupCircle cupCircle, int nMoves, Cup firstCup, int highestCupLabel)
        {
            var cup = firstCup;

            for (var move = 0; move < nMoves; move++)
            {
                var pickedUpCups   = cupCircle.PickUpNextThreeCups(cup);
                var pickedUpLabels = new int[3];

                var currentCup = pickedUpCups;
                for (var i = 0; i < 3; i++)
                {
                    pickedUpLabels[i] = currentCup.Label;
                    currentCup        = currentCup.Next;
                }

                var destination = cup.Label > 1 ? cup.Label - 1 : highestCupLabel;
                while (pickedUpLabels.Contains(destination))
                {
                    destination = destination > 1 ? destination - 1 : highestCupLabel;
                }

                var destinationCup = cupCircle.CupWithLabel(destination);
                cupCircle.PlaceCupsAfter(pickedUpCups, destinationCup);

                cup = cup.Next;
            }
        }
Esempio n. 5
0
        public void ProcessModifier(Cup dice)
        {
            var copy = dice.Copy();

            dice.Dice.Clear();
            dice.AddDice(Equipment.DamageTables.ConvertDamageBySize(copy, Size).Dice);
        }
Esempio n. 6
0
        public void GetChampionOfTheYearReturnsCorrectPlayer()
        {
            var cup1    = new Cup("Cup1", DateTime.Now, DateTime.Now);
            var cup2    = new Cup("Cup2", DateTime.Now, DateTime.Now);
            var player1 = new Member("TestName1", "TestAddress1", new Membership(1, new DateTime()));
            var player2 = new Member("TestName2", "TestAddress2", new Membership(2, new DateTime()));

            var game1 = new Game {
                Player1 = player1, Player2 = player2, TimeStamp = DateTime.Now
            };
            var game2 = new Game {
                Player1 = player1, Player2 = player2, TimeStamp = DateTime.Now
            };
            var game3 = new Game {
                Player1 = player1, Player2 = player2, TimeStamp = DateTime.Now
            };

            cup1.PlayedGames.Add(game1);
            cup2.PlayedGames.Add(game2);
            cup1.PlayedGames.Add(game3);
            game1.GameSeries.Add(new GameSerie(100, 110));
            game2.GameSeries.Add(new GameSerie(100, 110));
            game3.GameSeries.Add(new GameSerie(200, 10));
            var allCups = new List <Cup>();

            allCups.Add(cup1);
            allCups.Add(cup2);
            Assert.AreEqual(player2, new ChampionOfTheYearCalculator().GetChampionOfTheYear(allCups, DateTime.Now.Year));
        }
        public List <Movie> PostCupMovies([FromBody] MoviesDto movies)
        {
            try
            {
                Cup cup = Cup.New();

                foreach (Movie movie in movies.Movies)
                {
                    cup.AddMovie(movie);
                }

                cup.CupResult();

                List <Movie> response = new List <Movie>();

                foreach (Movie movie in cup.FinalResult)
                {
                    response.Add(movie);
                }

                return(response);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 8
0
            public CrabCups(string input, int length)
            {
                Cups = new Dictionary <int, Cup>();

                var ints = input
                           .Select(c => c.ToString())
                           .Select(Int32.Parse);

                var maxValueOfInput = ints.Max();

                ints = ints
                       .Concat(Enumerable.Range(maxValueOfInput + 1, length - input.Length))
                       .Reverse();

                Max = ints.Max();

                Cup lastCup = null;
                Cup next    = null;

                foreach (var value in ints)
                {
                    var newCup = new Cup(value, next);

                    Cups[value] = newCup;
                    if (next == null)
                    {
                        lastCup = newCup;
                    }

                    next = newCup;
                }

                // make the last one point to the first cup
                Current = Cups[lastCup.Value].Next = next;
            }
Esempio n. 9
0
        private bool IsApplicablePosition(Cup cup, int x, int y, int patternWidth)
        {
            for (var i = x; i < x + patternWidth; i++)
            {
                for (var j = y + 1; j < cup.Size; j++)
                {
                    if (cup.Board.GetAt(i, j) != Element.NONE)
                    {
                        var cfls = CurrentFigureLocationStrategyFactory.GetLocationStrategy(
                            cup.Board.GetCurrentFigureType());

                        if (!cfls.IsCurrentFigurePoint(cup.Board.GetCurrentFigurePosition(), new Point(i, j)))
                        {
                            return(false);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }

            return(true);
        }
Esempio n. 10
0
        public async Task <IActionResult> DefineCup([FromRoute] string cid, [FromRoute] string uid)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Cup d = _context.Cups.Where(s => s.Id == cid).First();

            if (d.owner != null)
            {
                return(BadRequest());
            }
            d.owner = uid;

            Console.WriteLine(d);



            _context.Entry(d).State = EntityState.Modified;
            _context.SaveChanges();

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
            }

            return(Ok(d));
        }
Esempio n. 11
0
        public static Dictionary <int, Cup> PlayGame(int iterations, Dictionary <int, Cup> map, int first)
        {
            Dictionary <int, Cup> cupMap = new Dictionary <int, Cup>(map);
            Cup currentCupNode           = cupMap[first];

            for (int i = 0; i < iterations; i++)
            {
                int currentLabel = currentCupNode.Label;
                int label        = currentLabel;

                List <Cup> toRemove = new List <Cup>();
                toRemove.Add(currentCupNode.Next);
                toRemove.Add(toRemove.Last().Next);
                toRemove.Add(toRemove.Last().Next);
                currentCupNode.Next = toRemove.Last().Next;

                Cup insertAt = null;
                while (insertAt == null)
                {
                    label = label - 1 <= 0 ? cupMap.Keys.Max() : label - 1;
                    if (toRemove.Any(c => c.Label == label))
                    {
                        continue;
                    }

                    insertAt = cupMap[label];
                }

                toRemove.Last().Next = insertAt.Next;
                insertAt.Next  = toRemove.First();
                currentCupNode = currentCupNode.Next;
            }

            return(cupMap);
        }
Esempio n. 12
0
        public PlaceForFigure Find(Cup cup, FigurePatternCollection patternCollection)
        {
            var placesForFigure = new List <PlaceForFigure>();

            foreach (var pattern in patternCollection.Collection)
            {
                for (var y = 0; y < cup.Size - 2; y++)
                {
                    for (var x = 0; x < (cup.Size - (pattern.Width - 1)); x++)
                    {
                        var result = string.Empty;

                        for (var k = y; k > y - pattern.Height; k--)
                        {
                            var startIndex = cup.Size * (cup.Size - 1 - k) + x;
                            result = result + cup.Line.Substring(startIndex, pattern.Width);
                        }

                        if (result == pattern.Line && IsApplicablePosition(cup, x, y, pattern.Width))
                        {
                            placesForFigure.Add(new PlaceForFigure(pattern, new Point(x, y)));
                        }
                    }
                }
            }


            var minLevel    = placesForFigure.Min(pff => pff.Level);
            var resultPlace = placesForFigure.FirstOrDefault(pff => pff.Level == minLevel);

            return(resultPlace);
        }
Esempio n. 13
0
 // Update is called once per frame
 void Update()
 {
     if (Hand.transform.childCount == 0)
     {
         Cup = null;
     }
     if (Cup != null)
     {
         Anim.SetBool(AnimBool_HasCup, true);
     }
     else
     {
         Anim.SetBool(AnimBool_HasCup, false);
     }
     if (ToGetSoda)
     {
         GetSoda();
         ToGetSoda = false;
     }
     if (ToGiveSoda)
     {
         GiveCup();
         ToGiveSoda = false;
     }
     if (PlayingAnimation == false)
     {
         CheckInput();
     }
 }
Esempio n. 14
0
    public void GetSoda()
    {
        if (CurrentCleanCupTray != null)
        {
            audio.PlayOneShot(Mug, 0.3f);
            Debug.Log("Did");
            var cup = CurrentCleanCupTray.TakeCup();
            this.Cup = cup;
            cup.transform.SetParent(this.Hand.transform);
            cup.transform.localPosition    = Vector3.zero;
            cup.transform.localEulerAngles = Vector3.zero;

            CurrentCleanCupTray = null;
            Debug.Log("SettoNull");
        }
        else if (CurrentSodaMachine != null)
        {
            TakeCup(CurrentSodaMachine.TakeCup());
            CurrentSodaMachine = null;
        }
        else
        {
            print("else");
            TakeCup(AccessingCounter.GetDirtyCup());
            AccessingCounter = null;
        }
    }
Esempio n. 15
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Uid != 0UL)
            {
                hash ^= Uid.GetHashCode();
            }
            if (ModelId != 0)
            {
                hash ^= ModelId.GetHashCode();
            }
            if (ModelLv != 0)
            {
                hash ^= ModelLv.GetHashCode();
            }
            if (Cup != 0)
            {
                hash ^= Cup.GetHashCode();
            }
            if (Uname.Length != 0)
            {
                hash ^= Uname.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Esempio n. 16
0
 public void cup(object obj)
 {
     try
     {
         Cup      cup    = null;
         Recharge charge = null;
         //OrderLog log = null;
         while (true)
         {
             cup = cupQueue.ReceiveCup();
             // objs = regQueue.GetAllUserMessage();
             if (cup != null)
             {
                 Console.WriteLine("银联付款消息Cup" + cup.orderId);
                 charge = cupQueue.ReceiveRecharge();
                 if (charge != null)
                 {
                     Console.WriteLine("银联付款消息Recharge" + charge.OrderID);
                     // log = cupQueue.ReceiveOrderLog();
                     // if (log != null)
                     // {
                     //  Console.WriteLine("银联付款消息log" + log.Remark);
                     pays.Addpay(charge);
                     //  pays.Addlog(log);
                     pays.AddCup(cup);
                     // }
                 }
             }
             Thread.Sleep(100);
         }
     }
     catch
     {
     }
 }
        public PlayerCupStats UpdatePlayerCupStats(PlayerFixture playerFixture, Cup cup, Season season)
        {
            PlayerCupStats playerCupStats;

            // Get all PlayerFixture records for specified season
            List <PlayerFixture> playerFixturesForCup = statsReportingService.GetPlayerFixtureStatsForCupAndSeason(playerFixture.Player.Id, cup.Id, season.Id).ToList();

            // Total stats
            int totalPoints = playerFixturesForCup.Sum(pf => pf.PointsScored);
            int totalFouls  = playerFixturesForCup.Sum(pf => pf.Fouls);
            int mvpAwards   = playerFixturesForCup.Count(pf => pf.IsMvp == "Y");


            // Find existing record
            playerCupStats = statsReportingService.GetPlayerCupStats(playerFixture.Player.Id, cup.Id, season.Id);

            // If doesn't exist, create new
            if (playerCupStats == null)
            {
                playerCupStats = new PlayerCupStats(playerFixture.Player, cup, season, totalPoints, totalFouls, playerFixturesForCup.Count, mvpAwards);
            }
            else
            {
                // Update values
                playerCupStats.UpdateStats(totalPoints, totalFouls, playerFixturesForCup.Count, mvpAwards);
            }

            // Save
            matchResultRepository.SavePlayerCupStats(playerCupStats);

            return(playerCupStats);
        }
Esempio n. 18
0
        public async Task <IActionResult> PutCup([FromRoute] string id, [FromRoute] string money)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Cup d = _context.Cups.Where(s => s.Id == id).First();

            int tmpmoney = Int32.Parse(d.limit);
            int newlimit = tmpmoney + Int32.Parse(money);

            d.limit = newlimit.ToString();


            Console.WriteLine(d);

            _context.Entry(d).State = EntityState.Modified;
            _context.SaveChanges();

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
            }

            return(NoContent());
        }
 public void UpdatePlayerCupStats(List <PlayerFixture> playerFixtures, Cup cup, Season season)
 {
     foreach (PlayerFixture pf in playerFixtures)
     {
         UpdatePlayerCupStats(pf, cup, season);
     }
 }
Esempio n. 20
0
 public int CurrentPos(Cup Cup, Score Score)
 {
     if (Score.Hits > 18)
     {
         isRunning = false;
         throw new ToManySwings();
         //Exception
     }
     if (Cup.Distance > 200)
     {
         isRunning = false;
         throw new ToMuchDistance();
         //Exception
     }
     if (Cup.Distance == Cup.Position)
     {
         Cup.Distance = Math.Abs(Convert.ToInt16(Cup.Position - Ball.Calculation()));
         return(Cup.Distance);
     }
     else
     {
         Cup.Distance = Math.Abs(Convert.ToInt16(Cup.Distance - Ball.Calculation()));
         Score.HitsDistance.Add("Ball traveled " + Cup.Distance + "meters");
         return(Cup.Distance);
     }
 }
Esempio n. 21
0
    public void OnInteract()
    {
        switch (currentState)
        {
        case Status.Empty:
            GameObject obj = GameObject.Find("Player").GetComponent <PlayerBehaviour>().GetHeldObject();

            if (obj == null)
            {
                return;
            }

            obj.transform.parent        = cupPlacement;
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localRotation = Quaternion.identity;

            cup = obj.GetComponent <Cup>();
            cup.currentState = Cup.Status.OnMachine;
            currentState     = Status.Idle;
            break;

        case Status.Idle:
            currentState     = Status.Filling;
            cup.currentState = Cup.Status.Filling;
            break;

        case Status.Filling:
            currentState     = Status.Idle;
            cup.currentState = Cup.Status.OnMachine;
            break;
        }
    }
Esempio n. 22
0
        public GroupViewModel(Cup cup, List <Manager> managers, Group group = null) : this()
        {
            if (group == null)
            {
                Group = new Group(cup.CupId);
            }
            else
            {
                Group = group;
            }

            Cup = cup;

            foreach (var manager in managers)
            {
                bool selected = false;

                if (Group.Managers.Exists(x => x.ManagerId == manager.ManagerId))
                {
                    selected = true;
                }

                Managers.Add(new ManagerSelection(manager, selected));
            }
        }
Esempio n. 23
0
        private void MakeTurn(Cup cup)
        {
            Cup threeCupHead = cup.next;
            Cup threeCupTail = cup.next.next.next;

            // snip out the 3 cups
            cup.next = threeCupTail.next;

            // find next suitable selected cup

            int next_label = cup.label - 1;

            if (next_label < 1)
            {
                next_label += cups.Count;
            }
            ;
            while (threeCupHead.label.Equals(next_label) || threeCupHead.next.label.Equals(next_label) || threeCupHead.next.next.label.Equals(next_label))
            {
                next_label -= 1;
                if (next_label < 1)
                {
                    next_label += cups.Count;
                }
                ;
            }
            cup = cups[next_label];

            // connect set of 3 cups to the right of the new selected cup
            threeCupTail.next = cup.next;
            cup.next          = threeCupHead;
        }
Esempio n. 24
0
            public void Play(int turns = 10)
            {
                for (int move = 1; move <= turns; move++)
                {
                    if (PRINT)
                    {
                        Console.WriteLine($"-- move {move} --");
                    }

                    // find the current cup!
                    var(_, next) = Current;

                    if (PRINT)
                    {
                        PrintCups();
                    }

                    // the next cup should be the third cup
                    var(_, (_, nextNextCup)) = next;

                    // select a destination cup. the cup with a label equal to the current cup's label minus one
                    // can only be on the board to search. if not found lowest, go up and search from the highest again
                    var destinationCup = SelectDestinationCup();

                    // tricky...
                    Current.Next        = nextNextCup.Next; // the current cup should point after the cups we have picked up
                    nextNextCup.Next    = destinationCup.Next;
                    destinationCup.Next = next;

                    // move to the next cup
                    Current = Current.Next;
                }
            }
Esempio n. 25
0
        private void InitialiseCups(List <int> input, int extras)
        {
            Cup cup = new Cup(input[0]);

            cups.Add(cup.label, cup);

            // start with the input
            for (int i = 1; i < input.Count; i++)
            {
                Cup nextCup = new Cup(input[i]);
                cup.next = nextCup;
                cups.Add(nextCup.label, nextCup);
                cup = nextCup;
            }

            // pad extras (for part 2)
            for (int j = input.Count + 1; j < extras + 1; j++)
            {
                Cup nextCup = new Cup(j);
                cup.next = nextCup;
                cups.Add(nextCup.label, nextCup);
                cup = nextCup;
            }

            cup.next = cups[input[0]];
        }
Esempio n. 26
0
    void OnVuforiaStarted()
    {
        // コップの初期化
        var cupTargetBehaviour = noodleCupTargetObject1.GetComponent <CylinderTargetBehaviour>();

        cup = new Cup(cupTargetBehaviour, cameraMat.rows());
    }
        public Cup GetCoffee()
        {
            Cup cup = _coffeeService.GetCoffee();

            cup.ingredients.Add("Cream");
            return(cup);
        }
Esempio n. 28
0
        private static Cup Rearrange(Cup head, int highest, Dictionary <int, Cup> cache)
        {
            var removed          = new Cup[] { head.Next, head.Next.Next, head.Next.Next.Next };
            int destinationValue = head.Value - 1;

            if (destinationValue == 0)
            {
                destinationValue = highest;
            }

            while (destinationValue == removed[0].Value || destinationValue == removed[1].Value || destinationValue == removed[2].Value)
            {
                destinationValue--;

                if (destinationValue == 0)
                {
                    destinationValue = highest;
                }
            }

            var destination      = cache[destinationValue];
            var afterDestination = destination.Next;
            var afterRemoved     = removed[2].Next;

            afterRemoved.AttachAfter(head);
            removed[0].AttachAfter(destination);
            afterDestination.AttachAfter(removed[2]);

            return(head.Next);
        }
Esempio n. 29
0
        private Cup ParseCupNode(XmlNode cupNode)
        {
            try
            {
                Cup cup = new Cup();

                foreach (XmlNode xmlNode in cupNode.ChildNodes)
                {
                    switch (xmlNode.Name)
                    {
                    case Tags.CupID:
                    {
                        cup.cupIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;
                    }

                    case Tags.CupName:
                    {
                        cup.cupNameField = xmlNode.InnerText;
                        break;
                    }
                    }
                }

                return(cup);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 30
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,ClubsNumber")] Cup cup)
        {
            if (id != cup.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cup);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CupExists(cup.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cup));
        }
Esempio n. 31
0
 public void TestCupWithThee()
 {
     var c = new Cup<Thee>();
     c.Beverage = new Thee
     {
         Sugar = false,
         Flavour = Flavour.EarlGrey
     };
 }
Esempio n. 32
0
        public CupSeason Build()
        {
            if (cup == null)
            {
                cup = A.Cup.WithSampleStages().Build();
            }

            if (!teams.Any())
            {
                teams.AddRange(Enumerable.Repeat(0, cup.StagesOrdered.First().TeamCount).Select(x => A.Team.InWorld(cup.World).Build()));
            }

            return new CupSeason(cup, new DateTime(2012, 08, 01), new DateTime(2013, 05, 31), teams);
        }
Esempio n. 33
0
		public static void Main() {
			int N = int.Parse(System.Console.ReadLine());

			var cup = new Cup();

			for (int i=0; i<N; i++) {
				var line = System.Console.ReadLine().Split(' ');
				int operation = int.Parse(line[0]);
				int gram = int.Parse(line[1]);

				switch(operation) {
				case 1: cup.addWater(gram); break;
				case 2: cup.addCafee(gram); break;
				default: cup.tasting(gram); break;
				}
			}

			System.Console.WriteLine((int)(100*cup.concentration()));
		}
Esempio n. 34
0
 public void TestMethod1()
 {
     var c = new Cup<int>();
     c.Beverage = 3;
 }
Esempio n. 35
0
 public CupSeasonBuilder ForCup(Cup cup)
 {
     this.cup = cup;
     return this;
 }