-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstorm.cpp
118 lines (106 loc) · 3.03 KB
/
storm.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include "initialization.h"
#include <ctime>
#include <iostream>
#include <cstdlib>
using namespace std;
bool storm(list<Zone> &mainList){
//random number
int random;
//setting severe weather
bool severeweather= false;
random = rand() % 10 + 1;
//cout<<"random number: ";
// cout<<random<<endl;
cout<<"Weather: ";
switch(random){
case 1:
//severe weather
cout<<"Severe Tornado"<<endl;
severeweather= true;
break;
case 2:
//weather but it is not severe
cout<<"Normal Storm"<<endl;
break;
case 3:
//no storm
cout<<"Sunshine"<<endl;
break;
case 4:
//severe weather
cout<<"Severe Weather"<<endl;
severeweather= true;
break;
case 5:
//no storm
cout<<"Sun and Light wind"<<endl;
break;
case 6:
//severe weather
cout<<"Acid Rain"<<endl;
severeweather= true;
break;
case 7:
//not severe
cout<<"Light showers"<<endl;
break;
case 8:
//no storm
cout<<"Sunshine"<<endl;
break;
case 9:
//no storm
cout<<"Overcast"<<endl;
break;
case 10:
//severe weather
cout<<"Severe Sinkhole"<<endl;
severeweather = true;
break;
}
return severeweather;
}
void severe(list<Zone> &mainList){
//getting max row and col of simcity for storm location
int row=0;
int col=0;
for( auto it : mainList){
if(it.Getx() > col){
col= it.Getx();
}
if(it.Gety() > row){
row= it.Gety();
}
}
//getting random coordinates
int xcoord;
int ycoord;
xcoord = rand() % row + 1;
ycoord = rand() % col +1;
//cout storm location
cout<<"storm coordinates: ("<<xcoord<<", "<<ycoord<<")"<<endl;
//practice to make sure its working/debug
//int pop=0;
//int newpop=0;
//iterates through the mainlist to find the correct corridnate then it is resident/commerical/or industrial area it changes pop
for(auto it = mainList.begin(); it != mainList.end(); ++it){
int x= it->Getx();
int y= it->Gety();
if(x == xcoord && y == ycoord){
//cout<<"location thing: "<< it->GetZoneType()<<endl;
if(it->GetZoneType() == 'R'&& it->GetPop()> 0){
//pop=it->GetPop();
it->SetPop(0);
//newpop=it->GetPop();
}else if(it->GetZoneType() == 'C'&& it->GetPop()> 0){
//pop=it->GetPop();
it->SetPop(0);
//newpop=it->GetPop();
}else if(it->GetZoneType() == 'I'&& it->GetPop()> 0){
//pop=it->GetPop();
it->SetPop(0);
//newpop=it->GetPop();
}else{}
}
}
}