public virtual bool isTrue(ESMSTeam team, ESMSTeam opponent, int min) { int diff = team.Score - opponent.Score; // HZ: cambie Condition_Fields de STRUC a ENUM y agregue (Condition_Fields) al SWITCH switch ((Condition_Fields)sign) { case Engine.Conditions.Condition_Fields.EQUALS: { return(diff == scoreDiff); } case Engine.Conditions.Condition_Fields.GREATER: { return(diff > scoreDiff); } case Engine.Conditions.Condition_Fields.LESS: { return(diff < scoreDiff); } case Engine.Conditions.Condition_Fields.GREATEREQUALS: { return(diff >= scoreDiff); } case Engine.Conditions.Condition_Fields.LESSEQUALS: { return(diff <= scoreDiff); } default: { throw new System.Exception("Sign is not of the available one"); } } }
public virtual bool isTrue(ESMSTeam team, ESMSTeam away, int Minute) { // HZ: converti Condition_Fields de STRUC a ENUM y agregue (Condition_Fields) en el SWITCH switch ((Condition_Fields)sign) { case Engine.Conditions.Condition_Fields.EQUALS: { return(Minute == minute); } case Engine.Conditions.Condition_Fields.GREATER: { return(Minute > minute); } case Engine.Conditions.Condition_Fields.LESS: { return(Minute < minute); } case Engine.Conditions.Condition_Fields.GREATEREQUALS: { return(Minute >= minute); } case Engine.Conditions.Condition_Fields.LESSEQUALS: { return(Minute <= minute); } default: { throw new System.Exception("Sign is not of the available one"); } } }
public virtual void execute(ESMSTeam team) { if (team.Tactic.Name.Equals(tacticName) || (lastMinuteActive == CSEsMS.ESMS.ESMS.currentMinute && lastActiveTeam.Equals(team.Abbreviation))) { return; } lastMinuteActive = CSEsMS.ESMS.ESMS.currentMinute; lastActiveTeam = team.Abbreviation; team.Tactic = (Tactic)Tactic._Tactics[tacticName]; CSEsMS.ESMS.ESMS.output.Write("<ChangeTactic min=\"" + CSEsMS.ESMS.ESMS.currentMinute + "\" team=\""); CSEsMS.ESMS.ESMS.output.Write(team.Abbreviation + "\" tactic=\"" + tacticName + "\">"); string[] params_Renamed = new string[] { System.Convert.ToString(CSEsMS.ESMS.ESMS.currentMinute), team.Abbreviation, team.Name, tacticName }; CSEsMS.ESMS.ESMS.output.Write(Comment.getComment().getCommentString("CHANGETACTIC", params_Renamed)); CSEsMS.ESMS.ESMS.output.Write("</ChangeTactic>"); CSEsMS.ESMS.ESMS.output.Flush(); }
public virtual bool isTrue(ESMSTeam team, ESMSTeam away, int min) { /* I need to know if player is a number or a position */ int number = -1; bool isNumber = true; if (team.RedCarded == null) { return(false); } try { number = System.Int32.Parse(this.player); } catch (System.FormatException err) { isNumber = false; } if (!isNumber) { if (team.getPosition(team.RedCarded).Equals(player)) { return(true); } else { return(false); } } else { if (team.RedCarded.Name.Equals(team.getPlayer(number).Name)) { return(true); } else { return(false); } } }
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(); } }