public void LabyrinthMoveUpTest() { PlayerPosition startPosition = new PlayerPosition(3, 3); string[] rawData = new string[Labyrinth.LabyrinthSize] { "XXXXXXX", "X-X---X", "X---X-X", "X--*--X", "X-X----", "X-----X", "XXXXXXX" }; Cell[,] board = LabyrinthDataFromStringArray(rawData); Labyrinth labyrinth = new Labyrinth(startPosition, board); var privateObject = new PrivateObject(labyrinth); privateObject.Invoke("ProcessMoveUp", 3, 3); string result = @"X X X X X X X X - X - - - X X - - * X - X X - - - - - X X - X - - - - X - - - - - X X X X X X X X "; string expected = labyrinth.ToString(); Assert.AreEqual(expected, result); }
/// <summary> /// Adds all moves to Tree /// </summary> /// <param name="whitePos">Position of white figures on board</param> /// <param name="moves">Pairs of moves and replies e.g. ("e2-e4", "e7-e5")</param> public void AddMoves(PlayerPosition whitePos, params string[] moves) { Move temp = new Move(moves[0]); MoveNode tempNode = new MoveNode(temp); //iterator, that will add move to tree MoveIterator pushingIterator = null; MoveNode next = null; if (!rootMoves.ContainsKey(tempNode)) { rootMoves.Add(tempNode, tempNode); next = rootMoves[tempNode].Add(new Move(moves[1])); } else { next = rootMoves[tempNode].Add(new Move(moves[1])); } pushingIterator = GetIterator(tempNode); //next answer pushingIterator.CurrentNode = next; int i = 2; while (i < moves.Length) { pushingIterator.CurrentNode = pushingIterator.CurrentNode.Add(moves[i], whitePos); ++i; } }
public void Init(Action<Square> action, PlayerPosition position, Color color) { if (position == PlayerPosition.Up) this.ShuffleUp(action, color); else this.ShuffleDown(action, color); }
public PlayerPosition PlayCard(Card card, PlayerPosition playerPosition) { _nextPlayer = BridgeHelper.GetNextPlayerPosition(playerPosition); if (_currentTrick.Deck.Count == 0) { _currentTrick = new Trick(); _currentTrick.TrickDealer = playerPosition; } if (_currentTrick.Deck.Count <= 4) { card.PlayerPosition = playerPosition; _currentTrick.Deck.Cards.Add(card); } if (_currentTrick.Deck.Count == 4) { Tricks.Add(_currentTrick); var winner = FindWinner(_currentTrick, Contract.Trump); _currentTrick.TrickWinner = winner; _nextPlayer = winner; _currentTrick = new Trick() { TrickDealer = winner }; } GameState[playerPosition].RemoveCard(card); return _nextPlayer; }
public PlayerInfo this[PlayerPosition position] { get { return new PlayerInfo(this.gameManager[position]); } }
public static PlayerPosition GetNextPlayerPosition(PlayerPosition currentSide) { if (currentSide.Order == 3) return PlayerPosition.North; return new PlayerPosition(currentSide.Order + 1); }
void CheckPlayer(PlayerPosition pla, float start, float end) { var p = pla.transform.position.x; if( p >= start && p < end ) { this.detected_players_.Add(pla); } }
public void SetupOrientation(PlayerPosition pp) { if (pp == PlayerPosition.Up) this.rankMask = rank8; else if (pp == PlayerPosition.Down) this.rankMask = rank1; }
public void AddPosition(PlayerPosition position) { if (position != null && position.id != null && position.id != "") { positions [position.id] = position; } }
public void CreatePlayer(PlayerPosition pos) { GameObject obj = (GameObject) Instantiate(characterModel, new Vector3(pos.x,0,pos.y), Quaternion.identity); Character suppo = obj.GetComponent<Character> (); suppo.id = pos.id; suppo.lastPosition = pos; }
public Bidding(GameSession gameSession, PlayerPosition startPosition) { _gameSession = gameSession; Bids = new List<Bid>(); CurrentTurn = startPosition; }
public PlayerBoard(PlayerPosition playerPosition, Color playerColor, MovesArrayAllocator arrayAllocator) { this.position = playerPosition; this.color = playerColor; this.allocator = arrayAllocator; this.ResetAll(); }
public void SendPosition(PlayerPosition position) { channel.BasicPublish( exchange: POSITION_EXCHANGE_NAME, routingKey: POSITION_TAG_NAME, basicProperties: null, body: position.ToMessageData() ); }
public void IsGameWonTestFalse() { PlayerPosition startPosition = new PlayerPosition(3, 3); Labyrinth labyrinth = new Labyrinth(startPosition); var privateObject = new PrivateObject(labyrinth); var actual = privateObject.Invoke("IsGameWon", 3, 3); Assert.AreEqual(false, actual); }
public void IsOnBoarderTest() { PlayerPosition startPosition = new PlayerPosition(3, 3); Labyrinth labyrinth = new Labyrinth(startPosition); var privateObject = new PrivateObject(labyrinth); var actual = privateObject.Invoke("IsOnBorder", 6, 6); Assert.AreEqual(true, actual); }
// -------------------------------------------------------------------------------- // AccountToPosition // -------------------------------------------------------------------------------- // Set position public static Coroutine SetPosition(string accountId, PlayerPosition position, GameDB.ActionOnResult<PlayerPosition> func = null) { return GameDB.instance.StartCoroutine(GameDB.Set<PlayerPosition>( "AccountToPosition", accountId, position, func )); }
public SantaseGame(IPlayer firstPlayer, IPlayer secondPlayer, PlayerPosition firstToPlay) { this.firstPlayerTotalPoints = 0; this.secondPlayerTotalPoints = 0; this.roundsCount = 0; this.firstPlayer = firstPlayer; this.secondPlayer = secondPlayer; this.firstToPlay = firstToPlay; }
IEnumerator Start() { Application.runInBackground = true; id = System.Guid.NewGuid().ToString(); lastPos = new PlayerPosition (id, 0, 0, 0); posQ.AddPosition (new PlayerPosition (id, 0, 0, 0)); mh = new MessageHandler (); yield return StartCoroutine(mh.startListening ()); }
public BridgeGame(Dictionary<PlayerPosition, Deck> state, PlayerPosition declarer) { GameState = state; Tricks = new List<Trick>(); Declarer = declarer; Dummy = BridgeHelper.GetNextPlayerPosition(BridgeHelper.GetNextPlayerPosition(declarer)); Contract = new Contract(); _currentTrick = new Trick() { TrickDealer = Declarer }; }
public Contract(PlayerPosition playerPosition, ContractType type, bool isDoubled = false, bool isReDoubled = false) : this() { this.IsAvailable = true; this.Type = type; this.PlayerPosition = playerPosition; this.OriginalBidder = playerPosition; this.IsDoubled = isDoubled; this.IsReDoubled = isReDoubled; }
public int ChangeTrackForPlayer(PlayerPosition player, int track_change) { int next_track = GetNextTrack(player.track_index, track_change); var track = players_on_track_[next_track]; foreach(var other_player in track) { if( PlayerPosition.IsOverlapping(player, other_player) ) { Debug.Log (string.Format("{0} is blocking for {1}", other_player.name, player.name)); return player.track_index; } } return next_track; }
public bool FeedPosition(PlayerPosition p) { if( p.transform.position.x >= this.End.transform.position.x ) { if( winners_.Contains(p) == false ) { winners_.Add(p); Debug.Log(string.Format("{0} won!", p.name)); } return true; } return winners_.Count > 0; }
public GameSession() { Id = Guid.NewGuid(); CreationTime = DateTime.Now; Status = GameSessionStatus.WaitingForPlayers; teams = new Dictionary<TeamPosition, Team>(2) { { TeamPosition.NorthSouth, new Team() }, { TeamPosition.EastWest, new Team() } }; //initialize bidding start position to the one to the right of South currentBiddingStartPosition = PlayerPosition.East; MatchScore = new MatchScore(); }
public static BridgeGame GetGameFromPbn(string pbnHand) { var hands = new Dictionary<PlayerPosition, Deck>(); var pbnhands = pbnHand.Split(':', ' '); var side = new PlayerPosition(pbnhands.First()); var declarer = side; for (var i = 1; i < 5; i++) { hands.Add(side, GetDeck(pbnhands[i])); side = GetNextPlayerPosition(side); } return new BridgeGame(hands, declarer); }
public Contract(string contract, PlayerPosition declarer) { Value = int.Parse(contract[0].ToString()); PlayerPosition = declarer; var suit = Suit.Suits.FirstOrDefault(x => x.ShortName == new string(contract[1], 1)); if (suit !=null) { Trump = new Trump(suit); } else { Trump = Trump.NoTrump; } }
public SimRound( ISimPlayer firstPlayer, ISimPlayer secondPlayer, IGameRules gameRules, PlayerPosition firstToPlay = PlayerPosition.FirstPlayer) { this.gameRules = gameRules; this.deck = new SimDeck(); this.stateManager = new SimStateManager(); this.firstPlayer = new SimRoundPlayerInfo(firstPlayer); this.secondPlayer = new SimRoundPlayerInfo(secondPlayer); this.firstToPlay = firstToPlay; }
void EndGame(PlayerPosition player) { Ball.winEvent -= EndGame; HideAll(); if(player == PlayerPosition.RIGHT) { ShowPanel(endMonk); audio.clip = monk; } else { ShowPanel(endCrane); audio.clip = crane; } audio.Play(); }
public PawnAttacksGenerator(PlayerPosition position) { if (position == PlayerPosition.Down) { this.direction = 1; this.index = 0; } else { this.direction = -1; this.index = 1; } this.cases = new ulong[2]; this.attacks = new ulong[4]; }
public void GetWinnerPointsShouldReturnFirstPlayerAsWinnerWithThreePoints( int firstPlayerPoints, int secondPlayerPoints, PlayerPosition gameClosedBy, PlayerPosition noTricksPlayer) { IRoundWinnerPointsLogic roundWinnerPointsLogic = new RoundWinnerPointsPointsLogic(); var result = roundWinnerPointsLogic.GetWinnerPoints( firstPlayerPoints, secondPlayerPoints, gameClosedBy, noTricksPlayer, GameRulesProvider.Santase); Assert.AreEqual(PlayerPosition.FirstPlayer, result.Winner); Assert.AreEqual(3, result.Points); }
public static BridgeGame GetGameFromPbn(string pbnHand, string contract, string dec) { var hands = new Dictionary<PlayerPosition, Deck>(); var pbnhands = pbnHand.Split(':', ' '); var side = new PlayerPosition(pbnhands.First()); var declarer = side; for (var i = 1; i < 5; i++) { hands.Add(side, GetDeck(pbnhands[i])); side = GetNextPlayerPosition(side); } if (!string.IsNullOrEmpty(dec)) { declarer = new PlayerPosition(dec); } return new BridgeGame(hands, declarer, contract); }
private bool undoPress(TouchType eventtype, TouchRect touchbox, int x, int y, bool collide) { if (State.Congrats) { return(false); } if (GameService.ClassicGameState.Board.MoveToPosition != null) { return(false); } if (eventtype == TouchType.TouchDown) { Client.PlaySoundEffect(Assets.Sounds.Click); if (State.Moves.Count > 0) { PlayerPosition undo = State.Moves[State.Moves.Count - 1]; State.Moves.Remove(undo); undo.Character.Position.X = undo.X; undo.Character.Position.Y = undo.Y; undo.Character.Direction = undo.Direction; } } return(false); }
public override void AddPlayer() { ILabyrinthNav navi; if (this.detailsConfiguration.LabyrinthNavigation != null) { navi = this.detailsConfiguration.LabyrinthNavigation; } else { navi = new LabyrinthNavigation(this.labyrinth); } var player = new PlayerPosition( this.detailsConfiguration.PlayerNick , navi , this.detailsConfiguration.PlayerVisualization , this.detailsConfiguration.PlayerForegroundColor , this.detailsConfiguration.PlayerBackgroundColor); Position startPosition = this.labyrinth.StartPosition; this.labyrinth[startPosition] = player; }
public void ValidRandomGenerate() { PlayerPosition startPosition = new PlayerPosition(3, 3); string[] rawData = new string[Labyrinth.LabyrinthSize] { "XXXXXXX", "X-X---X", "X---X-X", "X--*--X", "X-X----", "X-----X", "XXXXXXX" }; Cell[,] board = LabyrinthDataFromStringArray(rawData); Labyrinth labyrinth = new Labyrinth(startPosition, board); var privateObject = new PrivateObject(labyrinth); privateObject.Invoke("Generate"); string result = @"X X X X X X X X - X - - - X X - - - X - X X - - * - - X X - X - - - - X - - - - - X X X X X X X X "; string expected = labyrinth.ToString(); Assert.AreNotEqual(labyrinth.ToString(), result); }
public static void MoveLeftRight(double distance) { var controller = BLObject.GetPlayerController(); if (controller == null) goto Failed; var pawn = controller["Pawn"] as BLObject; if (pawn == null || pawn.Class != "WillowPlayerPawn") goto Failed; var position = new PlayerPosition(controller, pawn); if (position == null) goto Failed; position.Yaw += Math.PI / 2; position.X += Math.Cos(position.Yaw) * distance; position.Y += Math.Sin(position.Yaw) * distance; PerformAction($"set {pawn.Name} Location {position.FormatLocation()}", null); return; Failed: RunCommand("say Failed to move position"); }
public void HostPositionSwitchRequest(PlayerPosition playerPosition) { if (playerPosition == PlayerPosition.Spectator) { _hostPlayer.PlayerPosition = playerPosition; LobbyPlayersUpdate(); } else { if (GetAllLobbyPlayers().Find(x => x.PlayerPosition == playerPosition) != null) { return; } // Když byl doteď divák, nastavit volnou barvu if (_hostPlayer.PlayerPosition == PlayerPosition.Spectator) { _hostPlayer.Color = GetNextFreeColor(null); } _hostPlayer.PlayerPosition = playerPosition; LobbyPlayersUpdate(); } }
public void stackUpdated(PlayerPosition position, int stackValue) { MainGrid.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate() { switch (position) { case PlayerPosition.Right: RightLabel.Text = stackValue.ToString(); break; case PlayerPosition.Middle: MiddleLabel.Text = stackValue.ToString(); break; case PlayerPosition.Left: LeftLabel.Text = stackValue.ToString(); break; default: new Exception("Tried to update a stack that doesn't exist"); break; } })); }
public PlayerPosition Start(PlayerPosition firstToPlayInFirstRound = PlayerPosition.FirstPlayer) { this.firstToPlay = firstToPlayInFirstRound; this.RestartGame(); // Inform players this.firstPlayer.StartGame(this.secondPlayer.Name); this.secondPlayer.StartGame(this.firstPlayer.Name); // Play rounds until game winner is determined while (this.GameWinner() == PlayerPosition.NoOne) { this.PlayRound(); this.RoundsPlayed++; } var gameWinner = this.GameWinner(); // Inform players this.firstPlayer.EndGame(gameWinner == PlayerPosition.FirstPlayer); this.secondPlayer.EndGame(gameWinner == PlayerPosition.SecondPlayer); return(gameWinner); }
public static Player CreatePlayer ( PersonName name, Gender gender, BirthInfo birthInfo, Foot favouriteFoot, BodyMassIndex bmi, Percentile percentile, PhysicalFeatureSet physicalFeatureSet, PlayerPosition playerPosition, params Country[] nationalities ) => new Player ( PersonId.CreateNew(), name, gender, birthInfo, favouriteFoot, bmi, percentile, physicalFeatureSet, playerPosition, nationalities );
public void LabyrinthMoveDownTest() { PlayerPosition startPosition = new PlayerPosition(3, 3); string[] rawData = new string[Labyrinth.LabyrinthSize] { "XXXXXXX", "X-X---X", "X---X-X", "X--*--X", "X-X----", "X-----X", "XXXXXXX" }; Cell[,] board = LabyrinthDataFromStringArray(rawData); Labyrinth labyrinth = new Labyrinth(startPosition, board); var privateObject = new PrivateObject(labyrinth); privateObject.Invoke("ProcessMoveDown", 3, 3); string result = @"X X X X X X X X - X - - - X X - - - X - X X - - - - - X X - X * - - - X - - - - - X X X X X X X X "; string expected = labyrinth.ToString(); Assert.AreEqual(expected, result); }
public void TestBasicGame() { GameSession gameSession = PrepareGameSession(); Assert.AreEqual <GameSessionStatus>(GameSessionStatus.GamePlay, gameSession.Status); Player north = gameSession.GetPlayer(PlayerPosition.North); Player south = gameSession.GetPlayer(PlayerPosition.South); Player east = gameSession.GetPlayer(PlayerPosition.East); Player west = gameSession.GetPlayer(PlayerPosition.West); Assert.AreEqual <Suit>(Suit.Spades, gameSession.CurrentBid.Suit); Assert.AreEqual <int>(2, gameSession.CurrentBid.Tricks); Assert.AreEqual <TeamPosition>( TeamPosition.NorthSouth, gameSession.GetTeamPosition( gameSession.GetPlayerPosition(gameSession.CurrentBid.Player))); //--- while (gameSession.Status == GameSessionStatus.GamePlay) { PlayerPosition currentTurn = gameSession.CurrentTurn.Value; GamePlayState tempState; tempState = gameSession.GetGamePlayState(gameSession.GetPlayer(currentTurn)); List <Card> cards = tempState.CurrentCards; Card card = PlayRandomCard(cards, tempState.CurrentTrickBaseSuit); gameSession.PlaceCard(gameSession.GetPlayer(currentTurn), card); Console.WriteLine("{0}-{1}", currentTurn.ToString(), card.ToString()); } Console.WriteLine("NS:{0} - EW:{1}", gameSession.MatchScore.Scores[TeamPosition.NorthSouth], gameSession.MatchScore.Scores[TeamPosition.EastWest]); }
public void playerRaised(PlayerPosition position, int potValue, int stackValue, int raiseAmount) { MainGrid.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate(){ switch (position) { case PlayerPosition.Right: RightLabel.Text = stackValue.ToString(); break; case PlayerPosition.Middle: MiddleLabel.Text = stackValue.ToString(); break; case PlayerPosition.Left: LeftLabel.Text = stackValue.ToString(); break; default: throw new Exception("Tried to update a player that doesn't exist."); } potLabel.Text = potValue.ToString(); addToTextDisplay(String.Concat(position.ToString(), " raised by ", raiseAmount.ToString(), "\n")); })); }
protected override void UpdateScore(Dictionary <PlayerPosition, int> currentScore, PlayerPosition player) { base.UpdateScore(currentScore, player); ResetPoints(bottomPoints.points, out bottomPointCounter, PlayerPosition.Bottom); ResetPoints(topPoints.points, out topPointCounter, PlayerPosition.Top); }
internal IList <BidType> GetAvailableBidsAfterThisContract(PlayerPosition teamMatePosition) { IList <BidType> availableBids = new List <BidType> { BidType.Pass }; if (!this.IsAvailable) { availableBids = new List <BidType> { BidType.Pass, BidType.Clubs, BidType.Diamonds, BidType.Hearts, BidType.Spades, BidType.NoTrumps, BidType.AllTrumps }; } else { switch (this.Type) { case ContractType.Clubs: availableBids = new List <BidType> { BidType.Pass, BidType.Diamonds, BidType.Hearts, BidType.Spades, BidType.NoTrumps, BidType.AllTrumps }; break; case ContractType.Diamonds: availableBids = new List <BidType> { BidType.Pass, BidType.Hearts, BidType.Spades, BidType.NoTrumps, BidType.AllTrumps }; break; case ContractType.Hearts: availableBids = new List <BidType> { BidType.Pass, BidType.Spades, BidType.NoTrumps, BidType.AllTrumps }; break; case ContractType.Spades: availableBids = new List <BidType> { BidType.Pass, BidType.NoTrumps, BidType.AllTrumps }; break; case ContractType.NoTrumps: availableBids = new List <BidType> { BidType.Pass, BidType.AllTrumps }; break; case ContractType.AllTrumps: availableBids = new List <BidType> { BidType.Pass }; break; } if (teamMatePosition != this.PlayerPosition) { // The contract is not from the team mate if (this.IsDoubled) { availableBids.Add(BidType.ReDouble); } else if (!this.IsReDoubled) { availableBids.Add(BidType.Double); } } } return(availableBids); }
public async Task SendMovement(PlayerPosition playerPosition) { await _hubContext.Clients.All.SendAsync("ReceiveMovement", playerPosition); }
void SetInitialPosition() { currentPosition = PlayerPosition.Middle; transform.position = new Vector3(positions[(int)currentPosition], transform.position.y, transform.position.z); }
private object DeserializePlayPacket(UncompressedPacket packet) { var br = new SpanReader(packet.Data); object innerPacket; switch (packet.PacketId) { // Teleport Confirm case 0x00: innerPacket = TeleportConfirm.Deserialize(ref br); break; // Chat Message case 0x03: innerPacket = ServerboundChatMessage.Deserialize(ref br); break; // Client Settings case 0x05: innerPacket = ClientSettings.Deserialize(ref br); break; // Plugin Message case 0x0A: innerPacket = ServerboundPluginMessage.Deserialize(ref br); break; // Keep Alive case 0x0C: innerPacket = ServerboundKeepAlive.Deserialize(ref br); break; // Player On Ground case 0x0D: innerPacket = PlayerOnGround.Deserialize(ref br); break; // Player Position case 0x0E: innerPacket = PlayerPosition.Deserialize(ref br); break; // Position And Look case 0x0F: innerPacket = ServerboundPositionAndLook.Deserialize(ref br); break; // Player Look case 0x10: innerPacket = PlayerLook.Deserialize(ref br); break; // Player Digging case 0x14: innerPacket = PlayerDigging.Deserialize(ref br); break; // Entity Action case 0x15: innerPacket = EntityAction.Deserialize(ref br); break; // Held Item Change case 0x1A: innerPacket = ServerboundHeldItemChange.Deserialize(ref br); break; // Animation case 0x1D: innerPacket = ServerboundAnimation.Deserialize(ref br); break; // Player Block Placement case 0x1F: innerPacket = PlayerBlockPlacement.Deserialize(ref br); break; // Use Item case 0x20: innerPacket = UseItem.Deserialize(ref br); break; // Click Window case 0x08: innerPacket = ClickWindow.Deserialize(ref br); break; // Close Window case 0x09: innerPacket = ServerboundCloseWindow.Deserialize(ref br); break; default: Logger.LogWarning($"Unrecognizable packet id: 0x{packet.PacketId:X2}."); return(null); } if (!br.IsCosumed) { throw new InvalidDataException($"Packet data is not fully consumed."); } return(innerPacket); }
private bool ValidatePlay(PlayerPosition position, Card card) { //TODO: validate the played card return(true); }
public void Start() { IPlayer firstToPlay; IPlayer secondToPlay; IList <Card> firstToPlayCards; IList <Card> secondToPlayCards; if (this.whoWillPlayFirst == PlayerPosition.FirstPlayer) { firstToPlay = this.firstPlayer; firstToPlayCards = this.firstPlayerCards; secondToPlay = this.secondPlayer; secondToPlayCards = this.secondPlayerCards; } else { firstToPlay = this.secondPlayer; firstToPlayCards = this.secondPlayerCards; secondToPlay = this.firstPlayer; secondToPlayCards = this.firstPlayerCards; } var context = new PlayerTurnContext(this.state, deck.GetTrumpCard, deck.CardsLeft); PlayerAction firstPlayerAction = null; do { firstPlayerAction = this.FirstPlayerTurn(firstToPlay, context); if (!this.actionValidator.IsValid(firstPlayerAction, context, firstToPlayCards)) { // TODO: Do something more graceful? throw new InternalGameException("Invalid turn!"); } }while (firstPlayerAction.Type != PlayerActionType.PlayCard); context.FirstPlayedCard = firstPlayerAction.Card; PlayerAction secondPlayerAction = secondToPlay.GetTurn( context, this.actionValidator); if (!this.actionValidator.IsValid(secondPlayerAction, context, secondToPlayCards)) { // TODO: Do something more graceful? throw new InternalGameException("Invalid turn!"); } context.SecondPlayedCard = secondPlayerAction.Card; if (firstToPlay == this.firstPlayer) { this.firstPlayerCard = firstPlayerAction.Card; this.firstPlayerAnnounce = firstPlayerAction.Announce; this.secondPlayerCard = secondPlayerAction.Card; this.secondPlayerAnnounce = secondPlayerAction.Announce; } else { this.firstPlayerCard = secondPlayerAction.Card; this.firstPlayerAnnounce = secondPlayerAction.Announce; this.secondPlayerCard = firstPlayerAction.Card; this.secondPlayerAnnounce = firstPlayerAction.Announce; } firstToPlay.EndTurn(context); secondToPlay.EndTurn(context); ICardWinner cardWinner = new CardWinner(); if (firstToPlay == this.firstPlayer) { this.winner = cardWinner.Winner( firstPlayerAction.Card, secondPlayerAction.Card, this.deck.GetTrumpCard.Suit); } else { this.winner = cardWinner.Winner( secondPlayerAction.Card, firstPlayerAction.Card, this.deck.GetTrumpCard.Suit); } }
public async Task <Player[]> GenerateManyAsync(int nbOfPlayers, Gender?playerGender = null, Country[] countries = null, PlayerPosition playerPosition = null) { List <Task <Player> > tasks = new List <Task <Player> >(); for (int i = 0; i < nbOfPlayers; i++) { tasks.Add(GenerateAsync(playerGender, countries, playerPosition)); } return(await Task.WhenAll(tasks)); }
private static PlayerPosition GetPreviousPlayerPosition(PlayerPosition position) => GetNextPlayerPosition(GetNextPlayerPosition(GetNextPlayerPosition(position)));
public Bid LastOpponentBid() { PlayerPosition partnerPosition = GetOppositePlayerPosition(UserPosition); return(BiddingHistory.LastOrDefault(e => e.PlayerPosition != UserPosition && e.PlayerPosition != partnerPosition)); }
private static PlayerPosition GetOppositePlayerPosition(PlayerPosition position) => GetNextPlayerPosition(GetNextPlayerPosition(position));
public void LobbyPositionSwitchRequest(PlayerPosition playerPosition) { _client.SendMessage(new PlayerPositionSwitchRequest((int)playerPosition)); }
private async Task <ICollection <VmanPlayer> > ProcessFreeMarketPage(int mininumAge, int maximumAge, PlayerPosition position, int page) { Console.WriteLine($"TRACE: Started processing page {page}"); var response = await client.GetAsync($"https://www.virtualmanager.com/free_transfer_listings?minimum_age={mininumAge}&maximum_age={maximumAge}&page={page}&position={position.Value}&country_id=&search=1&commit=Search"); var pageContents = await response.Content.ReadAsStringAsync(); HtmlDocument pageDocument = new HtmlDocument(); pageDocument.LoadHtml(pageContents); Thread.Sleep(100); var playerInfoNodes = pageDocument.DocumentNode.SelectNodes("(//td[contains(@class,'player')]//a[@href])"); var playerInfoLinks = playerInfoNodes .Select(x => x.Attributes.FirstOrDefault(x => x.Name == "href").Value) .Distinct() .ToList(); var players = new List <VmanPlayer>(); for (var i = 0; i < playerInfoLinks.Count(); i++) { var player = new FreeMarketPlayer(client, playerInfoLinks[i]); await player.GetFreeMarketInfo(); await player.GetPlayerInfo(); players.Add(player); } return(players); }
public Player[] GenerateMany(int nbOfPlayers, Gender?playerGender = null, Country[] countries = null, PlayerPosition playerPosition = null) { var list = new List <Player>(); for (int i = 0; i < nbOfPlayers; i++) { list.Add(Generate(playerGender, countries, playerPosition)); } return(list.ToArray()); }
public bool PlayerPosition_IsMidLaneTest(string position) { return(PlayerPosition.IsMidLane(position)); }
public Player[] GenerateManyParallel(int nbOfPlayers, Gender?playerGender = null, Country[] countries = null, PlayerPosition playerPosition = null) { var items = new BlockingCollection <Player>(); Parallel.For(0, nbOfPlayers, (i) => { items.Add(Generate(Gender.Male)); }); items.CompleteAdding(); return(items.ToArray()); }
/// <summary> /// Place the specified card by the specified player in the current trick. /// And evaluate the trick to determine the winner /// </summary> public void PlaceCard(Player player, Card card) { PlayerPosition position = gameSession.GetPlayerPosition(player); if (position == CurrentTurn) { Card tempCard; if (!CurrentTrick.TryGetValue(position, out tempCard)) { if (ValidatePlay(position, card)) { CurrentTrick[position] = card; PlayerCards[position].Remove(card); if (CurrentTrick.Values.Count == 1) { //First card in the trick CurrentTrickBaseSuit = card.Suit; } if (CurrentTrick.Values.Count >= 4) { //Trick is complete -> evalueate PlayerPosition trickWinner = EvaluateCurrentTrick(); CurrentTurn = trickWinner; switch (trickWinner) { case PlayerPosition.North: case PlayerPosition.South: TricksWon[TeamPosition.NorthSouth]++; break; case PlayerPosition.East: case PlayerPosition.West: TricksWon[TeamPosition.EastWest]++; break; } CleanCurrentTrick(); currentNumberOfTricks++; if (IsComplete) { gameSession.GameComplete(); } } else { NextTurn(); } } else { throw new ArgumentException("The played card is invalid"); } } else { throw new InvalidOperationException("The player already placed card for the current trick"); } } else { throw new InvalidOperationException("The player has played not in the right turn"); } }
public Player Generate(Gender?playerGender = null, Country[] countries = null, PlayerPosition playerPosition = null) { if (playerGender == null) { playerGender = _genderGenerator.Generate(); } if (countries == null) { countries = _countriesGenerator.Generate().Value; } PersonName playerName = _nameGenerator.Generate(playerGender.Value, countries.FirstOrDefault()); Date dob = _dobGenerator.Generate(); PersonAge playerAge = PersonAge.FromDate(dob, _game.CurrentDate); Location birthLocation = _birthLocationGenerator.Generate(countries.FirstOrDefault()); Foot playerFoot = _favouriteFootGenerator.Generate(); Percentile percentile = _percentileGenerator.Generate(); BodyMassIndex bmi = _bmiGenerator.Generate(countries.FirstOrDefault(), playerGender.Value, percentile, dob); PlayerPosition position = _playerPositionGenerator.Generate(); PhysicalFeatureSet playerFeatureSet = _physicalFeatureSetGenerator.Generate(position, bmi, countries.FirstOrDefault(), playerAge); // first name & last name => according to the player's country return(new PlayerBuilder() .WithName(playerName) .WithGender(playerGender.Value) .WithBirthInfo(new BirthInfo(dob, birthLocation)) .WithFoot(playerFoot) .WithPercentile(percentile) .WithBodyMassIndex(bmi) .WithPlayerPosition(position) .WithFeatureSet(playerFeatureSet) .WithCountries(countries) .Build()); }
protected void CheckAbandonOne(Mahjong newOne, PlayerPosition playerPos) { }