public BattleHUD() { _abilityDetailDict = new Dictionary <Int32, AbilityPlayerDetail>(); _magicSwordCond = new MagicSwordCondition(); _enemyCount = -1; _playerCount = -1; _currentCharacterHp = new List <ParameterStatus>(); _currentEnemyDieState = new List <Boolean>(); _hpInfoVal = new List <DamageAnimationInfo>(); _mpInfoVal = new List <DamageAnimationInfo>(); _currentMpValue = -1; _currentButtonGroup = String.Empty; CurrentPlayerIndex = -1; _currentTargetIndex = -1; _targetIndexList = new List <Int32>(); ReadyQueue = new List <Int32>(); InputFinishList = new List <Int32>(); _unconsciousStateList = new List <Int32>(); _firstCommand = new CommandDetail(); _commandCursorMemorize = new Dictionary <Int32, CommandMenu>(); _ability1CursorMemorize = new Dictionary <Int32, Int32>(); _ability2CursorMemorize = new Dictionary <Int32, Int32>(); _itemCursorMemorize = new Dictionary <Int32, Int32>(); _matchBattleIdPlayerList = new List <Int32>(); _matchBattleIdEnemyList = new List <Int32>(); _itemIdList = new List <Int32>(); _oneTime = true; }
protected void HandleServerAuthResponse(InPacket packet) { CommandDetail detail = (CommandDetail)packet.ReadByte(); uint billingTimeRemaining = packet.ReadUInt32(); byte billingFlags = packet.ReadByte(); uint billingTimeRested = packet.ReadUInt32(); byte expansion = packet.ReadByte(); if (detail == CommandDetail.AuthSuccess) { OutPacket request = new OutPacket(WorldCommand.CMSG_CHAR_ENUM); Send(request); } else { Game.UI.LogLine(string.Format("Authentication succeeded, but received response {0}", detail)); Game.UI.Exit(); } }
protected void HandleServerAuthResponse(InPacket packet) { CommandDetail detail = (CommandDetail)packet.ReadByte(); uint billingTimeRemaining = packet.ReadUInt32(); byte billingFlags = packet.ReadByte(); uint billingTimeRested = packet.ReadUInt32(); byte expansion = packet.ReadByte(); if (detail == CommandDetail.AUTH_OK) { OutPacket request = new OutPacket(WorldCommand.CMSG_CHAR_ENUM); Send(request); AuthFrame.ShowCharacterUI = true; Exchange.AuthMessage = "Retrieving character list..."; } else { Exchange.AuthMessage = "Authentication succeeded, but received response " + detail; } }
public override void ExecuteCommand(TCPSocketSession session, StringRequestInfo requestInfo) { if (requestInfo.Parameters.Count() != CommonTools.OUTGOINGTRYSUCCESS_PARACOUNT) //need 3 parameters { session.AppServer.Logger.Error("CustomLog CALLSTART PARAMETER MUST BE 7 , now is :" + requestInfo.Key + @":" + requestInfo.Body); return; } CommandDetail cmdDetail = new CommandDetail(); cmdDetail.requestID = Guid.NewGuid().ToString(); cmdDetail.sessionIP = session.RemoteEndPoint.ToString(); cmdDetail.sessionID = session.SessionID; cmdDetail.commandName = this.Name; cmdDetail.cmd_recv_time = DateTime.Now; cmdDetail.cmd_content = requestInfo.Key + @":" + requestInfo.Body; string strCallID = requestInfo.Parameters[0].ToString(); string strNAPout = requestInfo.Parameters[3].ToString(); string sSendToMonitor = "From " + requestInfo.Key + @":" + requestInfo.Body; //Console.WriteLine("callid {0} callstart have recv at {1}", strCallID, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff")); ((TCPSocketServer)session.AppServer).Logger.Debug("callid " + strCallID + " callstart have recv at " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff")); #region new methoc use tcpserver cache CacheItem ci = new CacheItem(); ci.session = session; ci.commandKey = requestInfo.Key; ci.commandParameter = requestInfo.Body; ci.cDetail = cmdDetail; ci.sToMonitor = sSendToMonitor; if (!((TCPSocketServer)session.AppServer).cacheList.enQueue(ci)) { Console.WriteLine("cache have full"); //TODO : if queue is full , what about this request , return will lose it return; } #endregion string sReply = @"<reply>" + @"OUTGOINGTRYSUCCESS;" + strCallID + @"," + strNAPout + @",OK" + @"</reply>"; byte[] rv = Encoding.ASCII.GetBytes(sReply); try { //Console.WriteLine("quick reply " + sReply + " {0} times", session.iTotalRecv); cmdDetail.cmd_reply_time = DateTime.Now; session.Send(rv, 0, rv.Length); // reply OK first sSendToMonitor = sSendToMonitor + "To " + "OUTGOINGTRYSUCCESSIsOK"; //throw TODO simulate send error ; } catch (Exception tc) //for exampleTimeoutException { cmdDetail.cmd_reply_time = DateTime.Now; session.AppServer.Logger.Error("send OUTGOINGTRYSUCCESS ok back error"); //Console.WriteLine("send ROUTEREQUEST ok back error"); //when become service , will print this line in output window cmdDetail.reply_content = sReply; cmdDetail.err_reason = "send OUTGOINGTRYSUCCESS ok back time out"; //write log , send what fail ((TCPSocketServer)session.AppServer).CommandDetailList.Enqueue(cmdDetail); sSendToMonitor = @"<reply>NORMALLOG@" + sSendToMonitor + @". error:send ok back time out" + @"</reply>"; CommonTools.SendToEveryMonitor(sSendToMonitor, session); return; } return; } //end of execute command
public override void ExecuteCommand(TCPSocketSession session, StringRequestInfo requestInfo) { if (requestInfo.Parameters.Count() != CommonTools.ROUTEREQUEST_PARACOUNT) { // if need send back TODO session.Send("The wrong format\r\n"); session.AppServer.Logger.Error("CustomLog ROUTEREQUEST PARAMETER MUST BE 5 , now is :" + requestInfo.Key + @":" + requestInfo.Body); return; } CommandDetail cmdDetail = new CommandDetail(); cmdDetail.requestID = Guid.NewGuid().ToString(); cmdDetail.sessionIP = session.RemoteEndPoint.ToString(); cmdDetail.sessionID = session.SessionID; cmdDetail.commandName = this.Name; cmdDetail.cmd_recv_time = DateTime.Now; cmdDetail.cmd_content = requestInfo.Key + @":" + requestInfo.Body; //now cmdDetail only left reply content and err reason is empty string strCallID = requestInfo.Parameters[0].ToString(); //Console.WriteLine("callid {0} route request have recv at {1}", strCallID,DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff")); ((TCPSocketServer)session.AppServer).Logger.Debug("callid " + strCallID + " route request have recv at " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff")); session.iTotalRecv++; #region SaveRequestIntoSQL // using (SqlConnection conn = new SqlConnection(Properties.Settings.Default.ConnectionString.ToString())) //{ // SqlCommand sqlCmd = null; // SqlCommand sqlCmdUpdate = null; // DateTime dtNow = DateTime.Now; // try // { // conn.Open(); // sqlCmdUpdate = new SqlCommand("insert into Table_RequestReply ( Session_SN,Request_ID,Request_Content) values ( @SessionSN,@RequestID,@RequestBody) ", conn); // sqlCmdUpdate.Parameters.AddWithValue("@SessionSN", session.SN); // sqlCmdUpdate.Parameters.AddWithValue("@RequestID", requestID); // sqlCmdUpdate.Parameters.AddWithValue("@RequestBody", requestInfo.Body); // sqlCmdUpdate.CommandTimeout = 200; // if (conn.State == ConnectionState.Closed) // conn.Open(); // try // { // sqlCmdUpdate.ExecuteNonQuery(); // } // catch (Exception aep) // { // // File.AppendAllText(strCurrentPath + @"\test.txt", "insert error " + aep.Message + "\r\n"); // return; // } // } // catch (Exception cep) // { // } //} //using (SqlConnection conn = new SqlConnection(Properties.Settings.Default.ConnectionString.ToString())) //{ // SqlCommand sqlCmd = null; // SqlCommand sqlCmdUpdate = null; // DateTime dtNow = DateTime.Now; // try // { // conn.Open(); // sqlCmdUpdate = new SqlCommand("update SessionTable set Session_Total_Recv_Request = @SessionRecv, Session_Total_Handle_Request= @SessionHandled where Session_SN = @SessionID", conn); // sqlCmdUpdate.Parameters.AddWithValue("@SessionID", session.SN); // sqlCmdUpdate.Parameters.AddWithValue("@SessionRecv", session.iTotalRecv); // sqlCmdUpdate.Parameters.AddWithValue("@SessionHandled", session.iTotalFinish); // sqlCmdUpdate.CommandTimeout = 200; // if (conn.State == ConnectionState.Closed) // conn.Open(); // try // { // sqlCmdUpdate.ExecuteNonQuery(); // } // catch (Exception aep) // { // // File.AppendAllText(strCurrentPath + @"\test.txt", "insert error " + aep.Message + "\r\n"); // return; // } // } // catch (Exception cep) // { // } //} #endregion string sSendToMonitor = "From " + requestInfo.Key + @":" + requestInfo.Body; #region new methoc use tcpserver cache CacheItem ci = new CacheItem(); ci.session = session; ci.commandKey = requestInfo.Key; ci.commandParameter = requestInfo.Body; ci.cDetail = cmdDetail; ci.sToMonitor = sSendToMonitor; if (!((TCPSocketServer)session.AppServer).cacheList.enQueue(ci)) { Console.WriteLine("cache have full"); //TODO : if queue is full , what about this request , return will lose it return; } #endregion string sReply = @"<reply>" + @"ROUTEREQUEST;" + strCallID + @",GetNapRouteIsOK" + @"</reply>"; byte[] rv = Encoding.ASCII.GetBytes(sReply); try { //Console.WriteLine("quick reply " + sReply + " {0} times", session.iTotalRecv); cmdDetail.cmd_reply_time = DateTime.Now; session.Send(rv, 0, rv.Length); // reply OK first sSendToMonitor = sSendToMonitor + "To " + "GetNapRouteIsOK"; //throw TODO simulate send error ; } catch (Exception tc) //for exampleTimeoutException { cmdDetail.cmd_reply_time = DateTime.Now; session.AppServer.Logger.Error("send ROUTEREQUEST ok back error"); //Console.WriteLine("send ROUTEREQUEST ok back error"); //when become service , will print this line in output window cmdDetail.reply_content = sReply; cmdDetail.err_reason = "send ROUTEREQUEST ok back time out"; //write log , send what fail ((TCPSocketServer)session.AppServer).CommandDetailList.Enqueue(cmdDetail); sSendToMonitor = @"<reply>NORMALLOG@" + sSendToMonitor + @". error:send ok back time out" + @"</reply>"; CommonTools.SendToEveryMonitor(sSendToMonitor, session); return; } //put all parameter into one class 2017-6-1 temp comment old method //classParameterSessionAndRequestID cp1 = new classParameterSessionAndRequestID(); //cp1.ts = session; //cp1.sToMonitor = sSendToMonitor; //cp1.cmdDetail = cmdDetail; //ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadWhichWillCallSQL), cp1); //put all parameter into one class 2017-6-1 temp comment return; }
public override Boolean OnKeyConfirm(GameObject go) { if (!base.OnKeyConfirm(go) || _hidingHud) { return(true); } if (ButtonGroupState.ActiveGroup == CommandGroupButton) { FF9Sfx.FF9SFX_Play(103); _currentCommandIndex = (CommandMenu)go.transform.GetSiblingIndex(); _currentCommandId = (UInt32)GetCommandFromCommandIndex(_currentCommandIndex, CurrentPlayerIndex); _commandCursorMemorize[CurrentPlayerIndex] = _currentCommandIndex; _subMenuType = SubMenuType.Normal; if (IsDoubleCast && _doubleCastCount < 2) { ++_doubleCastCount; } switch (_currentCommandIndex) { case CommandMenu.Attack: SetCommandVisibility(false, false); SetTargetVisibility(true); break; case CommandMenu.Defend: _targetCursor = 0; SendCommand(ProcessCommand(CurrentPlayerIndex, CursorGroup.Individual)); SetIdle(); break; case CommandMenu.Ability1: case CommandMenu.Ability2: //int num = currentCommandIndex != CommandMenu.Ability2 ? 0 : 1; CharacterCommand ff9Command = CharacterCommands.Commands[_currentCommandId]; if (ff9Command.Type == CharacterCommandType.Normal) { _subMenuType = SubMenuType.Normal; SetCommandVisibility(false, false); SetTargetVisibility(true); break; } if (ff9Command.Type == CharacterCommandType.Ability) { _subMenuType = SubMenuType.Ability; DisplayAbility(); SetCommandVisibility(false, false); SetAbilityPanelVisibility(true, false); break; } if (ff9Command.Type == CharacterCommandType.Throw) { _subMenuType = SubMenuType.Throw; DisplayItem(true); SetCommandVisibility(false, false); SetItemPanelVisibility(true, false); } break; case CommandMenu.Item: DisplayItem(false); SetCommandVisibility(false, false); SetItemPanelVisibility(true, false); break; case CommandMenu.Change: _targetCursor = 0; CommandDetail command = ProcessCommand(CurrentPlayerIndex, CursorGroup.Individual); if (_isManualTrance) { command.SubId = 96; // Trance } SendCommand(command); SetIdle(); break; } } else if (ButtonGroupState.ActiveGroup == TargetGroupButton) { FF9Sfx.FF9SFX_Play(103); if (_cursorType == CursorGroup.Individual) { for (Int32 i = 0; i < _matchBattleIdEnemyList.Count; i++) { if (i < _targetPanel.Enemies.Count && _targetPanel.Enemies[i].GameObject == go) { CheckDoubleCast(_matchBattleIdEnemyList[i], _cursorType); return(true); } } for (Int32 i = 0; i < _matchBattleIdPlayerList.Count; i++) { if (i < _targetPanel.Players.Count && _targetPanel.Players[i].GameObject == go) { CheckDoubleCast(_matchBattleIdPlayerList[i], _cursorType); return(true); } } } else if (_cursorType == CursorGroup.AllPlayer || _cursorType == CursorGroup.AllEnemy || _cursorType == CursorGroup.All) { CheckDoubleCast(-1, _cursorType); } } else if (ButtonGroupState.ActiveGroup == AbilityGroupButton) { if (CheckAbilityStatus(go.GetComponent <RecycleListItem>().ItemDataIndex) == AbilityStatus.Enable) { FF9Sfx.FF9SFX_Play(103); _currentSubMenuIndex = go.GetComponent <RecycleListItem>().ItemDataIndex; if (_currentCommandIndex == CommandMenu.Ability1) { _ability1CursorMemorize[CurrentPlayerIndex] = _currentSubMenuIndex; } else { _ability2CursorMemorize[CurrentPlayerIndex] = _currentSubMenuIndex; } SetAbilityPanelVisibility(false, false); SetTargetVisibility(true); } else { FF9Sfx.FF9SFX_Play(102); } } else if (ButtonGroupState.ActiveGroup == ItemGroupButton) { if (_itemIdList[_currentSubMenuIndex] != Byte.MaxValue) { FF9Sfx.FF9SFX_Play(103); _currentSubMenuIndex = go.GetComponent <RecycleListItem>().ItemDataIndex; _itemCursorMemorize[CurrentPlayerIndex] = _currentSubMenuIndex; SetItemPanelVisibility(false, false); SetTargetVisibility(true); } else { FF9Sfx.FF9SFX_Play(102); } } return(true); }
private static void displayCommand(ResultBuilder builder, CommandDetail detail) { builder.WriteLine(); builder.WriteLine(string.Format("COMMAND: {0}", detail.Name)); builder.WriteLine(string.Format(" {0}", detail.Help)); builder.WriteLine(); builder.WriteLine(string.Format("USAGE: {0}", detail.Usage)); }
public override void CharacterCreationFailed(CommandDetail result) { #warning ToDo: create a character with a different name Log($"Bot {Username} failed creating a character with error {result.ToString()}", LogLevel.Error); }