Skip to content

Commit

Permalink
Fix sending trade model data to server
Browse files Browse the repository at this point in the history
  • Loading branch information
Rivixer committed Jun 13, 2023
1 parent f618835 commit 25783b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
12 changes: 12 additions & 0 deletions WZIMopoly/Models/GameScene/TradeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@ public TradeModel(List<TileController> tiles, List<PlayerInfoController> playerI
/// </summary>
public int TotalValue => ChosenOfferorTilesValue + ChosenRecipientTilesValue + Math.Abs(OfferedMoney);

/// <summary>
/// Resets the trade model.
/// </summary>
public void Reset()
{
Offeror = null;
Recipient = null;
ChosenOfferorTiles.Clear();
ChosenRecipientTiles.Clear();
OfferedMoney = 0;
}

/// <summary>
/// Updates the trade model.
/// </summary>
Expand Down
7 changes: 3 additions & 4 deletions WZIMopoly/Scenes/GameScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,15 +451,14 @@ private void InitializeButtons()
if (GameSettings.CurrentPlayer.PlayerStatus == PlayerStatus.Trading)
{
GameSettings.CurrentPlayer.PlayerStatus = PlayerStatus.BeforeRollingDice;
var tradeModel = _tradeController.Model;
tradeModel.Reset();
}
else if (GameSettings.CurrentPlayer.PlayerStatus == PlayerStatus.BeforeRollingDice)
{
var tradeModel = _tradeController.Model;
tradeModel.Reset();
tradeModel.Offeror = GameSettings.CurrentPlayer;
tradeModel.Recipient = null;
tradeModel.OfferedMoney = 0;
tradeModel.ChosenOfferorTiles.Clear();
tradeModel.ChosenRecipientTiles.Clear();
GameSettings.CurrentPlayer.PlayerStatus = PlayerStatus.Trading;
}
};
Expand Down

0 comments on commit 25783b7

Please sign in to comment.