/* * THIS DOES NOT WORK EXCEPT FOR VERY SIMPLE SEQ SERIES JYS !!!! need UnStack and to use patterns * This joins one SEQ series under another so as to concatanate the two series * */ /* * this just exposes the top card and check to see if it can be recovered * jys this needs to be able to expose all cards that are exposable * (8s,6h,7D) expose to 8S,7D,6H * * right now, the series underneath must be SEQ, use the SOS one for that, but it does not use placeholders * * */ public int ExposeOneTop(ref board tb) { int e, n; int LocAbove; // location of card just above the top card card CardAbove; int Any = 0; int OriginalSource; foreach (card cT in tb.TopMost) { LocAbove = cT.iCard - 1; if (LocAbove <= 0) { continue; // nothing to expose } CardAbove = tb.ThisColumn[cT.iStack].Cards[LocAbove]; if (CardAbove.bFaceUp) { continue; // already exposed } // we want only unexposed cards and the series underneath must be SEQ // we can expose this card by moving the one below it (our card cT) if (CardAbove.rank - 1 != cT.rank) { continue; // nope, wrong rank, we want to move it back } n = tb.ThisColumn[cT.iStack].Cards.Count - cT.iCard; // number of cards to move // the below does no error checking nor any statistics computation if (tb.NumEmptyColumns > 0) { e = tb.Empties[0]; OriginalSource = cT.iStack; tb.PerformMove(cT.iStack, cT.iCard, e, n); tb.PerformMove(e, 0, OriginalSource, n); Any++; } else { // we will have to find a card that can hold it temporarily foreach (card bC in tb.BottomMost) { if (bC.iStack == cT.iStack) { continue; } if (bC.rank - 1 == cT.rank) { OriginalSource = cT.iStack; n = tb.ThisColumn[cT.iStack].Cards.Count - cT.iCard; tb.PerformMove(cT.iStack, cT.iCard, bC.iStack, n); tb.PerformMove(bC.iStack, bC.iCard + 1, OriginalSource, n); Any++; } } } if (Any > 0) { tb.ThisColumn[cT.iStack].CalculateColumnValue(cT.iStack, tb.NumEmptyColumns, tb.BoardState()); } } if (Any > 0) { tb.ReScoreBoard(); // alternately CalcBoardScore and then GetSortedTops return(ExposeOneTop(ref tb)); } return(Any); }