-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlevel.cc
39 lines (31 loc) · 1.09 KB
/
level.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "level.h"
#include <cstdlib>
#include <ctime>
#include <cstdlib>
using namespace std;
Level::Level(): currentLvl(1){}
Level::Level(int currentLvl): currentLvl(currentLvl){}
int Level::getCurrentLvl(){ return currentLvl; }
void Level:: setCurrentLvl(int newLvl){ currentLvl = newLvl; }
char Level::generator(int I, int J, int L, int O, int S, int Z, int T){
int weightI = I;
int weightJ = weightI + J;
int weightL = weightJ + L;
int weightO = weightL + O;
int weightS = weightO + S;
int weightZ = weightS + Z;
int weightT = weightZ + T;
int total = weightT;
srand(time(0));
int randomNum = 1 + (rand() % total);
if(randomNum <= weightI) return 'I';
else if(randomNum <= weightJ) return 'J';
else if(randomNum <= weightL) return 'L';
else if(randomNum <= weightO) return 'O';
else if(randomNum <= weightS) return 'S';
else if(randomNum <= weightZ) return 'Z';
else return 'T';
}
char Level::lvlOne(){ return generator(2, 2, 2, 2, 1, 1, 2); }
char Level::lvlTwo(){ return generator(1, 1, 1, 1, 1, 1, 1); }
char Level::lvlThree(){ return generator(1, 1, 1, 1, 2, 2, 1); }