Skip to content

Commit

Permalink
Merge branch 'develop' into macos-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
backwardsEric committed Jul 3, 2024
2 parents 5ae487d + 5e81104 commit 1fbb5cc
Show file tree
Hide file tree
Showing 56 changed files with 4,535 additions and 3,987 deletions.
5,570 changes: 2,785 additions & 2,785 deletions lib/edit/ClassMagicDefinitions.jsonc

Large diffs are not rendered by default.

1,265 changes: 1,264 additions & 1 deletion lib/edit/SpellDefinitions.jsonc

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions schema/ClassMagicDefinitions.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,16 @@
"description": "呪文情報",
"additionalProperties": false,
"required": [
"spell_id",
"spell_tag",
"learn_level",
"mana_cost",
"difficulty",
"first_cast_exp_rate"
],
"properties": {
"spell_id": {
"type": "integer",
"description": "呪文番号",
"minimum": 0,
"maximum": 31
"spell_tag": {
"type": "string",
"description": "呪文タグ"
},
"learn_level": {
"type": "integer",
Expand Down
5 changes: 4 additions & 1 deletion schema/SpellDefinitions.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
"ARCANE",
"CRAFT",
"DEMON",
"CRUSADE"
"CRUSADE",
"MUSIC",
"HISSATSU",
"HEX"
]
},
"books": {
Expand Down
6 changes: 4 additions & 2 deletions src/avatar/avatar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "game-option/text-display-options.h"
#include "player-info/class-info.h"
#include "player-info/race-types.h"
#include "player/player-realm.h"
#include "realm/realm-names-table.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
Expand Down Expand Up @@ -374,14 +375,15 @@ void initialize_virtues(PlayerType *player_ptr)
}

/* Get a virtue_names for realms */
if (player_ptr->realm1) {
PlayerRealm pr(player_ptr);
if (pr.realm1().is_available()) {
tmp_vir = get_realm_virtues(player_ptr, player_ptr->realm1);
if (tmp_vir != Virtue::NONE) {
player_ptr->vir_types[i++] = tmp_vir;
}
}

if (player_ptr->realm2) {
if (pr.realm2().is_available()) {
tmp_vir = get_realm_virtues(player_ptr, player_ptr->realm2);
if (tmp_vir != Virtue::NONE) {
player_ptr->vir_types[i++] = tmp_vir;
Expand Down
9 changes: 7 additions & 2 deletions src/birth/birth-explanations-table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ const std::vector<std::string_view> personality_explanations = {
};

/*! 魔法領域の詳細解説メッセージテーブル */
const std::vector<std::string_view> realm_explanations = {
const std::vector<std::string_view> magic_explanations = {
_("生命は回復能力に優れた魔法です。治療や防御、感知魔法が多く含まれていますが、攻撃呪文もわずかに持っています。特に高レベルの呪文にはアンデッドを塵に帰す力をあると言われています。",
"Life magic is very good for healing; it relies mostly on healing, protection and detection spells. Also life magic has a few attack spells as well. It's said that some high level spells of life magic can disintegrate Undead monsters into ash."),

Expand Down Expand Up @@ -282,7 +282,9 @@ const std::vector<std::string_view> realm_explanations = {

_("破邪は「正義」の魔法です。直接敵を傷つける魔法が多く含まれ、特に邪悪な敵に対する力は恐るべきものがあります。しかし、善良な敵にはあまり効果がありません。",
"Crusade is a magic of 'Justice'. It includes damage spells, which are greatly effective against foul and evil monsters, but have poor effects against good monsters."),
};

const std::vector<std::string_view> technic_explanations = {
_("歌集は、歌によって効果を発揮する魔法です。魔法と同様、使った時に効果のあるものと、歌い続けることによって持続して効果を発揮するものがあります。後者の場合は、MPの続く限り効果を発揮することができますが、同時に歌える歌は1つだけという制限もあります。",
"Music magic works through the caster singing songs. There are two types of songs; one which shows effects instantly and another which shows effects continuously until SP runs out. The latter type has a limit: only one song can be sung at a time."),

Expand All @@ -294,7 +296,7 @@ const std::vector<std::string_view> realm_explanations = {
};

/*! 魔法領域の簡易解説メッセージテーブル */
const std::vector<std::string_view> realm_subinfo = {
const std::vector<std::string_view> magic_subinfo = {
_("感知と防御と回復に優れています", "Good at detection and healing."),
_("攻撃はできませんが非常に便利です", "Utility and protective spells."),
_("感知と防御に優れています", "Good at detection and defence."),
Expand All @@ -305,6 +307,9 @@ const std::vector<std::string_view> realm_subinfo = {
_("直接戦闘の補助に優れています", "Support for melee fighting."),
_("攻撃と防御の両面に優れています", "Good at both offence and defence."),
_("邪悪な怪物に対する攻撃に優れています", "Destroys evil creatures."),
};

const std::vector<std::string_view> technic_subinfo = {
_("様々な魔法効果を持った歌を歌います", "Songs with magical effects."),
_("打撃攻撃に特殊能力を付加します", "Special abilities for melee."),
_("敵を邪魔しつつ復讐を狙います", "Good at obstacle and revenge."),
Expand Down
6 changes: 4 additions & 2 deletions src/birth/birth-explanations-table.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
extern const std::vector<std::string_view> race_explanations;
extern const std::vector<std::string_view> class_explanations;
extern const std::vector<std::string_view> personality_explanations;
extern const std::vector<std::string_view> realm_explanations;
extern const std::vector<std::string_view> realm_subinfo;
extern const std::vector<std::string_view> magic_explanations;
extern const std::vector<std::string_view> technic_explanations;
extern const std::vector<std::string_view> magic_subinfo;
extern const std::vector<std::string_view> technic_subinfo;
118 changes: 52 additions & 66 deletions src/birth/birth-select-realm.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "birth/birth-select-realm.h"
#include "birth/birth-explanations-table.h"
#include "birth/birth-util.h"
#include "core/asking-player.h"
#include "io/input-key-acceptor.h"
Expand All @@ -13,6 +12,7 @@
#include "term/z-form.h"
#include "util/int-char-converter.h"
#include "view/display-util.h"
#include <optional>
#include <string>

static const byte REALM_SELECT_CANCEL = 255;
Expand Down Expand Up @@ -43,37 +43,31 @@ static birth_realm_type *initialize_birth_realm_type(birth_realm_type *birth_rea

static void impose_first_realm(PlayerType *player_ptr, RealmChoices &choices)
{
if (player_ptr->realm2 == REALM_SELECT_CANCEL) {
PlayerRealm pr(player_ptr);
if (!pr.realm1().is_available()) {
return;
}

if (!PlayerClass(player_ptr).equals(PlayerClassType::PRIEST)) {
return;
}

if (PlayerRealm(player_ptr).realm1().is_good_attribute()) {
if (pr.realm1().is_good_attribute()) {
choices.reset({ REALM_DEATH, REALM_DAEMON });
} else {
choices.reset({ REALM_LIFE, REALM_CRUSADE });
}
}

static void analyze_realms(const PlayerType *player_ptr, const RealmChoices &choices, birth_realm_type *birth_realm_ptr)
static void analyze_realms(PlayerType *player_ptr, magic_realm_type selecting_realm, const RealmChoices &choices, birth_realm_type *birth_realm_ptr)
{
PlayerRealm pr(player_ptr);
for (auto realm : EnumRange(REALM_LIFE, REALM_MAX)) {
if (choices.has_not(realm)) {
if (choices.has_not(realm) || pr.realm1().equals(realm)) {
continue;
}

if (player_ptr->realm1 == realm) {
if (player_ptr->realm2 == REALM_SELECT_CANCEL) {
birth_realm_ptr->cs = birth_realm_ptr->n;
} else {
continue;
}
}

if (player_ptr->realm2 == realm) {
if (realm == selecting_realm) {
birth_realm_ptr->cs = birth_realm_ptr->n;
}

Expand All @@ -96,12 +90,13 @@ static void move_birth_realm_cursor(birth_realm_type *birth_realm_ptr)
if (birth_realm_ptr->cs == birth_realm_ptr->n) {
birth_realm_ptr->cur = format("%c%c %s", '*', birth_realm_ptr->p2, _("ランダム", "Random"));
} else {
const auto &realm_name = PlayerRealm::get_name(birth_realm_ptr->picks[birth_realm_ptr->cs]);
const auto realm = birth_realm_ptr->picks[birth_realm_ptr->cs];
const auto &realm_name = PlayerRealm::get_name(realm);
birth_realm_ptr->cur = format("%c%c %s", birth_realm_ptr->sym[birth_realm_ptr->cs], birth_realm_ptr->p2,
realm_name.data());
c_put_str(TERM_L_BLUE, realm_name, 3, 40);
prt(_("の特徴", ": Characteristic"), 3, 40 + realm_name->length());
prt(realm_subinfo[technic2magic(birth_realm_ptr->picks[birth_realm_ptr->cs]) - 1], 4, 40);
prt(PlayerRealm::get_subinfo(realm), 4, 40);
}

c_put_str(TERM_YELLOW, birth_realm_ptr->cur, 12 + (birth_realm_ptr->cs / 5), 2 + 15 * (birth_realm_ptr->cs % 5));
Expand Down Expand Up @@ -195,12 +190,12 @@ static bool get_a_realm(PlayerType *player_ptr, birth_realm_type *birth_realm_pt

/*!
* @brief プレイヤーの魔法領域を選択する / Choose from one of the available magical realms
* @param selecting_realm 現在選択中の魔法領域
* @param choices 選択可能な魔法領域のビット配列
* @param count 選択可能な魔法領域を返すポインタ群。
* @return 選択した魔法領域のID
* @details 領域数が0 (戦士等)or 1 (観光客等)なら自動での値を返す
*/
static byte select_realm(PlayerType *player_ptr, RealmChoices choices)
static std::optional<magic_realm_type> select_realm(PlayerType *player_ptr, magic_realm_type selecting_realm, RealmChoices choices)
{
clear_from(10);
if (choices.count() <= 1) {
Expand All @@ -213,14 +208,14 @@ static byte select_realm(PlayerType *player_ptr, RealmChoices choices)

birth_realm_type tmp_birth_realm;
birth_realm_type *birth_realm_ptr = initialize_birth_realm_type(&tmp_birth_realm);
analyze_realms(player_ptr, choices, birth_realm_ptr);
analyze_realms(player_ptr, selecting_realm, choices, birth_realm_ptr);
birth_realm_ptr->cur = format("%c%c %s", '*', birth_realm_ptr->p2, _("ランダム", "Random"));
if (get_a_realm(player_ptr, birth_realm_ptr)) {
return REALM_SELECT_CANCEL;
return std::nullopt;
}

clear_from(10);
return static_cast<byte>(birth_realm_ptr->picks[birth_realm_ptr->k]);
return i2enum<magic_realm_type>(birth_realm_ptr->picks[birth_realm_ptr->k]);
}

static void cleanup_realm_selection_window(void)
Expand Down Expand Up @@ -250,16 +245,35 @@ static bool check_realm_selection(PlayerType *player_ptr, int count)
return false;
}

static std::optional<magic_realm_type> process_choose_realm(PlayerType *player_ptr, RealmChoices choices)
{
auto selecting_realm = REALM_NONE;
while (true) {
const auto selected_realm = select_realm(player_ptr, selecting_realm, choices);
if (!selected_realm || *selected_realm == REALM_NONE) {
return selected_realm;
}

cleanup_realm_selection_window();
display_wrap_around(PlayerRealm::get_explanation(*selected_realm), 74, 12, 3);

if (check_realm_selection(player_ptr, choices.count())) {
return selected_realm;
}
selecting_realm = *selected_realm;
}
}

static void print_choosed_realms(PlayerType *player_ptr)
{
put_str(_("魔法 :", "Magic :"), 6, 1);

PlayerRealm pr(player_ptr);
std::string choosed_realms;
if (player_ptr->realm2 == REALM_NONE) {
choosed_realms = pr.realm1().get_name();
} else {
if (pr.realm2().is_available()) {
choosed_realms = format("%s, %s", pr.realm1().get_name().data(), pr.realm2().get_name().data());
} else {
choosed_realms = pr.realm1().get_name();
}

c_put_str(TERM_L_BLUE, choosed_realms, 6, 15);
Expand All @@ -277,9 +291,8 @@ bool get_player_realms(PlayerType *player_ptr)
put_str(" ", 5, 40);
put_str(" ", 6, 40);

/* Select the first realm */
player_ptr->realm1 = REALM_NONE;
player_ptr->realm2 = REALM_SELECT_CANCEL;
player_ptr->realm2 = REALM_NONE;

if (PlayerClass(player_ptr).equals(PlayerClassType::ELEMENTALIST)) {
player_ptr->element = select_element_realm(player_ptr);
Expand All @@ -289,56 +302,29 @@ bool get_player_realms(PlayerType *player_ptr)

put_str(_("魔法 :", "Magic :"), 6, 1);
c_put_str(TERM_L_BLUE, get_element_title(player_ptr->element), 6, 15);
player_ptr->realm2 = REALM_NONE;
return true;
}

while (true) {
auto choices = PlayerRealm::get_realm1_choices(player_ptr->pclass);
player_ptr->realm1 = select_realm(player_ptr, choices);
if (player_ptr->realm1 == REALM_SELECT_CANCEL) {
return false;
}
if (!player_ptr->realm1) {
break;
}

cleanup_realm_selection_window();
display_wrap_around(realm_explanations[technic2magic(player_ptr->realm1) - 1], 74, 12, 3);

if (check_realm_selection(player_ptr, choices.count())) {
break;
}
/* Select the first realm */
const auto realm1 = process_choose_realm(player_ptr, PlayerRealm::get_realm1_choices(player_ptr->pclass));
if (!realm1) {
return false;
}

/* Select the second realm */
player_ptr->realm2 = REALM_NONE;
if (player_ptr->realm1 == REALM_NONE) {
if (*realm1 == REALM_NONE) {
return true;
}

player_ptr->realm1 = *realm1;
print_choosed_realms(player_ptr);

/* Select the second realm */
while (true) {
auto choices = PlayerRealm::get_realm2_choices(player_ptr->pclass);
player_ptr->realm2 = select_realm(player_ptr, choices);

if (player_ptr->realm2 == REALM_SELECT_CANCEL) {
return false;
}
if (!player_ptr->realm2) {
break;
}

cleanup_realm_selection_window();
display_wrap_around(realm_explanations[technic2magic(player_ptr->realm2) - 1], 74, 12, 3);

if (check_realm_selection(player_ptr, choices.count())) {
break;
}
const auto realm2 = process_choose_realm(player_ptr, PlayerRealm::get_realm2_choices(player_ptr->pclass));
if (!realm2) {
return false;
}

if (*realm2 == REALM_NONE) {
return true;
}
player_ptr->realm2 = *realm2;
print_choosed_realms(player_ptr);

return true;
Expand Down
4 changes: 2 additions & 2 deletions src/birth/character-builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ static void write_birth_diary(PlayerType *player_ptr)
const auto mes_class = format(_("%s職業に%sを選択した。", "%schose %s class."), indent, class_info.at(player_ptr->pclass).title.data());
exe_write_diary(floor, DiaryKind::DESCRIPTION, 1, mes_class);
PlayerRealm pr(player_ptr);
if (player_ptr->realm1) {
const auto mes_realm2 = player_ptr->realm2 ? format(_("と%s", " and %s realms"), pr.realm2().get_name().data()) : _("", " realm");
if (pr.realm1().is_available()) {
const auto mes_realm2 = pr.realm2().is_available() ? format(_("と%s", " and %s realms"), pr.realm2().get_name().data()) : _("", " realm");
const auto mes_realm = format(_("%s魔法の領域に%s%sを選択した。", "%schose %s%s."), indent, pr.realm1().get_name().data(), mes_realm2.data());
exe_write_diary(floor, DiaryKind::DESCRIPTION, 1, mes_realm);
}
Expand Down
8 changes: 4 additions & 4 deletions src/cmd-action/cmd-hissatsu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ static int get_hissatsu_power(PlayerType *player_ptr, SPELL_IDX *sn)
}

/* Dump the spell --(-- */
const auto spell_name = exe_spell(player_ptr, REALM_HISSATSU, i, SpellProcessType::NAME);
psi_desc.append(format(" %-18s%2d %3d", spell_name->data(), spell.slevel, spell.smana));
const auto &spell_name = PlayerRealm::get_spell_name(REALM_HISSATSU, i);
psi_desc.append(format(" %-18s%2d %3d", spell_name.data(), spell.slevel, spell.smana));
prt(psi_desc, y + (line % 17) + (line >= 17), x + (line / 17) * 30);
prt("", y + (line % 17) + (line >= 17) + 1, x + (line / 17) * 30);
}
Expand Down Expand Up @@ -406,8 +406,8 @@ void do_cmd_gain_hissatsu(PlayerType *player_ptr)

player_ptr->spell_learned1 |= (1UL << i);
player_ptr->spell_worked1 |= (1UL << i);
const auto spell_name = exe_spell(player_ptr, REALM_HISSATSU, i, SpellProcessType::NAME);
msg_format(_("%sの技を覚えた。", "You have learned the special attack of %s."), spell_name->data());
const auto &spell_name = PlayerRealm::get_spell_name(REALM_HISSATSU, i);
msg_format(_("%sの技を覚えた。", "You have learned the special attack of %s."), spell_name.data());
int j;
for (j = 0; j < 64; j++) {
/* Stop at the first empty space */
Expand Down
Loading

0 comments on commit 1fbb5cc

Please sign in to comment.