卡牌模块入口(eve.Card):定义注册、对象工厂与每帧 update/render。 更多...
#include <Card.h>
Public 成员函数 | |
| Module_REG (Card) | |
| Card () | |
Declared out of line so the incomplete CardControl member needs no deleter here. | |
| ~Card () override | |
| Card. | |
| Card (const Card &)=delete | |
| Card & | operator= (const Card &)=delete |
| Card (Card &&) noexcept | |
| Card. | |
| Card & | operator= (Card &&) noexcept |
| Operator =. | |
| int | registerCardsFromJson (const std::string &json) |
| 从 JSON 注册卡牌类型;返回成功注册数量。 | |
| void | clearCardDefinitions () |
| 清空全部卡牌类型定义。 | |
| int | getCardDefinitionCount () |
| 已注册卡牌类型数量。 | |
| std::string | getCardDefinitionId (int index) const |
| Return a definition ID in deterministic sorted order. | |
| bool | hasCardDefinition (const std::string &id) |
| 卡牌类型查询。 | |
| bool | setCardDefinition (const std::string &id, const std::string &name, const std::string &kind, int cost, int attack, int health, float tintR, float tintG, float tintB) |
| Insert or replace one definition for project-owned authoring tools. | |
| bool | removeCardDefinition (const std::string &id) |
| Remove one definition by stable identifier. | |
| eve::Result< void > | setCardPlayCondition (const std::string &id, decision::Condition condition) |
| Replace the side-effect-free condition required to play a definition. | |
| std::string | getCardDefinitionName (const std::string &id) |
| std::string | getCardDefinitionKind (const std::string &id) |
| Returns the card definition kind. | |
| int | getCardDefinitionCost (const std::string &id) |
| Returns the card definition cost. | |
| int | getCardDefinitionAttack (const std::string &id) |
| Returns the card definition attack. | |
| int | getCardDefinitionHealth (const std::string &id) |
| Returns the card definition health. | |
| float | getCardDefinitionTintR (const std::string &id) |
| Returns the card definition tint r. | |
| float | getCardDefinitionTintG (const std::string &id) |
| Returns the card definition tint g. | |
| float | getCardDefinitionTintB (const std::string &id) |
| Returns the card definition tint b. | |
| LayoutConfig * | newConfig () |
| 工厂:对象由 ECS 表持有,脚本持有的是非拥有句柄。 | |
| CardData * | newCard (const std::string &defId) |
| Creates a card. @ownership Caller deletes unless documented otherwise. | |
| Deck * | newDeck () |
| Creates a deck. @ownership Caller deletes unless documented otherwise. | |
| Zone * | newZone (const std::string &id, const std::string &label, float x, float y, float w, float h) |
| 创建一个落牌区。 | |
| Hand * | newHand (LayoutConfig *cfg) |
| 创建一个手牌布局。 | |
| CardPlaneMapper * | newPlaneMapper () |
| Create a reusable logical-card-canvas to 3D plane mapper. | |
| void | setConfig (LayoutConfig *cfg) |
| 游戏状态:当前布局、手牌、落牌区、牌库。 | |
| LayoutConfig * | getConfig () const |
| Returns the config. | |
| int | handCount () const |
| Hand count. | |
| Hand * | getHand (int index) const |
| Returns the hand. | |
| Hand * | findHand (const std::string &owner) const |
| Finds hand. | |
| int | zoneCount () const |
| Zone count. | |
| Zone * | getZone (int index) const |
| Returns the zone. | |
| Deck * | getDeck () const |
| Returns the deck. | |
| CardData * | drawCard (const std::string &handOwner) |
| 从牌库抽一张牌加入指定手牌;无牌时返回 nullptr。 | |
| decision::ConditionResult | evaluatePlay (const CardData *card, CardPlayConditionQueries queries={}) const |
| Evaluate a card's pure play condition through the shared protocol. | |
| eve::Result< double > | getCardAttribute (CardData &card, std::string_view attribute) const |
| Read one canonical combat attribute through the Card facade. | |
| eve::Result< void > | setCardAttribute (CardData &card, std::string_view attribute, double value) const |
| Set one canonical combat attribute through the Card facade. | |
| eve::Result< effects::EffectHandle > | applyEffect (CardData &card, const CardEffectDefinition &definition, eve::SubjectRef subject) const |
| Apply a domain card effect to the card-owned lifecycle component. | |
| eve::Result< std::size_t > | step (const eve::SimulationStep &step) |
| Advance all card-owned effects and project current health. | |
| eve::Result< eve::transaction::TransactionReceipt > | play (CardData &card, eve::resource::IResourceAccount &playerAccount, CardPlayComposition composition={}, std::string transactionId={}) |
| Play a card through the facade's condition, container and payment transaction. | |
| int | capturePresentation () |
| Capture all live cards into a contiguous presentation snapshot buffer. | |
| int | getPresentationCount () const |
| Return the number of entries in the most recently captured buffer. | |
| CardPresentationSnapshot * | getPresentation (int index) |
| Return an entry from the most recently captured buffer, or nullptr. | |
| void | update (float dt, float mx, float my, bool down) |
| 每帧更新布局与交互。 | |
| void | render (graphics::Graphics *gfx) |
| 绘制手牌/落牌区(与牌库)。 | |
| void | renderDeck (graphics::Graphics *gfx) |
| Renders deck. | |
| void | setBuiltInVisuals (bool enabled) |
| Enable or disable the built-in card visuals while retaining layout and interaction. | |
| bool | getBuiltInVisuals () const |
| Return whether Card::render draws the built-in card faces. | |
| eve::Result< void > | publishGameplay (const std::string &instanceId, const std::string &ownerId, Hand *hand, eve::resource::IResourceAccount *account=nullptr) |
把一副手牌发布到共享玩法协议(eve_gameplay / MCP)。 | |
| eve::Result< void > | unpublishGameplay (const std::string &instanceId) |
| 取消发布一个实例;该实例未发布(或 id 非法)时返回诊断。 | |
| void | clearGameplayControls () |
| 取消发布本模块持有的全部玩法实例。 | |
| int | gameplayControlCount () const |
| 已发布的玩法实例数量。 | |
| std::vector< std::string > | gameplayInstances () const |
| 已发布的玩法实例标识(发布顺序)。 | |
Public 成员函数 继承自 eve::Module | |
| virtual | ~Module () |
| Module. | |
| virtual std::string | getName () const =0 |
| Returns the name. | |
详细描述
构造及析构函数说明
◆ Card() [1/3]
|
default |
Declared out of line so the incomplete CardControl member needs no deleter here.
◆ ~Card()
◆ Card() [2/3]
|
delete |
◆ Card() [3/3]
成员函数说明
◆ applyEffect()
| eve::Result< effects::EffectHandle > eve::card::Card::applyEffect | ( | CardData & | card, |
| const CardEffectDefinition & | definition, | ||
| eve::SubjectRef | subject | ||
| ) | const |
Apply a domain card effect to the card-owned lifecycle component.
- 参数
-
card Borrowed CardData whose Effects component owns the instance. definition Effect policy and card-specific interpretation. subject Stable subject identity used by the common effect store.
- 返回
- Generation-qualified effect handle owned by the caller.
引用了 eve::card::CardAttributeAdapter::ensure(), eve::Diagnostic::error(), eve::Result< T >::failure(), eve::StaleHandle , 以及 subject.
◆ capturePresentation()
| int eve::card::Card::capturePresentation | ( | ) |
◆ clearCardDefinitions()
◆ clearGameplayControls()
◆ drawCard()
| CardData * eve::card::Card::drawCard | ( | const std::string & | handOwner | ) |
从牌库抽一张牌加入指定手牌;无牌时返回 nullptr。
引用了 c, eve::card::Deck, eve::card::LayoutConfig::deckX, eve::card::LayoutConfig::deckY, eve::card::Deck::draw(), findHand() , 以及 h.
◆ evaluatePlay()
| decision::ConditionResult eve::card::Card::evaluatePlay | ( | const CardData * | card, |
| CardPlayConditionQueries | queries = {} |
||
| ) | const |
Evaluate a card's pure play condition through the shared protocol.
- 参数
-
card Borrowed card instance observed synchronously; it is not moved. queries Optional read-only resource, authority and policy providers.
- 返回
- Stable passed/rejected result with evidence and UI details.
引用了 eve::card::CardPlayConditionAdapter::evaluate(), eve::decision::ConditionResult::failed() , 以及 eve::decision::InvalidCondition.
◆ findHand()
| Hand * eve::card::Card::findHand | ( | const std::string & | owner | ) | const |
◆ gameplayControlCount()
◆ gameplayInstances()
| std::vector< std::string > eve::card::Card::gameplayInstances | ( | ) | const |
◆ getBuiltInVisuals()
|
inline |
Return whether Card::render draws the built-in card faces.
◆ getCardAttribute()
| eve::Result< double > eve::card::Card::getCardAttribute | ( | CardData & | card, |
| std::string_view | attribute | ||
| ) | const |
Read one canonical combat attribute through the Card facade.
- 参数
-
card Borrowed live CardData owned by this ECS world. attribute Selected attribute name such as attackorhealth.
- 返回
- The canonical final value, or a structured rejection.
引用了 eve::Diagnostic::error(), eve::Result< T >::failure(), eve::card::CardAttributeAdapter::read() , 以及 eve::StaleHandle.
◆ getCardDefinitionAttack()
| int eve::card::Card::getCardDefinitionAttack | ( | const std::string & | id | ) |
◆ getCardDefinitionCost()
| int eve::card::Card::getCardDefinitionCost | ( | const std::string & | id | ) |
◆ getCardDefinitionCount()
◆ getCardDefinitionHealth()
| int eve::card::Card::getCardDefinitionHealth | ( | const std::string & | id | ) |
◆ getCardDefinitionId()
| std::string eve::card::Card::getCardDefinitionId | ( | int | index | ) | const |
◆ getCardDefinitionKind()
| std::string eve::card::Card::getCardDefinitionKind | ( | const std::string & | id | ) |
◆ getCardDefinitionName()
| std::string eve::card::Card::getCardDefinitionName | ( | const std::string & | id | ) |
◆ getCardDefinitionTintB()
| float eve::card::Card::getCardDefinitionTintB | ( | const std::string & | id | ) |
◆ getCardDefinitionTintG()
| float eve::card::Card::getCardDefinitionTintG | ( | const std::string & | id | ) |
◆ getCardDefinitionTintR()
| float eve::card::Card::getCardDefinitionTintR | ( | const std::string & | id | ) |
◆ getConfig()
| LayoutConfig * eve::card::Card::getConfig | ( | ) | const |
◆ getDeck()
◆ getHand()
| Hand * eve::card::Card::getHand | ( | int | index | ) | const |
◆ getPresentation()
| CardPresentationSnapshot * eve::card::Card::getPresentation | ( | int | index | ) |
◆ getPresentationCount()
| int eve::card::Card::getPresentationCount | ( | ) | const |
◆ getZone()
| Zone * eve::card::Card::getZone | ( | int | index | ) | const |
◆ handCount()
◆ hasCardDefinition()
◆ Module_REG()
| eve::card::Card::Module_REG | ( | Card | ) |
◆ newCard()
| CardData * eve::card::Card::newCard | ( | const std::string & | defId | ) |
Creates a card. @ownership Caller deletes unless documented otherwise.
引用了 c, eve::card::CardData::createCard(), d, eve::card::CardAttributeAdapter::ensure(), eve::card::CardEffectTarget::health , 以及 target.
◆ newConfig()
| LayoutConfig * eve::card::Card::newConfig | ( | ) |
◆ newDeck()
| Deck * eve::card::Card::newDeck | ( | ) |
Creates a deck. @ownership Caller deletes unless documented otherwise.
引用了 eve::card::Deck::createDeck() , 以及 d.
◆ newHand()
| Hand * eve::card::Card::newHand | ( | LayoutConfig * | cfg | ) |
◆ newPlaneMapper()
| CardPlaneMapper * eve::card::Card::newPlaneMapper | ( | ) |
◆ newZone()
| Zone * eve::card::Card::newZone | ( | const std::string & | id, |
| const std::string & | label, | ||
| float | x, | ||
| float | y, | ||
| float | w, | ||
| float | h | ||
| ) |
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ play()
| eve::Result< eve::transaction::TransactionReceipt > eve::card::Card::play | ( | CardData & | card, |
| eve::resource::IResourceAccount & | playerAccount, | ||
| CardPlayComposition | composition = {}, |
||
| std::string | transactionId = {} |
||
| ) |
Play a card through the facade's condition, container and payment transaction.
- 参数
-
card Borrowed CardData whose definition is registered by this module. playerAccount Borrowed authoritative player account. composition Optional caller-owned container/effect ports. transactionId Optional non-empty transaction correlation id.
- 返回
- Committed transaction receipt, or a failure with no partial play.
引用了 eve::card::CardPlayRequest::card, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::NotFound, eve::card::CardPlayPaymentAdapter::play(), request , 以及 eve::StaleHandle.
◆ publishGameplay()
| eve::Result< void > eve::card::Card::publishGameplay | ( | const std::string & | instanceId, |
| const std::string & | ownerId, | ||
| Hand * | hand, | ||
| eve::resource::IResourceAccount * | account = nullptr |
||
| ) |
把一副手牌发布到共享玩法协议(eve_gameplay / MCP)。
领域动作词表就是本模块自己的操作:card:draw 走牌库到手牌的抽取, card:play 走 Card::play(条件 + 容器 + 支付事务),card:set-attribute 因为会改写权威战斗属性,只对 test-driver / developer-cheat 开放。 出牌需要游戏自己的权威账户,适配器不能凭空创造:发布时可以绑定一个借用 的 IResourceAccount;未绑定时 card:play 既不广播也不接受,观察结果里 payment 为 unbound,缺口是可见的而不是静默缺失。
- 参数
-
instanceId 实例稳定标识,必须是规范持久 id(UUID 文本)。 ownerId 控制该实例的玩家/角色稳定标识,同为规范持久 id。 hand 借用的一副手牌,必须比本次发布存活更久。 account 借用的玩家支付账户,可为 null。
- 返回
- 成功返回空结果;id 非法或实例重复返回诊断。 @ownership 适配器由本模块持有并随模块销毁;hand / account 所有权不变。 @thread 所有者模拟线程。
引用了 account, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::SubjectRef::fromPersistentId(), eve::InvalidArgument , 以及 eve::detail::Id128< Tag >::parse().
◆ registerCardsFromJson()
| int eve::card::Card::registerCardsFromJson | ( | const std::string & | json | ) |
从 JSON 注册卡牌类型;返回成功注册数量。
引用了 n, eve::json::Document::parse(), eve::json::Document::root(), root , 以及 eve::json::Document::valid().
◆ removeCardDefinition()
| bool eve::card::Card::removeCardDefinition | ( | const std::string & | id | ) |
◆ render()
| void eve::card::Card::render | ( | graphics::Graphics * | gfx | ) |
◆ renderDeck()
| void eve::card::Card::renderDeck | ( | graphics::Graphics * | gfx | ) |
◆ setBuiltInVisuals()
|
inline |
◆ setCardAttribute()
| eve::Result< void > eve::card::Card::setCardAttribute | ( | CardData & | card, |
| std::string_view | attribute, | ||
| double | value | ||
| ) | const |
Set one canonical combat attribute through the Card facade.
- 参数
-
card Borrowed live CardData owned by this ECS world. attribute Selected attribute name such as attackorhealth.value New canonical base value.
- 返回
- Applied, or a structured rejection without a legacy side channel.
引用了 eve::Diagnostic::error(), eve::Result< T >::failure(), eve::card::CardAttributeAdapter::setBase(), eve::StaleHandle , 以及 value.
◆ setCardDefinition()
| bool eve::card::Card::setCardDefinition | ( | const std::string & | id, |
| const std::string & | name, | ||
| const std::string & | kind, | ||
| int | cost, | ||
| int | attack, | ||
| int | health, | ||
| float | tintR, | ||
| float | tintG, | ||
| float | tintB | ||
| ) |
Insert or replace one definition for project-owned authoring tools.
- 参数
-
id Stable definition identifier. name Display name; an empty value falls back to id. kind Project-defined card kind; an empty value falls back to creature. cost Non-negative resource cost. attack Non-negative attack value. health Non-negative health value. tintR Red tint channel, clamped to [0, 1]. tintG Green tint channel, clamped to [0, 1]. tintB Blue tint channel, clamped to [0, 1].
- 返回
- True when the definition was accepted.
◆ setCardPlayCondition()
| eve::Result< void > eve::card::Card::setCardPlayCondition | ( | const std::string & | id, |
| decision::Condition | condition | ||
| ) |
Replace the side-effect-free condition required to play a definition.
- 参数
-
id Stable card definition identifier. condition Owning condition tree; it is copied into the definition.
- 返回
- Success, or NotFound/Rejected when the definition or tree is invalid.
引用了 condition, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, eve::NotFound , 以及 eve::Result< T >::success().
◆ setConfig()
| void eve::card::Card::setConfig | ( | LayoutConfig * | cfg | ) |
◆ step()
| eve::Result< std::size_t > eve::card::Card::step | ( | const eve::SimulationStep & | step | ) |
Advance all card-owned effects and project current health.
- 参数
-
step Injected deterministic simulation tick and duration.
- 返回
- Number of settled periodic triggers, or a structured failure.
引用了 eve::Applied, eve::Result< T >::failure(), handle, eve::card::CardAttributeAdapter::healthAttribute, eve::NoOp, projected, eve::card::CardAttributeAdapter::setBase(), eve::Status::success(), eve::Result< T >::success() , 以及 updated.
◆ unpublishGameplay()
| eve::Result< void > eve::card::Card::unpublishGameplay | ( | const std::string & | instanceId | ) |
取消发布一个实例;该实例未发布(或 id 非法)时返回诊断。
引用了 eve::Diagnostic::error(), eve::Result< T >::failure(), eve::SubjectRef::fromPersistentId(), eve::InvalidArgument, eve::NotFound , 以及 eve::detail::Id128< Tag >::parse().
◆ update()
| void eve::card::Card::update | ( | float | dt, |
| float | mx, | ||
| float | my, | ||
| bool | down | ||
| ) |
◆ zoneCount()
该类的文档由以下文件生成:
Public 成员函数 继承自