Exemple #1
0
        public CreateSoldierEvent GetCreateSoldierIfNeedCreate(GameAggregate game, Army army)
        {
            if (!game.IsProductionState(army))
            {
                return(null);
            }
            var productEvent       = _domain.GetNotExecuteEvents <CreateSoldierEvent>(game.Id) ?? new List <CreateSoldierEvent>();
            var hasInProgressEvent = productEvent.Any(e => e.Army == army);

            if (hasInProgressEvent)
            {
                return(null);
            }
            var troopType = game.GetDefaultTroopType(army);

            //var needCoin = GetUpkeepCoinBySoldierType(game, army, troopType);
            //bool canProduction;
            //if (army == Army.Blue)
            //    canProduction = game.UserCoins > needCoin;
            //else
            //    canProduction = game.OpponentCoins > needCoin;
            //if (canProduction)
            return(GetCreateSoldierEvent(game.Id, army,
                                         troopType,
                                         game.GetUserId(army)));

            return(null);
        }