SCards dealDamageEnemy(int X) { return(this._game.cards .select(SFilter.located(SPlace.board), SFilter.enemy(this)) .targetOneCard(this, String.Format("Deal {0} damage to enemy unit", X)) .damage(X, this)); }
public override string ToString() { string res = ""; int placeCount = 8; List <string> reses = new List <string>(placeCount); for (int i = 0; i < placeCount; ++i) { reses.Add(""); select(SFilter.located((SPlace)i)).foreachCard((c) => { reses[i] += (reses[i].Length == 0 ? "" : ", ") + c.id; }); if (reses[i].Length > 0) { res += String.Format("{1}=<{0}> ", reses[i], ((SPlace)i).ToString()); } } return(res); }
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); }
public void trigger(STType triggerType, SCard source = null, int param = 0) { if (containsTrigger(triggerType)) { _triggers[triggerType](this, source, param); } // then show it to someone // or hide from someone viewAction(triggerType, source, param); // if a trigger from range 20..100 // then its a trigger, what will trigger // other cards with %OtherTrigger% case int triggerNum = (int)triggerType; if (triggerNum < 20 || triggerNum > 100) { return; } foreach (SCard otherCard in _game.cards.select(SFilter.inGame(), SFilter.otherThen(this)).cards) { otherCard.trigger((STType)(triggerNum + 100), this); } }
// 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)); }
public SCards targetOneCard(SCard source, string requestString) { SRequestSelectOneCard request = new SRequestSelectOneCard(requestString, this, source); return(select(SFilter.hasId(source.game.players.solve(request, source.game.logger).value))); }