CardBuff,Exhaustible

This commit is contained in:
SoulliesOfficial
2025-11-01 06:13:58 -04:00
parent ee1d3d9c0a
commit abc540809f
30 changed files with 395 additions and 46 deletions

View File

@@ -72,12 +72,24 @@ namespace Continentis.MainGame
current[attributeName] = originalAttribute;
}
}
public void SetAttribute(string attributeName, float value)
{
if (!current.ContainsKey(attributeName))
{
Debug.Log($"{attributeName} is not found in current attributes, use default value");
}
current[attributeName] = value;
}
public void ModifyAttribute(string attributeName,
float numericChange, float percentageChangeOfAccumulation, float percentChangeOfMultiplication)
{
if (!current.ContainsKey(attributeName))
{
Debug.Log($"{attributeName} is not found in current attributes, use default value");
if (attributeName.Contains("Multiplier"))
{
current[attributeName] = 1f;
@@ -86,8 +98,6 @@ namespace Continentis.MainGame
{
current[attributeName] = 0f;
}
Debug.Log($"{attributeName} is not found in current attributes, use default value");
}
current[attributeName] += numericChange;

View File

@@ -281,6 +281,36 @@ namespace Continentis.MainGame.Card
return ModManager.CreateInstance<T>(buffTypeID, parameters);
}
/// <summary>
/// 创建一个卡牌战斗Buff实例
/// 注意此函数依赖ModManager的类型注册功能请确保在Mod加载时已注册对应Buff类型
/// 此函数中的T并不是原型参数而是获取Mod中注册的类型用的
/// </summary>
public T CreateCardBuff<T>(params object[] parameters) where T :CardBuffBase
{
string buffTypeID = ModManager.GetTypeID(typeof(T));
if (string.IsNullOrEmpty(buffTypeID))
{
Debug.LogError($"Failed to get buff name for type {typeof(T).FullName}");
return null;
}
return ModManager.CreateInstance<T>(buffTypeID, parameters);
}
public T CreateCardBuff<T>(string buffTypeID, params object[] parameters) where T :CardBuffBase
{
if (string.IsNullOrEmpty(buffTypeID))
{
Debug.LogError($"Failed to get buff name for type {typeof(T).FullName}");
return null;
}
return ModManager.CreateInstance<T>(buffTypeID, parameters);
}
}
#endregion
}

View File

@@ -27,8 +27,8 @@ namespace Continentis.MainGame.Card
public override void OnAfterFirstApply()
{
attributeSubmodule?.RefreshAllModifiedAttributes();
}
}
public override void OnBuffRemove()
{
@@ -63,7 +63,7 @@ namespace Continentis.MainGame.Card
public partial class CardCombatBuffBase
{
protected bool FindExistingBuff<T>(out T existingBuff) where T : CardBuffBase
protected bool FindExistingSameBuff<T>(out T existingBuff) where T : CardBuffBase
{
return base.FindExistingSameBuff(out existingBuff, attachedCard.combatBuffSubmodule.buffList);
}
@@ -84,6 +84,13 @@ namespace Continentis.MainGame.Card
this.attachedCard.combatBuffSubmodule.buffList.Add(this);
OnAfterFirstApply();
}
attributeSubmodule?.RefreshAllModifiedAttributes();
Debug.Log(base.attachedCard.GetAttribute("Damage"));
CardTextInterpreter.InterpretText(attachedCard);
attachedCard.handCardView?.Setup();
attachedCard.intentionCardView?.Setup();
Debug.Log(base.attachedCard.contentSubmodule.interpretedFunctionText);
}
public override void Remove()

View File

@@ -238,13 +238,33 @@ namespace Continentis.MainGame.Card
return;
}
if (HasKeyword("Exhaust"))
{
CommandQueueManager.Instance.AddCommand(user.deckSubmodule.ExhaustCard(cardInstance));
return;
}
if(HasKeyword("Exhaustible"))
{
if (!cardInstance.cardLogic.HasAttribute("ExhaustibleCount"))
{
Debug.LogError("Exhaustible card missing ExhaustibleCount attribute: " + contentSubmodule.cardName);
CommandQueueManager.Instance.AddCommand(user.deckSubmodule.ExhaustCard(cardInstance));
return;
}
cardInstance.cardLogic.ModifyAttribute("ExhaustibleCount", -1);
if(cardInstance.cardLogic.GetAttribute("ExhaustibleCount") <= 0)
{
CommandQueueManager.Instance.AddCommand(user.deckSubmodule.ExhaustCard(cardInstance));
return;
}
}
if (user is PlayerHero playerHero)
{
if (HasKeyword("Exhaust"))
{
CommandQueueManager.Instance.AddCommand(playerHero.deckSubmodule.ExhaustCard(cardInstance));
}
else if(!HasKeyword("Reuse"))
if(!HasKeyword("Reuse"))
{
CommandQueueManager.Instance.AddCommand(playerHero.deckSubmodule.DiscardCard(cardInstance, false));
CommandQueueManager.Instance.AddCommand(new Cmd_Function(() =>
@@ -258,10 +278,7 @@ namespace Continentis.MainGame.Card
}
else if (user is CombatNPC npc)
{
if (HasKeyword("Exhaust"))
{
CommandQueueManager.Instance.AddCommand(npc.deckSubmodule.ExhaustCard(cardInstance));
}
}
}
}

View File

@@ -44,6 +44,7 @@ namespace Continentis.MainGame.Card
}
attributeGroup = new AttributeGroup(originalAttributes, endowingAttributes);
attributeGroup.ApplyAllAttributes();
}
}
@@ -59,6 +60,11 @@ namespace Continentis.MainGame.Card
owner.ApplyAttributeChangesByCard();
owner.combatBuffSubmodule.GetAttributeChange(attributeName, out float numeric, out float pAccumulation, out float pMultiplication);
attributeGroup.ModifyAttribute(attributeName, numeric, pAccumulation, pMultiplication);
string displayAttributeName = "Display" + attributeName;
if(attributeGroup.current.ContainsKey(displayAttributeName))
{
attributeGroup.SetAttribute(displayAttributeName, attributeGroup.current[attributeName]);
}
}
/// <summary>
@@ -77,6 +83,11 @@ namespace Continentis.MainGame.Card
{
owner.combatBuffSubmodule.GetAttributeChange(attributeName, out float numeric, out float pAccumulation, out float pMultiplication);
attributeGroup.ModifyAttribute(attributeName, numeric, pAccumulation, pMultiplication);
string displayAttributeName = "Display" + attributeName;
if(attributeGroup.current.ContainsKey(displayAttributeName))
{
attributeGroup.SetAttribute(displayAttributeName, attributeGroup.current[attributeName]);
}
}
}
}

View File

@@ -19,6 +19,8 @@ namespace Continentis.MainGame.Card
public override void OnPointerEnter(PointerEventData eventData)
{
base.OnPointerEnter(eventData);
CardTextInterpreter.InterpretText(cardLogic);
cardDescriptionText.text = cardLogic.contentSubmodule.interpretedFunctionText;
if (CombatUIManager.Instance.selectingCardView == null)
{
canvas.overrideSorting = true;

View File

@@ -45,6 +45,17 @@ namespace Continentis.MainGame.Character
{
return buffList.Exists(x => x.GetType() == typeof(T));
}
public List<CharacterCombatBuffBase> Dispel(BuffDispelLevel dispelLevel, CharacterBase dispelSource)
{
List<CharacterCombatBuffBase> dispelledBuffs = buffList
.Where(buff => buff.dispelThreshold <= dispelLevel &&
buff.buffType == (owner.IsAlly(dispelSource) ? BuffType.Negative : BuffType.Positive))
.ToList();
dispelledBuffs.For(buff => buff.Remove());
return dispelledBuffs;
}
}
public partial class CombatBuffSubmodule

View File

@@ -154,7 +154,7 @@ namespace Continentis.MainGame.Combat
playerHero.combatBuffSubmodule.ActionStart();
combatMainPage.handPile.isUpdatingLayout = false;
CommandQueueManager.Instance.AddCommand(playerHero.deckSubmodule.DrawCards(5));
CommandQueueManager.Instance.AddCommand(playerHero.deckSubmodule.DrawCards(playerHero.GetAttribute("DrawCardAmountPerAction")));
CommandQueueManager.Instance.AddCommand(new Cmd_Function(0f, () =>
{
//Debug.Log((drawCard.groupContext.context["DrawnCards"] as List<CardInstance>).Count);