public Card[] GetAAA(IHuContext huContext) { if (huContext == null) { throw new ArgumentNullException(nameof(huContext)); } if (!(huContext is TableHuContext)) { throw new ArgumentException($"非{nameof(TableAlgorithm)}!"); } var tableHuContext = huContext as TableHuContext; var types = tableHuContext.Types; var item = tableHuContext.Value; var AAACount = item & 0x7; var cards = new Card[AAACount]; for (var i = 0; i < AAACount; i++) { var offset = (byte)((item >> (10 + i * 4)) & 0xF); cards[i] = types[offset]; } return(cards); }
public Card[] GetABC(IHuContext huContext) { if (huContext == null) { throw new ArgumentNullException(nameof(huContext)); } if (!(huContext is TableHuContext)) { throw new ArgumentException($"非{nameof(TableAlgorithm)}!"); } var tableHuContext = huContext as TableHuContext; var types = tableHuContext.Types; var item = tableHuContext.Value; var AAACount = item & 0x7; var ABCCount = (item >> 3) & 0x7; var bytes = new Card[ABCCount]; for (var i = 0; i < ABCCount; i++) { var cardValue = types[(byte)((item >> (10 + AAACount * 4 + i * 4)) & 0xF)]; bytes[i] = cardValue; } return(bytes); }
public Card GetCC(IHuContext huContext) { if (huContext == null) { throw new ArgumentNullException(nameof(huContext)); } if (!(huContext is DFSHuContext)) { throw new ArgumentException($"非{nameof(DFSAlgorithm)}!"); } var dfsHuContext = huContext as DFSHuContext; return(dfsHuContext.CC); }
public Card GetCC(IHuContext huContext) { if (huContext == null) { throw new ArgumentNullException(nameof(huContext)); } if (!(huContext is TableHuContext)) { throw new ArgumentException($"非{nameof(TableAlgorithm)}!"); } var tableHuContext = huContext as TableHuContext; var types = tableHuContext.Types; var item = tableHuContext.Value; return(types[(byte)((item >> 6) & 0xF)]); }
public Context IsHu(Card[] cards, Card card) { if (cards == null) { throw new ArgumentNullException(nameof(cards)); } var typeCount = _bytePool.Rent(_typeLength); Value value = null; void callback(int key, int[] values, Card c) { if (c == card) { value = new Value() { Values = values, Card = c }; } } Card[] cardTypes = null; if (_huDict == null) { var count = cards.SortCards(typeCount); cardTypes = typeCount.CardTypes(); var key = CalculateKey(typeCount); TingCards(key, cardTypes, typeCount, callback); cardTypes.AddType(card); } else { cards.SortCards(card, typeCount); cardTypes = typeCount.CardTypes(); var key = CalculateKey(typeCount); HuCard(key, cardTypes, typeCount, (values) => { value = new Value() { Values = values }; }); } if (value == null) { return(null); } var huContexts = new IHuContext[value.Values.Length]; for (var i = 0; i < huContexts.Length; i++) { huContexts[i] = new TableHuContext() { Value = value.Values[i], Types = cardTypes }; } var gameContext = new Context(); gameContext.HuCard = card; gameContext.HuContexts = huContexts; gameContext.Cards = cardTypes; _bytePool.Return(typeCount, true); return(gameContext); }