Exemplo n.º 1
0
    // Client-called function to play a card from the player's hand
    public void PlayCardFromHand(int player, int cardID)
    {
        if (m_turnState == CGTurnState.WAIT_FOR_PLAY_CARD_FROM_HAND && m_activePlayerID == player)
        {
            if (m_activePlayer.CanPlayCard(cardID))
            {
                // Play the card from hand, adding any "OnPlay" effects to the stack
                m_activePlayer.PlayCardFromHand(cardID);

                // Add any "PlayCard" triggered effects to the stack
                TriggerEvent("PlayCard");

                ResolveStack();

                // Return to game logic once a card has been played
                m_turnState = CGTurnState.CARD_PLAYED_FROM_HAND;
                RunGameLogic();
                return;
            }

            // Tell client to highlight playable cards and keep waiting for a valid card
            List <int> playableCardIDs      = m_activePlayer.m_hand.GetPlayableCardIDs();
            CGC_WaitForPlayFromHand command = new CGC_WaitForPlayFromHand(playableCardIDs, m_activePlayerID);
            m_connection.TransmitStream(command.PackCommand(), m_activePlayerID);
        }
    }
Exemplo n.º 2
0
    /** "Play" phase */
    CGTurnState Phase3()
    {
        Debug.Log("Phase 3: Play phase");

        List <int> playableCardIDs = m_activePlayer.m_hand.GetPlayableCardIDs();

        if (playableCardIDs.Count == 0)
        {
            TriggerEvent("SkipCard");
            ResolveStack();
            return(CGTurnState.DEFAULT);
        }

        // Tell client to highlight playable cards
        CGC_WaitForPlayFromHand command = new CGC_WaitForPlayFromHand(playableCardIDs, m_activePlayerID);

        CGVisualManager.instance.AddCommand(command);

        // Wait for client to return chosen card
        return(CGTurnState.WAIT_FOR_PLAY_CARD_FROM_HAND);
    }
Exemplo n.º 3
0
    /** "Play" phase */
    CGTurnState Phase3()
    {
        Debug.Log("Phase 3: Play phase");

        SendPhaseTransition("Play step");

        List <int> playableCardIDs = m_activePlayer.m_hand.GetPlayableCardIDs();

        if (playableCardIDs.Count == 0)
        {
            TriggerEvent("SkipCard");
            ResolveStack();
            return(CGTurnState.DEFAULT);
        }

        // Tell client to highlight playable cards
        CGC_WaitForPlayFromHand command = new CGC_WaitForPlayFromHand(playableCardIDs, m_activePlayerID);

        m_connection.TransmitStream(command.PackCommand(), m_activePlayerID);

        // Wait for client to return chosen card
        return(CGTurnState.WAIT_FOR_PLAY_CARD_FROM_HAND);
    }
Exemplo n.º 4
0
    public static CGCommand CreateCommandFromPacket(BKSystem.IO.BitStream packet)
    {
        if (packet.Length < 0)
        {
            return(null);
        }

        ushort commandID;

        packet.Position = 0;
        packet.Read(out commandID, 0, 16);
        Debug.Log("Read packet with command ID: " + commandID);

        CGCommand command;

        switch (commandID)
        {
        case (ushort)CGCommandID.CAST_SPELL:
            command = new CGC_CastSpell(packet);
            break;

        case (ushort)CGCommandID.CHANNEL_SPELL:
            command = new CGC_ChannelSpell(packet);
            break;

        case (ushort)CGCommandID.MOVE_CARD_TO_GRAVEYARD:
            command = new CGC_MoveCardToGraveyard(packet);
            break;

        case (ushort)CGCommandID.OPPONENT_DRAW_CARD:
            command = new CGC_OpponentDrawCard(packet);
            break;

        case (ushort)CGCommandID.OPPONENT_PLAY_CARD_FROM_HAND:
            command = new CGC_OpponentPlayCardFromHand(packet);
            break;

        case (ushort)CGCommandID.PLAYER_DRAW_CARD:
            command = new CGC_PlayerDrawCard(packet);
            break;

        case (ushort)CGCommandID.PLAYER_PLAY_CARD_FROM_HAND:
            command = new CGC_PlayerPlayCardFromHand(packet);
            break;

        case (ushort)CGCommandID.SET_LIFE:
            command = new CGC_SetLife(packet);
            break;

        case (ushort)CGCommandID.WAIT_FOR_CAST_SELECTION:
            command = new CGC_WaitForCastSelection(packet);
            break;

        case (ushort)CGCommandID.WAIT_FOR_PLAY_FROM_HAND:
            command = new CGC_WaitForPlayFromHand(packet);
            break;

        case (ushort)CGCommandID.SET_PLAYER_ID:
            command = new CGC_SetPlayerID(packet);
            break;

        case (ushort)CGCommandID.PHASE_TRANSITION:
            command = new CGC_PhaseTransition(packet);
            break;

        case (ushort)CGCommandID.REQUEST_DECK:
            command = new CGC_RequestDeck(packet);
            break;

        case (ushort)CGCommandID.REFRESH_TIMEOUT:
            command = new CGC_RefreshTimeout(packet);
            break;

        default:
            command = null;
            break;
        }

        return(command);
    }