Example #1
0
        public static void InitializeTeamTaskIfNotPending(GameEntity product, int date, GameContext gameContext, TeamTask task)
        {
            if (task.IsPending)
                return;

            task.StartDate = date;

            if (task.IsMarketingTask)
            {
                var channelId = (task as TeamTaskChannelActivity).ChannelId;
                var channel = Markets.GetMarketingChannel(gameContext, channelId);

                if (!Marketing.IsActiveInChannel(product, channelId))
                {
                    var cost = Marketing.GetChannelCost(product, channelId);
                    var payer = Companies.GetPayer(product, gameContext);

                    if (Companies.Pay(payer, cost, "Marketing " + channel))
                    {
                        Marketing.EnableChannelActivity(product, channel);

                        var gain = Marketing.GetChannelClientGain(product, channelId);
                        Marketing.AddClients(product, gain);

                        var duration = Marketing.GetCampaignDuration(product, gain);
                        task.EndDate = date + duration;
                    }
                }
            }
        }