public virtual void execute(ESMSTeam team) { //Ovvio che così non funzioni, devo stabilire se si tratta di un numero e se è una //posizione devo trovare il peggiore in quel ruolo bool isNumber = true; int p = -1; if (lastMinuteActive == CSEsMS.ESMS.ESMS.currentMinute && lastActiveTeam.Equals(team.Abbreviation)) { return; } try { p = System.Int32.Parse(player); } catch (System.FormatException e) { isNumber = false; } if (!isNumber) { p = team.electWorsePlayer(player); } //if (p==-1) throw new Exception("Unable to detect player to substitute"); if (p == -1) { return; } if (team.getPosition(p).Equals(newpos)) { return; } lastMinuteActive = CSEsMS.ESMS.ESMS.currentMinute; lastActiveTeam = team.Abbreviation; team.changePosition(p, newpos); string[] params_Renamed = new string[] { System.Convert.ToString(CSEsMS.ESMS.ESMS.currentMinute), team.Abbreviation, team.getPlayer(p).Name, newpos }; CSEsMS.ESMS.ESMS.output.Write("<ChangePosition min=\"" + params_Renamed[0] + "\" team=\"" + params_Renamed[1] + "\" player=\"" + params_Renamed[2] + "\" newPosition=\"" + params_Renamed[3] + "\">"); CSEsMS.ESMS.ESMS.output.Write(Comment.getComment().getCommentString("CHANGEPOSITION", params_Renamed)); CSEsMS.ESMS.ESMS.output.Write("</ChangePosition>"); }
public virtual void execute(ESMSTeam team) { //Ovvio che così non funzioni, devo stabilire se si tratta di un numero e se è una //posizione devo trovare il peggiore in quel ruolo bool isInNumber = true; bool isOutNumber = true; int pIn = -1, pOut = -1; if (lastMinuteActive == CSEsMS.ESMS.ESMS.currentMinute && lastActiveTeam.Equals(team.Abbreviation)) { return; } if (team.Substitutions >= Config.getConfig().Substitutions) { return; } try { pIn = System.Int32.Parse(playerIn); } catch (System.FormatException e) { isInNumber = false; } try { //System.out.println("A"+playerOut); pOut = System.Int32.Parse(playerOut); } catch (System.FormatException e) { isOutNumber = false; } if (!isOutNumber) { pOut = team.electWorsePlayer(playerOut); } if (isInNumber) { if (pOut == -1) { throw new System.Exception("Unable to detect worse player on position"); } if (((ESMSPlayer)team.getPlayer(pIn)).Status != ESMSPlayer.SUBSTITUTION || ((ESMSPlayer)team.getPlayer(pOut)).Status != ESMSPlayer.PLAYING) { return; } lastMinuteActive = CSEsMS.ESMS.ESMS.currentMinute; lastActiveTeam = team.Abbreviation; team.substitutePlayer(pOut, pIn, newpos); string[] params_Renamed = new string[] { System.Convert.ToString(CSEsMS.ESMS.ESMS.currentMinute), team.Abbreviation, team.getPlayer(pIn).Name, team.getPlayer(pOut).Name, newpos }; CSEsMS.ESMS.ESMS.output.Write("<Substitution min=\"" + params_Renamed[0] + "\" team=\"" + params_Renamed[1] + "\" playerIn=\"" + params_Renamed[2] + "\" playerOut=\"" + params_Renamed[3] + "\" position=\"" + params_Renamed[4] + "\">"); CSEsMS.ESMS.ESMS.output.Write(Comment.getComment().getCommentString("SUB", params_Renamed)); CSEsMS.ESMS.ESMS.output.Write("</Substitution>"); CSEsMS.ESMS.ESMS.output.Flush(); } else { pIn = team.electBestSub(this.playerIn); if (pOut == -1) { throw new System.Exception("Unable to detect worse player on position2"); } if (pIn == -1) { throw new System.Exception("Unable to detect best substitute on position"); } if (((ESMSPlayer)team.getPlayer(pIn)).Status != ESMSPlayer.SUBSTITUTION || ((ESMSPlayer)team.getPlayer(pOut)).Status != ESMSPlayer.PLAYING) { return; } lastMinuteActive = CSEsMS.ESMS.ESMS.currentMinute; lastActiveTeam = team.Abbreviation; team.substitutePlayer(pOut, pIn, newpos); string[] params_Renamed = new string[] { System.Convert.ToString(CSEsMS.ESMS.ESMS.currentMinute), team.Abbreviation, team.getPlayer(pIn).Name, team.getPlayer(pOut).Name, newpos }; CSEsMS.ESMS.ESMS.output.Write("<Substitution min=\"" + params_Renamed[0] + "\" team=\"" + params_Renamed[1] + "\" playerIn=\"" + params_Renamed[2] + "\" playerOut=\"" + params_Renamed[3] + "\" position=\"" + params_Renamed[4] + "\">"); CSEsMS.ESMS.ESMS.output.Write(Comment.getComment().getCommentString("SUB", params_Renamed)); CSEsMS.ESMS.ESMS.output.Write("</Substitution>"); CSEsMS.ESMS.ESMS.output.Flush(); } }