public void InitializeNewGame(ulong?seed = null)
        {
            GameSeed     = seed ?? (ulong)DateTime.Now.Ticks;
            R            = new RNG(GameSeed);
            MapRNG       = new RNG(R.GetNext());
            Q            = new EventQueue();
            Map          = new DungeonMap(this);
            CurrentDepth = 1;

            //todo...while loading the rules, do i need a hook so that the UI can insert any message overrides it wants to?
            //hmmmmm.... is that what the Message/Effect split should be for? Basically, that the UI gets full control over the Message half?
            //    This is very interesting...see how well this lines up with reality.
            CreatureRules = new StatusRules();             // Also initializes creature definitions
            DeadCreatures = new List <Creature>();
            ItemDefinition.InitializeDefinitions();

            // now some setup. It seems likely that a bunch of this will be handed off to things like the dungeon generator:

            Player = new Creature(this)
            {
                CancelDecider = new PlayerCancelDecider(this)
            };
            Map.Creatures.Add(Player, new Point(1, 20));
            Initiative playerInitiative = Q.CreateInitiative(RelativeInitiativeOrder.First);

            Q.Schedule(new PlayerTurnEvent(this), TicksPerTurn, playerInitiative);

            Map.GenerateMap();
            Map.Light.AddLightSource(Player.Position, 5);
        }
Esempio n. 2
0
    void Start()
    {
        var g = Instantiate(GridPrefab, new Vector3(0, 0, 0), Quaternion.identity);

        grid = g.GetComponent <GridMaker>();
        grid.MoveCharacter        += MoveCharacter;
        grid.GetSelectedCharacter += () => { return(SelectedCharacter); };
        grid.GetCharacters        += GetCharacters;
        grid.IsFirstTurn          += IsFirstTurn;
        grid.SetFirstPosition     += SetInitialCharacterPosition;

        team1 = new List <Character>();
        team2 = new List <Character>();

        InitializeTeams();

        var teams = new List <Character>();

        teams.AddRange(team1);
        teams.AddRange(team2);
        initative = new Initiative();
        initative.Init(teams);

        Next();
    }
Esempio n. 3
0
    public override IEnumerator Attack(Target target)
    {
        currentTarget = target;

        //See if they are next to enemies which will later incur penalties to hit.
        RangeFinder.FindAdjacentUnits(owner);
        foreach (Unit unit in owner.adjacentUnits)
        {
            if (unit.unitInfo.faction != owner.unitInfo.faction)
            {
                NextToEnemy = true;
                break;
            }
        }

        owner.remainingActions--;
        owner.aimingBow = true;
        owner.FaceDirection(currentTarget.unitTargeted.gameObject.transform.position);
        yield return(new WaitForSeconds(0.3f));

        owner.unitAnim.SetTrigger("rangedAttack");

        yield return(new WaitForSeconds(owner.unitAnim.GetCurrentAnimatorStateInfo(0).length + 2));

        Initiative.EndAction();

        yield break;
    }
Esempio n. 4
0
        public async Task <Initiative> UpdateInitiativeAsync(Initiative initiative)
        {
            _initiativeContext.Entry(initiative).State = EntityState.Modified;
            await _initiativeContext.SaveChangesAsync();

            return(initiative);
        }
 //todo xml
 // if the given initiative is still being used by any EventScheduling, throws, unless forceCancelEvents is true.
 // ...if forceCancelEvents is true, all events using this initiative will first be canceled and removed.
 // also throws if the currently executing one is using this initiative.
 public bool UnregisterInitiative(Initiative initiative, bool forceCancelEvents = false)
 {
     if (initiative == null)
     {
         throw new ArgumentNullException(nameof(initiative));
     }
     if (!oc.Contains(initiative))
     {
         return(false);
     }
     if (currentlyExecuting?.Initiative == initiative)
     {
         throw new InvalidOperationException("Can't unregister an initiative while the currently executing EventScheduling is still using it");
     }
     EventScheduling[] schedulings = scheduledEventsForInitiatives[initiative].ToArray();
     if (schedulings.Length > 0)
     {
         if (!forceCancelEvents)
         {
             throw new InvalidOperationException("Can't unregister an initiative while an EventScheduling is still using it");
         }
         foreach (EventScheduling eventScheduling in schedulings)
         {
             InternalEventScheduling es = eventScheduling as InternalEventScheduling;
             if (!es.IsLive)
             {
                 continue;
             }
             es.Canceled = true;
         }
         scheduledEventsForInitiatives.Clear(initiative);
     }
     return(oc.Remove(initiative));
 }
        /// <summary>
        /// For Add initiative
        /// </summary>
        /// <param name="initiative"></param>
        /// <param name="userId">The account which added initiave</param>
        /// <param name="authors"></param>
        /// <returns></returns>
        public bool Add(Initiative initiative, string userId)
        {
            // the user which is the name of the initiative
            //
            if (string.IsNullOrEmpty(initiative.AccountId))
            {
                //
                // For User role
                initiative.AccountId = userId;
            }
            else
            {
                //
                // For Admin and SAdmin role
                initiative.AdminAccountId = userId;
            }

            initiative.IsDeactive = false;

            initiative.DateCreated = DateTime.Now;

            _initiativeRepository.Add(initiative);

            Save();

            return(true);
        }
        //todo xml, ignores given init if first/last/__current is used
        public Initiative CreateInitiative(RelativeInitiativeOrder relativeOrder, Initiative targetInitiative)
        {
            switch (relativeOrder)
            {
            case RelativeInitiativeOrder.BeforeCurrent:
            case RelativeInitiativeOrder.Current:
            case RelativeInitiativeOrder.AfterCurrent:
                if (currentlyExecuting == null)
                {
                    throw new InvalidOperationException("There is no currently executing event from which to get an initiative");
                }
                break;

            case RelativeInitiativeOrder.BeforeTarget:
            case RelativeInitiativeOrder.Target:
            case RelativeInitiativeOrder.AfterTarget:
                if (targetInitiative == null)
                {
                    throw new ArgumentNullException(nameof(targetInitiative), "The chosen RelativeInitiativeOrder requires a target initiative, but no initiative was passed in.");
                }
                break;
            }

            InternalInitiative init = new InternalInitiative();

            InsertInitiative(relativeOrder, init, targetInitiative);
            return(init);
        }
Esempio n. 8
0
        public void Create(string developerEmail, string initiativename)
        {
            developerEmail = developerEmail ?? "*";
            var initiative = new Initiative(Guid.NewGuid(), initiativename, GenerateClientToken(), developerEmail, new List <IDeveloperRole>(), new List <ApplicationGroup>());

            _repository.AddInitiative(initiative);
        }
        /// <summary>
        /// Updated the person assigned to the initiative
        /// </summary>
        /// <param name="idea"></param>
        /// <param name="assigneeEmail"></param>
        /// <param name="assigneeDisplayName"></param>
        /// <returns>True if the assignee was changed from its previous value</returns>
        private async Task <bool> UpdateIdeaAssignee(Initiative idea, string assigneeEmail, string assigneeDisplayName)
        {
            //Person assignee = null;
            int?assigneeId = 0;

            if (!string.IsNullOrWhiteSpace(assigneeEmail))
            {
                assigneeId = await _personRepository.GetPersonIdByEmailAsync(assigneeEmail);

                _logger.Information("PersonId for assigneeEmail {EmailAddress} is {PersonId}", assigneeEmail, assigneeId);

                // TODO: create the user if they don't exist?
            }
            else
            {
                _logger.Information("Assignee email is {EmailAddress}", assigneeEmail);
            }

            if (idea.AssigneeId != assigneeId)
            {
                _logger.Information("Updating assignee from id " + idea.AssigneeId + " to {AssigneeId}", assigneeId);
                idea.SetAssigneeId(assigneeId);
                return(true);
            }
            else
            {
                _logger.Information("Not updating assignee because the AssigneeId has not changed ({AssigneeId})", assigneeId);
                return(false);
            }
        }
Esempio n. 10
0
        public async Task <Initiative> CreateNewInitiative(InitiativeDto initiativeDto)
        {
            try
            {
                var initiative = new Initiative
                {
                    Id          = Guid.NewGuid(),
                    Name        = initiativeDto.Name,
                    Description = initiativeDto.Description,
                    CreatedBy   = "Super User",
                    CreatedDate = DateTime.UtcNow,
                    UpdatedBy   = "",
                    UpdatedDate = DateTime.MinValue
                };

                baseContext.Add(initiative);

                await SaveChanges();

                return(initiative);
            }catch (Exception ex)
            {
                logger.LogError(ex, ex.Message);
                throw;
            }
        }
Esempio n. 11
0
        public IActionResult OnGet()
        {
            var initiative = new Initiative();

            // Build META Tag List
            initiative.InitiativeMetaTag = new List <InitiativeMetaTag>();
            // Provides an empty collection for the foreach loop
            // in the Create Razor page.
            PopulateAssignedMetaTagData(_context, initiative);
            //Build Business List
            initiative.InitiativeBusiness = new List <InitiativeBusiness>();
            PopulateAssignedBusinessData(_context, initiative);
            //Build Facility List
            initiative.InitiativeFacility = new List <InitiativeFacility>();
            PopulateAssignedFacilityData(_context, initiative);

            // Continue with one to one relationships
            ViewData["EngagementTypeId"] = new SelectList(_context.EngagementType, "EngagementTypeId", "EngagementTypeDescription");
            ViewData["LocationId"]       = new SelectList(_context.Location, "LocationId", "LocationDescription");
            ViewData["Resource"]         = new SelectList(_context.Resource, "ResourceId", "FirstName");
            ViewData["SolutionTypeId"]   = new SelectList(_context.SolutionType, "SolutionTypeId", "SolutionTypeDescription");
            ViewData["CurrentStatusId"]  = new SelectList(_context.CurrentStatus, "CurrentStatusId", "CurrentStatusDescription");

            return(Page());
        }
Esempio n. 12
0
        private INodePresentable ConvertToINodePresentable(Initiative initiative)
        {
            var contentLinesToDisplay = initiative.CollectProperties();
            var subnodes = initiative.Measures.Select(measure => ConvertToNodePresentable(measure)).Concat(initiative.Epics.Select(epic => ConvertToINodePresentable(epic)));

            return(new NodePresentable(initiative.Id, contentLinesToDisplay, subnodes));
        }
 protected EventScheduling(IEvent scheduledEvent, long currentTick, long delay, Initiative init)
 {
     Event        = scheduledEvent;
     CreationTick = currentTick;
     Delay        = delay;
     initiative   = init;
 }
Esempio n. 14
0
        public int UpdateInitiative(Initiative initiative)
        {
            var output = 0;

            Guard.NotNull(initiative, nameof(initiative));
            Guard.NotDefault(initiative.Id, "Initiative Id is null.,");
            output = _initiativeRepo.UpdateInitiative(initiative);

            var init = _initiativeRepo.GetInitiativeById(initiative.Id);

            Guard.NotNull(init, "Initiative is not exists");

            if (initiative.InitiativeCampaign != null)
            {
                if (initiative.InitiativeCampaign.Count > 0)
                {
                    initiative.InitiativeCampaign.ToList().ForEach(x =>
                    {
                        Guard.NotDefault(x.CampaignId, "Campaign Id is null.,");
                        x.InitiativeId = init.Id;
                        output         = x.Id == 0 ? _initiativeCampaignRepo.CreateInitiativeCampaign(x) :
                                         _initiativeCampaignRepo.UpdateInitiativeCampaign(x);
                    });
                }
            }
            return(output);
        }
Esempio n. 15
0
 public void EndNPCTurn()
 {
     destination = null;
     ai.tasks.Clear();
     ai.task = null;
     Initiative.ForceTurnEnd(true);
 }
Esempio n. 16
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Initiative = await _context.Initiative
                         .Include(i => i.InitiativeBusiness).ThenInclude(i => i.Business)
                         .Include(i => i.InitiativeFacility).ThenInclude(i => i.Facility)
                         .Include(i => i.InitiativeMetaTag).ThenInclude(i => i.MetaTag)
                         .Include(i => i.EngagementTypeNavigation)
                         .Include(i => i.LocationNavigation)
                         .Include(i => i.ResourceNavigation)
                         .Include(i => i.SolutionTypeNavigation).SingleOrDefaultAsync(m => m.InitiativeId == id);

            if (Initiative == null)
            {
                return(NotFound());
            }
            PopulateAssignedBusinessData(_context, Initiative);
            PopulateAssignedFacilityData(_context, Initiative);
            PopulateAssignedMetaTagData(_context, Initiative);
            ViewData["EngagementTypeId"] = new SelectList(_context.EngagementType, "EngagementTypeId", "EngagementTypeDescription");
            ViewData["LocationId"]       = new SelectList(_context.Location, "LocationId", "LocationDescription");
            ViewData["Resource"]         = new SelectList(_context.Resource, "ResourceId", "FirstName");
            ViewData["SolutionTypeId"]   = new SelectList(_context.SolutionType, "SolutionTypeId", "SolutionTypeDescription");
            return(Page());
        }
        public async Task CreateInitiative()
        {
            var newInitiativeMessages = new List <InitiativeCreatedEventArgs>();

            serviceProvider.GetRequiredService <SynchronousInitiativeMessageReceiver>()
            .CreatedHandlers.Add((e, token) => { newInitiativeMessages.Add(e); return(Task.CompletedTask); });

            var initiativeRepository = serviceProvider.GetRequiredService <IInitiativeRepository>();

            // create a basic initiative
            var newInitiative = Initiative.Create(
                title: "Test Idea",
                description: "Test creating initiatives",
                ownerPersonId: 1,
                businessContactId: 2
                );

            // add some supporting documents
            newInitiative.AddSupportingDocument(
                SupportingDocument.Create("My Document", "www.edmonton.ca", SupportingDocumentsType.BusinessCases));
            newInitiative.AddSupportingDocument(
                SupportingDocument.Create("Document2", "github.com", SupportingDocumentsType.Other));

            // add some stakeholders
            newInitiative.AddStakeholder(3, StakeholderType.BusinessContact);

            var newInitiative2 = await initiativeRepository.AddInitiativeAsync(newInitiative);

            newInitiative2.Should().NotBeNull();
            newInitiative2.Title.Should().Be("Test Idea");
            newInitiative2.SupportingDocuments.Count().Should().Be(2);

            newInitiativeMessages.Count().Should().Be(1);
        }
Esempio n. 18
0
        /// <summary>
        /// Deletes the initiative.
        /// </summary>
        /// <param name="initiative">The initiative.</param>
        /// <returns></returns>
        public int DeleteInitiative(Initiative initiative)
        {
            var output  = 0;
            var context = new TawjeehContext();

            using (var ts = context.Database.BeginTransaction())
            {
                try
                {
                    var initiativeCamp = initiative.InitiativeCampaigns.DefaultIfEmpty().ToList();
                    context = PerformBatchDelete(context, initiativeCamp);
                    context = BatchSoftDelete(context, initiative);
                    output  = context.SaveChanges();
                }
                catch (Exception ex)
                {
                    output = 0;
                }
                finally
                {
                    if (output != 0)
                    {
                        ts.Commit();
                    }
                    else
                    {
                        ts.Rollback();
                    }
                    ts.Dispose();
                }
            }
            return(output);
        }
        protected virtual async Task SendInitiativeLoggedMessage(Initiative initiative,
                                                                 ClaimsPrincipal owner,
                                                                 Google.Apis.Sheets.v4.Data.AppendValuesResponse loggerResponse,
                                                                 bool skipEmailNotification)
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();

            try
            {
                await _initiativeMessageSender.SendInitiativeLoggedAsync(new InitiativeLoggedEventArgs()
                {
                    Initiative            = initiative,
                    Owner                 = owner,
                    RangeUpdated          = loggerResponse?.TableRange,
                    SkipEmailNotification = skipEmailNotification
                });

                _logger.Information("Sent message on Service Bus that initiative has been logged in {ElapsedMilliseconds}ms", watch.ElapsedMilliseconds);
            }
            catch (Exception err)
            {
                Trace.TraceError($"Unable to send IdeaLogged message: { err.Message }");
                _logger.Error(err, "Unable to send message on Service Bus that initiative {InitiativeId}: {ErrorMessage}", initiative.Id, err.Message);
            }
        }
Esempio n. 20
0
 public InitiativesControllerTests()
 {
     _logger = new Mock <ILogger <InitiativesController> >();
     _mockInitiativeService = new Mock <IInitiativeService>();
     _mockInitiative        = getTestInitiative();
     _mockInitiativeList    = getTestInitiativeList();
     _initiativesController = new InitiativesController(_mockInitiativeService.Object, _logger.Object);
 }
Esempio n. 21
0
 public override void ExecuteAction(ActionCost actionCost)
 {
     Initiative.queuedActions++;
     actioningUnit.GetComponent <TacticsMovement>().remainingMove    += actioningUnit.unitInfo.currentMove;
     actioningUnit.GetComponent <TacticsMovement>().remainingActions -= 1;
     actioningUnit.UpdateBreath(-1, true);
     Initiative.EndAction();
 }
Esempio n. 22
0
 public void PlayerEndsTurnEarly()
 {
     if (Initiative.queuedActions > 0)
     {
         return;
     }
     Initiative.ForceTurnEnd();
 }
Esempio n. 23
0
 public void DeleteInitiative(Initiative initiative)
 {
     if (initiative == null)
     {
         throw new ArgumentNullException(nameof(initiative));
     }
     _context.Initiatives.Remove(initiative);
 }
Esempio n. 24
0
 public void CreateInitiative(Initiative initiative)
 {
     if (initiative == null)
     {
         throw new ArgumentNullException(nameof(initiative));
     }
     _context.Initiatives.Add(initiative);
 }
Esempio n. 25
0
 public CampaignReadOnly()
 {
     CampaignDetails    = new List <CampaignDetail>();
     Goals              = new List <Goal>();
     CampaignDocument   = new List <CampaignDocument>();
     Initiative         = new Initiative();
     CampaignMultimedia = new List <CampaignMultimedia>();
 }
Esempio n. 26
0
        public void InitiativeIsBasedOnDexterity()
        {
            var abilities = new AbilityScores();

            abilities.SetScore(AbilityScoreTypes.Dexterity, 18);
            var init = new Initiative(abilities);

            Assert.AreEqual(4, init.TotalValue);
        }
        public void SingleBranchLVT_Initiative()
        {
            Initiative InitiativeObj = SingleBranchLVT.Vision.Goals[0].Bets[0].Initiatives[0];

            Assert.IsInstanceOf(typeof(Initiative), InitiativeObj, "Test Initiative should be instance of Iniative class");
            Assert.AreEqual("initiativeTitle", InitiativeObj.Title, "Test Initiative should have title");
            Assert.AreEqual(1, InitiativeObj.Measures.Count, "Test Initiative should have one Measure");
            Assert.AreEqual(1, InitiativeObj.Epics.Count, "Test Initiative should have one Epic");
        }
Esempio n. 28
0
        public AdapterBuilder AddGetStub(Initiative response = null)
        {
            var stubResult = response ?? new InitiativeBuilder().SbcaVolenteering().Build();

            _adapter.Expect(e => e.Get(Arg <Guid> .Is.Anything)).Return(stubResult);
            _adapter.Stub(e => e.Get(Arg <Guid> .Is.Anything)).Return(stubResult);

            return(this);
        }
Esempio n. 29
0
        private string BuildOrgChartDataString(Initiative initiative, string parentId)
        {
            var nodeString      = string.Format(Properties.Resources.OrgChartNodeString, initiative.Id, initiative.Type, initiative.ContentLineOne, parentId);
            var measuresStrings = initiative.Measures.Select(measure => BuildOrgChartDataString(measure, initiative.Id));
            var epicsStrings    = initiative.Epics.Select(epic => BuildOrgChartDataString(epic, initiative.Id));
            var subnodesStrings = measuresStrings.Concat(epicsStrings);

            return($"{nodeString}, {string.Join(" , ", subnodesStrings)}");
        }
Esempio n. 30
0
 public int CompareTo(Combatant other)
 {
     if (Initiative != other.Initiative)
     {
         return(Initiative.CompareTo(other.Initiative));
     }
     // If it comes down to a tiebreaker, order by ascending
     return(TieBreaker.CompareTo(other.TieBreaker) * -1);
 }
Esempio n. 31
0
        /// <summary>
        /// This reads the Initiatives that we do NOT want to report on from configuration
        /// settings to allow ignoring Initiatives for OCTO that we don't we want
        /// </summary>
        public static List<Initiative> GetInitiativeList()
        {
            List<Initiative> listReturn = new List<Initiative>();
            string[] IgnoreList = new string[0];

            // Full path and filename to read the Initiative list from
            LogOutput("Getting list of initiatives from 'ConfigurationManager'...", "GetInitiativeList", true);
            string strIgnoreList = ConfigurationManager.AppSettings["IgnoreList"];
            LogOutput("Configured ignore list is: " + strIgnoreList, "GetInitiativeList", true);
            System.Text.RegularExpressions.Regex myReg = new System.Text.RegularExpressions.Regex(",");
            IgnoreList = myReg.Split(strIgnoreList);
            LogOutput("Looping for each initiative to get full information...", "GetInitiativeList", false);

            // Grab all Information for the given initiative
            LogOutput("Using RallyAPI to request information for all Initiatives...", "GetInitiativeList", true);
            LogOutput("Building Rally Request...", "GetInitiativeList", true);
            //Request rallyRequest = new Request("PortfolioItem/Initiative");
            Request rallyRequest = new Request("PortfolioItem/Theme");
            // You can get the project reference for this next part by editing the main project "" and taking the URL.  We want the part after the word 'project'
            // so this is currently https://rally1.rallydev.com/#/22986814983d/custom/49666880093
            //rallyRequest.Project = "https://rally1.rallydev.com/#/22986814983d/custom/49666880093";  // This must be a reference to the project.  This project equates to "CTO Customer & Innovation Labs"
            //https://rally1.rallydev.com/slm/webservice/v2.0/project/22986814983
            //rallyRequest.Project = "/custom/22986814983";  // This must be a reference to the project.  This project equates to "CTO Customer & Innovation Labs"
            rallyRequest.Project = "https://rally1.rallydev.com/slm/webservice/v2.0/project/22986814983";
            rallyRequest.ProjectScopeDown = true;   // Specify that we want any projects under the main one
            rallyRequest.Fetch = new List<string>() { "Name", "FormattedID", "Owner", "PlannedStartDate", "PlannedEndDate",
                "ActualEndDate", "Description", "State", "StateChangedDate" };
            rallyRequest.Query = new Query("FormattedID", Query.Operator.DoesNotEqual, "T8");  // We really don't want a filter, but you need a query string of some sort
            LogOutput("Running Rally Query request...", "GetInitiativeList", true);
            QueryResult rallyResult = RallyAPI.Query(rallyRequest);
            LogOutput("Looping through Query result...", "GetInitiativeList", true);
            foreach (var result in rallyResult.Results)
            {
                // Only process this entry if NOT in the ignore list
                if (!CheckIgnoreList(IgnoreList, RationalizeData(result["FormattedID"])))
                {
                    // Create and populate the Initiative object
                    LogOutput("Creating new Initiative object and saving...", "GetInitiativeList", true);
                    Initiative initiative = new Initiative();
                    initiative.FormattedID = RationalizeData(result["FormattedID"]);
                    initiative.Name = RationalizeData(result["Name"]);
                    initiative.Owner = RationalizeData(result["Owner"]);
                    initiative.PlannedStartDate = Convert.ToDateTime(result["PlannedStartDate"]);
                    initiative.PlannedEndDate = Convert.ToDateTime(result["PlannedEndDate"]);
                    initiative.ActualEndDate = Convert.ToDateTime(result["ActualEndDate"]);
                    initiative.Description = GetPlainTextFromHtml(RationalizeData(result["Description"]));
                    initiative.State = RationalizeData(result["State"]);
                    initiative.StateChangedDate = Convert.ToDateTime(result["StateChangedDate"]);
                    LogOutput("Appending new initiative object to return list...", "GetInitiativeList", true);
                    listReturn.Add(initiative);
                }
            }

            LogOutput("Completed processing all initiatives, returning list", "GetInitiativeList", true);

            return listReturn;
        }