/// <summary> /// Adds cards to local user's hand. /// </summary> private void OnStartingHandReceived(MatchMessageStartingHand message) { if (message.PlayerId == _connection.Session.UserId) { for (int i = 0; i < message.Cards.Count; i++) { _localHandPanel.DrawCard(message.Cards[i], i); } _localGold.Restart(); _localGoldPanel.Init(_localGold); } }
/// <summary> /// Selects a number of cards equal to <see cref="Hand._cardIdsInHand"/> from players deck /// and sends them to that player. /// </summary> private void SendStartingHand(string userId) { Hand hand = userId == _connection.BattleConnection.HostId ? _localHand : _opponentHand; List <Card> cards = hand.DrawInitialCards(); MatchMessageStartingHand message = new MatchMessageStartingHand(userId, cards); if (userId == _connection.BattleConnection.HostId) { _stateManager.SendMatchStateMessageSelf(MatchMessageType.StartingHand, message); } else { _stateManager.SendMatchStateMessage(MatchMessageType.StartingHand, message); _opponentGold.Restart(); } }