
#include "Tscene.h"



void Tscene::perso_set_equipement(Tobjet& objet)
{
    static bool mode = false;
    int skeleton = 1;

    mode = (objet.getConteneur() == CONTENEUR_NULL);

    for (size_t i = 0; i < perso.size(); i++)
    {
        if (perso[i].getCode() == "skeleton_warrior")
        {
            skeleton = i;
            break;
        }
    }

    if (mode)
    {
        bool result = true;

        switch(objet.getType())
        {
        case OBJ_CASQUE:
            result = perso[skeleton].setEquipement( objet );
            break;
        case OBJ_BOUCLIER:
            result = perso[skeleton].setEquipement( objet );
            break;
        case OBJ_ARME:
            result = perso[skeleton].setEquipement( objet );
            break;
        case OBJ_ARME_TIR:
            result = perso[skeleton].setEquipement( objet );
            break;
        }
        if (result == false)
        {
            lblInfo1.setText("enlevez l'objet en place !");
        }
    }
    else
    {
        switch(objet.getType())
        {
        case OBJ_CASQUE:
            perso[skeleton].setEquipement_no( EMP_TETE );
            break;
        case OBJ_BOUCLIER:
            perso[skeleton].setEquipement_no( EMP_BRAS_G );
            break;
        case OBJ_ARME:
            perso[skeleton].setEquipement_no( EMP_MAIN_D );
            break;
        case OBJ_ARME_TIR:
            perso[skeleton].setEquipement_no( EMP_MAIN_D );
            break;
        }
    }
}

void Tscene::perso_set_effect(size_t idx, int bt)
{
    switch(bt)
    {
    case 0:
        perso[idx].setState(PER_STATE_NULL);
        for (size_t i = 0; i < btEffect.size(); i++)
        {
            btEffect[i].setState(OBUTTON_UP);
        }
        break;
    case 1:
        perso[idx].setState(PER_STATE_FREEZE_UP); // le barbare
        for (size_t i = 1; i < btEffect.size(); i++)
        {
            btEffect[i].setState(OBUTTON_ENABLED);
        }
        break;
    case 2:
        perso[idx].setState(PER_STATE_KO);
        for (size_t i = 1; i < btEffect.size(); i++)
        {
            btEffect[i].setState(OBUTTON_ENABLED);
        }
        break;
    case 3:
        perso[idx].setState(PER_STATE_FIRE);
        for (size_t i = 1; i < btEffect.size(); i++)
        {
            btEffect[i].setState(OBUTTON_ENABLED);
        }
        break;
    }
}


