rpg #1

Open
opened 2023-12-19 23:50:34 +01:00 by K3N1.2 · 0 comments
Owner

#pragma once
#include "hitpointypes.h"

class hp {
public:
// returns 1 if sccss
bool setMaxHP(hptype new_max_hp) {
if (new_max_hp < 1)
return false;
MaxHP = new_max_hp;

    if (CurrentHP > MaxHP)
        CurrentHP = MaxHP;
    return true;
}
    hptype getMaxHP(){
        return MaxHP;
}
hptype getCurrentHP(){
    return CurrentHP;

}

void TakeDamage(hptype damage){
    if (damage > CurrentHP ){
        CurrentHP = 0;
    return;
    }

    CurrentHP -= damage;

}

void heal(hptype amount){
    if (amount + CurrentHP > MaxHP){
        CurrentHP + MaxHP;
        return;

    }
    CurrentHP += amount;
}

private:
hptype MaxHP;
hptype CurrentHP;

};``

#pragma once #include "hitpointypes.h" class hp { public: // returns 1 if sccss bool setMaxHP(hptype new_max_hp) { if (new_max_hp < 1) return false; MaxHP = new_max_hp; if (CurrentHP > MaxHP) CurrentHP = MaxHP; return true; } hptype getMaxHP(){ return MaxHP; } hptype getCurrentHP(){ return CurrentHP; } void TakeDamage(hptype damage){ if (damage > CurrentHP ){ CurrentHP = 0; return; } CurrentHP -= damage; } void heal(hptype amount){ if (amount + CurrentHP > MaxHP){ CurrentHP + MaxHP; return; } CurrentHP += amount; } private: hptype MaxHP; hptype CurrentHP; };``
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: K3N1.2/RPG#1
No description provided.