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 Aug 14, 2024
2 parents cff0b43 + 322665e commit d777351
Show file tree
Hide file tree
Showing 13 changed files with 219 additions and 139 deletions.
5 changes: 3 additions & 2 deletions src/birth/game-play-initializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "info-reader/fixed-map-parser.h"
#include "inventory/inventory-slot-types.h"
#include "market/arena-entry.h"
#include "market/melee-arena.h"
#include "pet/pet-util.h"
#include "player-base/player-class.h"
#include "player-base/player-race.h"
Expand All @@ -17,6 +16,7 @@
#include "player/player-spell-status.h"
#include "system/artifact-type-definition.h"
#include "system/baseitem-info.h"
#include "system/building-type-definition.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
#include "system/inner-game-data.h"
Expand Down Expand Up @@ -129,7 +129,8 @@ void player_wipe_without_name(PlayerType *player_ptr)
ArenaEntryList::get_instance().reset_entry();
world.set_arena(true);
world.knows_daily_bounty = false;
update_melee_gladiators(player_ptr);
auto &melee_arena = MeleeArena::get_instance();
melee_arena.update_gladiators(player_ptr);
player_ptr->muta.clear();

for (int i = 0; i < 8; i++) {
Expand Down
5 changes: 3 additions & 2 deletions src/dungeon/dungeon-processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "io/cursor.h"
#include "io/input-key-requester.h"
#include "io/write-diary.h"
#include "market/melee-arena.h"
#include "mind/mind-ninja.h"
#include "monster/monster-compaction.h"
#include "monster/monster-processor.h"
Expand All @@ -31,6 +30,7 @@
#include "realm/realm-song.h"
#include "spell-realm/spells-song.h"
#include "system/angband-system.h"
#include "system/building-type-definition.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
#include "system/monster-race-info.h"
Expand Down Expand Up @@ -164,7 +164,8 @@ void process_dungeon(PlayerType *player_ptr, bool load_game)
if (is_watching) {
if (load_game) {
player_ptr->energy_need = 0;
update_melee_gladiators(player_ptr);
auto &melee_arena = MeleeArena::get_instance();
melee_arena.update_gladiators(player_ptr);
} else {
msg_print(_("試合開始!", "Ready..Fight!"));
msg_print(nullptr);
Expand Down
10 changes: 7 additions & 3 deletions src/floor/floor-generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,13 @@ static void generate_gambling_arena(PlayerType *player_ptr)

build_battle(player_ptr, &y, &x);
player_place(player_ptr, y, x);
for (MONSTER_IDX i = 0; i < 4; i++) {
const auto m_idx = place_specific_monster(player_ptr, player_ptr->y + 8 + (i / 2) * 4, player_ptr->x - 2 + (i % 2) * 4, battle_mon_list[i], (PM_NO_KAGE | PM_NO_PET));
if (m_idx) {
const auto &melee_arena = MeleeArena::get_instance();
for (auto i = 0; i < NUM_GLADIATORS; i++) {
const auto &gladiator = melee_arena.get_gladiator(i);
const Pos2D pos(player_ptr->y + 8 + (i / 2) * 4, player_ptr->x - 2 + (i % 2) * 4);
constexpr auto mode = PM_NO_KAGE | PM_NO_PET;
const auto m_idx = place_specific_monster(player_ptr, pos.y, pos.x, gladiator.monrace_id, mode);
if (m_idx > 0) {
floor_ptr->m_list[*m_idx].set_friendly();
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/load/player-info-loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "load/savedata-old-flag-types.h"
#include "load/world-loader.h"
#include "market/arena-entry.h"
#include "market/melee-arena.h"
#include "monster-race/race-ability-flags.h"
#include "mutation/mutation-calculator.h"
#include "object/tval-types.h"
Expand All @@ -23,6 +22,7 @@
#include "spell-realm/spells-song.h"
#include "system/angband-exceptions.h"
#include "system/angband-system.h"
#include "system/building-type-definition.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
#include "system/inner-game-data.h"
Expand Down Expand Up @@ -272,7 +272,8 @@ static void rd_phase_out(PlayerType *player_ptr)
static void rd_arena(PlayerType *player_ptr)
{
if (h_older_than(0, 0, 3)) {
update_melee_gladiators(player_ptr);
auto &melee_arena = MeleeArena::get_instance();
melee_arena.update_gladiators(player_ptr);
} else {
set_gambling_monsters();
}
Expand Down
10 changes: 7 additions & 3 deletions src/load/world-loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,17 @@ void rd_alter_reality(PlayerType *player_ptr)

void set_gambling_monsters()
{
auto &melee_arena = MeleeArena::get_instance();
for (auto i = 0; i < NUM_GLADIATORS; i++) {
battle_mon_list[i] = i2enum<MonsterRaceId>(rd_s16b());
const auto monrace_id = i2enum<MonsterRaceId>(rd_s16b());
uint32_t odds;
if (h_older_than(0, 3, 4)) {
mon_odds[i] = rd_s16b();
odds = rd_s16b();
} else {
mon_odds[i] = rd_u32b();
odds = rd_u32b();
}

melee_arena.set_gladiator(i, { monrace_id, odds });
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lore/combat-types-setter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void set_monster_blow_method(lore_type *lore_ptr, int m)
lore_ptr->pc = TERM_L_WHITE;
break;
case RaceBlowMethodType::CRUSH:
lore_ptr->p = _("体当たりする", "crush");
lore_ptr->p = _("締めつける", "crush");
lore_ptr->pc = TERM_L_WHITE;
break;
case RaceBlowMethodType::ENGULF:
Expand Down
118 changes: 9 additions & 109 deletions src/market/melee-arena.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,118 +10,16 @@
#include "io/input-key-acceptor.h"
#include "main/sound-of-music.h"
#include "market/building-util.h"
#include "monster-floor/place-monster-types.h"
#include "monster-race/monster-race-hook.h"
#include "monster/monster-list.h"
#include "monster/monster-util.h"
#include "status/buff-setter.h"
#include "system/angband-system.h"
#include "system/building-type-definition.h"
#include "system/dungeon-info.h"
#include "system/monster-race-info.h"
#include "system/player-type-definition.h"
#include "term/screen-processor.h"
#include "util/int-char-converter.h"
#include "view/display-messages.h"
#include "world/world.h"
#include <algorithm>
#include <numeric>

/*!
* @brief モンスター闘技場に参加するモンスターを更新する。
* @param player_ptr プレイヤーへの参照ポインタ
*/
void update_melee_gladiators(PlayerType *player_ptr)
{
auto max_dl = 0;
for (const auto &dungeon : dungeons_info) {
if (max_dl < max_dlv[dungeon.idx]) {
max_dl = max_dlv[dungeon.idx];
}
}

auto mon_level = randint1(std::min(max_dl, 122)) + 5;
if (evaluate_percent(60)) {
auto i = randint1(std::min(max_dl, 122)) + 5;
mon_level = std::max(i, mon_level);
}

if (evaluate_percent(30)) {
auto i = randint1(std::min(max_dl, 122)) + 5;
mon_level = std::max(i, mon_level);
}

const auto &monraces = MonraceList::get_instance();
while (true) {
auto total = 0;
auto is_applicable = false;
for (auto i = 0; i < NUM_GLADIATORS; i++) {
MonsterRaceId monrace_id;
int j;
while (true) {
get_mon_num_prep(player_ptr, monster_can_entry_arena, nullptr);
monrace_id = get_mon_num(player_ptr, 0, mon_level, PM_ARENA);
if (!MonraceList::is_valid(monrace_id)) {
continue;
}

const auto &monrace = monraces.get_monrace(monrace_id);
if (monrace.kind_flags.has(MonsterKindType::UNIQUE) || monrace.population_flags.has(MonsterPopulationType::ONLY_ONE)) {
if ((monrace.level + 10) > mon_level) {
continue;
}
}

for (j = 0; j < i; j++) {
if (monrace_id == battle_mon_list[j]) {
break;
}
}

if (j < i) {
continue;
}

break;
}

battle_mon_list[i] = monrace_id;
if (monraces.get_monrace(monrace_id).level < 45) {
is_applicable = true;
}
}

std::array<int, NUM_GLADIATORS> power;
std::transform(std::begin(battle_mon_list), std::end(battle_mon_list), std::begin(power),
[&monraces](auto monrace_id) { return monraces.get_monrace(monrace_id).calc_power(); });
total += std::reduce(std::begin(power), std::end(power));
int i;
for (i = 0; i < NUM_GLADIATORS; i++) {
if (power[i] <= 0) {
break;
}

power[i] = total * 60 / power[i];
if (is_applicable && ((power[i] < 160) || power[i] > 1500)) {
break;
}

if ((power[i] < 160) && randint0(20)) {
break;
}

if (power[i] < 101) {
power[i] = 100 + randint1(5);
}

mon_odds[i] = power[i];
}

if (i == NUM_GLADIATORS) {
break;
}
}
}

/*!
* @brief モンスター闘技場のメインルーチン
Expand All @@ -132,7 +30,8 @@ bool melee_arena_comm(PlayerType *player_ptr)
{
auto &world = AngbandWorld::get_instance();
if ((world.game_turn - world.arena_start_turn) > TURNS_PER_TICK * 250) {
update_melee_gladiators(player_ptr);
auto &melee_arena = MeleeArena::get_instance();
melee_arena.update_gladiators(player_ptr);
world.arena_start_turn = world.game_turn;
}

Expand All @@ -149,8 +48,10 @@ bool melee_arena_comm(PlayerType *player_ptr)
clear_bldg(4, 10);

prt(_("モンスター 倍率", "Monsters Odds"), 4, 4);
const auto &melee_arena = MeleeArena::get_instance();
for (auto i = 0; i < NUM_GLADIATORS; i++) {
const auto &monrace = monraces_info[battle_mon_list[i]];
const auto &gladiator = melee_arena.get_gladiator(i);
const auto &monrace = monraces_info[gladiator.monrace_id]; //@ 後でシングルトンに差し替え.
std::string name;
if (monrace.kind_flags.has(MonsterKindType::UNIQUE)) {
name = _(monrace.name, "Fake ");
Expand All @@ -160,22 +61,21 @@ bool melee_arena_comm(PlayerType *player_ptr)
name.append(_(" ", ""));
}

constexpr auto fmt = _("%d) %-58s %4ld.%02ld倍", "%d) %-58s %4ld.%02ld");
prt(format(fmt, i + 1, name.data(), (long int)mon_odds[i] / 100, (long int)mon_odds[i] % 100), 5 + i, 1);
constexpr auto fmt = _("%d) %-58s %4d.%02d倍", "%d) %-58s %4d.%02d");
prt(format(fmt, i + 1, name.data(), gladiator.odds / 100, gladiator.odds % 100), 5 + i, 1);
}

prt(_("どれに賭けますか:", "Which monster: "), 0, 0);
while (true) {
int i = inkey();

const auto i = inkey();
if (i == ESCAPE) {
screen_load();
return false;
}

if (i >= '1' && i <= '4') {
bet_number = i - '1';
battle_odds = mon_odds[bet_number];
battle_odds = melee_arena.get_gladiator(bet_number).odds;
break;
}

Expand Down
1 change: 0 additions & 1 deletion src/market/melee-arena.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#pragma once

class PlayerType;
void update_melee_gladiators(PlayerType *player_ptr);
bool melee_arena_comm(PlayerType *player_ptr);
7 changes: 4 additions & 3 deletions src/save/player-writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ void wr_player(PlayerType *player_ptr)
wr_bool(is_achieved);
}

for (auto i = 0; i < NUM_GLADIATORS; i++) {
wr_s16b(enum2i(battle_mon_list[i]));
wr_u32b(mon_odds[i]);
const auto &melee_arena = MeleeArena::get_instance();
for (const auto &gladiator : melee_arena.get_gladiators()) {
wr_s16b(enum2i(gladiator.monrace_id));
wr_u32b(gladiator.odds);
}

wr_s16b(player_ptr->town_num);
Expand Down
Loading

0 comments on commit d777351

Please sign in to comment.