Skip to content

Commit

Permalink
Merge pull request #3342 from sikabane-works/merge/heng#2404
Browse files Browse the repository at this point in the history
変愚「WeaponEnchanter を武器種別ごとに分離した #2404」のマージ
  • Loading branch information
sikabane-works authored Jun 21, 2023
2 parents f30780e + 0d55cd9 commit 62b8491
Show file tree
Hide file tree
Showing 13 changed files with 398 additions and 198 deletions.
10 changes: 8 additions & 2 deletions Bakabakaband/Bakabakaband/Bakabakaband.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@
<ClCompile Include="..\..\src\object-enchant\protector\apply-magic-hard-armor.cpp" />
<ClCompile Include="..\..\src\object-enchant\weapon\abstract-weapon-enchanter.cpp" />
<ClCompile Include="..\..\src\object-use\quaff\quaff-effects.cpp" />
<ClCompile Include="..\..\src\object-enchant\weapon\apply-magic-arrow.cpp" />
<ClCompile Include="..\..\src\object-enchant\weapon\apply-magic-digging.cpp" />
<ClCompile Include="..\..\src\object-enchant\weapon\apply-magic-sword.cpp" />
<ClCompile Include="..\..\src\object-use\read\gbh-shirt-read-executor.cpp" />
<ClCompile Include="..\..\src\object-use\read\parchment-read-executor.cpp" />
<ClCompile Include="..\..\src\object-use\read\read-executor-factory.cpp" />
Expand Down Expand Up @@ -685,7 +688,7 @@
<ClCompile Include="..\..\src\racial\racial-vampire.cpp" />
<ClCompile Include="..\..\src\object-enchant\protector\apply-magic-armor.cpp" />
<ClCompile Include="..\..\src\object-enchant\others\apply-magic-others.cpp" />
<ClCompile Include="..\..\src\object-enchant\weapon\apply-magic-weapon.cpp" />
<ClCompile Include="..\..\src\object-enchant\weapon\apply-magic-bow.cpp" />
<ClCompile Include="..\..\src\object-enchant\apply-magic.cpp" />
<ClCompile Include="..\..\src\player\eldritch-horror.cpp" />
<ClCompile Include="..\..\src\specific-object\bow.cpp" />
Expand Down Expand Up @@ -969,6 +972,9 @@
<ClInclude Include="..\..\src\object-enchant\protector\apply-magic-hard-armor.h" />
<ClInclude Include="..\..\src\object-enchant\weapon\abstract-weapon-enchanter.h" />
<ClInclude Include="..\..\src\object-use\quaff\quaff-effects.h" />
<ClInclude Include="..\..\src\object-enchant\weapon\apply-magic-arrow.h" />
<ClInclude Include="..\..\src\object-enchant\weapon\apply-magic-digging.h" />
<ClInclude Include="..\..\src\object-enchant\weapon\apply-magic-sword.h" />
<ClInclude Include="..\..\src\object-use\read\gbh-shirt-read-executor.h" />
<ClInclude Include="..\..\src\object-use\read\parchment-read-executor.h" />
<ClInclude Include="..\..\src\object-use\read\read-executor-base.h" />
Expand Down Expand Up @@ -1484,7 +1490,7 @@
<ClInclude Include="..\..\src\object-enchant\enchanter-base.h" />
<ClInclude Include="..\..\src\object-enchant\protector\apply-magic-armor.h" />
<ClInclude Include="..\..\src\object-enchant\others\apply-magic-others.h" />
<ClInclude Include="..\..\src\object-enchant\weapon\apply-magic-weapon.h" />
<ClInclude Include="..\..\src\object-enchant\weapon\apply-magic-bow.h" />
<ClInclude Include="..\..\src\object-enchant\apply-magic.h" />
<ClInclude Include="..\..\src\player\eldritch-horror.h" />
<ClInclude Include="..\..\src\realm\realm-types.h" />
Expand Down
24 changes: 20 additions & 4 deletions Bakabakaband/Bakabakaband/Bakabakaband.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -2352,7 +2352,7 @@
<ClCompile Include="..\..\src\object-enchant\weapon\abstract-weapon-enchanter.cpp">
<Filter>object-enchant\weapon</Filter>
</ClCompile>
<ClCompile Include="..\..\src\object-enchant\weapon\apply-magic-weapon.cpp">
<ClCompile Include="..\..\src\object-enchant\weapon\apply-magic-bow.cpp">
<Filter>object-enchant\weapon</Filter>
</ClCompile>
<ClCompile Include="..\..\src\smith\object-smith.cpp">
Expand Down Expand Up @@ -2430,7 +2430,15 @@
<ClCompile Include="..\..\src\object-enchant\protector\apply-magic-soft-armor.cpp">
<Filter>object-enchant\protector</Filter>
</ClCompile>
<ClCompile Include="..\..\src\knowledge\knowledge-incident.cpp" />
<ClCompile Include="..\..\src\object-enchant\weapon\apply-magic-sword.cpp">
<Filter>object-enchant\weapon</Filter>
</ClCompile>
<ClCompile Include="..\..\src\object-enchant\weapon\apply-magic-digging.cpp">
<Filter>object-enchant\weapon</Filter>
</ClCompile>
<ClCompile Include="..\..\src\object-enchant\weapon\apply-magic-arrow.cpp">
<Filter>object-enchant\weapon</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\combat\shoot.h">
Expand Down Expand Up @@ -5185,7 +5193,7 @@
<ClInclude Include="..\..\src\object-enchant\weapon\abstract-weapon-enchanter.h">
<Filter>object-enchant\weapon</Filter>
</ClInclude>
<ClInclude Include="..\..\src\object-enchant\weapon\apply-magic-weapon.h">
<ClInclude Include="..\..\src\object-enchant\weapon\apply-magic-bow.h">
<Filter>object-enchant\weapon</Filter>
</ClInclude>
<ClInclude Include="..\..\src\smith\object-smith.h">
Expand Down Expand Up @@ -5284,7 +5292,15 @@
<ClInclude Include="..\..\src\object-enchant\protector\apply-magic-soft-armor.h">
<Filter>object-enchant\protector</Filter>
</ClInclude>
<ClInclude Include="..\..\src\knowledge\knowledge-incident.h" />
<ClInclude Include="..\..\src\object-enchant\weapon\apply-magic-sword.h">
<Filter>object-enchant\weapon</Filter>
</ClInclude>
<ClInclude Include="..\..\src\object-enchant\weapon\apply-magic-digging.h">
<Filter>object-enchant\weapon</Filter>
</ClInclude>
<ClInclude Include="..\..\src\object-enchant\weapon\apply-magic-arrow.h">
<Filter>object-enchant\weapon</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\src\wall.bmp" />
Expand Down
5 changes: 4 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,10 @@ hengband_SOURCES = \
object-enchant/protector/apply-magic-soft-armor.cpp object-enchant/protector/apply-magic-soft-armor.h \
\
object-enchant/weapon/abstract-weapon-enchanter.cpp object-enchant/weapon/abstract-weapon-enchanter.h \
object-enchant/weapon/apply-magic-weapon.cpp object-enchant/weapon/apply-magic-weapon.h \
object-enchant/weapon/apply-magic-arrow.cpp object-enchant/weapon/apply-magic-arrow.h \
object-enchant/weapon/apply-magic-bow.cpp object-enchant/weapon/apply-magic-bow.h \
object-enchant/weapon/apply-magic-digging.cpp object-enchant/weapon/apply-magic-digging.h \
object-enchant/weapon/apply-magic-sword.cpp object-enchant/weapon/apply-magic-sword.h \
\
object-hook/hook-armor.cpp object-hook/hook-armor.h \
object-hook/hook-expendable.cpp object-hook/hook-expendable.h \
Expand Down
18 changes: 11 additions & 7 deletions src/object-enchant/apply-magic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
#include "object-enchant/tr-types.h"
#include "object-enchant/trc-types.h"
#include "object-enchant/trg-types.h"
#include "object-enchant/weapon/apply-magic-weapon.h"
#include "object-enchant/weapon/apply-magic-arrow.h"
#include "object-enchant/weapon/apply-magic-bow.h"
#include "object-enchant/weapon/apply-magic-digging.h"
#include "object-enchant/weapon/apply-magic-sword.h"
#include "object/object-kind.h"
#include "player/player-status-flags.h"
#include "sv-definition/sv-armor-types.h"
Expand Down Expand Up @@ -138,19 +141,20 @@ void apply_magic_to_object(PlayerType *player_ptr, ObjectType *o_ptr, DEPTH lev,
// @todo ファクトリパターンで抽象化する.
switch (o_ptr->tval) {
case ItemKindType::DIGGING:
case ItemKindType::HAFTED:
DiggingEnchanter(player_ptr, o_ptr, lev, power).apply_magic();
break;
case ItemKindType::BOW:
BowEnchanter(player_ptr, o_ptr, lev, power).apply_magic();
break;
case ItemKindType::SHOT:
case ItemKindType::ARROW:
case ItemKindType::BOLT:
WeaponEnchanter(player_ptr, o_ptr, lev, power).apply_magic();
ArrowEnchanter(player_ptr, o_ptr, lev, power).apply_magic();
break;
case ItemKindType::HAFTED:
case ItemKindType::POLEARM:
WeaponEnchanter(player_ptr, o_ptr, lev, power).apply_magic();
break;
case ItemKindType::SWORD:
// @todo いずれSwordEnchanter等作って分離する.
WeaponEnchanter(player_ptr, o_ptr, lev, power).apply_magic();
SwordEnchanter(player_ptr, o_ptr, lev, power).apply_magic();
break;
case ItemKindType::SHIELD:
ShieldEnchanter(player_ptr, o_ptr, lev, power).apply_magic();
Expand Down
60 changes: 60 additions & 0 deletions src/object-enchant/weapon/apply-magic-arrow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*!
* @brief 矢類のアイテムを強化する処理
* @date 2022/03/11
* @author Hourier
*/

#include "object-enchant/weapon/apply-magic-arrow.h"
#include "artifact/random-art-generator.h"
#include "floor/floor-base-definitions.h"
#include "inventory/inventory-slot-types.h"
#include "system/object-type-definition.h"
#include "system/player-type-definition.h"

/*!
* @brief 矢類強化クラスのコンストラクタ
* @param player_ptr プレイヤーへの参照ポインタ
* @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
* @param level 生成基準階
* @param power 生成ランク
*/
ArrowEnchanter::ArrowEnchanter(PlayerType *player_ptr, ObjectType *o_ptr, DEPTH level, int power)
: AbstractWeaponEnchanter(o_ptr, level, power)
, player_ptr(player_ptr)
{
}

/*!
* @brief 矢類に生成ランクごとの強化を与えるサブルーチン
* @details power > 2はデバッグ専用.
*/
void ArrowEnchanter::apply_magic()
{
if (this->should_skip) {
return;
}

if (this->power > 1) {
if (this->power > 2) {
become_random_artifact(this->player_ptr, this->o_ptr, false);
return;
}

this->o_ptr->ego_idx = get_random_ego(INVEN_AMMO, true);
while (one_in_(10 * this->o_ptr->dd * this->o_ptr->ds)) {
this->o_ptr->dd++;
}

if (this->o_ptr->dd > 9) {
this->o_ptr->dd = 9;
}

return;
}

if (this->power < -1) {
if (randint0(MAX_DEPTH) < this->level) {
this->o_ptr->ego_idx = get_random_ego(INVEN_AMMO, false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

class ObjectType;
class PlayerType;
class WeaponEnchanter : AbstractWeaponEnchanter {
class ArrowEnchanter : AbstractWeaponEnchanter {
public:
WeaponEnchanter(PlayerType *player_ptr, ObjectType *o_ptr, DEPTH level, int power);
ArrowEnchanter(PlayerType *player_ptr, ObjectType *o_ptr, DEPTH level, int power);
void apply_magic() override;

protected:
Expand Down
44 changes: 44 additions & 0 deletions src/object-enchant/weapon/apply-magic-bow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*!
* @brief 弓系のアイテムを強化する処理
* @date 2022/03/11
* @author Hourier
*/

#include "object-enchant/weapon/apply-magic-bow.h"
#include "artifact/random-art-generator.h"
#include "inventory/inventory-slot-types.h"
#include "system/object-type-definition.h"

/*!
* @brief 弓強化クラスのコンストラクタ
* @param player_ptr プレイヤーへの参照ポインタ
* @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
* @param level 生成基準階
* @param power 生成ランク
*/
BowEnchanter::BowEnchanter(PlayerType *player_ptr, ObjectType *o_ptr, DEPTH level, int power)
: AbstractWeaponEnchanter(o_ptr, level, power)
, player_ptr(player_ptr)
{
}

/*!
* @brief 弓系オブジェクトに生成ランクごとの強化を与えるサブルーチン
* Apply magic to an item known to be a "weapon"
* @details power > 2はデバッグ専用.
*/
void BowEnchanter::apply_magic()
{
if (this->should_skip) {
return;
}

if (this->power > 1) {
if ((this->power > 2) || one_in_(20)) {
become_random_artifact(this->player_ptr, this->o_ptr, false);
return;
}

this->o_ptr->ego_idx = get_random_ego(INVEN_BOW, true);
}
}
21 changes: 21 additions & 0 deletions src/object-enchant/weapon/apply-magic-bow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once

#include "object-enchant/weapon/abstract-weapon-enchanter.h"
#include "system/angband.h"

class ObjectType;
class PlayerType;
class BowEnchanter : AbstractWeaponEnchanter {
public:
BowEnchanter(PlayerType *player_ptr, ObjectType *o_ptr, DEPTH level, int power);
void apply_magic() override;

protected:
void sval_enchant() override{};
void give_ego_index() override{};
void give_high_ego_index() override{};
void give_cursed() override{};

private:
PlayerType *player_ptr;
};
54 changes: 54 additions & 0 deletions src/object-enchant/weapon/apply-magic-digging.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*!
* @brief 掘削武器に耐性等の追加効果を付与する処理
* @date 2022/03/11
* @author Hourier
*/

#include "object-enchant/weapon/apply-magic-digging.h"
#include "artifact/random-art-generator.h"
#include "system/object-type-definition.h"
#include "system/player-type-definition.h"

/*!
* @brief 掘削武器強化クラスのコンストラクタ
* @param player_ptr プレイヤーへの参照ポインタ
* @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
* @param level 生成基準階
* @param power 生成ランク
*/
DiggingEnchanter::DiggingEnchanter(PlayerType *player_ptr, ObjectType *o_ptr, DEPTH level, int power)
: AbstractWeaponEnchanter(o_ptr, level, power)
, player_ptr(player_ptr)
{
}

/*!
* @brief 掘削武器に生成ランクごとの強化を与えるサブルーチン
* @details power > 2はデバッグ専用.
*/
void DiggingEnchanter::apply_magic()
{
if (this->should_skip) {
return;
}

if (this->power > 1) {
if ((this->power > 2) || one_in_(30)) {
become_random_artifact(this->player_ptr, this->o_ptr, false);
} else {
this->o_ptr->ego_idx = EgoType::DIGGING;
}

return;
}

if (this->power < -1) {
this->o_ptr->pval = 0 - (5 + randint1(5));
return;
}

if (this->power < 0) {
this->o_ptr->pval = 0 - (this->o_ptr->pval);
return;
}
}
21 changes: 21 additions & 0 deletions src/object-enchant/weapon/apply-magic-digging.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once

#include "object-enchant/weapon/abstract-weapon-enchanter.h"
#include "system/angband.h"

class ObjectType;
class PlayerType;
class DiggingEnchanter : AbstractWeaponEnchanter {
public:
DiggingEnchanter(PlayerType *player_ptr, ObjectType *o_ptr, DEPTH level, int power);
void apply_magic() override;

protected:
void sval_enchant() override{};
void give_ego_index() override{};
void give_high_ego_index() override{};
void give_cursed() override{};

private:
PlayerType *player_ptr;
};
Loading

0 comments on commit 62b8491

Please sign in to comment.