using System; using System.Collections.Generic; using System.Linq; using Continentis.MainGame.Card; using UnityEngine; namespace Continentis.MainGame.Character { public partial class RecordSubmodule : SubmoduleBase { public int currentRound; public int currentAction; public List actionRecords; public RecordSubmodule(CharacterBase owner) : base(owner) { actionRecords = new List(); } public void SetAction(int round, int actionIndex) { currentRound = round; currentAction = actionIndex; actionRecords.Add(new ActionRecord(round, actionIndex, new List())); } } public partial class RecordSubmodule { public void RecordCardPlay(CardInstance card) { if (actionRecords.Count == 0) { Debug.LogWarning("No action record to add card play to."); return; } ActionRecord currentRecord = actionRecords[actionRecords.Count - 1]; currentRecord.cardsPlayed.Add(card); Debug.Log($"在回合 {currentRecord.round} 行动 {currentRecord.actionIndex} 中记录了卡牌 {card.cardLogic.contentSubmodule.cardName} 的使用。"); } } public partial class RecordSubmodule { public ActionRecord GetRecord(int round, int actionIndex) { return actionRecords.FirstOrDefault(record => record.round == round && record.actionIndex == actionIndex); } public List GetLastActionsRecords(int count) { return actionRecords.Skip(Mathf.Max(0, actionRecords.Count - count)).ToList(); } public List GetLastRoundsRecords(int roundCount) { int minRound = Mathf.Max(0, currentRound - roundCount + 1); return actionRecords.Where(record => record.round >= minRound).ToList(); } } [Serializable] public class ActionRecord { public int round; public int actionIndex; public List cardsPlayed; public ActionRecord(int round, int actionIndex, List cardsPlayed) { this.round = round; this.actionIndex = actionIndex; this.cardsPlayed = cardsPlayed; } } }