-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaviculturepage.cpp
More file actions
164 lines (152 loc) · 5.69 KB
/
Copy pathaviculturepage.cpp
File metadata and controls
164 lines (152 loc) · 5.69 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#include "aviculturepage.h"
#include "ui_aviculturepage.h"
#include <QMessageBox>
AviculturePage::AviculturePage(Aviculture* _aviculture, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::AviculturePage)
{
ui->setupUi(this);
this->setFixedSize(900,600);
setWindowTitle("Aviculture");
pix = new QPixmap(":/new/prefix1/img/logo.jpg");
icon = new QIcon(*pix);
this->setWindowIcon(*icon);
aviculture = _aviculture;
refresh_timer = new QTimer(this);
refresh_timer->start(50);
connect(refresh_timer, SIGNAL(timeout()), this, SLOT(Set_values()));
}
AviculturePage::~AviculturePage()
{
delete ui;
}
void AviculturePage::on_pushButton_clicked()
{
switch(aviculture->Build()){
case 1:
//qmessagebox --> "aviculture is already built";
QMessageBox::critical(this,"BUILT","aviculture is already built");
break;
case 2:
//qmessagebox --> "aviculture is locked";
QMessageBox::critical(this,"LEVEL","you cannot build aviculture until you reach level 2");
break;
case 3:
//qmessagebox --> "not enough coins for building"
QMessageBox::critical(this,"COINS","not enough coins for building \n10 coins are needed");
break;
case 4:
//qmessagebox --> "not enough nails for building"
QMessageBox::critical(this,"NAILS","not enough nails for building \n2nails are needed");
break;
case 5:
//qmessageboc --> "timer set for building"
QMessageBox::information(this,"START","timer set for building");
break;
}
}
void AviculturePage::on_pushButton_2_clicked()
{
switch(aviculture->Upgrade()){
case 1:
//qmessagebox --> "aviculture is not built yet"
QMessageBox::critical(this,"NOT BUILT","aviculture is not built yet");
break;
case 2:
//qmessagebox --> "you cannot upgrade aviculture until you reach level 3"
QMessageBox::critical(this,"LEVEL","you cannot upgrade aviculture until you reach level 3");
break;
case 3:
//qmessagebox --> "not enough coins for upgrading"
QMessageBox::critical(this,"COINS","not enough coins for upgrading \n10 coins are needed");
break;
case 4:
//qmessagebox --> "not enough nails for upgrading"
QMessageBox::critical(this,"NAILS","not enough nails for upgrading \n1 nail is needed");
break;
case 5:
QMessageBox::critical(this,"UPGEADING","aviculture is already in upgrading situation");
break;
case 6:
//qmessagebox --> "timer set for upgrading"
QMessageBox::information(this,"START","timer set for upgrading");
break;
}
}
void AviculturePage::on_pushButton_3_clicked()
{
switch(aviculture->Feed()){
case 1:
//qmessagebox --> "aviculture is not built yet"
QMessageBox::critical(this,"NOT BUILT","aviculture is not built yet");
break;
case 2:
//qmessagebox --> "aviculture is empty"
QMessageBox::critical(this,"EMPTY","aviculture is empty");
break;
case 3:
//qmessagebox --> "you have to wait for timer to finish and collect egg to feed chickens"
QMessageBox::critical(this,"NOT READY AND NOT COLLECTED PRODUCT","you have to wait for timer to finish and collect egg to feed chickens");
break;
case 4:
QMessageBox::critical(this,"UPGEADING","After Aghol upgraded you can feed them");
break;
case 5:
//qmessagebox --> "not enough wheat for feeding"
QMessageBox::critical(this,"NOT ENOUGH WHEAT","not enough wheat for feeding");
break;
case 6:
//qmessagebox --> "timer set for eggs"
QMessageBox::information(this,"START","timer set for eggs");
break;
}
}
void AviculturePage::on_pushButton_4_clicked()
{
switch (aviculture->Collect()) {
case 1:
//qmessagebox --> "no egg to collect"
QMessageBox::critical(this,"NO EGG","no egg to collect");
break;
case 2:
//qmessagebox --> "not enough space in store for eggs"
QMessageBox::critical(this,"NOT ENOUGH SPACE","not enough space in store for eggs");
break;
case 3:
//qmessagebox --> "eggs collected successfully"
QMessageBox::information(this,"SUCCESS","eggs collected successfully");
break;
case 4:
//qmessagebox --> "aviculture is not built yet"
QMessageBox::critical(this,"NOT BUILT","aviculture is not built yet");
break;
}
}
void AviculturePage::Set_values(){
ui->label->setText(QString::number(aviculture->Get_level()));
ui->label_2->setText(QString::number(aviculture->Get_used_storage()) + "/" + QString::number(aviculture->Get_total_storage()));
if(aviculture->Get_building_status() == 0){
ui->label_3->setText("Locked");
}
else if((aviculture->Get_building_status() == 1)&&(aviculture->Get_building_timer() == 0)){
ui->label_3->setText("Not built");
}
else if((aviculture->Get_building_status() == 1)&&(aviculture->Get_building_timer() > 0)){
ui->label_3->setText("Building..." + QString::number(aviculture->Get_building_timer()));
}
else if(aviculture->Get_upgrade_timer() > 0){
ui->label_3->setText("Upgrading" + QString::number(aviculture->Get_upgrade_timer()));
}
else if((aviculture->Get_feeding_status() == 0)&&(aviculture->Get_used_storage() > 0)){
ui->label_3->setText("Ready to feed");
}
else if((aviculture->Get_feeding_status() == 0)){
ui->label_3->setText("Empty");
}
else if(aviculture->Get_feeding_status() == 1){
ui->label_3->setText("Eggs ready in " + QString::number(aviculture->Get_feeding_timer()));
}
else {
ui->label_3->setText("Eggs ready");
}
}