Beispiel #1
0
/***************************************************************************
*
*  Função: JOG  &Destruir jogo
*  ****/
JOG_tpCondRet JOG_destruir(Jogo *jogo)
{
    //Assertiva de entrada
#ifdef _DEBUG  
  if(!jogo)
        return JOG_CondRetJogoInexistente;
#endif

    TAB_destruir(jogo->tabuleiro);
    free(jogo);
    return JOG_CondRetOK;
}/* Fim função: JOG  &Destruir jogo */
Tabuleiro *TAB_criar()
{
    int x, y;
    Tabuleiro *tabuleiro = (Tabuleiro*)malloc(sizeof(Tabuleiro));
    if(!tabuleiro)
        return NULL;
    //Tratamento de espaço dinamico
#ifdef _DEBUG
    CED_DefinirTipoEspaco(tabuleiro, TAB_Tabuleiro);
#endif

    tabuleiro->lista = LIS_CriarLista(ListaExcluirLista);
    if(!tabuleiro->lista) {
        free(tabuleiro);
        return NULL;
    }
    for(y = 0; y < TabuleiroAltura; ++y) {
        LIS_tppLista lista = LIS_CriarLista(ListaExcluirPeca);
        if(!lista) {
            TAB_destruir(tabuleiro);
            return NULL;
        }
        if(LIS_InserirElementoAntes(tabuleiro->lista, lista) != LIS_CondRetOK) {
            TAB_destruir(tabuleiro);
            return NULL;
        }
        for(x = 0; x < TabuleiroLargura; ++x){
            if(LIS_InserirElementoAntes(lista, NULL) != LIS_CondRetOK) {
                TAB_destruir(tabuleiro);
                return NULL;
            }
        }
    }

    return tabuleiro;
}/* Fim função: TAB  &Criar tabuleiro */