Ejemplo n.º 1
0
        public void AddPosition(string unitUUID, List <int> roleID)
        {
            List <OpPosition> newPositions = new List <OpPosition>();

            foreach (int id in roleID)
            {
                OpPosition pos = new OpPosition()
                {
                    uuid            = ANWI.Utility.UUID.GenerateUUID(),
                    unitUUID        = unitUUID,
                    critical        = false,
                    filledById      = -1,
                    filledByPointer = null,
                    role            = OperationRole.FetchById(id)
                };

                fleet.AddPosition(pos);
                newPositions.Add(pos);
            }

            PushToAll(new ANWI.Messaging.Ops.UpdatePositions(
                          newPositions,
                          null,
                          null));
        }
        public void AddPositions()
        {
            //
            // Add a Skipper position to the Legend of Dave
            OpPosition one = new OpPosition()
            {
                uuid     = "2jrj2jsnn3kjnksnr",
                unitUUID = "klkj4rlkjlkj2-asd-ei2",
                critical = false,
                role     = new OperationRole()
                {
                    name = "Skipper"
                }
            };

            fleet.AddPosition(one);

            Assert.AreEqual(4, fleet.TotalPositions);
            Assert.AreEqual(3, fleet.TotalCriticalPositions);

            Ship dave = fleet.GetUnit("klkj4rlkjlkj2-asd-ei2") as Ship;

            Assert.AreEqual(2, dave.positions.Count);
            Assert.AreEqual("2jrj2jsnn3kjnksnr", dave.positions[1].uuid);

            //
            // Add a copilot position to Dickthunder 1
            OpPosition two = new OpPosition()
            {
                uuid     = "4832yufdjn45iua",
                unitUUID = "498osjblj4lksjlkaj",
                critical = false,
                role     = new OperationRole()
                {
                    name = "Co-Pilot"
                }
            };

            fleet.AddPosition(two);
            Assert.AreEqual(5, fleet.TotalPositions);
            Assert.AreEqual(3, fleet.TotalCriticalPositions);

            Boat d1 = fleet.GetUnit("498osjblj4lksjlkaj") as Boat;

            Assert.AreEqual("4832yufdjn45iua", d1.positions[1].uuid);
        }
Ejemplo n.º 3
0
        private void ProcessUpdatePositions(ANWI.Messaging.IMessagePayload p)
        {
            ANWI.Messaging.Ops.UpdatePositions up
                = p as ANWI.Messaging.Ops.UpdatePositions;

            if (up.added != null)
            {
                foreach (OpPosition pos in up.added)
                {
                    fleet.AddPosition(pos);
                }
            }

            if (up.changed != null)
            {
                foreach (OpPosition pos in up.changed)
                {
                    OpPosition old = fleet.GetPosition(pos.uuid);
                    if (old != null)
                    {
                        old.critical = pos.critical;
                    }
                }
            }

            if (up.removed != null)
            {
                foreach (string rem in up.removed)
                {
                    fleet.DeletePosition(rem);
                }
            }

            RebuildC2();

            NotifyPropertyChanged(string.Empty);
        }