This commit is contained in:
Andrei Yankovich 2019-11-20 18:12:18 +03:00
parent b272942672
commit d632b240b3
5 changed files with 28 additions and 3 deletions

View File

@ -283,3 +283,14 @@ void BackEnd::setProfile(QString profile) {
_profile = profile;
emit profileChanged(_profile);
}
void BackEnd::setReward(int revard) {
auto profile = _profileList.value(_profile, nullptr);
if (!profile) {
return;
}
if (profile->record() < revard) {
profile->setRecord(revard);
}
}

View File

@ -109,6 +109,8 @@ public slots:
void setProfile(QString profile);
void setReward(int);
signals:
void firstChanged();
void animationChanged();

View File

@ -207,8 +207,9 @@ Rectangle {
if ( tower3.items.length === all) {
if (all === tumbler.spin.maximumValue) {
backEnd.gameState.unlockNextLvl();
popUp.text = qsTr("You have passed the level in %0 steps and unlocked level %1" +
"\n Minimum steps for this lvl: %2").
popUp.text = qsTr("You have passed the level in %0 steps and unlocked level %1") +
qsTr("\n Minimum steps for this lvl: %2") +
qsTr("\n you reward = %3").
arg(step.ste).arg(all + 1).arg(backEnd.getMinSteps(all));
popUp.open()

View File

@ -10,6 +10,14 @@ void ProfileData::setOnline(bool onlineProfile) {
}
}
void ProfileData::setRecord(int rec) {
if (record() == rec)
return;
_userData.extraData()["points"] = rec;
emit recordChanged(rec);
}
void ProfileData::handleServerResponce(const NetworkProtocol::UserData& data) {
if (_userData.token() != data.token()) {
_userData = data;

View File

@ -10,7 +10,7 @@ class ProfileData : public QObject, public NetworkProtocol::StreamBase
Q_PROPERTY(QObject* gameState READ gameState NOTIFY gameStateChanged)
Q_PROPERTY(QString name READ name)
Q_PROPERTY(int record READ record)
Q_PROPERTY(int record READ record WRITE setRecord NOTIFY recordChanged)
Q_PROPERTY(bool onlineUser READ isOnline WRITE setOnline NOTIFY onlineChanged)
private:
@ -36,10 +36,13 @@ public:
public slots:
void setOnline(bool onlineUser);
void setRecord(int record);
signals:
void gameStateChanged(QObject* gameState);
void onlineChanged(bool onlineUser);
void onlineRequest();
void recordChanged(int record);
};
#endif // PROFILEDATA_H