载入中...
搜索中...
未找到
eve::rpg::Battle类 参考

一场回合制战斗(任意阵营数)。 @ownership 由调用方创建/销毁;Battle 不持有参与者的所有权(参与者为借用 ECS actor)。 @thread 在单一模拟线程上驱动整场战斗。 更多...

#include <Battle.h>

Public 成员函数

 Battle ()=default
 Battle.
 
 ~Battle ()=default
 Battle.
 
 Battle (const Battle &)=delete
 
Battle & operator= (const Battle &)=delete
 
void addActor (RPGActor *actor, int side)
 加入参战者;side 为任意阵营 id。
 
eve::Result< void > configureSettlementRules (const settlement::SettlementRuleSet &rules)
 Replace declarative buff/effect rules used by subsequent battle settlements.
 
eve::Result< std::vector< settlement::SettlementBatchItemResult > > settleStatusTick (const StatusTickEvent &tick, SubjectRef source, SimulationTick simulationTick)
 Execute one emitted periodic status tick through this battle's canonical settlement path.
 
void setAction (RPGActor *actor, const std::string &skillId, RPGActor *target=nullptr)
 为参战者设置本回合行动;target 为空由目标规则自动解析。
 
eve::Result< void > setActionChecked (RPGActor *actor, const std::string &skillId, RPGActor *target=nullptr)
 Validate and queue exactly one action for a living participant this round.
 
eve::Result< void > setActionByPolicyChecked (RPGActor *actor, const std::string &skillId, BattleTargetPolicy policy)
 Resolve a deterministic target policy and queue one checked action atomically.
 
void autoEnemyActions ()
 未设行动的 AI 侧自动选一个随机已学技能(或普攻)打随机存活敌对目标。
 
void startRound ()
 结算所有已设行动:先攻排序、清空待行动,回合数 +1。
 
bool executeNextAction ()
 执行下一条行动(compatibility facade (脚本兼容门面));返回是否执行了一条。
 
bool isFinished () const
 战斗是否已结束(仅剩一方存活 / 双方全灭)。
 
bool isVictory () const
 是否胜利:获胜方 == 玩家侧。
 
bool isDefeat () const
 是否战败:已结束且获胜方 != 玩家侧。
 
void setPlayerSide (int side)
 玩家阵营 id(isVictory/isDefeat 依据),默认 0。
 
int getPlayerSide () const
 Returns the player side.
 
int getWinnerSide () const
 获胜阵营 id;未结束或平局(双方全灭)返回 -1。
 
int getTurn () const
 当前回合数(1 起)。
 
bool isActorAlive (RPGActor *actor) const
 True when actor alive.
 
int getActorCount () const
 Returns the actor count.
 
RPGActor * getActor (int index) const
 Return a participant actor by index, or null when out of range.
 
int getSide (int index) const
 Returns the side.
 
int getEventCount () const
 Returns the event count.
 
BattleEvent getEvent (int index) const
 Returns the event.
 
void pollEvents ()
 Polls events.
 
std::string getEventAction (int index) const
 Returns the event action.
 
std::string getEventSkillId (int index) const
 Returns the event skill id.
 
RPGActor * getEventCaster (int index) const
 Return the caster of a polled event, or null when out of range.
 
RPGActor * getEventTarget (int index) const
 Return the target of a polled event, or null when out of range.
 
double getEventAmount (int index) const
 Returns the event amount.
 
bool getEventCrit (int index) const
 Returns the event crit.
 

友元

class BattleTacticsCatalogue
 

详细描述

一场回合制战斗(任意阵营数)。 @ownership 由调用方创建/销毁;Battle 不持有参与者的所有权(参与者为借用 ECS actor)。 @thread 在单一模拟线程上驱动整场战斗。

在文件 Battle.h 第 54 行定义.

构造及析构函数说明

◆ Battle() [1/2]

eve::rpg::Battle::Battle ( )
default

◆ ~Battle()

eve::rpg::Battle::~Battle ( )
default

◆ Battle() [2/2]

eve::rpg::Battle::Battle ( const Battle &  )
delete

成员函数说明

◆ addActor()

void eve::rpg::Battle::addActor ( RPGActor *  actor,
int  side 
)

加入参战者;side 为任意阵营 id。

在文件 Battle.cpp 第 17 行定义.

引用了 bytes, eve::SubjectRef::fromPersistentId(), index, sequence , 以及 side.

被这些函数引用 eve::rpg::Party::addToBattle().

◆ autoEnemyActions()

void eve::rpg::Battle::autoEnemyActions ( )

未设行动的 AI 侧自动选一个随机已学技能(或普攻)打随机存活敌对目标。

在文件 Battle.cpp 第 261 行定义.

引用了 p.

被这些函数引用 eve::rpg::BattleControl::advanceGameplay().

◆ configureSettlementRules()

eve::Result< void > eve::rpg::Battle::configureSettlementRules ( const settlement::SettlementRuleSet &  rules)

Replace declarative buff/effect rules used by subsequent battle settlements.

参数
rulesValidated rule set to install.
返回
Applied, or a structured configuration failure while retaining the previous rules. @thread Call on the battle's owning simulation thread between rounds. @reentrancy Does not invoke callbacks.

在文件 Battle.cpp 第 27 行定义.

引用了 eve::Applied, eve::settlement::SettlementRuleSet::install(), eve::Status::success() , 以及 eve::Result< T >::success().

◆ executeNextAction()

bool eve::rpg::Battle::executeNextAction ( )

执行下一条行动(compatibility facade (脚本兼容门面));返回是否执行了一条。

在文件 Battle.cpp 第 305 行定义.

引用了 eve::rpg::SkillSystem::getTargetType(), eve::rpg::VitalsSystem::isDead(), p, target , 以及 w.

被这些函数引用 eve::rpg::BattleControl::advanceGameplay().

◆ getActor()

RPGActor * eve::rpg::Battle::getActor ( int  index) const

Return a participant actor by index, or null when out of range.

返回
Borrowed nullable ECS actor; the battle does not own it. @ownership The ECS world owns the actor; callers must not delete it. @lifetime Valid until the actor or battle is destroyed; do not retain across rounds.

在文件 Battle.cpp 第 467 行定义.

引用了 index.

被这些函数引用 eve::rpg::BattleControl::bindParticipant() , 以及 eve::rpg::BattleControl::observeGameplay().

◆ getActorCount()

int eve::rpg::Battle::getActorCount ( ) const

Returns the actor count.

在文件 Battle.cpp 第 466 行定义.

被这些函数引用 eve::rpg::BattleControl::bindParticipant() , 以及 eve::rpg::BattleControl::observeGameplay().

◆ getEvent()

BattleEvent eve::rpg::Battle::getEvent ( int  index) const

Returns the event.

在文件 Battle.cpp 第 477 行定义.

引用了 index.

◆ getEventAction()

std::string eve::rpg::Battle::getEventAction ( int  index) const

Returns the event action.

在文件 Battle.cpp 第 486 行定义.

引用了 index.

被这些函数引用 eve::rpg::BattleControl::advanceGameplay().

◆ getEventAmount()

double eve::rpg::Battle::getEventAmount ( int  index) const

Returns the event amount.

在文件 Battle.cpp 第 502 行定义.

引用了 index.

被这些函数引用 eve::rpg::BattleControl::advanceGameplay().

◆ getEventCaster()

RPGActor * eve::rpg::Battle::getEventCaster ( int  index) const

Return the caster of a polled event, or null when out of range.

返回
Borrowed nullable ECS actor; the event cache does not own it. @ownership The ECS world owns the actor; callers must not delete it. @lifetime Valid until the actor is destroyed; do not retain beyond the poll.

在文件 Battle.cpp 第 494 行定义.

引用了 index.

被这些函数引用 eve::rpg::BattleControl::advanceGameplay().

◆ getEventCount()

int eve::rpg::Battle::getEventCount ( ) const

Returns the event count.

在文件 Battle.cpp 第 476 行定义.

被这些函数引用 eve::rpg::BattleControl::advanceGameplay().

◆ getEventCrit()

bool eve::rpg::Battle::getEventCrit ( int  index) const

Returns the event crit.

在文件 Battle.cpp 第 506 行定义.

引用了 index.

被这些函数引用 eve::rpg::BattleControl::advanceGameplay().

◆ getEventSkillId()

std::string eve::rpg::Battle::getEventSkillId ( int  index) const

Returns the event skill id.

在文件 Battle.cpp 第 490 行定义.

引用了 index.

被这些函数引用 eve::rpg::BattleControl::advanceGameplay().

◆ getEventTarget()

RPGActor * eve::rpg::Battle::getEventTarget ( int  index) const

Return the target of a polled event, or null when out of range.

返回
Borrowed nullable ECS actor; the event cache does not own it. @ownership The ECS world owns the actor; callers must not delete it. @lifetime Valid until the actor is destroyed; do not retain beyond the poll.

在文件 Battle.cpp 第 498 行定义.

引用了 index.

被这些函数引用 eve::rpg::BattleControl::advanceGameplay().

◆ getPlayerSide()

int eve::rpg::Battle::getPlayerSide ( ) const

Returns the player side.

在文件 Battle.cpp 第 175 行定义.

◆ getSide()

int eve::rpg::Battle::getSide ( int  index) const

Returns the side.

在文件 Battle.cpp 第 471 行定义.

引用了 index.

被这些函数引用 eve::rpg::BattleControl::observeGameplay().

◆ getTurn()

int eve::rpg::Battle::getTurn ( ) const

当前回合数(1 起)。

在文件 Battle.cpp 第 181 行定义.

被这些函数引用 eve::rpg::BattleControl::observeGameplay() , 以及 eve::rpg::BattleControl::submitGameplay().

◆ getWinnerSide()

int eve::rpg::Battle::getWinnerSide ( ) const

获胜阵营 id;未结束或平局(双方全灭)返回 -1。

在文件 Battle.cpp 第 180 行定义.

◆ isActorAlive()

bool eve::rpg::Battle::isActorAlive ( RPGActor *  actor) const

True when actor alive.

在文件 Battle.cpp 第 127 行定义.

引用了 eve::rpg::VitalsSystem::isDead().

被这些函数引用 eve::rpg::BattleControl::availableGameplayActions() , 以及 eve::rpg::BattleControl::observeGameplay().

◆ isDefeat()

bool eve::rpg::Battle::isDefeat ( ) const

是否战败:已结束且获胜方 != 玩家侧。

在文件 Battle.cpp 第 179 行定义.

被这些函数引用 eve::rpg::BattleControl::observeGameplay().

◆ isFinished()

bool eve::rpg::Battle::isFinished ( ) const

战斗是否已结束(仅剩一方存活 / 双方全灭)。

在文件 Battle.cpp 第 177 行定义.

被这些函数引用 eve::rpg::BattleControl::advanceGameplay(), eve::rpg::BattleControl::availableGameplayActions() , 以及 eve::rpg::BattleControl::observeGameplay().

◆ isVictory()

bool eve::rpg::Battle::isVictory ( ) const

是否胜利:获胜方 == 玩家侧。

在文件 Battle.cpp 第 178 行定义.

被这些函数引用 eve::rpg::BattleControl::observeGameplay().

◆ operator=()

Battle & eve::rpg::Battle::operator= ( const Battle &  )
delete

◆ pollEvents()

void eve::rpg::Battle::pollEvents ( )

Polls events.

在文件 Battle.cpp 第 481 行定义.

被这些函数引用 eve::rpg::BattleControl::advanceGameplay().

◆ setAction()

void eve::rpg::Battle::setAction ( RPGActor *  actor,
const std::string &  skillId,
RPGActor *  target = nullptr 
)

为参战者设置本回合行动;target 为空由目标规则自动解析。

在文件 Battle.cpp 第 183 行定义.

引用了 eve::Result< void >::ignore(), setActionChecked() , 以及 target.

◆ setActionByPolicyChecked()

eve::Result< void > eve::rpg::Battle::setActionByPolicyChecked ( RPGActor *  actor,
const std::string &  skillId,
BattleTargetPolicy  policy 
)

Resolve a deterministic target policy and queue one checked action atomically.

返回
Applied, or a structured failure without changing the pending action set.
备注
Lowest-health ties preserve participant insertion order. Policy and skill target type must agree; Auto retains the normal target-type resolver.

在文件 Battle.cpp 第 243 行定义.

引用了 eve::rpg::Auto, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::rpg::LowestHealthAlly, eve::rpg::LowestHealthEnemy, eve::NotFound, eve::rpg::Self, setActionChecked(), side , 以及 target.

被这些函数引用 eve::rpg::BattleTacticsCatalogue::queueAction().

◆ setActionChecked()

eve::Result< void > eve::rpg::Battle::setActionChecked ( RPGActor *  actor,
const std::string &  skillId,
RPGActor *  target = nullptr 
)

Validate and queue exactly one action for a living participant this round.

返回
Applied, or a structured failure without mutating the pending action set.
备注
Explicit targets must be living participants on the legal side for the skill target type. @thread Call on the battle's owning simulation thread between rounds. @reentrancy Does not invoke callbacks.

在文件 Battle.cpp 第 203 行定义.

引用了 eve::Applied, code, eve::Conflict, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::rpg::SkillSystem::getTargetType(), eve::InvalidArgument, eve::rpg::RPGActor::knowsSkill(), message, eve::NotFound, path, eve::Status::success(), eve::Result< T >::success(), target , 以及 value.

被这些函数引用 setAction(), setActionByPolicyChecked() , 以及 eve::rpg::BattleControl::submitGameplay().

◆ setPlayerSide()

void eve::rpg::Battle::setPlayerSide ( int  side)

玩家阵营 id(isVictory/isDefeat 依据),默认 0。

在文件 Battle.cpp 第 174 行定义.

引用了 side.

◆ settleStatusTick()

eve::Result< std::vector< settlement::SettlementBatchItemResult > > eve::rpg::Battle::settleStatusTick ( const StatusTickEvent &  tick,
SubjectRef  source,
SimulationTick  simulationTick 
)

Execute one emitted periodic status tick through this battle's canonical settlement path.

参数
tickTick whose target actor must be a current battle participant.
sourceStable source identity, or nil when the effect source is not a participant identity.
simulationTickDeterministic scheduler tick recorded in settlement and replay data.
返回
Owning root/derived outcomes in stable chain order, or a checked projection/chain failure.
备注
Successful numeric outcomes publish the same VitalsEvent and BattleEvent forms as actions. @thread Call on the battle and actor owning simulation thread after StatusSystem emits the tick. @reentrancy Does not invoke scripts; policies must not re-enter this battle. @cost One normal settlement per root/derived request plus active status projection for each chain item.

在文件 Battle.cpp 第 92 行定义.

引用了 action, eve::rpg::makeStatusTickSettlementRequest(), eve::rpg::VitalsSystem::publishSettledChange(), request, source, target , 以及 tick.

◆ startRound()

void eve::rpg::Battle::startRound ( )

结算所有已设行动:先攻排序、清空待行动,回合数 +1。

在文件 Battle.cpp 第 287 行定义.

引用了 eve::rpg::TraitSystem::getAttackSpeed(), eve::rpg::AttributeSystem::getFinal(), x , 以及 y.

被这些函数引用 eve::rpg::BattleControl::advanceGameplay().

友元及相关函数文档

◆ BattleTacticsCatalogue

friend class BattleTacticsCatalogue
friend

在文件 Battle.h 第 213 行定义.


该类的文档由以下文件生成: