载入中...
搜索中...
未找到
Battle.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include "common/Result.h"
6#include "common/SubjectRef.h"
9
20#include <string>
21#include <vector>
22
23namespace eve::rpg {
24
25class RPGActor;
26class BattleTacticsCatalogue;
27struct StatusTickEvent;
28
30namespace BattleSide {
31inline constexpr int Party = 0;
32inline constexpr int Enemies = 1;
33} // namespace BattleSide
34
37
41 std::string action;
42 std::string skillId;
43 class RPGActor* caster = nullptr;
44 class RPGActor* target = nullptr;
45 double amount = 0.0;
46 bool crit = false;
47};
48
55public:
57 Battle() = default;
59 ~Battle() = default;
60
61 Battle(const Battle&) = delete;
62 Battle& operator=(const Battle&) = delete;
63
65 void addActor(RPGActor* actor, int side);
73 [[nodiscard]] eve::Result<void> configureSettlementRules(const settlement::SettlementRuleSet& rules);
86 const StatusTickEvent& tick, SubjectRef source, SimulationTick simulationTick);
88 void setAction(RPGActor* actor, const std::string& skillId, RPGActor* target = nullptr);
96 [[nodiscard]] eve::Result<void> setActionChecked(RPGActor* actor, const std::string& skillId,
97 RPGActor* target = nullptr);
104 [[nodiscard]] eve::Result<void> setActionByPolicyChecked(RPGActor* actor, const std::string& skillId,
105 BattleTargetPolicy policy);
107 void autoEnemyActions();
109 void startRound();
111 bool executeNextAction();
113 bool isFinished() const;
115 bool isVictory() const;
117 bool isDefeat() const;
119 void setPlayerSide(int side);
121 int getPlayerSide() const;
123 int getWinnerSide() const;
125 int getTurn() const;
127 bool isActorAlive(RPGActor* actor) const;
128
130 int getActorCount() const;
137 RPGActor* getActor(int index) const;
139 int getSide(int index) const;
140
142 int getEventCount() const;
144 BattleEvent getEvent(int index) const;
146 void pollEvents();
147 // 事件字段访问(脚本向)
149 std::string getEventAction(int index) const;
151 std::string getEventSkillId(int index) const;
158 RPGActor* getEventCaster(int index) const;
165 RPGActor* getEventTarget(int index) const;
167 double getEventAmount(int index) const;
169 bool getEventCrit(int index) const;
170
171private:
172 struct Participant {
173 RPGActor* actor = nullptr;
174 int side = 0;
175 SubjectRef settlementSubject;
176 };
177 struct PendingAction {
178 RPGActor* actor = nullptr;
179 std::string skillId;
180 RPGActor* target = nullptr;
181 double initiative = 0.0;
182 };
183
184 bool isDead(const Participant& p) const;
185 std::vector<RPGActor*> livingOnSide(int side) const;
186 int sideOf(RPGActor* actor) const;
187 SubjectRef settlementSubjectOf(RPGActor* actor) const noexcept;
193 RPGActor* randomOpponent(int mySide);
194 RPGActor* lowestHealthTarget(int side, bool sameSide) const;
195 int computeWinnerSide() const;
198 void execute(PendingAction& pa, unsigned& seedCounter);
199
200 std::vector<Participant> participants_;
201 std::vector<PendingAction> queue_;
202 std::vector<PendingAction> roundActions_;
203 std::vector<BattleEvent> events_;
204 std::vector<BattleEvent> polled_;
205 int turn_ = 0;
206 bool started_ = false;
207 bool finished_ = false;
208 int winner_ = -1;
209 int playerSide_ = BattleSide::Party;
210 unsigned seedCounter_ = 1;
211 std::uint64_t nextSettlementSubject_ = 1;
214};
215
216} // namespace eve::rpg
LogicalId target
glm::vec4 p[6]
#define EVENGINE_API_PLATFORM
Definition Export.h:107
const GltfImportRequest & request
Move-only, checked operation results for the common layer.
Declarative, domain-neutral rules for buffs and gameplay effects.
Stable reference to a runtime gameplay subject.
SimulationTick tick
ecs::EntityHandle side
uint32_t index
const UnitySourceAsset & source
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Strong, domain-neutral reference to a runtime subject.
Definition SubjectRef.h:26
Process-local strict catalogue that selects and queues companion/AI actions.
一场回合制战斗(任意阵营数)。 @ownership 由调用方创建/销毁;Battle 不持有参与者的所有权(参与者为借用 ECS actor)。 @thread 在单一模拟线程上驱动整场战斗。
Definition Battle.h:54
Battle(const Battle &)=delete
Battle()=default
Battle.
Battle & operator=(const Battle &)=delete
~Battle()=default
Battle.
Authoritative ordered relationship between stable party member IDs and RPG actors....
Definition Party.h:24
属性 / 状态 / 技能三表合一的 ECS 实体。
Definition RPGActor.h:34
Deterministically ordered, composable settlement pipeline.
Definition Settlement.h:542
Validated immutable-style rule collection installable into pipelines.
constexpr int Enemies
Definition Battle.h:32
RPG 模块的基础实体:把属性 / 状态 / 技能三张表挂到一个 ECS 实体上。
BattleTargetPolicy
Deterministic target-selection policies for queued battle actions.
Definition Battle.h:36
Domain-neutral, deterministic settlement pipeline.
一次战斗反馈事件。
Definition Battle.h:39
std::string skillId
Definition Battle.h:42
class RPGActor * caster
Definition Battle.h:43
class RPGActor * target
Definition Battle.h:44
std::string action
roundStart | actionStart | damage | heal | miss | effect | settlementFailed | victory | defeat
Definition Battle.h:41
周期性状态触发的 tick 事件。周期效果(period > 0)不会自动修改属性, 而是每个周期产生一个 tick 事件交给上层(脚本或 C++ 结算系统)处理—— 这样伤害/治疗类周期效果可以完整地...
Definition StatusTypes.h:69
Domain-neutral input to one settlement operation.
Definition Settlement.h:107