深渊协奏 (Abyssal Chord) - A MoonBit card battle game engine with CLI demo
| 项目 | 详情 |
|---|---|
| 项目名称 | 深渊协奏 (Abyssal Chord) — MoonBit 卡牌对战游戏引擎 |
| 项目方向 | 游戏引擎 / 卡牌策略游戏 |
| 适用场景 | 单机卡牌对战、局域网多人对战、AI 难度挑战、生存模式 |
| 实现语言 | MoonBit(主要)+ TypeScript(前端可视化) |
| GitHub | https://github.com/sssssurf/abyssal-chord |
| Gitlink | https://gitlink.org.cn/surf3/abyssal-chord |
| 许可证 | Apache-2.0 |
| 原创性 | 原创项目,卡牌体系与游戏机制为自主设计 |
engine/
├── types.mbt # 核心类型定义 (193行)
├── battle_effect.mbt # 卡牌效果解析引擎 (255行)
├── battle_state.mbt # 战斗状态管理 (124行)
├── enemy_ai.mbt # 敌人AI系统 (96行)
├── ai_levels.mbt # AI难度等级 (179行)
├── xian_yin_engine.mbt # 弦音专属引擎 (202行)
├── relic_engine.mbt # 遗物系统 (104行)
├── battle_formation.mbt # 阵型系统 (133行)
├── survival_mode.mbt # 生存模式 (159行)
├── multiplayer_engine.mbt # 多人对战引擎 (379行)
├── achievements.mbt # 成就系统 (194行)
├── daily_challenge.mbt # 每日挑战 (重建中)
├── card_database.mbt # 卡牌数据库 (247行)
├── deck_builder.mbt # 套牌构建器 (200行)
├── card_synergy.mbt # 卡牌协同系统 (199行)
├── balance_calc.mbt # 平衡性计算器 (249行)
├── battle_replay.mbt # 战斗回放 (184行)
├── battle_simulator.mbt # 战斗模拟器 (140行)
├── json_io.mbt # JSON序列化 (171行)
├── game_guide.mbt # 游戏攻略手册 (221行)
├── interactive_cli.mbt # 交互CLI (331行)
├── card_data.mbt # 卡牌数据 (38行)
├── more_cards.mbt # 扩展卡牌 (56行)
├── card_rebalance.mbt # 卡牌平衡分析 (149行)
├── character_data.mbt # 角色数据 (28行)
├── enemy_data.mbt # 敌人数据 (70行)
├── more_enemies.mbt # 扩展敌人 (130行)
├── pollution.mbt # 污染度系统 (41行)
├── engine_test.mbt # 自动化测试 (698行)
└── cmd/main/main.mbt # CLI演示入口 (93行)# MoonBit 引擎编译
cd engine
moon build # 编译(0 errors)
moon test # 运行测试(108/108 passed)
moon run cmd/main # CLI 对战演示
# Web 前端运行
cd ../projects
pnpm install
pnpm dev # 启动 http://localhost:5000| 指标 | 数值 |
|---|---|
| MoonBit 源文件 | 30个 |
| MoonBit 代码行数 | 5,266 行 |
| TypeScript 代码行数 | ~4,000 行(手写逻辑) |
| 总卡牌数 | 55 张 |
| 角色数 | 2 个 |
| 敌人数 | 7 个(含2 Boss) |
| 游戏模式 | 6 种 |
| AI 难度等级 | 4 级 |
| 自动化测试 | 108 个(全部通过) |
| CI/CD | GitHub Actions |
| 等级 | 范围 | 效果 |
|---|---|---|
| 寂静期 | 0-15 | 无额外效果 |
| 低鸣期 | 16-40 | 敌人伤害+2 |
| 共振期 | 41-70 | 敌人伤害+4,每回合+3护甲 |
| 咆哮期 | 71-90 | 敌人伤害+6,每回合+5护甲,玩家穿透-3 |
| 终焉和弦 | 91-100 | 敌人伤害+10,玩家穿透-5 |
| 流派 | 角色 | 特点 |
|---|---|---|
| 低频堡垒 | 钟律 | 叠甲→转化伤害,以守为攻 |
| 过载冲击 | 钟律 | 自伤换超高爆发,血线换杀线 |
| 高频刺客 | 弦音 | 高频率低费攻击,声爆快速叠加 |
| 回声幻影 | 弦音 | 牌效翻倍,资源效率极致 |
pub struct Achievement {
id : String
name : String
description : String
category : AchievementCategory
is_secret : Bool
points : Int
}pub struct ActiveAbility {
id : String
card_id : String
name : String
effect : String
}pub struct ArchetypeGuide {
name : String
description : String
key_cards : Array[String]
playstyle : String
strengths : String
weaknesses : String
recommended_relic : String
}pub struct BattleMetrics {
turns_played : Int
total_damage_dealt : Int
total_damage_taken : Int
total_armor_gained : Int
total_sonic_boom_applied : Int
cards_played : Int
abilities_activated : Int
pollution_peak : Int
victory : Bool
}pub struct BattleReplay {
character_id : String
enemy_id : String
frames : Array[ReplayFrame]
total_frames : Int
result : String
duration : Int
version : String
}pub struct BattleState {
player : PlayerState
enemy : EnemyState
player_char : Character
enemy_data : Enemy
phase : BattlePhase
turn_number : Int
pollution : Int
log : Array[String]
}pub struct Card {
id : String
name : String
name_en : String
card_type : CardType
archetype : CardArchetype
cost : Int
target : CardTarget
effect : String
design_note : String
base_damage : Int
base_armor : Int
self_damage : Int
sonic_boom : Int
pollution_modifier : Int
exhaust : Bool
retain : Bool
}pub struct CardEfficiency {
name : String
ap_cost : Int
raw_damage : Int
raw_armor : Int
self_damage : Int
sonic_boom_value : Int
utility_score : Double
archetype_label : String
tier : String
}pub struct CardQuery {
card_type : String
archetype : String
min_cost : Int
max_cost : Int
target : String
keyword : String
has_special : Bool
character : String
}pub struct Character {
id : String
name : String
name_en : String
title : String
title_en : String
max_hp : Int
relic : String
relic_en : String
relic_effect : String
lore : String
}pub struct CharacterComparison {
aspect : String
zhong_lv_value : String
xian_yin_value : String
}pub struct ChatMessage {
sender_id : String
sender_name : String
content : String
turn : Int
is_emote : Bool
}pub struct DeckConfig {
name : String
character_id : String
card_ids : Array[String]
max_cards : Int
min_cards : Int
description : String
total_cost : Int
}pub struct DeckStats {
total_cards : Int
total_damage_potential : Int
total_armor_potential : Int
average_ap_cost : Double
attack_ratio : Double
skill_ratio : Double
ability_ratio : Double
s_tier_cards : Int
a_tier_cards : Int
b_tier_cards : Int
c_tier_cards : Int
}pub struct DifficultyConfig {
level : AIDifficulty
label : String
enemy_hp_mult : Double
enemy_dmg_bonus : Int
dice_bias : Int
pollution_rate_bonus : Int
player_ap_penalty : Int
}pub struct Enemy {
id : String
name : String
name_en : String
lore : String
hp_1p : Int
hp_2p : Int
hp_3p : Int
hp_4p : Int
actions : Array[EnemyAction]
is_boss : Bool
has_phase2 : Bool
phase2_actions : Array[EnemyAction]
phase2_trigger : String
phase2_effect : String
}pub struct EnemyAction {
dice_min : Int
dice_max : Int
name : String
name_en : String
action_type : EnemyActionType
effect : String
damage : Int
armor : Int
sonic_boom : Int
pollution_increase : Int
piercing : Bool
special : String
}pub struct Formation {
name : String
name_en : String
formation_type : FormationType
attack_bonus : Int
armor_bonus : Int
sonic_boom_multiplier : Double
pollution_resistance : Int
ap_bonus : Int
}pub struct MatchResult {
room_id : String
winner_name : String
loser_names : Array[String]
total_turns : Int
final_pollution : Int
mvp_player : String
}pub struct MultiplayerSlot {
player_id : String
name : String
character : Character
player_state : PlayerState
is_connected : Bool
is_ready : Bool
is_eliminated : Bool
}pub struct MultiplayerState {
room_id : String
players : Array[MultiplayerSlot]
current_player_index : Int
turn_number : Int
pollution : Int
is_active : Bool
winner_id : String
log : Array[String]
}pub struct NetworkPacket {
packet_type : String
room_id : String
player_id : String
data : String
sequence : Int
}pub struct PlayerAchievement {
achievement_id : String
unlocked : Bool
unlocked_at : String
progress : Int
target : Int
}pub struct PlayerState {
id : String
name : String
hp : Int
max_hp : Int
armor : Int
ap : Int
max_ap : Int
hand : Array[Card]
deck : Array[Card]
discard : Array[Card]
exiled : Array[Card]
permanent_abilities : Array[ActiveAbility]
damage_bonus : Int
armor_per_turn : Int
extra_damage_per_armor : Double
cards_played_this_turn : Int
has_taken_self_damage : Bool
next_attack_bonus : Int
harmonic_active : Bool
free_second_attack : Bool
debuffs : Array[Debuff]
}pub struct PollutionGuide {
tier_name : String
threshold : String
what_to_do : String
danger_warning : String
}pub struct PollutionLevel {
min_val : Int
max_val : Int
name : String
name_en : String
damage_bonus : Int
armor_per_turn : Int
player_piercing_dmg : Int
}pub struct Relic {
id : String
relic_type : RelicType
name : String
name_en : String
effect : String
owner_id : String
}pub struct ReplayFrame {
frame_id : Int
action_type : String
player_hp : Int
player_armor : Int
player_ap : Int
enemy_hp : Int
enemy_armor : Int
pollution : Int
card_id : String
card_name : String
enemy_action_name : String
damage_dealt : Int
damage_taken : Int
armor_gained : Int
}pub struct SimulationResult {
battles_run : Int
player_wins : Int
enemy_wins : Int
avg_turns : Double
avg_player_hp : Double
avg_pollution : Double
fastest_win : Int
slowest_win : Int
total_cards_played : Int
total_damage_dealt : Int
total_armor_gained : Int
}pub struct SpectatorSlot {
spectator_id : String
name : String
joined_at_turn : Int
}pub struct SurvivalState {
battle : BattleState
wave : Int
score : Int
enemies_defeated : Int
is_active : Bool
difficulty_multiplier : Double
}pub struct Synergy {
card_a_id : String
card_b_id : String
synergy_type : SynergyType
description : String
power_rating : Int
}fn add_spectator(spectators : Array[SpectatorSlot], name : String, turn : Int) -> Array[SpectatorSlot]fn archetype_menu() -> Stringfn character_select_menu() -> Stringfn check_achievement_progress(achievements : Array[PlayerAchievement], achievement_id : String, progress : Int, target : Int) -> Array[PlayerAchievement]fn check_snapped_string(state : BattleState, card_type : CardType, cards_played : Int) -> BattleStatefn create_message(sender_id : String, sender_name : String, content : String, turn : Int, is_emote : Bool) -> ChatMessagefn create_packet(packet_type : String, room_id : String, player_id : String, data : String, seq : Int) -> NetworkPacketfn create_team_config(char_id : String, formation_type : FormationType, difficulty : Int, enemy_id : String) -> TeamConfigfn difficulty_menu() -> Stringfn main_menu_text() -> Stringfn record_enemy_frame(replay : BattleReplay, state : BattleState, action_name : String) -> BattleReplayfn record_frame(replay : BattleReplay, state : BattleState, action_type : String, card_id : String, card_name : String) -> BattleReplay深渊协奏 (Abyssal Chord) - A MoonBit card battle game engine with CLI demo