forked from Haroooold/motaGroup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbattle.h
53 lines (44 loc) · 1.39 KB
/
battle.h
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
/*
* File: battle.h
* --------------
* This file exports a class <code>battle</code>. Information about monster
* and hero would be input. After checking whether the hero is stronger than
* monster, <code>battleFrame</code> shows with Hps of hero and monster
* decreasing in turn. Delete frame and set focus back to <code>Hero</code>.
*/
#ifndef BATTLE_H
#define BATTLE_H
#include <QGraphicsRectItem>
#include <QGraphicsTextItem>
#include <QBrush>
#include <QObject>
#include <QTimer>
#include "Hero.h"
#include "Monster.h"
#include "Game.h"
class battle: public QObject
{ Q_OBJECT
public:
// constructor
battle(Monster* monster, Hero* hero);
// public methods
void battleFrameShow(Monster* monster, Hero* hero);
bool checkBattle();
void updateText();
public slots:
void battleOnce(); // show
private:
// private variables
int monsterId, monsterHp, monsterAtk, monsterDef;
int heroHp, heroAtk, heroDef;
int monsterHarm, heroHarm; // harm = atk - def
QString monsterHpInfo, monsterAtkInfo, monsterDefInfo;
QString heroHpInfo, heroAtkInfo, heroDefInfo;
QGraphicsTextItem* monsterHpText,* monsterAtkText,* monsterDefText;
QGraphicsTextItem* heroHpText,* heroAtkText,* heroDefText;
QGraphicsRectItem* battleFrame;
QGraphicsPixmapItem* hero_img_battle;
QGraphicsPixmapItem* monster_img_battle;
QTimer* timer;
};
#endif // BATTLE_H