//Function to generate StuffItem randomly StuffItem* generateWeapon() { int price = doRand(100, 1000); int type = doRand(0,6); char *name = generateName(type); int bonusATT = doRand(1,10); int bonusDEFRel = doRand(1,5); int bonusDEFAbs = doRand(1,10); StuffItem* newStuff = stuffItem_ctor(name,price,type,bonusATT,bonusDEFRel,bonusDEFAbs); return newStuff; }
int setDestroyer(int nbDestroyer, int plateau[PLATEAU_HEIGHT][PLATEAU_WIDTH]){ int i = 0; int x = -1; int y = -1; int flag = 1; for(i=0;i<nbDestroyer;i++){ while(flag){ y = doRand(0,PLATEAU_HEIGHT); x = doRand(0,PLATEAU_WIDTH); if(testCase(x,y,DESTROYER_WIDTH,plateau) == 0){ setNavire(x,y,DESTROYER_WIDTH,DESTROYER_ID,plateau); flag = 0; } } flag = 1; } }
int setCorvette(int nbCorvette, int plateau[PLATEAU_HEIGHT][PLATEAU_WIDTH]){ int i = 0; int x = -1; int y = -1; int flag = 1; for(i=0;i<nbCorvette;i++){ while(flag){ y = doRand(0,PLATEAU_HEIGHT); x = doRand(0,PLATEAU_WIDTH); if(testCase(x,y,CORVETTE_WIDTH,plateau) == 0){ setNavire(x,y,CORVETTE_WIDTH,CORVETTE_ID,plateau); flag = 0; } } flag = 1; } }
int setCroiseur(int nbCroiseur, int plateau[PLATEAU_HEIGHT][PLATEAU_WIDTH]){ int i = 0; int x = -1; int y = -1; int flag = 1; for(i=0;i<nbCroiseur;i++){ while(flag){ y = doRand(0,PLATEAU_HEIGHT); x = doRand(0,PLATEAU_WIDTH); if(testCase(x,y,CROISEUR_WIDTH,plateau) == 0){ setNavire(x,y,CROISEUR_WIDTH,CROISEUR_ID,plateau); flag = 0; } } flag = 1; } }