-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
214 lines (155 loc) · 5.34 KB
/
Copy pathmainwindow.cpp
File metadata and controls
214 lines (155 loc) · 5.34 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "ZorkUL.h"
#include "Room.h"
#include "Parser.h"
#include "CommandWords.h"
#include "Command.h"
#include <iostream>
#include <QPixmap>
#include <QMessageBox>
#include <stdlib.h>
#include <QString>
string z = "\n";
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
zorkgame = new ZorkUL();
parser = new Parser();
//commandword = new CommandWords();
}
inline void MainWindow::paragraph(){
ui->OutputCons0le->append(QString::fromStdString(z));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
//2.cin
}
//void MainWindow::playbutton()
//{
// play();
//}
void MainWindow::on_ClearButton_clicked()
{
ui->OutputCons0le->clear();
}
void MainWindow::on_Description_clicked()
{
ui->OutputCons0le->append(QString::fromStdString(zorkgame->currentRoom->longDescription()));
// ui->OutputCons0le->append(QString::fromStdString(z));
paragraph();
}
void MainWindow::on_west_clicked()
{
zorkgame->go("west");
ui->OutputCons0le->append(QString::fromStdString(zorkgame->currentRoom->shortDescription()));
paragraph();
}
void MainWindow::on_North_clicked()
{
zorkgame->go("north");
ui->OutputCons0le->append(QString::fromStdString(zorkgame->currentRoom->shortDescription()));
paragraph();
}
void MainWindow::on_Search_clicked()
{
ui->OutputCons0le->append(QString::fromStdString(zorkgame->currentRoom->longDescription()));
paragraph();
}
//void MainWindow::updateText( const QString & newText )
//{
// connect(zork, SIGNAL( sendText( const QString & ) ), ui, SLOT( updateText( const QString & ) ) );
//}
void MainWindow::on_South_clicked()
{
zorkgame->go("south");
ui->OutputCons0le->append(QString::fromStdString(zorkgame->currentRoom->shortDescription()));
paragraph();
}
void MainWindow::on_East_clicked()
{
zorkgame->go("east");
ui->OutputCons0le->append(QString::fromStdString(zorkgame->currentRoom->shortDescription()));
paragraph();
}
void MainWindow::on_GoldTooltip_clicked()
{
QString text = ui->GoldCounter->toPlainText();
if(text == "golden"){
ui->OutputCons0le->append("CONGRADS youve won the game good job");
}
}
void MainWindow::on_Use_clicked()
{
if(zorkgame->inventory.size() > 6){
cout << "congrads you have completed the game" << endl;
qApp->quit();
}
}
void MainWindow::on_Item_clicked()
{
if(zorkgame->inventory.size() > 6){
ui->Inventory->append("The gold statue when assembled makes out the word : golden ");
}
else{
ui->OutputCons0le->append("no cheating");
}
}
void MainWindow::on_LOOT_clicked()
{
//zorkgame->take("gold");
ui->Inventory->append(QString::fromStdString(zorkgame->addItemToInv(zorkgame->currentRoom->numberOfItems()-1)));
paragraph();
}
void MainWindow::on_Map_clicked()
{
ui->OutputCons0le->append( " [H]<--->[F]<--->[G] \n"
" | | \n"
" [C]<--->[A]<--->[B] \n"
" | | \n"
" [I]<--->[D]<--->[E] \n"
" | \n"
" [J] \n"
" | \n"
" [K] \n");
}
void MainWindow::on_OutputCons0le_textChanged()
{
}
void MainWindow::on_Playbutton_clicked()
{
// zorkgame->play();
//ui->OutputCons0le->setText(QString::fromStdString(zorkgame->play());
string help = "click the direction buttons to move through rooms. You will need to search rooms in order to find out what they contain."
"if your screen gets cluttered click the clear button however being able to see what past rooms contained can be helpful."
"Just rememeber to carefully search the rooms and click loot howver many times is nessarsy to pick up the items you need."
"If you reference the map via the button you will your starting point is A and it is oriented accordingly."
"Collect the 7 piece a mthyical gold treasure and click ITEM in order to get the final sercret word."
"Once Completed click USE to end the game once you have the 7 pieces or click item to reveal the secret word which you "
"can enter into the text bpx TO ESCAPE. Good Luck adventurer ";
ui->OutputCons0le->append("Welcome To Zork. This game takes place in a house where you have just awoken \n");
ui->OutputCons0le->append(QString::fromStdString(help + z));
ui->OutputCons0le->append(QString::fromStdString(zorkgame->currentRoom->shortDescription()));
paragraph();
// ui->OutputCons0le->append(QString::fromStdString(zorkgame->printHelp()));
}
void MainWindow::on_Teleport_released()
{
//cannot get to work by moving rooms after teleporting
zorkgame->randTeleport();
ui->OutputCons0le->append(QString::fromStdString(zorkgame->currentRoom->shortDescription()));
paragraph();
}
void MainWindow::on_Inventory_copyAvailable(bool b)
{
b;
}
void MainWindow::on_GoldCounter_copyAvailable(bool b)
{
}