Merge branch 'main' of https://git.ambigrat.com/card_game/tcg_client
This commit is contained in:
@@ -13,4 +13,5 @@ MonoBehaviour:
|
|||||||
m_Name: is_slot_in_range
|
m_Name: is_slot_in_range
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
range_x: 1
|
range_x: 1
|
||||||
range_p: 1
|
range_y: 0
|
||||||
|
range_p: 0
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -34,24 +34,6 @@ namespace TcgEngine
|
|||||||
return CompareInt(target.mana, oper, value);
|
return CompareInt(target.mana, oper, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增:火系法力值检查
|
|
||||||
if (type == ConditionStatType.ManaFire)
|
|
||||||
{
|
|
||||||
return CompareInt(target.mana_fire, oper, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 新增:森林法力值检查
|
|
||||||
if (type == ConditionStatType.ManaForest)
|
|
||||||
{
|
|
||||||
return CompareInt(target.mana_forest, oper, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 新增:水系法力值检查
|
|
||||||
if (type == ConditionStatType.ManaWater)
|
|
||||||
{
|
|
||||||
return CompareInt(target.mana_water, oper, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ namespace TcgEngine
|
|||||||
Attack = 10,
|
Attack = 10,
|
||||||
HP = 20,
|
HP = 20,
|
||||||
Mana = 30,
|
Mana = 30,
|
||||||
ManaFire = 40,
|
|
||||||
ManaForest = 50,
|
|
||||||
ManaWater = 60,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -44,24 +41,6 @@ namespace TcgEngine
|
|||||||
return CompareInt(target.GetMana(), oper, value);
|
return CompareInt(target.GetMana(), oper, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增:火系法力值检查
|
|
||||||
if (type == ConditionStatType.ManaFire)
|
|
||||||
{
|
|
||||||
return CompareInt(target.GetManaFire(), oper, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 新增:森林法力值检查
|
|
||||||
if (type == ConditionStatType.ManaForest)
|
|
||||||
{
|
|
||||||
return CompareInt(target.GetManaForest(), oper, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 新增:水系法力值检查
|
|
||||||
if (type == ConditionStatType.ManaWater)
|
|
||||||
{
|
|
||||||
return CompareInt(target.GetManaWater(), oper, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,24 +56,6 @@ namespace TcgEngine
|
|||||||
return CompareInt(target.mana, oper, value);
|
return CompareInt(target.mana, oper, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增:火系法力值检查
|
|
||||||
if (type == ConditionStatType.ManaFire)
|
|
||||||
{
|
|
||||||
return CompareInt(target.mana_fire, oper, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 新增:森林法力值检查
|
|
||||||
if (type == ConditionStatType.ManaForest)
|
|
||||||
{
|
|
||||||
return CompareInt(target.mana_forest, oper, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 新增:水系法力值检查
|
|
||||||
if (type == ConditionStatType.ManaWater)
|
|
||||||
{
|
|
||||||
return CompareInt(target.mana_water, oper, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,21 +47,6 @@ namespace TcgEngine
|
|||||||
{
|
{
|
||||||
return card.GetMana();
|
return card.GetMana();
|
||||||
}
|
}
|
||||||
// 新增:火系法力值检查
|
|
||||||
if (stat == ConditionStatType.ManaFire)
|
|
||||||
{
|
|
||||||
return card.GetManaFire();
|
|
||||||
}
|
|
||||||
// 新增:森林法力值检查
|
|
||||||
if (stat == ConditionStatType.ManaForest)
|
|
||||||
{
|
|
||||||
return card.GetManaForest();
|
|
||||||
}
|
|
||||||
// 新增:水系法力值检查
|
|
||||||
if (stat == ConditionStatType.ManaWater)
|
|
||||||
{
|
|
||||||
return card.GetManaWater();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,21 +47,6 @@ namespace TcgEngine
|
|||||||
{
|
{
|
||||||
return card.GetMana();
|
return card.GetMana();
|
||||||
}
|
}
|
||||||
// 新增:火系法力值检查
|
|
||||||
if (stat == ConditionStatType.ManaFire)
|
|
||||||
{
|
|
||||||
return card.GetManaFire();
|
|
||||||
}
|
|
||||||
// 新增:森林法力值检查
|
|
||||||
if (stat == ConditionStatType.ManaForest)
|
|
||||||
{
|
|
||||||
return card.GetManaForest();
|
|
||||||
}
|
|
||||||
// 新增:水系法力值检查
|
|
||||||
if (stat == ConditionStatType.ManaWater)
|
|
||||||
{
|
|
||||||
return card.GetManaWater();
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,11 +48,6 @@ namespace TcgEngine
|
|||||||
public int attack;
|
public int attack;
|
||||||
public int hp;
|
public int hp;
|
||||||
|
|
||||||
// 新增:三种元素法力值
|
|
||||||
public int mana_fire;
|
|
||||||
public int mana_forest;
|
|
||||||
public int mana_water;
|
|
||||||
|
|
||||||
[Header("Traits")]
|
[Header("Traits")]
|
||||||
public TraitData[] traits;
|
public TraitData[] traits;
|
||||||
public TraitStat[] stats;
|
public TraitStat[] stats;
|
||||||
@@ -187,18 +182,6 @@ namespace TcgEngine
|
|||||||
if (mana > 99)
|
if (mana > 99)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// 检查火系法力值是否为动态消耗
|
|
||||||
if (mana_fire > 99)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// 检查森林法力值是否为动态消耗
|
|
||||||
if (mana_forest > 99)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// 检查水系法力值是否为动态消耗
|
|
||||||
if (mana_water > 99)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,6 @@ namespace TcgEngine
|
|||||||
public class EffectAddStat : EffectData
|
public class EffectAddStat : EffectData
|
||||||
{
|
{
|
||||||
public EffectStatType type;
|
public EffectStatType type;
|
||||||
|
|
||||||
[Header("Team Mana (only for Mana type)")]
|
|
||||||
public string team_id = ""; // 当type为Mana时,指定影响的阵营
|
|
||||||
|
|
||||||
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Player target)
|
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Player target)
|
||||||
{
|
{
|
||||||
@@ -27,19 +24,10 @@ namespace TcgEngine
|
|||||||
|
|
||||||
if (type == EffectStatType.Mana)
|
if (type == EffectStatType.Mana)
|
||||||
{
|
{
|
||||||
// 如果指定了阵营,影响阵营mana;否则影响通用mana
|
target.mana += ability.value;
|
||||||
if (!string.IsNullOrEmpty(team_id))
|
target.mana_max += ability.value;
|
||||||
{
|
target.mana = Mathf.Max(target.mana, 0);
|
||||||
target.AddTeamMana(team_id, ability.value, ability.value);
|
target.mana_max = Mathf.Clamp(target.mana_max, 0, GameplayData.Get().mana_max);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Log($"AddStat Mana 通用: {ability.value}");
|
|
||||||
target.mana += ability.value;
|
|
||||||
target.mana_max += ability.value;
|
|
||||||
target.mana = Mathf.Max(target.mana, 0);
|
|
||||||
target.mana_max = Mathf.Clamp(target.mana_max, 0, GameplayData.Get().mana_max);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,13 +40,6 @@ namespace TcgEngine
|
|||||||
target.hp += ability.value;
|
target.hp += ability.value;
|
||||||
if (type == EffectStatType.Mana)
|
if (type == EffectStatType.Mana)
|
||||||
target.mana += ability.value;
|
target.mana += ability.value;
|
||||||
|
|
||||||
if (type == EffectStatType.ManaFire)
|
|
||||||
target.mana_fire += ability.value;
|
|
||||||
if (type == EffectStatType.ManaForest)
|
|
||||||
target.mana_forest += ability.value;
|
|
||||||
if (type == EffectStatType.ManaWater)
|
|
||||||
target.mana_water += ability.value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 临时效果
|
// 临时效果
|
||||||
@@ -70,13 +51,6 @@ namespace TcgEngine
|
|||||||
target.hp_ongoing += ability.value;
|
target.hp_ongoing += ability.value;
|
||||||
if (type == EffectStatType.Mana)
|
if (type == EffectStatType.Mana)
|
||||||
target.mana_ongoing += ability.value;
|
target.mana_ongoing += ability.value;
|
||||||
|
|
||||||
if (type == EffectStatType.ManaFire)
|
|
||||||
target.mana_fire_ongoing += ability.value;
|
|
||||||
if (type == EffectStatType.ManaForest)
|
|
||||||
target.mana_forest_ongoing += ability.value;
|
|
||||||
if (type == EffectStatType.ManaWater)
|
|
||||||
target.mana_water_ongoing += ability.value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -87,9 +61,5 @@ namespace TcgEngine
|
|||||||
Attack = 10,
|
Attack = 10,
|
||||||
HP = 20,
|
HP = 20,
|
||||||
Mana = 30,
|
Mana = 30,
|
||||||
// 新增:三种元素法力值
|
|
||||||
ManaFire = 40,
|
|
||||||
ManaForest = 50,
|
|
||||||
ManaWater = 60,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@ namespace TcgEngine
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Effect that sets stats equal to a dynamic calculated value from a pile (number of cards on board/hand/deck)
|
/// Effect that sets stats equal to a dynamic calculated value from a pile (number of cards on board/hand/deck)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[CreateAssetMenu(fileName = "effect", menuName = "TcgEngine/Effect/AddStatCount", order = 10)]
|
[CreateAssetMenu(fileName = "effect", menuName = "TcgEngine/Effect/AddStatCount", order = 10)]
|
||||||
public class EffectAddStatCount : EffectData
|
public class EffectAddStatCount : EffectData
|
||||||
{
|
{
|
||||||
@@ -19,9 +19,6 @@ namespace TcgEngine
|
|||||||
public CardType has_type;
|
public CardType has_type;
|
||||||
public TeamData has_team;
|
public TeamData has_team;
|
||||||
public TraitData has_trait;
|
public TraitData has_trait;
|
||||||
|
|
||||||
[Header("Team Mana (only for Mana type)")]
|
|
||||||
public string team_id = ""; // 当type为Mana时,指定影响的阵营
|
|
||||||
|
|
||||||
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Player target)
|
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Player target)
|
||||||
{
|
{
|
||||||
@@ -34,19 +31,10 @@ namespace TcgEngine
|
|||||||
|
|
||||||
if (type == EffectStatType.Mana)
|
if (type == EffectStatType.Mana)
|
||||||
{
|
{
|
||||||
// 如果指定了阵营,影响阵营mana;否则影响通用mana
|
target.mana += val;
|
||||||
if (!string.IsNullOrEmpty(team_id))
|
target.mana_max += val;
|
||||||
{
|
target.mana = Mathf.Max(target.mana, 0);
|
||||||
target.AddTeamMana(team_id, val, val);
|
target.mana_max = Mathf.Clamp(target.mana_max, 0, GameplayData.Get().mana_max);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Log($"AddStatCount Mana 通用: {val}");
|
|
||||||
target.mana += val;
|
|
||||||
target.mana_max += val;
|
|
||||||
target.mana = Mathf.Max(target.mana, 0);
|
|
||||||
target.mana_max = Mathf.Clamp(target.mana_max, 0, GameplayData.Get().mana_max);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,13 +47,6 @@ namespace TcgEngine
|
|||||||
target.hp += val;
|
target.hp += val;
|
||||||
if (type == EffectStatType.Mana)
|
if (type == EffectStatType.Mana)
|
||||||
target.mana += val;
|
target.mana += val;
|
||||||
|
|
||||||
if (type == EffectStatType.ManaFire)
|
|
||||||
target.mana_fire += val;
|
|
||||||
if (type == EffectStatType.ManaForest)
|
|
||||||
target.mana_forest += val;
|
|
||||||
if (type == EffectStatType.ManaWater)
|
|
||||||
target.mana_water += val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DoOngoingEffect(GameLogic logic, AbilityData ability, Card caster, Card target)
|
public override void DoOngoingEffect(GameLogic logic, AbilityData ability, Card caster, Card target)
|
||||||
@@ -77,13 +58,6 @@ namespace TcgEngine
|
|||||||
target.hp_ongoing += val;
|
target.hp_ongoing += val;
|
||||||
if (type == EffectStatType.Mana)
|
if (type == EffectStatType.Mana)
|
||||||
target.mana_ongoing += val;
|
target.mana_ongoing += val;
|
||||||
|
|
||||||
if (type == EffectStatType.ManaFire)
|
|
||||||
target.mana_fire_ongoing += val;
|
|
||||||
if (type == EffectStatType.ManaForest)
|
|
||||||
target.mana_forest_ongoing += val;
|
|
||||||
if (type == EffectStatType.ManaWater)
|
|
||||||
target.mana_water_ongoing += val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetCount(Game data, Card caster)
|
private int GetCount(Game data, Card caster)
|
||||||
|
|||||||
@@ -31,22 +31,6 @@ namespace TcgEngine
|
|||||||
target.mana = Mathf.Max(target.mana, 0);
|
target.mana = Mathf.Max(target.mana, 0);
|
||||||
target.mana_max = Mathf.Clamp(target.mana_max, 0, GameplayData.Get().mana_max);
|
target.mana_max = Mathf.Clamp(target.mana_max, 0, GameplayData.Get().mana_max);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == EffectStatType.ManaFire)
|
|
||||||
target.mana_fire += data.rolled_value;
|
|
||||||
target.mana_fire_max += data.rolled_value;
|
|
||||||
target.mana_fire = Mathf.Max(target.mana_fire, 0);
|
|
||||||
target.mana_fire_max = Mathf.Clamp(target.mana_fire_max, 0, GameplayData.Get().mana_max);
|
|
||||||
if (type == EffectStatType.ManaForest)
|
|
||||||
target.mana_forest += data.rolled_value;
|
|
||||||
target.mana_forest_max += data.rolled_value;
|
|
||||||
target.mana_forest = Mathf.Max(target.mana_forest, 0);
|
|
||||||
target.mana_forest_max = Mathf.Clamp(target.mana_forest_max, 0, GameplayData.Get().mana_max);
|
|
||||||
if (type == EffectStatType.ManaWater)
|
|
||||||
target.mana_water += data.rolled_value;
|
|
||||||
target.mana_water_max += data.rolled_value;
|
|
||||||
target.mana_water = Mathf.Max(target.mana_water, 0);
|
|
||||||
target.mana_water_max = Mathf.Clamp(target.mana_water_max, 0, GameplayData.Get().mana_max);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Card target)
|
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Card target)
|
||||||
@@ -59,13 +43,6 @@ namespace TcgEngine
|
|||||||
target.hp += data.rolled_value;
|
target.hp += data.rolled_value;
|
||||||
if (type == EffectStatType.Mana)
|
if (type == EffectStatType.Mana)
|
||||||
target.mana += data.rolled_value;
|
target.mana += data.rolled_value;
|
||||||
|
|
||||||
if (type == EffectStatType.ManaFire)
|
|
||||||
target.mana_fire += data.rolled_value;
|
|
||||||
if (type == EffectStatType.ManaForest)
|
|
||||||
target.mana_forest += data.rolled_value;
|
|
||||||
if (type == EffectStatType.ManaWater)
|
|
||||||
target.mana_water += data.rolled_value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,34 +14,19 @@ namespace TcgEngine
|
|||||||
{
|
{
|
||||||
public bool increase_value;
|
public bool increase_value;
|
||||||
public bool increase_max;
|
public bool increase_max;
|
||||||
|
|
||||||
[Header("Team Mana")]
|
|
||||||
public string team_id = ""; // 指定影响的阵营,空值表示影响通用mana
|
|
||||||
|
|
||||||
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Player target)
|
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Player target)
|
||||||
{
|
{
|
||||||
// 如果指定了阵营,影响阵营mana;否则影响通用mana
|
if (increase_max)
|
||||||
if (!string.IsNullOrEmpty(team_id))
|
|
||||||
{
|
{
|
||||||
// 影响阵营mana
|
target.mana_max += ability.value;
|
||||||
int current_add = increase_value ? ability.value : 0;
|
target.mana_max = Mathf.Clamp(target.mana_max, 0, GameplayData.Get().mana_max);
|
||||||
int max_add = increase_max ? ability.value : 0;
|
|
||||||
target.AddTeamMana(team_id, current_add, max_add);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (increase_value)
|
||||||
{
|
{
|
||||||
// 影响通用mana(保持原有逻辑)
|
target.mana += ability.value;
|
||||||
if (increase_max)
|
target.mana = Mathf.Max(target.mana, 0);
|
||||||
{
|
|
||||||
target.mana_max += ability.value;
|
|
||||||
target.mana_max = Mathf.Clamp(target.mana_max, 0, GameplayData.Get().mana_max);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(increase_value)
|
|
||||||
{
|
|
||||||
target.mana += ability.value;
|
|
||||||
target.mana = Mathf.Max(target.mana, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,6 @@ namespace TcgEngine
|
|||||||
public class EffectSetStat : EffectData
|
public class EffectSetStat : EffectData
|
||||||
{
|
{
|
||||||
public EffectStatType type;
|
public EffectStatType type;
|
||||||
|
|
||||||
[Header("Team Mana (only for Mana type)")]
|
|
||||||
public string team_id = ""; // 当type为Mana时,指定影响的阵营
|
|
||||||
|
|
||||||
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Player target)
|
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Player target)
|
||||||
{
|
{
|
||||||
@@ -26,17 +23,8 @@ namespace TcgEngine
|
|||||||
|
|
||||||
if (type == EffectStatType.Mana)
|
if (type == EffectStatType.Mana)
|
||||||
{
|
{
|
||||||
// 如果指定了阵营,设置阵营mana;否则设置通用mana
|
target.mana = ability.value;
|
||||||
if (!string.IsNullOrEmpty(team_id))
|
target.mana = Mathf.Max(target.mana, 0);
|
||||||
{
|
|
||||||
target.SetTeamMana(team_id, ability.value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Log($"SetStat Mana 通用: {ability.value}");
|
|
||||||
target.mana = ability.value;
|
|
||||||
target.mana = Mathf.Max(target.mana, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,13 +39,6 @@ namespace TcgEngine
|
|||||||
target.hp = ability.value;
|
target.hp = ability.value;
|
||||||
target.damage = 0;
|
target.damage = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == EffectStatType.ManaFire)
|
|
||||||
target.mana_fire = ability.value;
|
|
||||||
if (type == EffectStatType.ManaForest)
|
|
||||||
target.mana_forest = ability.value;
|
|
||||||
if (type == EffectStatType.ManaWater)
|
|
||||||
target.mana_water = ability.value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DoOngoingEffect(GameLogic logic, AbilityData ability, Card caster, Card target)
|
public override void DoOngoingEffect(GameLogic logic, AbilityData ability, Card caster, Card target)
|
||||||
@@ -68,13 +49,6 @@ namespace TcgEngine
|
|||||||
target.hp = ability.value;
|
target.hp = ability.value;
|
||||||
if (type == EffectStatType.Mana)
|
if (type == EffectStatType.Mana)
|
||||||
target.mana = ability.value;
|
target.mana = ability.value;
|
||||||
|
|
||||||
if (type == EffectStatType.ManaFire)
|
|
||||||
target.mana_fire = ability.value;
|
|
||||||
if (type == EffectStatType.ManaForest)
|
|
||||||
target.mana_forest = ability.value;
|
|
||||||
if (type == EffectStatType.ManaWater)
|
|
||||||
target.mana_water = ability.value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,14 +57,14 @@ namespace TcgEngine.Client
|
|||||||
|
|
||||||
//Find target opacity value
|
//Find target opacity value
|
||||||
target_alpha = 0f;
|
target_alpha = 0f;
|
||||||
if (your_turn && dcard != null && dcard.CardData.IsBoardCard() && gdata.CanPlayCard(dcard, slot, true))
|
if (your_turn && dcard != null && dcard.CardData.IsBoardCard() && gdata.CanPlayCard(dcard, slot))
|
||||||
{
|
{
|
||||||
target_alpha = 1f; //hightlight when dragging a character or artifact (skip mana cost)
|
target_alpha = 1f; //hightlight when dragging a character or artifact
|
||||||
}
|
}
|
||||||
|
|
||||||
if (your_turn && dcard != null && dcard.CardData.IsRequireTarget() && gdata.CanPlayCard(dcard, slot, true))
|
if (your_turn && dcard != null && dcard.CardData.IsRequireTarget() && gdata.CanPlayCard(dcard, slot))
|
||||||
{
|
{
|
||||||
target_alpha = 1f; //Highlight when dragin a spell with target (skip mana cost)
|
target_alpha = 1f; //Highlight when dragin a spell with target
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gdata.selector == SelectorType.SelectTarget && player.player_id == gdata.selector_player_id)
|
if (gdata.selector == SelectorType.SelectTarget && player.player_id == gdata.selector_player_id)
|
||||||
|
|||||||
@@ -77,8 +77,8 @@ namespace TcgEngine.Client
|
|||||||
{
|
{
|
||||||
foreach (GroupSlot slot in group_slots)
|
foreach (GroupSlot slot in group_slots)
|
||||||
{
|
{
|
||||||
if(gdata.CanPlayCard(dcard, slot.slot, true))
|
if(gdata.CanPlayCard(dcard, slot.slot))
|
||||||
target_alpha = 1f; //hightlight when dragging a character or artifact (skip mana cost)
|
target_alpha = 1f; //hightlight when dragging a character or artifact
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,17 +67,16 @@ namespace TcgEngine.Client
|
|||||||
|
|
||||||
target_alpha = 0f;
|
target_alpha = 0f;
|
||||||
Card select_card = bcard_selected?.GetCard();
|
Card select_card = bcard_selected?.GetCard();
|
||||||
// if (select_card != null)
|
if (select_card != null)
|
||||||
// {
|
{
|
||||||
// bool can_do_attack = gdata.IsPlayerActionTurn(player) && select_card.CanAttack();
|
bool can_do_attack = gdata.IsPlayerActionTurn(player) && select_card.CanAttack();
|
||||||
// bool can_be_attacked = gdata.CanAttackTarget(select_card, oplayer);
|
bool can_be_attacked = gdata.CanAttackTarget(select_card, oplayer);
|
||||||
|
|
||||||
// 敌方可被攻击时高亮
|
if (can_do_attack && can_be_attacked)
|
||||||
// if (can_do_attack && can_be_attacked)
|
{
|
||||||
// {
|
target_alpha = 1f;
|
||||||
// target_alpha = 1f;
|
}
|
||||||
// }
|
}
|
||||||
//}
|
|
||||||
|
|
||||||
if (your_turn && drag_card != null && drag_card.CardData.IsRequireTargetSpell() && gdata.IsPlayTargetValid(drag_card.GetCard(), GetPlayer()))
|
if (your_turn && drag_card != null && drag_card.CardData.IsRequireTargetSpell() && gdata.IsPlayTargetValid(drag_card.GetCard(), GetPlayer()))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -234,6 +234,7 @@ namespace TcgEngine.Client
|
|||||||
// 检查本回合是否已经上场过场上卡牌(只有怪物牌等场上卡牌受限制)
|
// 检查本回合是否已经上场过场上卡牌(只有怪物牌等场上卡牌受限制)
|
||||||
if (card.CardData.IsBoardCard() && player.cards_played_this_turn >= 1)
|
if (card.CardData.IsBoardCard() && player.cards_played_this_turn >= 1)
|
||||||
{
|
{
|
||||||
|
// TODO 通知
|
||||||
Debug.Log("本回合只能上场一张场上卡牌");
|
Debug.Log("本回合只能上场一张场上卡牌");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,16 +22,6 @@ namespace TcgEngine
|
|||||||
public int attack = 0;
|
public int attack = 0;
|
||||||
public int hp = 0;
|
public int hp = 0;
|
||||||
|
|
||||||
// 新增:三种元素法力值
|
|
||||||
public int mana_fire = 0;
|
|
||||||
public int mana_forest = 0;
|
|
||||||
public int mana_water = 0;
|
|
||||||
|
|
||||||
// 新增:三种元素法力值的临时加成
|
|
||||||
public int mana_fire_ongoing = 0;
|
|
||||||
public int mana_forest_ongoing = 0;
|
|
||||||
public int mana_water_ongoing = 0;
|
|
||||||
|
|
||||||
public int mana_ongoing = 0;
|
public int mana_ongoing = 0;
|
||||||
public int attack_ongoing = 0;
|
public int attack_ongoing = 0;
|
||||||
public int hp_ongoing = 0;
|
public int hp_ongoing = 0;
|
||||||
@@ -58,10 +48,6 @@ namespace TcgEngine
|
|||||||
public virtual void ClearOngoing()
|
public virtual void ClearOngoing()
|
||||||
{
|
{
|
||||||
ongoing_status.Clear(); ongoing_traits.Clear(); ClearOngoingAbility(); attack_ongoing = 0; hp_ongoing = 0; mana_ongoing = 0;
|
ongoing_status.Clear(); ongoing_traits.Clear(); ClearOngoingAbility(); attack_ongoing = 0; hp_ongoing = 0; mana_ongoing = 0;
|
||||||
// 新增:清除元素法力值临时加成
|
|
||||||
mana_fire_ongoing = 0;
|
|
||||||
mana_forest_ongoing = 0;
|
|
||||||
mana_water_ongoing = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Clear()
|
public virtual void Clear()
|
||||||
@@ -86,9 +72,6 @@ namespace TcgEngine
|
|||||||
hp = icard.hp;
|
hp = icard.hp;
|
||||||
// 设置法力值
|
// 设置法力值
|
||||||
mana = icard.mana;
|
mana = icard.mana;
|
||||||
mana_fire = icard.mana_fire;
|
|
||||||
mana_forest = icard.mana_forest;
|
|
||||||
mana_water = icard.mana_water;
|
|
||||||
SetTraits(icard);
|
SetTraits(icard);
|
||||||
SetAbilities(icard);
|
SetAbilities(icard);
|
||||||
}
|
}
|
||||||
@@ -233,27 +216,6 @@ namespace TcgEngine
|
|||||||
public bool HasStat(string id) => HasTrait(id);
|
public bool HasStat(string id) => HasTrait(id);
|
||||||
public List<CardTrait> GetAllStats() => GetAllTraits();
|
public List<CardTrait> GetAllStats() => GetAllTraits();
|
||||||
|
|
||||||
// 新增:获取元素法力值的方法
|
|
||||||
public virtual int GetManaFire() { return Mathf.Max(mana_fire + mana_fire_ongoing, 0); }
|
|
||||||
public virtual int GetManaForest() { return Mathf.Max(mana_forest + mana_forest_ongoing, 0); }
|
|
||||||
public virtual int GetManaWater() { return Mathf.Max(mana_water + mana_water_ongoing, 0); }
|
|
||||||
|
|
||||||
|
|
||||||
// 新增:设置元素法力值的方法
|
|
||||||
public void SetManaFire(int value) { mana_fire = value; }
|
|
||||||
public void SetManaForest(int value) { mana_forest = value; }
|
|
||||||
public void SetManaWater(int value) { mana_water = value; }
|
|
||||||
|
|
||||||
// 新增:增加元素法力值的方法
|
|
||||||
public void AddManaFire(int value) { mana_fire += value; }
|
|
||||||
public void AddManaForest(int value) { mana_forest += value; }
|
|
||||||
public void AddManaWater(int value) { mana_water += value; }
|
|
||||||
|
|
||||||
// 新增:增加元素法力值临时加成的方法
|
|
||||||
public void AddManaFireOngoing(int value) { mana_fire_ongoing += value; }
|
|
||||||
public void AddManaForestOngoing(int value) { mana_forest_ongoing += value; }
|
|
||||||
public void AddManaWaterOngoing(int value) { mana_water_ongoing += value; }
|
|
||||||
|
|
||||||
//------ Status Effects ---------
|
//------ Status Effects ---------
|
||||||
|
|
||||||
public void AddStatus(StatusData status, int value, int duration)
|
public void AddStatus(StatusData status, int value, int duration)
|
||||||
@@ -594,14 +556,6 @@ namespace TcgEngine
|
|||||||
dest.hp = source.hp;
|
dest.hp = source.hp;
|
||||||
dest.mana = source.mana;
|
dest.mana = source.mana;
|
||||||
|
|
||||||
dest.mana_fire = source.mana_fire;
|
|
||||||
dest.mana_forest = source.mana_forest;
|
|
||||||
dest.mana_water = source.mana_water;
|
|
||||||
|
|
||||||
dest.mana_fire_ongoing = source.mana_fire_ongoing;
|
|
||||||
dest.mana_forest_ongoing = source.mana_forest_ongoing;
|
|
||||||
dest.mana_water_ongoing = source.mana_water_ongoing;
|
|
||||||
|
|
||||||
dest.mana_ongoing = source.mana_ongoing;
|
dest.mana_ongoing = source.mana_ongoing;
|
||||||
dest.attack_ongoing = source.attack_ongoing;
|
dest.attack_ongoing = source.attack_ongoing;
|
||||||
dest.hp_ongoing = source.hp_ongoing;
|
dest.hp_ongoing = source.hp_ongoing;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace TcgEngine
|
|||||||
public HashSet<string> cards_attacked = new HashSet<string>();
|
public HashSet<string> cards_attacked = new HashSet<string>();
|
||||||
|
|
||||||
public Game() { }
|
public Game() { }
|
||||||
|
|
||||||
public Game(string uid, int nb_players)
|
public Game(string uid, int nb_players)
|
||||||
{
|
{
|
||||||
this.game_uid = uid;
|
this.game_uid = uid;
|
||||||
@@ -84,13 +84,13 @@ namespace TcgEngine
|
|||||||
|
|
||||||
public virtual bool IsPlayerActionTurn(Player player)
|
public virtual bool IsPlayerActionTurn(Player player)
|
||||||
{
|
{
|
||||||
return player != null && current_player == player.player_id
|
return player != null && current_player == player.player_id
|
||||||
&& state == GameState.Play && phase == GamePhase.Main && selector == SelectorType.None;
|
&& state == GameState.Play && phase == GamePhase.Main && selector == SelectorType.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool IsPlayerSelectorTurn(Player player)
|
public virtual bool IsPlayerSelectorTurn(Player player)
|
||||||
{
|
{
|
||||||
return player != null && selector_player_id == player.player_id
|
return player != null && selector_player_id == player.player_id
|
||||||
&& state == GameState.Play && phase == GamePhase.Main && selector != SelectorType.None;
|
&& state == GameState.Play && phase == GamePhase.Main && selector != SelectorType.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ namespace TcgEngine
|
|||||||
{
|
{
|
||||||
return phase == GamePhase.Mulligan && !player.ready;
|
return phase == GamePhase.Mulligan && !player.ready;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if a card is allowed to be played on slot
|
//Check if a card is allowed to be played on slot
|
||||||
public virtual bool CanPlayCard(Card card, Slot slot, bool skip_cost = false)
|
public virtual bool CanPlayCard(Card card, Slot slot, bool skip_cost = false)
|
||||||
{
|
{
|
||||||
@@ -106,18 +106,13 @@ namespace TcgEngine
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
Player player = GetPlayer(card.player_id);
|
Player player = GetPlayer(card.player_id);
|
||||||
if (!skip_cost && !player.CanPayTeamMana(card))
|
if (!skip_cost && !player.CanPayMana(card))
|
||||||
return false; //Cant pay mana
|
return false; //Cant pay mana
|
||||||
if (!player.HasCard(player.cards_hand, card))
|
if (!player.HasCard(player.cards_hand, card))
|
||||||
return false; // Card not in hand
|
return false; // Card not in hand
|
||||||
// AI 不能在没有对应阵营mana时使用动态费用卡牌
|
|
||||||
if (player.is_ai && card.CardData.IsDynamicManaCost())
|
if (player.is_ai && card.CardData.IsDynamicManaCost() && player.mana == 0)
|
||||||
{
|
return false; // AI cant play X-cost card at 0 cost AI 不能在没有mana时使用动态费用卡牌
|
||||||
string team_id = card.CardData.team?.id;
|
|
||||||
int available_mana = string.IsNullOrEmpty(team_id) ? player.mana : player.GetTeamMana(team_id);
|
|
||||||
if (available_mana == 0)
|
|
||||||
return false; // AI cant play X-cost card at 0 cost
|
|
||||||
}
|
|
||||||
|
|
||||||
if (card.CardData.IsBoardCard())
|
if (card.CardData.IsBoardCard())
|
||||||
{
|
{
|
||||||
@@ -177,7 +172,7 @@ namespace TcgEngine
|
|||||||
//Check if a card is allowed to attack a player
|
//Check if a card is allowed to attack a player
|
||||||
public virtual bool CanAttackTarget(Card attacker, Player target, bool skip_cost = false)
|
public virtual bool CanAttackTarget(Card attacker, Player target, bool skip_cost = false)
|
||||||
{
|
{
|
||||||
if(attacker == null || target == null)
|
if (attacker == null || target == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!attacker.CanAttack(skip_cost))
|
if (!attacker.CanAttack(skip_cost))
|
||||||
@@ -192,10 +187,6 @@ namespace TcgEngine
|
|||||||
if (target.HasStatus(StatusType.Protected) && !attacker.HasStatus(StatusType.Flying))
|
if (target.HasStatus(StatusType.Protected) && !attacker.HasStatus(StatusType.Flying))
|
||||||
return false; //Protected by taunt
|
return false; //Protected by taunt
|
||||||
|
|
||||||
// 检查目标玩家场上是否有卡牌,如有则无法直接攻击玩家
|
|
||||||
if (target.cards_board.Count > 0)
|
|
||||||
return false; //Cannot attack player when they have cards on board
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -465,7 +456,7 @@ namespace TcgEngine
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual Player GetRandomPlayer(System.Random rand)
|
public virtual Player GetRandomPlayer(System.Random rand)
|
||||||
{
|
{
|
||||||
Player player = GetPlayer(rand.NextDouble() < 0.5 ? 1 : 0);
|
Player player = GetPlayer(rand.NextDouble() < 0.5 ? 1 : 0);
|
||||||
@@ -558,7 +549,7 @@ namespace TcgEngine
|
|||||||
if (dest.players == null)
|
if (dest.players == null)
|
||||||
{
|
{
|
||||||
dest.players = new Player[source.players.Length];
|
dest.players = new Player[source.players.Length];
|
||||||
for(int i=0; i< source.players.Length; i++)
|
for (int i = 0; i < source.players.Length; i++)
|
||||||
dest.players[i] = new Player(i);
|
dest.players[i] = new Player(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ namespace TcgEngine.Gameplay
|
|||||||
|
|
||||||
//Choose first player
|
//Choose first player
|
||||||
game_data.state = GameState.Play;
|
game_data.state = GameState.Play;
|
||||||
game_data.first_player = random.NextDouble() < 0.5 ? 0 : 1;
|
|
||||||
game_data.current_player = game_data.first_player;
|
game_data.current_player = game_data.first_player;
|
||||||
game_data.turn_count = 1;
|
game_data.turn_count = 1;
|
||||||
|
|
||||||
@@ -124,33 +123,24 @@ namespace TcgEngine.Gameplay
|
|||||||
player.mana_max = pdeck != null ? pdeck.start_mana : GameplayData.Get().mana_start;
|
player.mana_max = pdeck != null ? pdeck.start_mana : GameplayData.Get().mana_start;
|
||||||
player.mana = player.mana_max;
|
player.mana = player.mana_max;
|
||||||
|
|
||||||
//初始化三种阵营mana
|
|
||||||
int start_mana = pdeck != null ? pdeck.start_mana : GameplayData.Get().mana_start;
|
|
||||||
player.SetTeamMana("fire", start_mana, start_mana);
|
|
||||||
player.SetTeamMana("forest", start_mana, start_mana);
|
|
||||||
player.SetTeamMana("water", start_mana, start_mana);
|
|
||||||
|
|
||||||
//Draw starting cards 开始抽卡
|
//Draw starting cards 开始抽卡
|
||||||
int dcards = pdeck != null ? pdeck.start_cards : GameplayData.Get().cards_start;
|
int dcards = pdeck != null ? pdeck.start_cards : GameplayData.Get().cards_start;
|
||||||
DrawCard(player, dcards);
|
DrawCard(player, dcards);
|
||||||
|
|
||||||
//Add coin second player
|
|
||||||
bool is_random = level == null || level.first_player == LevelFirst.Random;
|
|
||||||
if (is_random && player.player_id != game_data.first_player && GameplayData.Get().second_bonus != null)
|
|
||||||
{
|
|
||||||
Card card = Card.Create(GameplayData.Get().second_bonus, VariantData.GetDefault(), player);
|
|
||||||
player.cards_hand.Add(card);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Start state
|
//Start state
|
||||||
RefreshData();
|
RefreshData();
|
||||||
onGameStart?.Invoke();
|
onGameStart?.Invoke();
|
||||||
|
|
||||||
if(should_mulligan)
|
if (should_mulligan)
|
||||||
|
{
|
||||||
GoToMulligan();
|
GoToMulligan();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
CalculateFirstPlayer();
|
||||||
StartTurn();
|
StartTurn();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//开始回合
|
//开始回合
|
||||||
@@ -172,25 +162,14 @@ namespace TcgEngine.Gameplay
|
|||||||
DrawCard(player, GameplayData.Get().cards_per_turn);
|
DrawCard(player, GameplayData.Get().cards_per_turn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Mana
|
//Mana
|
||||||
player.mana_max += GameplayData.Get().mana_per_turn;
|
player.mana_max += GameplayData.Get().mana_per_turn;
|
||||||
player.mana_max = Mathf.Min(player.mana_max, GameplayData.Get().mana_max);
|
player.mana_max = Mathf.Min(player.mana_max, GameplayData.Get().mana_max);
|
||||||
player.mana = player.mana_max;
|
player.mana = player.mana_max;
|
||||||
|
|
||||||
//阵营Mana增长:基础每回合+1,场上有对应阵营角色额外+1
|
// 回合开始时检查mana,如果超过5则设置为5
|
||||||
UpdateTeamMana(player, "fire");
|
if (player.mana > player.mana_max)
|
||||||
UpdateTeamMana(player, "forest");
|
|
||||||
UpdateTeamMana(player, "water");
|
|
||||||
|
|
||||||
// 回合开始时检查所有阵营mana,如果超过5则设置为5
|
|
||||||
if (player.GetTeamMana("fire") > 5)
|
|
||||||
player.SetTeamMana("fire", 5);
|
|
||||||
if (player.GetTeamMana("forest") > 5)
|
|
||||||
player.SetTeamMana("forest", 5);
|
|
||||||
if (player.GetTeamMana("water") > 5)
|
|
||||||
player.SetTeamMana("water", 5);
|
|
||||||
if (player.mana > 5)
|
|
||||||
player.mana = 5;
|
player.mana = 5;
|
||||||
|
|
||||||
//Turn timer and history
|
//Turn timer and history
|
||||||
@@ -448,9 +427,9 @@ namespace TcgEngine.Gameplay
|
|||||||
{
|
{
|
||||||
Player player = game_data.GetPlayer(card.player_id);
|
Player player = game_data.GetPlayer(card.player_id);
|
||||||
|
|
||||||
//Cost - 使用阵营mana支付
|
//Cost - 使用mana支付
|
||||||
if (!skip_cost)
|
if (!skip_cost)
|
||||||
player.PayTeamMana(card);
|
player.PayMana(card);
|
||||||
|
|
||||||
//Play card
|
//Play card
|
||||||
player.RemoveCardFromAllGroups(card);
|
player.RemoveCardFromAllGroups(card);
|
||||||
@@ -1081,7 +1060,7 @@ namespace TcgEngine.Gameplay
|
|||||||
{
|
{
|
||||||
// 不消耗mana强制上场
|
// 不消耗mana强制上场
|
||||||
PlayCard(characterCard, emptySlot, true); // skip_cost = true
|
PlayCard(characterCard, emptySlot, true); // skip_cost = true
|
||||||
|
|
||||||
// 设置为疲劳状态
|
// 设置为疲劳状态
|
||||||
characterCard.exhausted = true;
|
characterCard.exhausted = true;
|
||||||
}
|
}
|
||||||
@@ -1920,18 +1899,19 @@ namespace TcgEngine.Gameplay
|
|||||||
|
|
||||||
player.ready = true;
|
player.ready = true;
|
||||||
DrawCard(player, count);
|
DrawCard(player, count);
|
||||||
|
|
||||||
// 将换掉的卡牌重新加入牌组并洗牌
|
// 将换掉的卡牌重新加入牌组并洗牌
|
||||||
foreach (Card card in mulligan_cards)
|
foreach (Card card in mulligan_cards)
|
||||||
{
|
{
|
||||||
player.cards_deck.Add(card);
|
player.cards_deck.Add(card);
|
||||||
}
|
}
|
||||||
ShuffleDeck(player.cards_deck);
|
ShuffleDeck(player.cards_deck);
|
||||||
|
|
||||||
RefreshData();
|
RefreshData();
|
||||||
|
|
||||||
if (game_data.AreAllPlayersReady())
|
if (game_data.AreAllPlayersReady())
|
||||||
{
|
{
|
||||||
|
CalculateFirstPlayer();
|
||||||
StartTurn();
|
StartTurn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1985,6 +1965,41 @@ namespace TcgEngine.Gameplay
|
|||||||
RefreshData();
|
RefreshData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 根据手牌攻击力计算先手玩家
|
||||||
|
protected virtual void CalculateFirstPlayer()
|
||||||
|
{
|
||||||
|
int f = 0, l = 0;
|
||||||
|
|
||||||
|
foreach (Player player in game_data.players)
|
||||||
|
{
|
||||||
|
int allCardAttack = 0;
|
||||||
|
foreach (Card card in player.cards_hand)
|
||||||
|
{
|
||||||
|
allCardAttack += card.CardData.attack;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.player_id == 0)
|
||||||
|
{
|
||||||
|
f = allCardAttack;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
l = allCardAttack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
game_data.first_player = f < l ? 0 : 1;
|
||||||
|
game_data.current_player = game_data.first_player;
|
||||||
|
|
||||||
|
// 后手补偿(已取消)
|
||||||
|
// int second_player_id = f < l ? 1 : 0; // 后手玩家ID
|
||||||
|
// if (GameplayData.Get().second_bonus != null)
|
||||||
|
// {
|
||||||
|
// Card bonus_card = Card.Create(GameplayData.Get().second_bonus, VariantData.GetDefault(), game_data.players[second_player_id]);
|
||||||
|
// game_data.players[second_player_id].cards_hand.Add(bonus_card);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
//-------------
|
//-------------
|
||||||
|
|
||||||
public virtual void RefreshData()
|
public virtual void RefreshData()
|
||||||
@@ -2022,22 +2037,6 @@ namespace TcgEngine.Gameplay
|
|||||||
return random;
|
return random;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 更新指定阵营的mana,基础每回合+1,场上有对应阵营角色额外+角色数量
|
|
||||||
/// </summary>
|
|
||||||
private void UpdateTeamMana(Player player, string team_id)
|
|
||||||
{
|
|
||||||
int base_increase = GameplayData.Get().mana_per_turn; // 基础增长
|
|
||||||
int team_bonus = player.GetBoardTeamCount(team_id); // 场上同阵营角色数量
|
|
||||||
int total_increase = base_increase + team_bonus;
|
|
||||||
|
|
||||||
// 增加最大mana
|
|
||||||
player.AddTeamMana(team_id, 0, total_increase);
|
|
||||||
|
|
||||||
// 当前mana设置为最大值
|
|
||||||
player.SetTeamMana(team_id, player.GetTeamManaMax(team_id));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Game GameData { get { return game_data; } }
|
public Game GameData { get { return game_data; } }
|
||||||
public ResolveQueue ResolveQueue { get { return resolve_queue; } }
|
public ResolveQueue ResolveQueue { get { return resolve_queue; } }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,33 +24,8 @@ namespace TcgEngine
|
|||||||
public int hp;
|
public int hp;
|
||||||
public int hp_max;
|
public int hp_max;
|
||||||
|
|
||||||
// 三种阵营mana系统
|
|
||||||
[System.Serializable]
|
|
||||||
public class TeamMana
|
|
||||||
{
|
|
||||||
public int current = 0;
|
|
||||||
public int max = 0;
|
|
||||||
|
|
||||||
public TeamMana(int start_value = 0)
|
|
||||||
{
|
|
||||||
current = start_value;
|
|
||||||
max = start_value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 新mana
|
|
||||||
|
|
||||||
public int mana_fire = 0;
|
|
||||||
public int mana_forest = 0;
|
|
||||||
public int mana_water = 0;
|
|
||||||
|
|
||||||
// 保留原有mana属性以兼容现有代码,将作为通用mana使用
|
|
||||||
public int mana = 0;
|
public int mana = 0;
|
||||||
public int mana_max = 0;
|
public int mana_max = 0;
|
||||||
|
|
||||||
// 新增:三种元素法力值的最大值
|
|
||||||
public int mana_fire_max = 0;
|
|
||||||
public int mana_forest_max = 0;
|
|
||||||
public int mana_water_max = 0;
|
|
||||||
public int kill_count = 0;
|
public int kill_count = 0;
|
||||||
public int cards_played_this_turn = 0; // 本回合已上场的卡牌数量
|
public int cards_played_this_turn = 0; // 本回合已上场的卡牌数量
|
||||||
public Dictionary<string, Card> cards_all = new Dictionary<string, Card>(); //Dictionnary for quick access to any card by UID
|
public Dictionary<string, Card> cards_all = new Dictionary<string, Card>(); //Dictionnary for quick access to any card by UID
|
||||||
@@ -618,11 +593,6 @@ namespace TcgEngine
|
|||||||
dest.mana = source.mana;
|
dest.mana = source.mana;
|
||||||
dest.mana_max = source.mana_max;
|
dest.mana_max = source.mana_max;
|
||||||
|
|
||||||
// 复制新mana
|
|
||||||
dest.mana_fire = source.mana;
|
|
||||||
dest.mana_forest = source.mana;
|
|
||||||
dest.mana_water = source.mana;
|
|
||||||
|
|
||||||
Card.CloneNull(source.hero, ref dest.hero);
|
Card.CloneNull(source.hero, ref dest.hero);
|
||||||
Card.CloneDict(source.cards_all, dest.cards_all);
|
Card.CloneDict(source.cards_all, dest.cards_all);
|
||||||
Card.CloneListRef(dest.cards_all, source.cards_board, dest.cards_board);
|
Card.CloneListRef(dest.cards_all, source.cards_board, dest.cards_board);
|
||||||
@@ -636,165 +606,6 @@ namespace TcgEngine
|
|||||||
CardStatus.CloneList(source.status, dest.status);
|
CardStatus.CloneList(source.status, dest.status);
|
||||||
CardStatus.CloneList(source.ongoing_status, dest.ongoing_status);
|
CardStatus.CloneList(source.ongoing_status, dest.ongoing_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------- 阵营Mana相关方法 -------------
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取指定阵营的当前mana值
|
|
||||||
/// </summary>
|
|
||||||
public int GetTeamMana(string team_id)
|
|
||||||
{
|
|
||||||
if (team_id == "fire") return mana_fire;
|
|
||||||
if (team_id == "forest") return mana_forest;
|
|
||||||
if (team_id == "water") return mana_water;
|
|
||||||
|
|
||||||
Debug.Log($"GetTeamMana: {team_id} not found");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取指定阵营的最大mana值
|
|
||||||
/// </summary>
|
|
||||||
public int GetTeamManaMax(string team_id)
|
|
||||||
{
|
|
||||||
return mana_max;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设置指定阵营的mana值
|
|
||||||
/// </summary>
|
|
||||||
public void SetTeamMana(string team_id, int current, int max = -1)
|
|
||||||
{
|
|
||||||
if (team_id == "fire")
|
|
||||||
{
|
|
||||||
mana_fire = current;
|
|
||||||
if (max >= 0) mana_fire = max;
|
|
||||||
}
|
|
||||||
else if (team_id == "forest")
|
|
||||||
{
|
|
||||||
mana_forest = current;
|
|
||||||
if (max >= 0) mana_forest = max;
|
|
||||||
}
|
|
||||||
else if (team_id == "water")
|
|
||||||
{
|
|
||||||
mana_water = current;
|
|
||||||
if (max >= 0) mana_water = max;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 增加指定阵营的mana值
|
|
||||||
/// </summary>
|
|
||||||
public void AddTeamMana(string team_id, int current_add = 0, int max_add = 0)
|
|
||||||
{
|
|
||||||
if (team_id == "fire")
|
|
||||||
{
|
|
||||||
mana_fire += current_add;
|
|
||||||
mana_fire = Mathf.Max(mana_fire, 0);
|
|
||||||
mana_fire = Mathf.Clamp(mana_fire, 0, GameplayData.Get().mana_max);
|
|
||||||
}
|
|
||||||
else if (team_id == "forest")
|
|
||||||
{
|
|
||||||
mana_forest += current_add;
|
|
||||||
mana_forest = Mathf.Max(mana_forest, 0);
|
|
||||||
mana_forest = Mathf.Clamp(mana_forest, 0, GameplayData.Get().mana_max);
|
|
||||||
}
|
|
||||||
else if (team_id == "water")
|
|
||||||
{
|
|
||||||
mana_water += current_add;
|
|
||||||
mana_water = Mathf.Max(mana_water, 0);
|
|
||||||
mana_water = Mathf.Clamp(mana_water, 0, GameplayData.Get().mana_max);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 检查是否有足够的阵营mana支付卡牌费用
|
|
||||||
/// </summary>
|
|
||||||
public virtual bool CanPayTeamMana(Card card)
|
|
||||||
{
|
|
||||||
if (card.CardData.IsDynamicManaCost())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
string team_id = card.CardData.team?.id;
|
|
||||||
if (string.IsNullOrEmpty(team_id)){
|
|
||||||
Debug.Log($"not CanPayTeamMana checking team mana: {mana} >= {card.GetMana()}");
|
|
||||||
return mana >= card.GetMana(); // 使用通用mana
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Log($"Checking team mana for {team_id}: {GetTeamMana(team_id)} >= {card.GetMana()}");
|
|
||||||
return GetTeamMana(team_id) >= card.GetMana();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 支付卡牌的阵营mana费用
|
|
||||||
/// </summary>
|
|
||||||
public virtual void PayTeamMana(Card card)
|
|
||||||
{
|
|
||||||
if (card.CardData.IsDynamicManaCost())
|
|
||||||
return;
|
|
||||||
|
|
||||||
string team_id = card.CardData.team?.id;
|
|
||||||
if (string.IsNullOrEmpty(team_id))
|
|
||||||
{
|
|
||||||
Debug.Log($"PayTeamMana 通用mana: {mana} -= {card.GetMana()}");
|
|
||||||
mana -= card.GetMana(); // 使用通用mana
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int cost = card.GetMana();
|
|
||||||
if (team_id == "fire")
|
|
||||||
{
|
|
||||||
mana_fire -= cost;
|
|
||||||
mana_fire = Mathf.Max(mana_fire, 0);
|
|
||||||
}
|
|
||||||
else if (team_id == "forest")
|
|
||||||
{
|
|
||||||
mana_forest -= cost;
|
|
||||||
mana_forest = Mathf.Max(mana_forest, 0);
|
|
||||||
}
|
|
||||||
else if (team_id == "water")
|
|
||||||
{
|
|
||||||
mana_water -= cost;
|
|
||||||
mana_water = Mathf.Max(mana_water, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取场上指定阵营的角色数量
|
|
||||||
/// </summary>
|
|
||||||
public int GetBoardTeamCount(string team_id)
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
Debug.Log($"Checking board for {team_id} characters. Total cards on board: {cards_board.Count}");
|
|
||||||
|
|
||||||
foreach (Card card in cards_board)
|
|
||||||
{
|
|
||||||
if (card.CardData.IsCharacter() && card.CardData.team?.id == team_id)
|
|
||||||
{
|
|
||||||
count++;
|
|
||||||
Debug.Log($"Found {team_id} character: {card.CardData.title}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Debug.Log($"Total {team_id} characters on board: {count}");
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 测试方法:打印当前所有阵营mana状态
|
|
||||||
/// </summary>
|
|
||||||
public void DebugTeamMana()
|
|
||||||
{
|
|
||||||
Debug.Log($"=== Player {player_id} Team Mana Debug ===");
|
|
||||||
Debug.Log($"General: {mana}/{mana_max}");
|
|
||||||
Debug.Log($"Board cards: {cards_board.Count}");
|
|
||||||
Debug.Log($"Fire characters on board: {GetBoardTeamCount("fire")}");
|
|
||||||
Debug.Log($"Forest characters on board: {GetBoardTeamCount("forest")}");
|
|
||||||
Debug.Log($"Water characters on board: {GetBoardTeamCount("water")}");
|
|
||||||
Debug.Log("=====================================");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
|
|||||||
@@ -18,10 +18,6 @@ namespace TcgEngine.UI
|
|||||||
public Text pname;
|
public Text pname;
|
||||||
public AvatarUI avatar;
|
public AvatarUI avatar;
|
||||||
public IconBar mana_bar; // 保留原有mana条,作为通用mana显示
|
public IconBar mana_bar; // 保留原有mana条,作为通用mana显示
|
||||||
|
|
||||||
[Header("Team Mana Bars")]
|
|
||||||
public IconBar[] team_mana_bars = new IconBar[3]; // ManaBar_0, ManaBar_1, ManaBar_2
|
|
||||||
|
|
||||||
public Text hp_txt;
|
public Text hp_txt;
|
||||||
public Text hp_max_txt;
|
public Text hp_max_txt;
|
||||||
|
|
||||||
@@ -77,49 +73,6 @@ namespace TcgEngine.UI
|
|||||||
mana_bar.value = player.mana;
|
mana_bar.value = player.mana;
|
||||||
mana_bar.max_value = player.mana_max;
|
mana_bar.max_value = player.mana_max;
|
||||||
|
|
||||||
// 更新阵营mana条 - fire, forest, water
|
|
||||||
if (team_mana_bars.Length >= 3)
|
|
||||||
{
|
|
||||||
// ManaBar_0 = fire
|
|
||||||
if (team_mana_bars[0] != null)
|
|
||||||
{
|
|
||||||
team_mana_bars[0].value = player.mana_fire;
|
|
||||||
team_mana_bars[0].max_value = player.mana_max;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.LogWarning("team_mana_bars[0] is null!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// ManaBar_1 = forest
|
|
||||||
if (team_mana_bars[1] != null)
|
|
||||||
{
|
|
||||||
team_mana_bars[1].value = player.mana_forest;
|
|
||||||
team_mana_bars[1].max_value = player.mana_max;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.LogWarning("team_mana_bars[1] is null!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// ManaBar_2 = water
|
|
||||||
if (team_mana_bars[2] != null)
|
|
||||||
{
|
|
||||||
team_mana_bars[2].value = player.mana_water;
|
|
||||||
team_mana_bars[2].max_value = player.mana_max;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.LogWarning("team_mana_bars[2] is null!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.LogWarning($"team_mana_bars.Length = {team_mana_bars.Length}, expected 3");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
hp_txt.text = prev_hp.ToString();
|
hp_txt.text = prev_hp.ToString();
|
||||||
hp_max_txt.text = "/" + player.hp_max.ToString();
|
hp_max_txt.text = "/" + player.hp_max.ToString();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user