110 lines
3.1 KiB
C#
110 lines
3.1 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
|
||
namespace Models;
|
||
|
||
/// <summary>
|
||
/// 学生数据模型 (StudentModel)
|
||
/// 设计说明:
|
||
/// 1) 不再继承 UnitModel,而是通过 Core 组合通用组件(属性/状态/标签/装备等)。
|
||
/// 2) 学生特有内容(年级/体力/忠诚/署名贡献)放在独立组件中,保持高内聚。
|
||
/// 3) Model 层仅负责数据,不做 Godot 行为调用,方便后续存档与 Mod 注入。
|
||
/// 注意事项:
|
||
/// - Traits 实际上是标签(Tag),统一走 Core.Tags.TraitIds,避免双份真相。
|
||
/// - Grade 仅表示“学年进度”,不是学术能力值。
|
||
/// 未来扩展:
|
||
/// - 可新增“毕业/退学事件队列”,由系统层驱动。
|
||
/// - 可新增“论文署名历史”用于复盘与羁绊叠层回溯。
|
||
/// </summary>
|
||
public sealed class StudentModel {
|
||
/// <summary>
|
||
/// 学生类型
|
||
/// </summary>
|
||
public enum StudentType {
|
||
MasterCandidate, // 硕士生
|
||
DoctorCandidate // 博士生
|
||
}
|
||
|
||
/// <summary>
|
||
/// 构造函数
|
||
/// </summary>
|
||
/// <param name="name">名字</param>
|
||
/// <param name="random">随机数生成器</param>
|
||
public StudentModel(string name, Random random = null) {
|
||
var rng = random ?? Random.Shared;
|
||
Core = new UnitModel(name, rng);
|
||
Type = rng.Next(2) == 0 ? StudentType.MasterCandidate : StudentType.DoctorCandidate;
|
||
Progress = new StudentProgress(Type);
|
||
Contributions = new StudentContributions();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 核心单位数据
|
||
/// </summary>
|
||
public UnitModel Core { get; }
|
||
|
||
/// <summary>
|
||
/// 学生类型
|
||
/// </summary>
|
||
public StudentType Type { get; }
|
||
|
||
/// <summary>
|
||
/// 进度数据
|
||
/// </summary>
|
||
public StudentProgress Progress { get; }
|
||
|
||
/// <summary>
|
||
/// 贡献记录
|
||
/// </summary>
|
||
public StudentContributions Contributions { get; }
|
||
|
||
/// <summary>
|
||
/// 名字(便捷访问)
|
||
/// </summary>
|
||
public string Name {
|
||
get => Core.Name;
|
||
set => Core.Name = value;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 特质列表(便捷访问)
|
||
/// </summary>
|
||
public List<string> Traits => Core.Tags.TraitIds;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 学生进度组件(只关心学生生命周期)
|
||
/// </summary>
|
||
public sealed class StudentProgress {
|
||
public StudentProgress(StudentModel.StudentType type) {
|
||
Stamina = new StatusValue(100);
|
||
Loyalty = new StatusValue(80);
|
||
var maxGrade = type == StudentModel.StudentType.DoctorCandidate ? 6 : 3;
|
||
Grade = new PropertyValue(0, 0, maxGrade);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 体力
|
||
/// </summary>
|
||
public StatusValue Stamina { get; set; }
|
||
|
||
/// <summary>
|
||
/// 忠诚度
|
||
/// </summary>
|
||
public StatusValue Loyalty { get; set; }
|
||
|
||
/// <summary>
|
||
/// 年级
|
||
/// </summary>
|
||
public PropertyValue Grade { get; set; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 署名贡献记录(任务 -> 贡献值)
|
||
/// </summary>
|
||
public sealed class StudentContributions {
|
||
/// <summary>
|
||
/// 按任务ID索引的贡献值
|
||
/// </summary>
|
||
public Dictionary<Guid, PropertyValue> ByTask { get; } = new();
|
||
} |