void mulliganCard(SCard card) { // currently solving for Mulligan-problem // if you swap a card you will always // draw from deck the first card // with a different name // (if all deck has only theese names) // then drop it bool allSameName = _cards .select(SFilter.hostBy(card.host), SFilter.located(SPlace.deck)) .isAll(SFilter.withName(card.name)); var deck = _cards.select(SFilter.hostBy(card.host), SFilter.located(SPlace.deck)); // then select first or first // with different name // and move it yto your hand (allSameName ? deck.first() : deck.first(1, SFilter.mulliganName(card.name))) .move(SPlace.hand); }
// if card is shown before // then it has format X, where X - is its id // otherwise // card has format <cY>, where Y - index in its // current place string cardView(SCard card, int p) { //return isVisible(card, p) || card.host == p ? // String.Format("[id={0}]", card.id.ToString()) // : String.Format("[c{0}]", card.game.cards.select(SFilter.located(card.location.place), SFilter.hostBy(card.host)).indexOf(card)); string place = String.Format("{0}st card in p{1}'s {2}", card.game.cards.select(SFilter.located(card.location.place), SFilter.hostBy(card.host)).indexOf(card), card.host, card.location); string id = isVisible(card, p)? String.Format("id={0} ", card.id) : ""; return(String.Format("{0}{1}", id, place)); }
SCards deck(int player) { return(_cards.select(SFilter.hostBy(player), SFilter.located(SPlace.deck))); }
SCards shuffleDeck(int player) { return(_cards.shuffle(_random, SFilter.hostBy(player), SFilter.located(SPlace.deck))); }
// shuffle a card from somewhere to a deck // puts it to deck // then put it to random position in deck public SCard shuffleCard(SCard card) { card.maybe.move(SPlace.deck); _cards.putRandom(_random, card, SFilter.hostBy(card.host), SFilter.located(SPlace.deck)); return(card); }
SLocationView _locationView() { return(new SLocationView(_location, game.cards.select(SFilter.located(_location.place), SFilter.hostBy(_player)).indexOf(this), _player)); }