Exemple #1
0
void Player::setHp(int hp)
{
    if (this->hp != hp) {
        this->hp = hp;
        emit hp_changed();
    }
}
Exemple #2
0
void Player::setMaxHp(int max_hp) {
    if (this->max_hp == max_hp)
        return;
    this->max_hp = max_hp;
    if (hp > max_hp)
        hp = max_hp;
    emit hp_changed();
}
Exemple #3
0
void Client::hpChange(const QJsonValue &change_str){
	QJsonArray texts = change_str.toArray();
	if(texts.size() < 2 || texts.size() > 3){
		return;
	}

	QString who = texts.at(0).toString();
	int delta = (int) texts.at(1).toDouble();
	QString nature_str = texts.at(2).toString();

	DamageStruct::Nature nature;
	if(nature_str == "F")
		nature = DamageStruct::Fire;
	else if(nature_str == "T")
		nature = DamageStruct::Thunder;
	else
		nature = DamageStruct::Normal;

	emit hp_changed(who, delta, nature, nature_str == "L");
}