public static Card createCard(Card source, List <Card> listOriginal, params CardPredicat[] filters) { if (listOriginal.Count == 0) { return(null); } var fs = filters.ToList(); fs.Add((crd) => { return(crd.name != source.name); }); filters = fs.ToArray(); Card c = source.host.selectCard( Filter.randomCardsFrom( Select.Cards(listOriginal, filters), createChoiseOptionCount), source.QestionString()); if (c == null) { return(null); } if (c as Unit != null) { Unit u = c.spawnDefaultCopy(source.host, source) as Unit; u.context.Log(u, "unit created by " + source.ToString()); return(u); } if (c as Special != null) { Special s = c.spawnDefaultCopy(source.host, source) as Special; s.context.Log(s, "special created by " + source.ToString()); return(s); } return(null); }
public bool Turn() { // if all playes passed then finish round if (everyPlayerPassed) { return(true); } Console.SetCursorPosition(0, 0); Console.Write("Press any key..."); Console.ReadKey(); topLeftTextBox.ClearLogWindow(); // activate all turn start-triggers foreach (Card c in Select.Cards(cards, Filter.anyCardHostByPlayer(currentPlayer))) { c._onTurnStart(c); } foreach (RowEffect r in rowEffects) { if (r.PlayerUnderEffect == currentPlayer) { r.onTurnStart(); } } // actions performed only if player has not passed yet if (!currentPlayer.passed) { //foreach (Card c in _handWithLeaderOf(currentPlayer)) // topLeftTextBox.AddLog(c.ToString().PadLeft(30) + " = " + c._valueDeploy(c, Place.hand), ConsoleColor.Magenta); //Console.ReadLine(); // draw current state for human player //if (currentPlayer as PlayerHuman != null) { State(); Console.ReadLine(); State(); } Card selected = currentPlayer.selectCardOrNone(_handWithLeaderOf(currentPlayer), "Select a card to play in this turn or pass", "Pass"); if (selected != null) { // current player plays a selected card currentPlayer.playCard(selected); } else { Log(String.Format("{0} passed!", currentPlayer.ToString())); currentPlayer.passed = true; } } // activate all turn end-triigers foreach (Card c in Select.Cards(cards, Filter.anyCardHostByPlayer(currentPlayer))) { c._onTurnEnd(c); } //if (currentPlayer as PlayerHuman != null) State(); // _currentPlayerIndex = (_currentPlayerIndex + 1) % players.Count; return(false); }
List <Card> _handWithLeaderOf(Player player) { var res = Select.Cards(cards, Filter.anyCardHostByPlayerIn(Place.hand, player)); var allPossibleLeadersToPlay = Select.Cards(cards, Filter.anyCardHostByPlayerIn(Place.leader, player)); foreach (Card c in allPossibleLeadersToPlay) { res.Add(c); } return(res); }
List <Card> _handOf(Player player) { return(Select.Cards(cards, Filter.anyCardHostByPlayerIn(Place.hand, player))); }
List <Card> _deckOf(Player player) { return(Select.Cards(cards, Filter.anyCardHostByPlayerIn(Place.deck, player))); }
public void setAllCardPositions(Player watcher) { allRowLines.Clear(); int cardAllignOffset = 4; for (int i = 0; i < _context.players.Count; ++i) { Player p = _context.players[i]; int playerCardAllignLeft = Utils.fieldStartHorizontal + i * Utils.fieldPerPlayerHorizontal; int currentLine = Utils.fieldStartVerticalOffset; List <int> rowLines = new List <int>(); for (int row = 0; row < 3; ++row) { rowLines.Add(currentLine + 1); currentLine += 2; foreach (Card u in Select.Cards(_context.cards, Filter.anyCardHostByPlayerIn(Place.battlefield, p))) { if (u as Unit != null && (u as Unit).row == row) { u._show.setPosition(new Point(playerCardAllignLeft + cardAllignOffset + 2, currentLine++)); } } } allRowLines.Add(rowLines); // rest == non-battlefield List <int> linesForPlaces = new List <int>(); List <int> cardsInPlaces = new List <int>(); foreach (Place place in Utils.allPlaces) { if (place != Place.battlefield) { // skip 1 line each separation linesForPlaces.Add(currentLine + 1); currentLine += 2; int cardsInPlace = 0; bool lastWasInvisible = false; foreach (Card c in Select.Cards(_context.cards, Filter.anyCardHostByPlayerIn(place, p))) { if (lastWasInvisible && !c.isVisibleTo(watcher)) { currentLine--; } c._show.setPosition(new Point(playerCardAllignLeft + cardAllignOffset, currentLine)); currentLine++; cardsInPlace++; lastWasInvisible = !c.isVisibleTo(watcher); } cardsInPlaces.Add(cardsInPlace); //if (cardsInPlace == 0 && place != Place.deck) // linesForPlaces[linesForPlaces.Count - 1] = -1; } } // indexes changes to ignore battlefield for (int j = 0; j < linesForPlaces.Count; ++j) { clearLine(i, linesForPlaces[j] - 1, linesForPlaces[j]); Console.SetCursorPosition(playerCardAllignLeft, linesForPlaces[j] + Utils.fieldStartVerticalOffset); swapColor(_lightPlayerColors[i], ConsoleColor.White); if (linesForPlaces[j] < 0) { continue; } if (cardsInPlaces[j] > 0) { Console.Write(String.Format("{0}'s {1}:{2}", p, Utils.allPlaces[j + 1], String.Format(" <{0}>", cardsInPlaces[j]))); } popColor(); } } updateAllRowWeatherAndValues(); }
public static double meanTopdeckValue(Card asker) { return(meanPlayValue(Select.Cards(asker.context.cards, Filter.anyCardInBaseHostDeck(asker)))); }