根据手牌攻击力计算先手
This commit is contained in:
@@ -95,7 +95,6 @@ namespace TcgEngine.Gameplay
|
||||
|
||||
//Choose first player
|
||||
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.turn_count = 1;
|
||||
|
||||
@@ -141,10 +140,15 @@ namespace TcgEngine.Gameplay
|
||||
RefreshData();
|
||||
onGameStart?.Invoke();
|
||||
|
||||
if(should_mulligan)
|
||||
if (should_mulligan)
|
||||
{
|
||||
GoToMulligan();
|
||||
}
|
||||
else
|
||||
{
|
||||
CalculateFirstPlayer();
|
||||
StartTurn();
|
||||
}
|
||||
}
|
||||
|
||||
//开始回合
|
||||
@@ -166,7 +170,7 @@ namespace TcgEngine.Gameplay
|
||||
DrawCard(player, GameplayData.Get().cards_per_turn);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Mana
|
||||
player.mana_max += GameplayData.Get().mana_per_turn;
|
||||
player.mana_max = Mathf.Min(player.mana_max, GameplayData.Get().mana_max);
|
||||
@@ -1064,7 +1068,7 @@ namespace TcgEngine.Gameplay
|
||||
{
|
||||
// 不消耗mana强制上场
|
||||
PlayCard(characterCard, emptySlot, true); // skip_cost = true
|
||||
|
||||
|
||||
// 设置为疲劳状态
|
||||
characterCard.exhausted = true;
|
||||
}
|
||||
@@ -1903,18 +1907,19 @@ namespace TcgEngine.Gameplay
|
||||
|
||||
player.ready = true;
|
||||
DrawCard(player, count);
|
||||
|
||||
|
||||
// 将换掉的卡牌重新加入牌组并洗牌
|
||||
foreach (Card card in mulligan_cards)
|
||||
{
|
||||
player.cards_deck.Add(card);
|
||||
}
|
||||
ShuffleDeck(player.cards_deck);
|
||||
|
||||
|
||||
RefreshData();
|
||||
|
||||
if (game_data.AreAllPlayersReady())
|
||||
{
|
||||
CalculateFirstPlayer();
|
||||
StartTurn();
|
||||
}
|
||||
}
|
||||
@@ -1968,6 +1973,33 @@ namespace TcgEngine.Gameplay
|
||||
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;
|
||||
}
|
||||
|
||||
//-------------
|
||||
|
||||
public virtual void RefreshData()
|
||||
|
||||
Reference in New Issue
Block a user