Пример #1
0
 private void MatchAdd(FinalMatch thismatch)
 {
     lock (calcLock) {
         matchesfoundcount++;
         matches.Add(thismatch);
         if (matches.Count > settings.nummatches)
         {
             matches = matches.OrderBy(i => i.totalprice).Take(settings.nummatches).ToList();
         }
     }
 }
Пример #2
0
        private void GenerateWinnerCertificates()
        {
            var    finalMatch = this.FinalMatch.FirstOrDefault();
            string winner     = FinalMatch.First().Winner.Name;
            string looser     = FinalMatch.First().Looser.Name;

            if (finalMatch != null && finalMatch.Winner != null && finalMatch.Looser != null)
            {
                winner = finalMatch.Winner.Name;
                looser = finalMatch.Looser.Name;
            }

            MessengerInstance.Send(new GenerateWinnerCertificatesMessage(winner, looser, this.Name, GetStreetAddressForCoordinates(), DateTime.Now));
        }
Пример #3
0
        public void GenerateBracket()
        {
            if (Participants.Count == 2)
            {
                return;
            }

            SetBracketOrder();

            CreateMatch(FinalMatch);
            if (EdgeCaseParticipants != null)
            {
                var height = BracketHeight;
                FinalMatch.SetEdgeCaseMatches(EdgeCaseParticipantsInBracketOrder, height);
                BracketHeight = height + 1;
            }
        }
Пример #4
0
        //When a final match is found, populate a list with the names of the
        //stores and use this method to add the correct information about the final match
        private void addFinalMatch(List <string> storeNamesInMatch)
        {
            matchesfound = true;

            FinalMatch   theMatch      = new FinalMatch();
            List <Store> storesInMatch = new List <Store>();

            foreach (string storename in storeNamesInMatch)
            {
                theMatch.AddStore(storename);
                storesInMatch.Add(new Store(storename, StoreDictionary[storename]));
            }

            for (int i = 0; i < WantedItemList.Count; i++)
            {
                Item item = WantedItemList[i];
                storesInMatch = storesInMatch.OrderBy(s => s.getPrice(item.extid)).ThenByDescending((s => s.getQty(item.extid))).ToList();
                int totalwantedqty = item.qty;
                int storeindex     = 0;
                while (totalwantedqty > 0)
                {
                    Store currentStore       = storesInMatch[storeindex];
                    int   storeQty           = currentStore.getQty(item.extid);
                    int   actualQtyFromStore = (storeQty >= totalwantedqty) ? totalwantedqty : storeQty;
                    totalwantedqty -= actualQtyFromStore;
                    theMatch.GetDetails(currentStore.getName()).AddItem(item.extid, actualQtyFromStore, currentStore.getPrice(item.extid), currentStore.getColour(item.extid));
                    storeindex++;
                }
            }
            // Check for a solution that doesn't use one of the stores.  Reject it since it would have been
            // found for a smaller value of k.
            foreach (string storename in theMatch.GetStoreNames())
            {
                if (theMatch.GetDetails(storename).totalStorePrice == 0)
                {
                    return;
                }
            }
            MatchAdd(theMatch);
        }