Example #1
0
    public void RemoveFromInitiative(Unit unit)
    {
        for (int i = 0; i < InitiativeOrder.Count; i++)
        {
            if (InitiativeOrder[i] == unit)
            {
                InitiativeOrder.RemoveAt(i);
                if (i < TurnCounter)
                {
                    TurnCounter--;
                }
                // This still doesn't handle the possibility that the currently active unit dies in its own turn
            }
        }

        //Fix edge cases by bounding turncounter
        if (TurnCounter < 0)
        {
            TurnCounter = 0;
        }
        else if (TurnCounter >= InitiativeOrder.Count)
        {
            TurnCounter = InitiativeOrder.Count - 1;
        }
    }
Example #2
0
        public override InitiativePassSlot Next()
        {
            InitiativeOrder.Sort();
            var slot = InitiativeOrder.FirstOrDefault(_leftToAct);

            if (slot != null)
            {
                slot.CurrentInitiative -= 10;
            }
            return(slot);
        }
Example #3
0
    public void AddToInitiative(Unit unit)
    {
        // Find the Unit's place in initiative
        for (int i = 0; i < InitiativeOrder.Count; i++)
        {
            if (InitiativeOrder[i].initiative < unit.initiative)
            {
                InitiativeOrder.Insert(i, unit);
                return;
            }
        }

        InitiativeOrder.Add(unit);
    }
Example #4
0
        public void Setup(IDiceBag diceBag, IEnumerable <ICharacter> participants)
        {
            if (diceBag == null)
            {
                throw new ArgumentNullException("diceBag");
            }
            if (participants == null)
            {
                throw new ArgumentNullException("participants");
            }

            InitiativeOrder = participants.Select(x =>
                                                  new InitiativePassSlot()
            {
                Participant = x,
                HasActed    = false
            }).ToList();

            InitiativeOrder.ForEach(x => x.CurrentInitiative = x.RollInitiative(diceBag));

            InitiativeOrder.Sort();
        }
Example #5
0
 public override void Reset()
 {
     InitiativeOrder.ForEach(x => x.HasActed = false);
     InitiativeOrder = InitiativeOrder.Where(_leftToAct).ToList();
 }
Example #6
0
 public override InitiativePassSlot Next()
 {
     InitiativeOrder.Sort();
     return(InitiativeOrder.FirstOrDefault(_leftToAct));
 }