@echo off
SETLOCAL EnableExtensions DisableDelayedExpansion
if not ''=='%1' if not '%1'=='--help' if not '%1'=='?' if not '%1'=='/?' goto NoHelp
echo Syntax: wows-class _player_name _class [_race] [male^|female]
echo Example:
echo   wows-class.cmd Marenzu Priest Undead Male
echo Examples of _class _race combinations:
echo   Paladin
echo   warrior gnome
echo   Druid race
echo   class DWARF
echo   "" "DWARF"
echo   mage 1
echo   3 1
EXIT /B 254

:NoHelp
call .\wows-where.cmd& if errorlevel 1 exit /b 253
set "MYOP=%BASEDIR%\_MySQL\bin\mysql.exe --user=root --password=ascent characters"
set "CLASS=%~2"
if "%CLASS%"=="" set CLASS=class
set _RACE=NightElf
if /I "%CLASS%"=="Warrior"     set CLASS=1& set "_RACE=Human"
if /I "%CLASS%"=="Paladin"     set CLASS=2& set "_RACE=Human"
if /I "%CLASS%"=="Hunter"      set CLASS=3& set "_RACE=NightElf"
if /I "%CLASS%"=="Rogue"       set CLASS=4& set "_RACE=Human"
if /I "%CLASS%"=="Priest"      set CLASS=5& set "_RACE=Human"
if /I "%CLASS%"=="DeathKnight" set CLASS=6& set "_RACE=Human"
if /I "%CLASS%"=="Shaman"      set CLASS=7& set "_RACE=Tauren"
if /I "%CLASS%"=="Mage"        set CLASS=8& set "_RACE=Human"
if /I "%CLASS%"=="Warlock"     set CLASS=9& set "_RACE=Human"
if /I "%CLASS%"=="Druid"      set CLASS=11& set "_RACE=NightElf"
if /I "%~1"=="Lylanva" (
  set _RACE=BloodElf
  if /I "%~2"=="Warrior" set "_RACE=Tauren"
  if /I "%~2"=="Shaman"  set "_RACE=Tauren"
  if /I "%~2"=="Druid"   set "_RACE=Tauren"
)
echo SELECT class,race,gender FROM characters WHERE name="%~1"; |%MYOP%

set "RACE=%~3"
if "%CLASS%"=="class" if "%RACE%"=="" EXIT /B 252
if "%RACE%"=="" set "RACE=%_RACE%"
set PB=PlayerBytes & set PBB=PlayerBytes2 & set mPB=PlayerBytes& set mPBB=PlayerBytes2
REM PB  hairColor | hairStyle | faceStyle/hornStyle | skinColor (младший байт)
REM PB  hornColor | faceStyle | hornStyle | skinColor
REM PBB facialHair/Piercings/Markings/Braids
if /I "%RACE%"=="Human"    set RACE=1 & set PB=0x000E0506 & set PBB=0x01 & REM set PB=0x030A0206 & set PBB=0x00
if /I "%RACE%"=="Orc"      set RACE=2 & set PB=0x00060405 & set PBB=0x01
if /I "%RACE%"=="Dwarf"    set RACE=3 & set PB=0x050D0103 & set PBB=0x05 &REM set PB=0x02090108 & set PBB=0x05
if /I "%RACE%"=="NightElf" set RACE=4 & set PB=0x07000307 & set PB=0x07000707 & set PBB=0x09 &REM 09=без знаков на лице; 01=нормально выглядящие знаки
if /I "%RACE%"=="Undead"   set RACE=5 & set PB=0x08020002 & set PBB=0x00 & set mPB=0x00050100 & set mPB=0x01050104 & set mPBB=0x00
if /I "%RACE%"=="Tauren"   set RACE=6 & set PB=0x01000200 & set PBB=0x01 &REM set PB=0x01000204 & set PBB=0x04
if /I "%RACE%"=="Gnome"    set RACE=7 & set PB=0x08040004 & set PBB=0x02
if /I "%RACE%"=="Troll"    set RACE=8 & set PB=0x01010503 & set PBB=0x01 & set mPB=0x02050403 & set mPBB=0x00
if /I "%RACE%"=="Goblin"   set RACE=9 & set PB=0x00000000 & set PBB=0x00
if /I "%RACE%"=="BloodElf" set RACE=10& set PB=0x050B0603 & set PBB=0x0A &REM set PB=0x010B0609& set PBB=0x02
if /I "%RACE%"=="Draenei"  set RACE=11& set PB=0x06080605 & set PBB=0x04
if /I "%RACE%"=="Worgen"   set RACE=22& set PB=0x01010101 & set PBB=0x01
set GENDER=gender
if /I "%~4"=="male"   set GENDER=0& set "PB=%mPB%"& set "PBB=%mPBB%"
if /I "%~4"=="female" set GENDER=1
echo UPDATE characters SET class=%CLASS%, race=%RACE%, gender=%GENDER%, PlayerBytes=%PB%, PlayerBytes2=(PlayerBytes2 ^^^& ~0xff) ^^^| (%PBB% ^^^& 0xff) WHERE name="%~1"; |%MYOP% -v -v
