根据手牌攻击力计算先手
This commit is contained in:
@@ -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;
|
||||||
|
|
||||||
@@ -141,10 +140,15 @@ namespace TcgEngine.Gameplay
|
|||||||
RefreshData();
|
RefreshData();
|
||||||
onGameStart?.Invoke();
|
onGameStart?.Invoke();
|
||||||
|
|
||||||
if(should_mulligan)
|
if (should_mulligan)
|
||||||
|
{
|
||||||
GoToMulligan();
|
GoToMulligan();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
CalculateFirstPlayer();
|
||||||
StartTurn();
|
StartTurn();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//开始回合
|
//开始回合
|
||||||
@@ -1915,6 +1919,7 @@ namespace TcgEngine.Gameplay
|
|||||||
|
|
||||||
if (game_data.AreAllPlayersReady())
|
if (game_data.AreAllPlayersReady())
|
||||||
{
|
{
|
||||||
|
CalculateFirstPlayer();
|
||||||
StartTurn();
|
StartTurn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1968,6 +1973,33 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------
|
//-------------
|
||||||
|
|
||||||
public virtual void RefreshData()
|
public virtual void RefreshData()
|
||||||
|
|||||||
Reference in New Issue
Block a user