Files
Continentis/Assets/Scripts/MainGame/Character/CharacterSubmodules/RecordSubmodule.cs
SoulliesOfficial 85bbe2431c 意图初步
2025-11-15 09:08:36 -05:00

76 lines
2.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using Continentis.MainGame.Card;
using UnityEngine;
namespace Continentis.MainGame.Character
{
public partial class RecordSubmodule : SubmoduleBase<CharacterBase>
{
public int currentRound;
public int currentAction;
public List<ActionRecord> actionRecords;
public RecordSubmodule(CharacterBase owner) : base(owner)
{
actionRecords = new List<ActionRecord>();
}
public void SetAction(int round, int actionIndex)
{
currentRound = round;
currentAction = actionIndex;
actionRecords.Add(new ActionRecord(round, actionIndex, new List<CardInstance>()));
}
}
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<ActionRecord> GetLastActionsRecords(int count)
{
return actionRecords.Skip(Mathf.Max(0, actionRecords.Count - count)).ToList();
}
public List<ActionRecord> 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<CardInstance> cardsPlayed;
public ActionRecord(int round, int actionIndex, List<CardInstance> cardsPlayed)
{
this.round = round;
this.actionIndex = actionIndex;
this.cardsPlayed = cardsPlayed;
}
}
}