Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
16 kB
5
Indexable
Never
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "champion.h"

int main(int argc, char* argv[]){

        if(argc == NULL){
                printf("ERROR NO ARGS");
                return -1;
        }
        int numOfChamps = atoi(argv[1]);

        if(numOfChamps <= 0){
                printf("ERROR");
                return -1;
        }


        Champion *p1Champs = buildChampionList(numOfChamps);

        Champion *p2Champs = buildChampionList(numOfChamps);


        printf("============= PLAYER 1 V PLAYER 2 SHOWDOWN =============\n");


        int round = 1;



//      while(p1Champs != NULL && p2Champs != NULL){

                printf("\n----- ROUND %d -----\n", round);

                printf("Player 1: ");
                printChampionList(p1Champs);
                printf("\n");

                printf("Player 2: ");
                printChampionList(p2Champs);
                printf("\n");

                switch(p1Champs->role){

                        case 0:
                                if(p2Champs->role == 0){
                                         printf("Player 1 is a MAGE and Player 2 is a MAGE\n");
                                }
                                else if(p2Champs->role == 1){
                                        printf("Player 1 is a MAGE and Player 2 is a FIGHTER\n");
                                }
                                else if(p2Champs->role == 2){
                                        printf("Player 1 is a MAGE and Player 2 is a SUPPORT\n");
                                }
                                else if(p2Champs->role == 3){
                                        printf("Player 1 is a MAGE and Player 2 is a TANK\n");
                                }
                        //      printf("Player 1 is a %d and Player 2 is a %d\n", p1Champs->role, p2Champs->role);
                        break;

                        case 1:
                                if(p2Champs->role == 0){
                                         printf("Player 1 is a FIGHTER and Player 2 is a MAGE\n");
                                }
                                else if(p2Champs->role == 1){
                                        printf("Player 1 is a FIGHTER and Player 2 is a FIGHTER\n");
                                }
                                else if(p2Champs->role == 2){
                                        printf("Player 1 is a FIGHTER and Player 2 is a SUPPORT\n");
                                }
                                else if(p2Champs->role == 3){
                                        printf("Player 1 is a FIGHTER and Player 2 is a TANK\n");
                                }

                        break;

                        case 2:
                                if(p2Champs->role == 0){
                                         printf("Player 1 is a SUPPORT and Player 2 is a MAGE\n");
                                }
                                else if(p2Champs->role == 1){
                                        printf("Player 1 is a SUPPORT and Player 2 is a FIGHTER\n");
                                }
                                else if(p2Champs->role == 2){
                                        printf("Player 1 is a SUPPORT and Player 2 is a SUPPORT\n");
                                }
                                else if(p2Champs->role == 3){
                                        printf("Player 1 is a SUPPORT and Player 2 is a TANK\n");
                                }

                        break;

                        case 3:
                                if(p2Champs->role == 0){
                                         printf("Player 1 is a TANK and Player 2 is a MAGE\n");
                                }
                                else if(p2Champs->role == 1){
                                        printf("Player 1 is a TANK and Player 2 is a FIGHTER\n");
                                }
                                else if(p2Champs->role == 2){
                                        printf("Player 1 is a TANK and Player 2 is a SUPPORT\n");
                                }
                                else if(p2Champs->role == 3){
                                        printf("Player 1 is a TANK and Player 2 is a TANK\n");
                                }

                        break;

                }


                Champion *newP1;
                Champion *newP2;

                if(p1Champs->role == 0 && p2Champs->role == 0){
                        if(p1Champs->level > p2Champs->level){
                                printf("Player 1 (MAGE) wins and gains a new champion.\n");
                                printf("Player 2 (MAGE) loses one champion.\n");
                                // p1Champs addChampion();
                                newP1 = createChampion();
                                addChampion(p1Champs, newP1);
                                removeChampion(p2Champs);
                        }
                /*      else if(p2Champs->level > p1Champs->level){
                                printf("Player 1 (MAGE) loses one champion.\n");
                                printf("Player 2 (MAGE) wins and gains a new champion.\n");
                                // p2Champs addChampion();
                                newP2 = createChampion();
                                addChampion(p2Champs, newP2);
                                removeChampion(p1Champs);
                        }

                }
                else if(p1Champs->role == M && p2Champs->role == F){
                        if(p1Champs->level > p2Champs->level){
                                printf("Player 1 (MAGE) wins and gains a new champion.\n");
                                printf("Player 2 (FIGHTER) loses with no penalty.\n");
                                newP1 = createChampion();
                                addChampion(p1Champs, newP1);
                        }
                        else if(p2Champs->level > p1Champs->level){
                                printf("Player 1 (MAGE) loses one champion.\n");
                                printf("Player 2 (FIGHTER) wins but gains no reward.\n");
                                removeChampion(p1Champs);
                        }
                else if(p1Champs->role == M && p2Champs->role == S){
                        if(p1Champs->level > p2Champs->level){
                                printf("Player 1 (MAGE) wins and gains a new champion.\n");
                                printf("Player 2 (SUPPORT) loses two champions\n");
                                newP1 = createChampion();
                                addChampion(p1Champs, newP1);
                                removeChampion(p2Champs);
                                removeChampion(p2Champs);
                        }
                        else if(p2Champs->level > p1Champs->level){
                                printf("Player 1 (MAGE) loses one champion.\n");
                                printf("Player 2 (SUPPORT) wins and gains two new champions.\n");
                                removeChampion(p1Champs);
                                newP2 = createChampion();
                                addChampion(p2Champs, newP2);
                                newP2 = createChampion();
                                addChampion(p2Champs, newP2);

                        }
                }
                else if(p1Champs->role == M && p2Champs->role == T){
                        printf("Player 1 (MAGE) wins and gains a new champion.\n");
                        printf("Player 2 (TANK) loses a one champion.\n");
                        newP1 = createChampion();
                        addChampion(p1Champs, newP1);
                        removeChampion(p2Champs);
                }
                else if(p1Champs->role == F && p2Champs->role == M){
                        if(p1Champs->level > p2Champs->level){
                                printf("Player 1 (FIGHTER) wins but gains no reward.\n");
                                printf("Player 2 (MAGE) loses one champion.\n");
                                removeChampion(p2Champs);
                        }
                        else if(p2Champs->level > p1Champs->level){
                                printf("Player 1 (FIGHTER) loses but with no penalty.\n");
                                printf("Player 2 (MAGE) wins and gains a new champion.\n");
                                newP2 = createChampion();
                                addChampion(p2Champs, newP2);
                        }
                }
                else if(p1Champs->role == F && p2Champs->role == F){
                        printf("Player 1 (FIGHTER) gains a new champion");
                        printf("Player 2 (FIGHTER) gains a new champion");
                        newP1 = createChampion();
                        addChampion(p1Champs, newP1);
                        newP2 = createChampion();
                        addChampion(p2Champs, newP2);
                }
                else if(p1Champs->role == F && p2Champs->role == S){
                        if(p1Champs->level > p2Champs->level){
                                printf("Player 1 (FIGHTER) wins but gains no rewards.\n");
                                printf("Player 2 (SUPPORT) loses one champions.\n");
                                removeChampion(p2Champs);
                        }
                        else if(p2Champs->level > p1Champs->level){
                                printf("Player 1 (FIGHTER) loses but with no penalty.\n");
                                printf("Player 2 (SUPPORT) wins and gains one champion.\n");
                                newP2 = createChampion();
                                addChampion(p2Champs, newP2);
                        }
                }
                else if(p1Champs->role == F && p2Champs->role == T){
                        printf("Player 1 (FIGHTER) wins and gains a new champion.\n");
                        printf("Player 2 (TANK) loses but with no penalty.\n");
                        newP1 = createChampion();
                        addChampion(p1Champs, newP1);
                        }
                }
                else if(p1Champs->role == S && p2Champs->role == M){
                        if(p1Champs->level > p2Champs->level){
                                printf("Player 1 (SUPPORT) wins and gains two champions.\n");
                                printf("Player 2 (MAGE) loses one champion.\n");
                                newP1 = createChampion();
                                addChampion(p1Champs, newP1);
                                newP1 = createChampion();
                                addChampion(p1Champs, newP1);
                                removeChampion(p2Champs);
                        }
                        else if(p2Champs->level > p1Champs->level){
                                printf("Player 1 (SUPPORT) loses two champions.\n");
                                printf("Player 2 (MAGE) wins and gains a new champion.\n");
                                removeChampion(p1Champs);
                                removeChampion(p1Champs);
                                newP2 = createChampion();
                                addChampion(p2Champs, newP2);
                        }
                }
                else if(p1Champs->role == S && p2Champs->role == F){
                        if(p1Champs->level > p2Champs->level){
                                printf("Player 1 (SUPPORT) wins and gains a new champion.\n");
                                printf("Player 2 (FIGHTER) loses but with no penalty.\n");
                                newP1 = createChampion();
                                addChampion(p1Champs, newP1);
                        }
                        else if(p2Champs->level > p1Champs->level){
                                printf("Player 1 (SUPPORT) loses one champion.\n");
                                printf("Player 2 (FIGHTER) wins but gains no reward.\n");
                                removeChampion(p1Champs);
                        }
                }
                else if(p1Champs->role == S && p2Champs->role == S){
                        printf("Player 1 (SUPPORT) loses a champion.\n");
                        printf("Player 2 (SUPPORT) loses a champion.\n");
                        removeChampion(p1Champs);
                        removeChampion(p2Champs);
                }
                else if(p1Champs->role == S && p2Champs->role == T){
                        printf("Player 1 (SUPPORT) loses but with no penalty.\n");
                        printf("Player 2 (TANK) wins and gains a new champion.\n");
                        newP2 = createChampion();
                        addChampion(p2Champs, newP2);
                }
                else if(p1Champs->role == T && p2Champs->role == M){
                        printf("Player 1 (TANK) loses one champion.\n");
                        printf("Player 2 (MAGE) wins and gains a new champion.\n");
                        removeChampion(p1Champs);
                        newP2 = createChampion();
                        addChampion(p2Champs, newP2);
                }
                else if(p1Champs->role == T && p2Champs->role == F){
                        printf("Player 1 (TANK) loses but with no penalty.\n");
                        printf("Player 2 (FIGHTER) wins and gains a new champion.\n");
                        newP2 = createChampion();
                        addChampion(p2Champs, newP2);
                }
                else if(p1Champs->role == T && p2Champs->role == S){
                        printf("Player 1 (TANK) wins and gains a new champion.\n");
                        printf("Player 2 (SUPPORT) loses but with no penalty.\n");
                        newP1 = createChampion();
                        addChampion(p1Champs, newP1);
                }
                else if(p1Champs->role == T && p2Champs->role == T){
                        printf("Player 1 (TANK) gains no penalty or reward.\n");
                        printf("Player 2 (TANK) gains no penalty or reward.\n");
                }

                round++;
        }

        printf("\n============= GAME OVER =============\n\n");
        printf("Player 1 ending champion list: ");
        printChampionList(p1Champs);
        printf("Player 2 ending champion list: ");
        printChampionList(p2Champs);

        if(p1Champs == NULL && p2Champs == NULL){
                printf("\nTIE -- both players ran out of champions.\n");
        }
        else if(p1Champs == NULL){
                printf("\nPlayer 1 ran out of champions. Player 2 wins\n");
        }
        else{
                printf("\nPlayer 2 ran out of champions. Player 1 wins\n");
        }

        while(p1Champs != NULL){
                destroyChampionList(p1Champs);
        }
        while(p2Champs != NULL){
                destroyChampionList(p2Champs);
        }*/

return 0;
}
}