Skip to content

Commit

Permalink
[Refactor] hengband#1498 Defined StunRank and get_rank()
Browse files Browse the repository at this point in the history
  • Loading branch information
Hourier committed Sep 18, 2021
1 parent c9eb381 commit e49bae2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
24 changes: 23 additions & 1 deletion src/timed-effect/player-stun.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
#include "timed-effect/player-stun.h"

short PlayerStun::current()
short PlayerStun::current() const
{
return this->stun;
}

StunRank PlayerStun::get_rank() const
{
return this->get_rank(this->stun);
}

StunRank PlayerStun::get_rank(short value) const
{
if (value > 100) {
return StunRank::UNCONSCIOUS;
}

if (value > 50) {
return StunRank::HARD;
}

if (value > 0) {
return StunRank::NORMAL;
}

return StunRank::NONE;
}

void PlayerStun::set(short value)
{
}
11 changes: 10 additions & 1 deletion src/timed-effect/player-stun.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
#pragma once

enum class StunRank {
NONE = 0,
NORMAL = 1,
HARD = 2,
UNCONSCIOUS = 3,
};

class PlayerStun {
public:
PlayerStun() = default;
virtual ~PlayerStun() = default;

short current();
short current() const;
StunRank get_rank() const;
StunRank get_rank(short value) const;
void set(short value);

private:
Expand Down

0 comments on commit e49bae2

Please sign in to comment.