调整卡牌攻击

- 场上存在卡牌时无法直接攻击敌方玩家
- 取消卡牌攻击敌方玩家高亮显示
- 一回合只能上场一张角色卡
This commit is contained in:
xianyi
2025-08-06 11:35:29 +08:00
parent 80549b8e49
commit f6262481dc
7 changed files with 45 additions and 18 deletions

View File

@@ -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)) if (your_turn && dcard != null && dcard.CardData.IsBoardCard() && gdata.CanPlayCard(dcard, slot, true))
{ {
target_alpha = 1f; //hightlight when dragging a character or artifact target_alpha = 1f; //hightlight when dragging a character or artifact (skip mana cost)
} }
if (your_turn && dcard != null && dcard.CardData.IsRequireTarget() && gdata.CanPlayCard(dcard, slot)) if (your_turn && dcard != null && dcard.CardData.IsRequireTarget() && gdata.CanPlayCard(dcard, slot, true))
{ {
target_alpha = 1f; //Highlight when dragin a spell with target target_alpha = 1f; //Highlight when dragin a spell with target (skip mana cost)
} }
if (gdata.selector == SelectorType.SelectTarget && player.player_id == gdata.selector_player_id) if (gdata.selector == SelectorType.SelectTarget && player.player_id == gdata.selector_player_id)

View File

@@ -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)) if(gdata.CanPlayCard(dcard, slot.slot, true))
target_alpha = 1f; //hightlight when dragging a character or artifact target_alpha = 1f; //hightlight when dragging a character or artifact (skip mana cost)
} }
} }

View File

@@ -67,16 +67,17 @@ 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()))
{ {

View File

@@ -231,9 +231,10 @@ namespace TcgEngine.Client
return; return;
} }
if (!player.CanPayMana(card)) // 检查本回合是否已经上场过场上卡牌(只有怪物牌等场上卡牌受限制)
if (card.CardData.IsBoardCard() && player.cards_played_this_turn >= 1)
{ {
WarningText.ShowNoMana(); Debug.Log("本回合只能上场一张场上卡牌");
return; return;
} }

View File

@@ -186,6 +186,10 @@ 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;
} }

View File

@@ -303,7 +303,18 @@ namespace TcgEngine.Server
{ {
Card card = player.GetCard(msg.card_uid); Card card = player.GetCard(msg.card_uid);
if (card != null && card.player_id == player.player_id) if (card != null && card.player_id == player.player_id)
{
// 检查本回合是否已经上场过场上卡牌(只有怪物牌等场上卡牌受限制)
if (card.CardData.IsBoardCard() && player.cards_played_this_turn >= 1)
return; // 已经上场过场上卡牌,不能再上场
// 手动上场卡牌跳过mana消耗
// gameplay.PlayCard(card, msg.slot, true);
gameplay.PlayCard(card, msg.slot); gameplay.PlayCard(card, msg.slot);
// 只有场上卡牌才增加计数
if (card.CardData.IsBoardCard())
player.cards_played_this_turn++;
}
} }
} }

View File

@@ -33,9 +33,15 @@ namespace TcgEngine.UI
public void Refresh() public void Refresh()
{ {
if (icons == null)
return;
int index = 0; int index = 0;
foreach (Image icon in icons) foreach (Image icon in icons)
{ {
if (icon == null)
continue;
icon.gameObject.SetActive(index < value || index < max_value); icon.gameObject.SetActive(index < value || index < max_value);
icon.sprite = (index < value) ? sprite_full : sprite_empty; icon.sprite = (index < value) ? sprite_full : sprite_empty;
index++; index++;
@@ -44,9 +50,13 @@ namespace TcgEngine.UI
public void SetMat(Material mat) public void SetMat(Material mat)
{ {
if (icons == null)
return;
foreach (Image icon in icons) foreach (Image icon in icons)
{ {
icon.material = mat; if (icon != null)
icon.material = mat;
} }
} }
} }