Esempio n. 1
0
 public void AddPlayer(Player player)
 {
     if (Capacity > Count)
     {
         Roster.Add(player);
     }
 }
Esempio n. 2
0
 public ComputerOwner(int gladiators, int level, int goldBoost, int prestigeBoost)
     : base()
 {
     prestige = 100 + prestigeBoost;
     gold     = 1000 + goldBoost;
     win      = 0;
     loss     = 0;
     name     = Gladiator.list[Return.RandomInt(0, list.Count)];
     for (int i = 0; i < gladiators; i++)
     {
         Gladiator g = new Gladiator(Return.RandomInt(3, level));
         Roster.Add(g);
         g.Owner = this;
     }
 }
Esempio n. 3
0
    static void Main(string[] args)
    {
        int N;

        string[] name;
        double[] pay;
        string[] posada;
        string[] viddil;
        string[] email;
        string[] age;

        Roster sort = new Roster();

        Console.WriteLine("Input N size: ");
        N = Convert.ToInt32(Console.ReadLine());

        sort.Size(N);

        name   = new string[N];
        pay    = new double[N];
        posada = new string[N];
        viddil = new string[N];
        email  = new string[N];
        age    = new string[N];


        Console.WriteLine("");

        for (int i = 0; i < N; i++)
        {
            name[i]   = Console.ReadLine();
            pay[i]    = Convert.ToDouble(Console.ReadLine());
            posada[i] = Console.ReadLine();
            viddil[i] = Console.ReadLine();
            email[i]  = Console.ReadLine();
            age[i]    = Console.ReadLine();

            sort.Add(name[i], pay[i], posada[i], viddil[i], email[i], age[i], i);
            Console.WriteLine("");
        }

        sort.Sort();
        sort.Do();

        Console.ReadKey();
    }
Esempio n. 4
0
        private void OnCharacterNew(object sender, EventArgs e)
        {
            // display UI
            var form = new CharacterForm();

            while (true)
            {
                // add new character
                if (form.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                _roster.Add(form.Character);
                break;
            }

            BindList();
        }
        public ActionResult Add(CharacterModel character)
        {
            character.uniqueName = NameCheck(character.Name);
            ObjectValidator.TryValidateFullObject(character).ForEach(x => ModelState.AddModelError("", x.ErrorMessage));

            if (ModelState.IsValid)
            {
                try
                {
                    character.Id = s_characters.Add(character.Convert()).Id;
                    return(RedirectToAction(nameof(CharacterSheet), new { id = character.Id }));
                } catch (Exception e)
                {
                    ModelState.AddModelError("", e.Message);
                };
            }
            ;

            return(View(character));
        }
Esempio n. 6
0
        public void Add_Adds_Student_To_Roster()
        {
            Roster r = new Roster();

            Student s1 = new Student()
            {
                Name = "James",
                Gender = "Male"
            };

            Student s2 = new Student()
            {
                Name = "Jane",
                Gender = "Female"
            };

            Assert.AreEqual(0, r.Students.Count);

            r.Add(s1);

            Assert.AreEqual(1, r.Students.Count);
        }
Esempio n. 7
0
        private void Generate()
        {
            RootAttrib1 = NewAttrib("RootAttrib1", "This is some test data");
            Add(null, RootAttrib1);
            Root1 = NewNode("Root1");
            Add(null, Root1);
            Root2 = NewNode("Root2");
            Add(null, Root2);

            Node1 = NewNode("Node1Tag", "Node1Name");
            // Count the name attrib
            Node1AttribCount++;
            Add(Root1, Node1);
            Node2 = NewNode("Node2Tag", "Node2Name");
            // Count the name attrib
            Node2AttribCount++;
            Add(Root1, Node2);

            Node1Attrib1 = NewAttrib("Attrib1", "Value1");
            Add(Node1, Node1Attrib1);
            Node1Attrib2 = NewAttrib("Attrib2", "Value2");
            Add(Node1, Node1Attrib2);
            Node1Child1 = NewNode("Child1");
            Add(Node1, Node1Child1);
            Node1Child2 = NewNode("Child2");
            Add(Node1, Node1Child2);

            Node2Attrib1 = NewAttrib("Attrib1", "Value1");
            Add(Node2, Node2Attrib1);
            Node2Child1 = NewNode("Child1");
            Add(Node2, Node2Child1);

            KmlNode game = NewNode("GAME");

            Add(null, game);
            Flightstate = NewNode("FLIGHTSTATE");
            Add(game, Flightstate);
            Roster = NewNode("ROSTER");
            Add(game, Roster);

            Kerbal1 = NewNode("KERBAL", "Kerbal1") as KmlKerbal;
            Roster.Add(Kerbal1);
            Add(Kerbal1, NewAttrib("state", "Assigned"));
            Add(Kerbal1, NewAttrib("type", "Crew"));
            Add(Kerbal1, NewAttrib("trait", "Pilot"));
            Add(Kerbal1, NewAttrib("brave", "0.1"));
            Add(Kerbal1, NewAttrib("dumb", "0.2"));

            Kerbal2 = NewNode("KERBAL", "Kerbal2") as KmlKerbal;
            Add(Kerbal2, NewAttrib("state", "Available"));
            Add(Kerbal2, NewAttrib("type", "Crew"));
            Add(Kerbal2, NewAttrib("trait", "Scientist"));
            Add(Kerbal2, NewAttrib("brave", "0.2"));
            Add(Kerbal2, NewAttrib("dumb", "0.4"));
            Roster.Add(Kerbal2);

            Vessel1 = NewNode("VESSEL", "Vessel1") as KmlVessel;
            Add(Vessel1, NewAttrib("root", "0"));

            Vessel1Part1 = NewNode("PART", "Vessel1Part1") as KmlPart;
            Add(Vessel1Part1, NewAttrib("uid", "Vessel1Part1Uid"));
            Add(Vessel1Part1, NewAttrib("parent", "0"));
            Add(Vessel1Part1, NewAttrib("position", "0,0,0"));
            Add(Vessel1Part1, NewAttrib("attN", "bottom, 1"));
            Add(Vessel1Part1, NewAttrib("attN", "top, 2"));
            Add(Vessel1Part1, NewAttrib("attN", "left, 3"));
            Add(Vessel1Part1, NewAttrib("attN", "right, 4"));
            Add(Vessel1Part1, NewAttrib("attN", "back, 5"));
            Add(Vessel1Part1, NewAttrib("attN", "front, 6"));
            Add(Vessel1Part1, NewAttrib("flag", "Vessel1Flag1"));
            Add(Vessel1Part1, NewAttrib("crew", Kerbal1.Name));
            Vessel1Part1Resource1 = NewNode("RESOURCE", "Resource1") as KmlResource;
            Add(Vessel1Part1Resource1, NewAttrib("amount", "50"));
            Add(Vessel1Part1Resource1, NewAttrib("maxAmount", "100"));
            Add(Vessel1Part1, Vessel1Part1Resource1);
            Vessel1Part1Resource2 = NewNode("RESOURCE", "Resource2") as KmlResource;
            Add(Vessel1Part1Resource2, NewAttrib("amount", "200"));
            Add(Vessel1Part1Resource2, NewAttrib("maxAmount", "200"));
            Add(Vessel1Part1, Vessel1Part1Resource2);
            Add(Vessel1, Vessel1Part1);

            Vessel1Part2 = NewNode("PART", "Vessel1Part2") as KmlPart;
            Add(Vessel1Part2, NewAttrib("uid", "Vessel1Part2Uid"));
            Add(Vessel1Part2, NewAttrib("parent", "0"));
            Add(Vessel1Part2, NewAttrib("position", "0.0,-1.0,0.0"));
            Add(Vessel1Part2, NewAttrib("attN", "top, 0"));
            Add(Vessel1Part2, NewAttrib("attN", "bottom, -1"));
            Add(Vessel1Part2, NewAttrib("flag", "Vessel1Flag2"));
            Add(Vessel1, Vessel1Part2);

            Vessel1Part3 = NewNode("PART", "Vessel1Part3") as KmlPart;
            Add(Vessel1Part3, NewAttrib("parent", "0"));
            Add(Vessel1Part3, NewAttrib("position", "0.0,1.0,0.0"));
            Add(Vessel1Part3, NewAttrib("attN", "top, -1"));
            Add(Vessel1Part3, NewAttrib("attN", "bottom, 0"));
            Add(Vessel1, Vessel1Part3);

            Vessel1Part4 = NewNode("PART", "Vessel1Part4") as KmlPart;
            Add(Vessel1Part4, NewAttrib("parent", "0"));
            Add(Vessel1Part4, NewAttrib("position", "-1.0,0.0,0.0"));
            Add(Vessel1Part4, NewAttrib("attN", "top, 0"));
            Add(Vessel1Part4, NewAttrib("attN", "bottom, -1"));
            Add(Vessel1, Vessel1Part4);

            Vessel1Part5 = NewNode("PART", "Vessel1Part5") as KmlPart;
            Add(Vessel1Part5, NewAttrib("parent", "0"));
            Add(Vessel1Part5, NewAttrib("position", "1.0,0.0,0.0"));
            Add(Vessel1Part5, NewAttrib("attN", "top, 0"));
            Add(Vessel1Part5, NewAttrib("attN", "bottom, -1"));
            Add(Vessel1, Vessel1Part5);

            Vessel1Part6 = NewNode("PART", "Vessel1Part6") as KmlPart;
            Add(Vessel1Part6, NewAttrib("parent", "0"));
            Add(Vessel1Part6, NewAttrib("position", "0.0,0.0,-1.0"));
            Add(Vessel1Part6, NewAttrib("attN", "top, 0"));
            Add(Vessel1Part6, NewAttrib("attN", "bottom, -1"));
            Add(Vessel1, Vessel1Part6);

            Vessel1Part7 = NewNode("PART", "Vessel1Part7") as KmlPart;
            Add(Vessel1Part7, NewAttrib("parent", "0"));
            Add(Vessel1Part7, NewAttrib("position", "0.0,0.0,1.0"));
            Add(Vessel1Part7, NewAttrib("attN", "top, 0"));
            Add(Vessel1Part7, NewAttrib("attN", "bottom, -1"));
            Add(Vessel1, Vessel1Part7);

            Vessel1Part8 = NewNode("PART", "Vessel1Part8") as KmlPart;
            Add(Vessel1Part8, NewAttrib("parent", "1"));
            Add(Vessel1Part8, NewAttrib("position", "0.0,-2.0,0.0"));
            Add(Vessel1Part8, NewAttrib("srfN", "srfAttach, 1"));
            Add(Vessel1, Vessel1Part8);
            Add(Flightstate, Vessel1);

            // TODO TestData.Generate(): Maybe one item is replaced within Identify
            // and needs to be reassigned to a property.
            KmlItem.ParseMemory(Roots);
        }
Esempio n. 8
0
        void ProcessSetRoster(XmppBase.Iq iq)
        {
            Roster roster = iq.Query as Roster;
            Roster respRoster = new Roster();
            foreach (var item in roster.GetRoster())
            {
                string owner = Session.SessionUser.Username;
                string username = JIDEscaping.Unescape(item.Jid.User);

                string group = null;
                if (item.HasGroups)
                    group = item.GetGroups()[0];

                if (item.Subscription == Subscription.remove)
                {
                    FriendshipManager.Instance.RemoveFriend(owner,
                        JIDEscaping.Unescape(item.Jid.User));
                    return;
                }

                if (FriendshipManager.Instance.IsFriend(
                    Session.SessionUser.Username,
                    username))
                {
                    FriendUpdateFlags flags = FriendUpdateFlags.UpdateRemark;
                    if (group != null)
                        flags |= FriendUpdateFlags.UpdateGroup;
                    FriendshipManager.Instance.UpdateFriend(owner, username,
                        null, group, item.Name, null, flags);
                    respRoster.Add(item);
                }
                else
                {
                    var sqlUser = Server.AuthManager.GetUser(username);
                    if (sqlUser == null)
                        return;
                    FriendshipManager.Instance.AddFriend(Session.SessionUser.Username,
                        group, username, item.Name, sqlUser.Nickname, Subscription.from);
                }
            }
            iq.Type = IqType.result;
            iq.Query = respRoster;
            iq.SwitchDirection();
            Session.Send(iq);
        }
Esempio n. 9
0
        static public void InitRoster()
        {
            byte[][] LockerAddresses =
            {
                new byte[] { 100,  1 }, //{100, 2},
                new byte[] { 101,  4 }, //{100, 3},
                new byte[] { 101,  5 }, //{101, 6},
                new byte[] { 100,  2 }, //{101, 7},
                new byte[] { 100,  3 }, //{100, 4},
                new byte[] { 100,  4 }, //{100, 5},
                new byte[] { 100,  5 }, //{101, 4},
                new byte[] { 101,  6 }, //{101, 5},
                new byte[] { 101,  7 }, //{0, 0}, // isn't used
                new byte[] { 101,  8 },
                new byte[] { 101, 10 },
                new byte[] { 101,  9 },
                new byte[] { 101, 11 },
            };
            for (int i = 0; i < 13; i++)
            {
                Lockers.Add(new Locker("Locker " + (i + 1)));
                if (i < 3)
                {
                    Lockers[i].Group = 0;
                }
                else
                {
                    Lockers[i].Group = 1;
                }
                Lockers[i].bEnabled    = true;
                Lockers[i].StateSignal = new DataPoint(CommunicationLoop.ModbusBuffers[0],
                                                       EDataMode.Discrete, (ushort)(0x1000 + LockerAddresses[i][0]),
                                                       LockerAddresses[i][1]);
                Roster.Add("Locker " + i, Lockers[i]);
            }

            /*var CommonDirectionSignal = new DataPoint(CommunicationLoop.ModbusBuffers[1],
             *      EDataMode.Discrete, 0x1000 + 202, 6);
             * CommonCleanerGeneratorPower = new DataPoint
             * (CommunicationLoop.ModbusBuffers[1], EDataMode.Discrete, 0x1000 + 202, 5);
             * for (int i = 0; i < 2; i++)
             * {
             *  Cleaners.Add(new Cleaner("Cleaner " + i));
             *  Cleaners[i].Edge1Signal = new DataPoint(CommunicationLoop.ModbusBuffers[0],
             *      EDataMode.Discrete, 0x1000 + 101, (byte)(12 + i * 2));
             *  Cleaners[i].Edge2Signal = new DataPoint(CommunicationLoop.ModbusBuffers[0],
             *      EDataMode.Discrete, 0x1000 + 101, (byte)(13 + i * 2));
             *  Cleaners[i].LocationSignal = CommonDirectionSignal;
             *  Cleaners[i].PowerStateSignal = new DataPoint(CommunicationLoop.ModbusBuffers[1],
             *      EDataMode.Discrete, 0x1000 + 201, (byte)(12 + i));
             *  Cleaners[i].bEnabled = true;
             *  Roster.Add("Cleaner " + i, Cleaners[i]);
             * }*/
            byte[][] ContactorBCStateAddresses =
            {
                new byte[] { 100, 10 },
                new byte[] { 100, 11 },
                new byte[] { 100, 13 },
                new byte[] { 100, 14 },
                new byte[] { 100, 15 },
                new byte[] { 101,  0 },
                new byte[] { 100, 12 },
                new byte[] { 101,  1 },
                new byte[] { 100,  9 },
                new byte[] { 100,  8 }
            };
            byte[][] ContactorPowerStateAddresses =
            {
                new byte[] { 200, 10 },
                new byte[] { 200, 11 },
                new byte[] { 200, 13 },
                new byte[] { 200, 14 },
                new byte[] { 200, 15 },
                new byte[] { 201,  0 },
                new byte[] { 200, 12 },
                new byte[] { 201,  1 },
                new byte[] { 200,  9 },
                new byte[] { 200,  8 }
            };
            for (int i = 0; i < 10; i++)
            {
                Contactors.Add(new Contactor("Contactor " + (i + 1)));
                Contactors[i].BCDelay       = 1.5m;
                Contactors[i].BCStateSignal = new DataPoint(CommunicationLoop.ModbusBuffers[0],
                                                            EDataMode.Discrete, (ushort)(0x1000 + ContactorBCStateAddresses[i][0]),
                                                            ContactorBCStateAddresses[i][1]);
                Contactors[i].PowerStateSignal = new DataPoint(CommunicationLoop.ModbusBuffers[1],
                                                               EDataMode.Discrete, (ushort)(0x1000 + ContactorPowerStateAddresses[i][0]),
                                                               ContactorPowerStateAddresses[i][1]);
                Contactors[i].bEnabled = true;
                Roster.Add("Contactor " + i, Contactors[i]);
            }
            var FCBufferNumbers = new int[] { 6, 5, 4, 2, 3, 1, 0 };

            for (int i = 0; i < 7; i++)
            {
                FCs.Add(new FrequencyConverter("FC " + i));
                if (!CommunicationLoop.bDisableFCs)
                {
                    FCs[i].ApplyBuffer(CommunicationLoop.USSBuffers[i]);
                }
                FCs[i].bEnabled = true;
                Roster.Add("FC " + i, FCs[i]);
            }
            for (int i = 0; i < 2; i++)
            {
                HVPSes.Add(new HVPS("HVPS " + (i + 1)));
                if (i == 0)
                {
                    HVPSes[i].CurrentInSignal = new DataPoint(CommunicationLoop.ModbusBuffers[2],
                                                              EDataMode.Analog, 0x1000 + 301);
                    HVPSes[i].EmergencySignal = new DataPoint(CommunicationLoop.ModbusBuffers[0],
                                                              EDataMode.Discrete, 0x1000 + 101, 3);
                }
                HVPSes[i].PowerStateSignal = new DataPoint(CommunicationLoop.ModbusBuffers[1],
                                                           EDataMode.Discrete, 0x1000 + 201, (byte)(6 - i * 3));
                HVPSes[i].VoltageInSignal = new DataPoint(CommunicationLoop.ModbusBuffers[2],
                                                          EDataMode.Analog, 0x1000 + 300);
                HVPSes[i].VoltageOutSignal = new DataPoint(CommunicationLoop.ModbusBuffers[3],
                                                           EDataMode.Analog, (ushort)(0x1000 + 400 + i));
                HVPSes[i].bEnabled = true;
                Roster.Add("HVPS " + i, HVPSes[i]);
            }
            HVPSes[1].CurrentInSignal = new DataPoint(CommunicationLoop.ModbusBuffers[4],
                                                      EDataMode.Analog, 0x1000 + 506);
            HVPSes[1].bPolarity      = false;
            HVPSes[0].PolaritySignal = new DataPoint(CommunicationLoop.ModbusBuffers[1],
                                                     EDataMode.Discrete, 0x1000 + 201, 7);
            HVPSes[0].MaxScaleOut = 440;
        }