#!/bin/bash

select_char_sql="select win,pvp_point,pvp_grade from taiwan_cain.pvp_result where charac_no=$1";

char_attrs=$(mysql -ugame -p'uu5!^%jg' -e "select pvp_point,pvp_grade from taiwan_cain.pvp_result where charac_no=$1;");
pswd="uu5!^%jg";
char_attrs=${char_attrs#*pvp_point};

char_pvp_array=(${char_attrs// / });

char_point=$[${char_pvp_array[1]}+500];
char_grade=${char_pvp_array[2]};


if [ ${char_point} -lt 500 ];then
   char_grade=1;
elif [ ${char_point} -lt 1000 ];then
   char_grade=2;
elif [ ${char_point} -lt 1500 ];then
   char_grade=3;
elif [ ${char_point} -lt 2000 ];then
   char_grade=4;
elif [ ${char_point} -lt 2500 ];then
   char_grade=5;
elif [ ${char_point} -lt 3000 ];then
   char_grade=6;
elif [ ${char_point} -lt 3500 ];then
   char_grade=7;
elif [ ${char_point} -lt 4000 ];then
   char_grade=8;
elif [ ${char_point} -lt 4500 ];then
   char_grade=9;
elif [ ${char_point} -lt 5000 ];then
   char_grade=10;
elif [ ${char_point} -lt 5500 ];then
   char_grade=11;
elif [ ${char_point} -lt 6000 ];then
   char_grade=12;
elif [ ${char_point} -lt 6500 ];then
   char_grade=13;
elif [ ${char_point} -lt 7000 ];then
   char_grade=14;
elif [ ${char_point} -lt 7500 ];then
   char_grade=15;
elif [ ${char_point} -lt 8000 ];then
   char_grade=16;
elif [ ${char_point} -lt 8500 ];then
   char_grade=17;
elif [ ${char_point} -lt 9000 ];then
   char_grade=18;
elif [ ${char_point} -lt 9500 ];then
   char_grade=19;
elif [ ${char_point} -lt 10000 ];then
   char_grade=20;
elif [ ${char_point} -lt 10500 ];then
   char_grade=21;
elif [ ${char_point} -lt 11000 ];then
   char_grade=22;
elif [ ${char_point} -lt 11500 ];then
   char_grade=23;
elif [ ${char_point} -lt 12000 ];then
   char_grade=24;
elif [ ${char_point} -lt 12500 ];then
   char_grade=25;
elif [ ${char_point} -lt 13000 ];then
   char_grade=26;
elif [ ${char_point} -lt 13500 ];then
   char_grade=27;
elif [ ${char_point} -lt 14000 ];then
   char_grade=28;
elif [ ${char_point} -lt 14500 ];then
   char_grade=29;
elif [ ${char_point} -lt 15000 ];then
   char_grade=30;
elif [ ${char_point} -lt 9999999 ];then
   char_grade=31;
else
   char_grade=31;
fi

echo "update pvp_result set win=win+1,pvp_point=${char_point},pvp_grade=${char_grade},play_count=play_count+1,pvp_count=pvp_count+1,win_point=win_point+10 where charac_no=$1"
#covert_char_sql=mysql\ -ugame\ -p'uu5\!\^%jg'\ -e\ \"update\ taiwan_cain.pvp_result\ set\ win=win+1,pvp_point=${char_point},pvp_grade=${char_grade}\ where\ charac_no=$1\;\";
#covert_char_sql_sub=mysql\ -ugame\ -p'uu5\!\^%jg'\ -e\ \"update\ taiwan_cain.pvp_result\ set\ play_count=play_count+1,pvp_count=pvp_count+1,win_point=win_point+10\ where\ charac_no=$1\;\";
#echo "$covert_char_sql" >> /dp2/script/pvp_exp_inc_sql.log;
#echo "$covert_char_sql_sub" >> /dp2/script/pvp_exp_inc_sql.log;
#/bin/bash -c "$covert_char_sql";
#/bin/bash -c "$covert_char_sql_sub";
