private static ComboList GetCombos(PartList parts, Item board, double cumilativeArea = 0, double minimumArea = 0) { PartList mycopyofParts = parts.Copy(); // create a copy of the list, because we will be changing the list, but not the contents ComboList myCombos = new ComboList(); // collection of all the combinations we could construct // loop though all the parts ... foreach (var ipart in parts) { if (!board.BiggerThan(ipart)) // rule out parts that are too long/wide { mycopyofParts.Remove(ipart); continue; } double ncumArea = ipart.Area + cumilativeArea; if (ncumArea > board.Area) // dont add parts that would push the cumilative area of the combination over that of the board { continue; } if (ncumArea > minimumArea) { myCombos.Add(new Combo(ipart)); } mycopyofParts.Remove(ipart); if (mycopyofParts.Count == 0) { continue; // no need to try call myself again if there is no parts left } ComboList sublist = GetCombos(mycopyofParts, board, ncumArea, minimumArea); foreach (var icombo in sublist) { double cumsubArea = icombo.CumalativeArea + ncumArea; icombo.Add(ipart); if (icombo.Count > 1 && icombo[0].Width + icombo[1].Width > board.Width && icombo[0].Length + icombo[1].Length > board.Length) { continue; } myCombos.Add(icombo); } } return(myCombos); }
private void OnInput(KeyCode key, bool pressed, bool doubled, bool held) { m_inputHappened = true; m_combo.Add(key); m_comboMove.Add(new KeyCombo(key, pressed, doubled, held, Input.GetKey(KeyCode.LeftShift), Input.GetKey(KeyCode.LeftControl), Input.GetKey(KeyCode.LeftAlt))); if (m_combo.Count > MAX_COMBO) { HandleCombo(); } else { m_endTime = m_comboTimer + COMBO_TIMEOUT; } }
private void PopulateLists() { ComboList.Add(new CribbageCombos() { CardsToUse = 2, Description = "Fifteens", Points = 2, NumberNeeded = 15 }); ComboList.Add(new CribbageCombos() { CardsToUse = 5, Description = "Full House", IsFullHouse = true, Group = EnumScoreGroup.ScorePairRuns, Points = 5 }); ComboList.Add(new CribbageCombos() { CardsToUse = 2, Description = "Pairs", Group = EnumScoreGroup.ScorePairRuns, Points = 2, NumberForKind = 2 }); ComboList.Add(new CribbageCombos() { CardsToUse = 3, Description = "Three of a kind", Group = EnumScoreGroup.ScorePairRuns, NumberForKind = 3, Points = 6 }); ComboList.Add(new CribbageCombos() { CardsToUse = 4, Description = "Four Of a Kind", Group = EnumScoreGroup.ScorePairRuns, NumberForKind = 4, Points = 12 }); ComboList.Add(new CribbageCombos() { CardsToUse = 3, Description = "Run of three", Group = EnumScoreGroup.ScorePairRuns, NumberInStraight = 3, Points = 3 }); ComboList.Add(new CribbageCombos() { CardsToUse = 4, Description = "Run of four", Group = EnumScoreGroup.ScorePairRuns, NumberInStraight = 4, Points = 4 }); ComboList.Add(new CribbageCombos() { CardsToUse = 5, Description = "Run of five", Group = EnumScoreGroup.ScorePairRuns, NumberInStraight = 5, Points = 5 }); ComboList.Add(new CribbageCombos() { CardsToUse = 4, Description = "Double run of three", Group = EnumScoreGroup.ScorePairRuns, NumberInStraight = 3, NumberForKind = 2, Points = 8 }); ComboList.Add(new CribbageCombos() { CardsToUse = 5, Description = "Double run of four", Group = EnumScoreGroup.ScorePairRuns, NumberInStraight = 4, NumberForKind = 2, Points = 10 }); ComboList.Add(new CribbageCombos() { CardsToUse = 5, Description = "Triple run of three", Group = EnumScoreGroup.ScorePairRuns, NumberForKind = 3, NumberInStraight = 3, Points = 15 }); ComboList.Add(new CribbageCombos() { CardsToUse = 5, Description = "Quadruple run of three", Group = EnumScoreGroup.ScorePairRuns, NumberForKind = 2, NumberInStraight = 3, DoublePairNeeded = true, Points = 16 }); ComboList.Add(new CribbageCombos() { CardsToUse = 4, Description = "Four cards of same suit", IsFlush = true, Group = EnumScoreGroup.ScoreFlush, Points = 4 }); ComboList.Add(new CribbageCombos() { CardsToUse = 5, Description = "Five cards of same suit", IsFlush = true, Group = EnumScoreGroup.ScoreFlush, Points = 5 }); ComboList.Add(new CribbageCombos() { CardsToUse = 1, Description = "Jack of same suit", Points = 1, JackStatus = EnumJackType.Nob }); ComboList.Add(new CribbageCombos() { CardsToUse = 1, Description = "Same suit as starter jack", Points = 2, JackStatus = EnumJackType.Heels }); }