Exemplo n.º 1
0
        public static byte[] Upgrade(byte[] invoker, BigInteger feature)
        {
            Player     player = FindPlayer(invoker);
            BigInteger lvl    = -1;

            if (feature == 0)
            {
                lvl = player.lvlAtk;
            }
            else if (feature == 1)
            {
                lvl = player.lvlDef;
            }
            else if (feature == 2)
            {
                lvl = player.lvlSpd;
            }
            else if (feature == 3)
            {
                lvl = player.lvlHP;
            }
            else if (feature == 4)
            {
                lvl = player.lvlRev;
            }
            int f = Op.BigInt2Int(feature);

            BigInteger[] pimetals = AmountUpgrade(f, lvl + 1);
            if (player.water >= pimetals[0] && player.soil >= pimetals[1] &&
                player.wind >= pimetals[2] && player.fire >= pimetals[3])
            {
                player.water -= pimetals[0];
                player.soil  -= pimetals[1];
                player.wind  -= pimetals[2];
                player.fire  -= pimetals[3];

                if (feature == 0)
                {
                    player.lvlAtk += 1;
                }
                else if (feature == 1)
                {
                    player.lvlDef += 1;
                }
                else if (feature == 2)
                {
                    player.lvlSpd += 1;
                }
                else if (feature == 3)
                {
                    player.lvlHP += 1;
                }
                else if (feature == 4)
                {
                    player.lvlRev += 1;
                }
                return(NuTP.RespDataSuccess());
            }
            else
            {
                return(NuTP.RespDataWithCode(NuTP.SysDom, NuTP.Code.BadRequest));
            }
        }