dev
This commit is contained in:
parent
2bc78fc7b1
commit
b9ac801281
|
|
@ -72,14 +72,15 @@ namespace GameHandler.DeathGame
|
|||
return new DeathGameModel(1, coffins.OrderBy(_ => random.Next()).ToList().ToArray(), deathGameSettings, playerIds);
|
||||
}
|
||||
|
||||
public IGameModel Update(PinThrow pinThrow, IGameModel gameModel, BoardState boardStateBeforeUpdate)
|
||||
public IGameModel Update(PinThrow pinThrow, IGameModel gameModel, BoardState boardStateBeforeUpdate, ThrowState throwStateAfterUpdate)
|
||||
{
|
||||
var isTrowIntoAllPins = boardStateBeforeUpdate.PinPicture.UpCount == 9;
|
||||
var boardCleared = pinThrow.IsCleared;
|
||||
return CalcNextModel(gameModel as DeathGameModel, pinThrow.PinCount, isTrowIntoAllPins, boardCleared);
|
||||
var firstThrowInRound = throwStateAfterUpdate.ThrowCount == 1;
|
||||
return CalcNextModel(gameModel as DeathGameModel, pinThrow.PinCount, isTrowIntoAllPins, boardCleared, firstThrowInRound);
|
||||
}
|
||||
|
||||
public DeathGameModel CalcNextModel(DeathGameModel gm, int pinCount, bool isTrowIntoAllPins, bool boardCleared)
|
||||
public DeathGameModel CalcNextModel(DeathGameModel gm, int pinCount, bool isTrowIntoAllPins, bool boardCleared, bool firstThrowInRound)
|
||||
{
|
||||
var current = gm.Coffins.First();
|
||||
var next = gm.Coffins.Skip(1).First();
|
||||
|
|
@ -90,7 +91,7 @@ namespace GameHandler.DeathGame
|
|||
if (isTrowIntoAllPins) // into all pins
|
||||
{
|
||||
incX = true;
|
||||
if (pinCount < 3)
|
||||
if ((pinCount < 3) && firstThrowInRound)
|
||||
{
|
||||
OnFirstThrowFailed(gm, current);
|
||||
incLine = true;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace GameHandler.GameHandler
|
|||
return new FreeGameModel(playerIds, playerIds.First(), throws);
|
||||
}
|
||||
|
||||
public IGameModel Update(PinThrow pinThrow, IGameModel gameModel, BoardState boardStateBeforeUpdate)
|
||||
public IGameModel Update(PinThrow pinThrow, IGameModel gameModel, BoardState boardStateBeforeUpdate, ThrowState throwStateAfterUpdate)
|
||||
{
|
||||
if (gameModel == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -96,11 +96,11 @@ namespace GameHandler
|
|||
|
||||
pinThrow = AutoCompletePlayerId(pinThrow);
|
||||
|
||||
var throwState = _th.Update(_lastState.ThrowState, pinThrow);
|
||||
var gameModel = _gh.Update(pinThrow, _lastState.GameModel, boardStateBeforeUpdate);
|
||||
var expenseModel = _eh.CheckThrow(throwState.BoardState, pinThrow, gameModel.PlayerIds, _lastState.ExpenseModel);
|
||||
var throwStateAfterUpdate = _th.Update(_lastState.ThrowState, pinThrow);
|
||||
var gameModel = _gh.Update(pinThrow, _lastState.GameModel, boardStateBeforeUpdate, throwStateAfterUpdate);
|
||||
var expenseModel = _eh.CheckThrow(throwStateAfterUpdate.BoardState, pinThrow, gameModel.PlayerIds, _lastState.ExpenseModel);
|
||||
|
||||
_lastState = _lastState with { ThrowState = throwState, GameModel = gameModel, NextPlayerId = _gh.GetCurrentPlayerId(gameModel), ExpenseModel = expenseModel };
|
||||
_lastState = _lastState with { ThrowState = throwStateAfterUpdate, GameModel = gameModel, NextPlayerId = _gh.GetCurrentPlayerId(gameModel), ExpenseModel = expenseModel };
|
||||
return _lastState ;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ namespace GameModel.Contract
|
|||
IGameModel InitGameModel(int[] playerIds, IGameSettings gameSettings);
|
||||
int GetCurrentPlayerId(IGameModel gameModel);
|
||||
|
||||
IGameModel Update(PinThrow pinThrow, IGameModel gameModel, BoardState boardStateBeforeUpdate);
|
||||
IGameModel Update(PinThrow pinThrow, IGameModel gameModel, BoardState boardStateBeforeUpdate,
|
||||
ThrowState throwStateAfterUpdate);
|
||||
|
||||
event EventHandler GameExpenseOccured;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue