Esempio n. 1
0
    private void enemyMoveCharacter(JSONObject json)
    {
        JSONObject start_position = json.GetField("start_position");
        Position   start_pos      = JSONReader.getPositionInstance(start_position);

        JSONObject end_position = json.GetField("end_position");
        Position   end_pos      = JSONReader.getPositionInstance(end_position);

        control.moveCreature(start_pos, end_pos);
    }
Esempio n. 2
0
    /// <summary>
    /// Função ainda em alfa.
    /// </summary>
    /// <param name="json"></param>
    private void enemyPlayCharacter(JSONObject json)
    {
        int id = (int)json.GetField("id").n;

        JSONObject position = json.GetField("position");
        Position   pos      = JSONReader.getPositionInstance(position);

        int cost = (int)json.GetField("cost").n;

        this.opponentPlayCreature(id, cost, pos);
    }
Esempio n. 3
0
    /// <summary>
    /// Trata o json recebido quando o oponente joga uma magia.
    /// </summary>
    /// <param name="json"></param>
    private void enemyPlayMagic(JSONObject json)
    {
        int  id   = (int)json.GetField("id").n;
        Card card = control.getCardById(id);

        card.setPlayerId(control.getOpponentId());
        JSONObject positionJSON = json.GetField("position");
        Position   position     = null;

        if (positionJSON != null)
        {
            position = JSONReader.getPositionInstance(positionJSON);
        }
        this.control.playMagic(card, position);
    }
Esempio n. 4
0
    private void enemyAttack(JSONObject json)
    {
        int        target_id         = (int)json.GetField("target_id").n;
        JSONObject position          = json.GetField("attacker_position");
        Position   attacker_position = JSONReader.getPositionInstance(position);

        Card          attacker_card = control.getField().getCardByPosition(attacker_position);
        BattleControl battleControl = control.getBattleControl();

        //atacou direto
        if (target_id == -1)
        {
            battleControl.directAttack(attacker_card, control.getPlayerId());
        }
        else
        {
            JSONObject target_positionJSON = json.GetField("target_position");
            Position   target_position     = JSONReader.getPositionInstance(target_positionJSON);

            Card target_card = control.getField().getCardByPosition(target_position);
            battleControl.cardAttackCard(attacker_card, target_card);
        }
    }