Skip to content

Commit

Permalink
[Refactor] hengband#1498 Created timed-effect/ for separating timed-e…
Browse files Browse the repository at this point in the history
…ffect variables from player_type
  • Loading branch information
Hourier committed Sep 18, 2021
1 parent 28a42a6 commit 202115e
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Hengband/Hengband/Hengband.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,8 @@
<ClCompile Include="..\..\src\target\target-getter.cpp" />
<ClCompile Include="..\..\src\target\target-preparation.cpp" />
<ClCompile Include="..\..\src\target\target-setter.cpp" />
<ClCompile Include="..\..\src\timed-effect\player-stun.cpp" />
<ClCompile Include="..\..\src\timed-effect\timed-effects.cpp" />
<ClCompile Include="..\..\src\view\display-inventory.cpp" />
<ClCompile Include="..\..\src\view\display-map.cpp" />
<ClCompile Include="..\..\src\view\display-self-info.cpp" />
Expand Down Expand Up @@ -1291,6 +1293,8 @@
<ClInclude Include="..\..\src\target\target-setter.h" />
<ClInclude Include="..\..\src\target\target-types.h" />
<ClInclude Include="..\..\src\term\screen-processor.h" />
<ClInclude Include="..\..\src\timed-effect\player-stun.h" />
<ClInclude Include="..\..\src\timed-effect\timed-effects.h" />
<ClInclude Include="..\..\src\util\bit-flags-calculator.h" />
<ClInclude Include="..\..\src\util\buffer-shaper.h" />
<ClInclude Include="..\..\src\util\enum-converter.h" />
Expand Down
15 changes: 15 additions & 0 deletions Hengband/Hengband/Hengband.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -2331,6 +2331,12 @@
<ClCompile Include="..\..\src\object-enchant\smith-info.cpp">
<Filter>object-enchant</Filter>
</ClCompile>
<ClCompile Include="..\..\src\timed-effect\timed-effects.cpp">
<Filter>timed-effect</Filter>
</ClCompile>
<ClCompile Include="..\..\src\timed-effect\player-stun.cpp">
<Filter>timed-effect</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\combat\shoot.h">
Expand Down Expand Up @@ -5016,6 +5022,12 @@
<ClInclude Include="..\..\src\object-enchant\smith-info.h">
<Filter>object-enchant</Filter>
</ClInclude>
<ClInclude Include="..\..\src\timed-effect\timed-effects.h">
<Filter>timed-effect</Filter>
</ClInclude>
<ClInclude Include="..\..\src\timed-effect\player-stun.h">
<Filter>timed-effect</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\src\wall.bmp" />
Expand Down Expand Up @@ -5235,6 +5247,9 @@
<Filter Include="player-base">
<UniqueIdentifier>{0bd4660d-028e-44be-a5fe-c7cc7d3d00c2}</UniqueIdentifier>
</Filter>
<Filter Include="timed-effect">
<UniqueIdentifier>{b9e618e1-f780-4f5f-9413-d0270ac53660}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\src\angband.rc" />
Expand Down
3 changes: 3 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,9 @@ hengband_SOURCES = \
term/z-term.cpp term/z-term.h term/z-util.cpp term/z-util.h \
term/z-virt.cpp term/z-virt.h \
\
timed-effect/player-stun.cpp timed-effect/player-stun.h \
timed-effect/timed-effects.cpp timed-effect/timed-effects.h \
\
util/angband-files.cpp util/angband-files.h \
util/buffer-shaper.cpp util/buffer-shaper.h \
util/bit-flags-calculator.h \
Expand Down
5 changes: 5 additions & 0 deletions src/system/player-type-definition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ player_type p_body;
* @brief プレイヤー構造体へのグローバル参照ポインタ / Pointer to the player info
*/
player_type *p_ptr = &p_body;

std::shared_ptr<TimedEffects> player_type::effects() const
{
return this->timed_effects;
}
13 changes: 10 additions & 3 deletions src/system/player-type-definition.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "player/player-sex.h"
#include "system/angband.h"
#include "system/system-variables.h"
#include "timed-effect/timed-effects.h"
#include "util/flag-group.h"

#define MAX_SKILLS 10
Expand All @@ -19,8 +20,9 @@ enum class RF_ABILITY;

struct floor_type;
struct object_type;
;
typedef struct player_type {
class TimedEffects;
struct player_type {
public:
int player_uid{};
int player_euid{};
int player_egid{};
Expand Down Expand Up @@ -423,6 +425,11 @@ typedef struct player_type {
POSITION x{}; /*!< ダンジョンの現在X座標 / Player location in dungeon */
GAME_TEXT name[32]{}; /*!< 現在のプレイヤー名 / Current player's character name */
char base_name[32]{}; /*!< Stripped version of "player_name" */
} player_type;

std::shared_ptr<TimedEffects> effects() const;

private:
std::shared_ptr<TimedEffects> timed_effects = std::shared_ptr<TimedEffects>(new TimedEffects());
};

extern player_type *p_ptr;
10 changes: 10 additions & 0 deletions src/timed-effect/player-stun.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "timed-effect/player-stun.h"

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

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

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

short current();
void set(short value);

private:
short stun = 0;
};
6 changes: 6 additions & 0 deletions src/timed-effect/timed-effects.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "timed-effect/timed-effects.h"

std::shared_ptr<PlayerStun> TimedEffects::stun() const
{
return this->player_stun;
}
16 changes: 16 additions & 0 deletions src/timed-effect/timed-effects.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include "timed-effect/player-stun.h"
#include <memory>

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

std::shared_ptr<PlayerStun> stun() const;

private:
std::shared_ptr<PlayerStun> player_stun = std::shared_ptr<PlayerStun>(new PlayerStun());
};

0 comments on commit 202115e

Please sign in to comment.