示例#1
0
        public void MonTypeValuesValidTest(string speciesName, int id, int attack, int hp, int speed, bool isValid)
        {
            //--Arrange
            MonType monType             = new MonType(speciesName, id, attack, hp, speed);
            var     expectedId          = id;
            var     expectedHp          = hp;
            var     expectedAttack      = attack;
            var     expectedSpeed       = speed;
            var     expectedSpeciesName = speciesName;
            var     expectedValid       = isValid;

            //--Act
            var actualId          = monType.Id;
            var actualHp          = monType.Hp;
            var actualAttack      = monType.Attack;
            var actualSpeed       = monType.Speed;
            var actualSpeciesName = monType.SpeciesName;
            var actualValid       = monType.Validate();

            //--Assert
            Assert.AreEqual(expectedId, actualId);
            Assert.AreEqual(expectedSpeciesName, actualSpeciesName);
            Assert.AreEqual(expectedHp, actualHp);
            Assert.AreEqual(expectedAttack, actualAttack);
            Assert.AreEqual(expectedSpeed, actualSpeed);
            Assert.AreEqual(expectedValid, actualValid);
        }
示例#2
0
        public void MonTypeRepositoryAddTest()
        {
            //--Arrange
            MonType monType      = new MonType("guy", 42, 0, 0, 0);
            var     testDelegate = new TestDelegate(delegate { monTypeRepository.Add(monType); });

            //--Act and Assert
            Assert.DoesNotThrow(testDelegate);
        }
示例#3
0
        public ActionResult AddNewMon(string monname, int monlevel, int monhp, int monattack, int mondefense, int monspecialattack, int monspecialdefense, int monspeed, string montype1, string montype2, string move1, string move2, string move3, string move4)
        {
            int     move1int = int.Parse(move1);
            int     move2int = int.Parse(move2);
            int     move3int = int.Parse(move3);
            int     move4int = int.Parse(move4);
            MonType typeOne  = MonType.Find(montype1);
            Mon     newMon   = new Mon(monname, monlevel, monhp, monattack, mondefense, monspecialattack, monspecialdefense, monspeed);
            Move    monmove1 = Move.Find(move1int);

            newMon.Save();
            newMon.AddMonType(typeOne);
            newMon.AddMove(monmove1);


            if (montype2 != "NOOOO")
            {
                MonType typeTwo = MonType.Find(montype2);
                newMon.AddMonType(typeTwo);
            }
            if (move2int != 0)
            {
                Move monmove2 = Move.Find(move2int);
                newMon.AddMove(monmove2);
            }
            if (move3int != 0)
            {
                Move monmove3 = Move.Find(move3int);
                newMon.AddMove(monmove3);
            }
            if (move4int != 0)
            {
                Move monmove4 = Move.Find(move4int);
                newMon.AddMove(monmove4);
            }


            return(RedirectToAction("Dev"));
        }
示例#4
0
        private void DoSetMonTypeMessage(RequestMessage request)
        {
            ReturnMessage retMessage = new ReturnMessage();

            retMessage.Result    = true;
            retMessage.SessionID = SessionID;
            retMessage.Code      = 0;
            try
            {
                if (request.ListData == null ||
                    request.ListData.Count < 1)
                {
                    SendErrorMessage(request.Command, Defines.RET_PARAM_INVALID,
                                     string.Format("ListData is null or count invalid"));
                    return;
                }
                string strMonType = request.ListData[0];
                LogDebugMessage(request.Command, string.Format("Args:{0}", strMonType));
                int intValue;
                if (!int.TryParse(strMonType, out intValue))
                {
                    SendErrorMessage(request.Command, Defines.RET_PARAM_INVALID,
                                     string.Format("MonitorType invalid\t{0}", strMonType));
                    return;
                }
                MonType oldType = mMonType;
                MonType newType = (MonType)intValue;
                mMonType = newType;
                LogDebugMessage(request.Command, string.Format("MonType changed.\tNew:{0};Old:{1}", newType, oldType));
                retMessage.Command = (int)Service10Command.ResSetMonType;
                retMessage.ListData.Add(((int)newType).ToString());
                retMessage.ListData.Add(((int)oldType).ToString());
                SendMessage(retMessage);
            }
            catch (Exception ex)
            {
                SendErrorMessage(request.Command, Defines.RET_FAIL, ex.Message);
            }
        }
示例#5
0
        public void GetMonTypes_Test()
        {
            Mon newMon = new Mon("Rattata", 50, 30, 56, 35, 25, 35, 72);

            newMon.Save();
            MonType newMonType = new MonType("Grass");

            newMonType.Save();
            MonType newMonType1 = new MonType("Fire");

            newMonType1.Save();

            //Act
            newMon.AddMonType(newMonType);
            newMon.AddMonType(newMonType1);

            List <MonType> expectedResult = new List <MonType> {
                newMonType, newMonType1
            };
            List <MonType> result = newMon.GetMonTypes();

            //Assert
            CollectionAssert.AreEqual(expectedResult, result);
        }
 public void Dispose()
 {
     MonType.DeleteAll();
 }
示例#7
0
 public MonitorOperations(TcpClient tcpClient)
     : base(tcpClient)
 {
     mMonType        = MonType.Unkown;
     mListMonObjects = new List <MonitorObject>();
 }
示例#8
0
        public static Color TypeToColour(MonType t)
        {
            switch (t)
            {
            case MonType.bug:
                return(Color.GreenYellow);

            case MonType.dark:
                return(Color.DarkViolet);

            case MonType.dragon:
                return(Color.Indigo);

            case MonType.electric:
                return(Color.Goldenrod);

            case MonType.fairy:
                return(Color.LightPink);

            case MonType.fighting:
                return(Color.SaddleBrown);

            case MonType.fire:
                return(Color.OrangeRed);

            case MonType.flying:
                return(Color.LightSkyBlue);

            case MonType.ghost:
                return(Color.BlueViolet);

            case MonType.grass:
                return(Color.ForestGreen);

            case MonType.ground:
                return(Color.SandyBrown);

            case MonType.ice:
                return(Color.LightBlue);

            case MonType.normal:
                return(Color.Black);

            case MonType.poison:
                return(Color.MediumPurple);

            case MonType.psychic:
                return(Color.DeepPink);

            case MonType.rock:
                return(Color.SlateGray);

            case MonType.steel:
                return(Color.Gray);

            case MonType.water:
                return(Color.RoyalBlue);

            default:
                return(Color.Black);
            }
        }