if (to instanceof Infantry) {
if (Compute.clubMechHas(from) != null) {   if (to instanceof Mech){ location_table = ToHitData.HIT_NORMAL; if ((to.getElevation() == from.getElevation()-1) && !(to.isProne())){ location_table = ToHitData.HIT_PUNCH; } if ((to.getElevation() == from.getElevation()+1) && !(to.isProne())){ location_table = ToHitData.HIT_KICK; } } else { location_table = ToHitData.HIT_NORMAL; } odds = ClubAttackAction.toHit(game, from.getId(), to, Compute.clubMechHas(from)); if (odds.getValue() != ToHitData.IMPOSSIBLE) { damage = ClubAttackAction.getDamageFor(from, Compute.clubMechHas(from)); dmg = Compute.oddsAbove(odds.getValue()) / 100.0 * damage;  dmg *= punchThroughMod(to, game, location_table, target_arc, dmg, dmg);   if (dmg > bestDmg) { bestType = PhysicalOption.USE_CLUB; bestDmg = dmg; } } }  odds = PushAttackAction.toHit(game, from.getId(), to); if (odds.getValue() != ToHitData.IMPOSSIBLE) { int elev_diff = 1; double breach = 1; boolean water_landing = false; dmg = 0; int disp_dir = from.getPosition().direction(to.getPosition()); Coords disp_c = to.getPosition().translated(disp_dir);  if (Compute.isValidDisplacement(game, to.getId(), to.getPosition(), disp_c)){   if (!game.getBoard().contains(disp_c)){ dmg = to.getTotalArmor() * Compute.oddsAbove(odds.getValue()) / 100.0; } if (game.getBoard().contains(disp_c)){  elev_diff = game.getBoard().getHex(to.getPosition()).getElevation(); elev_diff -= game.getBoard().getHex(disp_c).getElevation(); if (elev_diff < 0){ elev_diff = 0; }  if (game.getBoard().getHex(disp_c).containsTerrain(Terrains.WATER)){ water_landing = true; }   dmg = Compute.oddsAbove(odds.getValue()) / 100.0; dmg = dmg * (1 - Compute.oddsAbove(elev_diff + to.getBasePilotingRoll().getValue())/100.0); dmg = dmg * to.getWeight() * 0.1 * (1 + elev_diff);  breach = punchThroughMod(to, game, ToHitData.HIT_NORMAL, ToHitData.SIDE_FRONT, dmg, Math.min(dmg, 5));  if ((breach > 1) && water_landing){ breach *= 2; }  if (to.getWalkMP() > 0){ dmg = dmg * Math.sqrt((1/(double)to.getWalkMP()) + to.getJumpMP()); } else { dmg = dmg * Math.max(1, Math.sqrt((double)to.getJumpMP())); }  dmg *= breach; } }  if (!Compute.isValidDisplacement(game, to.getId(), to.getPosition(), disp_c)){  if (game.getBoard().getHex(to.getPosition()).containsTerrain(Terrains.WATER)){ water_landing = true; }   dmg = Compute.oddsAbove(odds.getValue()) / 100.0; dmg = dmg * (1 - Compute.oddsAbove(to.getBasePilotingRoll().getValue())/100.0); dmg = dmg * to.getWeight() * 0.1;  breach = punchThroughMod(to, game, ToHitData.HIT_NORMAL, ToHitData.SIDE_FRONT, dmg, Math.min(dmg, 5));  if ((breach > 1) && water_landing){ breach *= 2; }  if (to.getWalkMP() > 0){ dmg = dmg * Math.sqrt((1/to.getWalkMP()) + to.getJumpMP()); } else { dmg = dmg * Math.max(1, Math.sqrt(to.getJumpMP())); }  dmg *= breach; }  if (dmg > bestDmg) { bestType = PhysicalOption.PUSH_ATTACK; bestDmg = dmg; } }   if ((to instanceof Infantry) && !(to instanceof BattleArmor)) {
    PhysicalOption getBestPhysicalAttack(Entity from, Entity to, IGame game) {        double bestDmg = 0, dmg;        int damage;        int bestType = PhysicalOption.PUNCH_LEFT;        // Infantry can't conduct physical attacks.        if (from instanceof Infantry) {            return null;        }        ToHitData odds = PunchAttackAction.toHit(game, from.getId(), to, PunchAttackAction.LEFT);        if (odds.getValue() != ToHitData.IMPOSSIBLE) {            damage = PunchAttackAction.getDamageFor(from, PunchAttackAction.LEFT);            bestDmg = Compute.oddsAbove(odds.getValue()) / 100.0 * damage;        }        odds = PunchAttackAction.toHit(game, from.getId(), to, PunchAttackAction.RIGHT);        if (odds.getValue() != ToHitData.IMPOSSIBLE) {            damage = PunchAttackAction.getDamageFor(from, PunchAttackAction.RIGHT);            dmg = Compute.oddsAbove(odds.getValue()) / 100.0 * damage;            if (dmg > 0 && bestDmg > 0) {                bestType = PhysicalOption.PUNCH_BOTH;                bestDmg += dmg;            } else {                bestType = PhysicalOption.PUNCH_RIGHT;                bestDmg = dmg;            }        }        odds = KickAttackAction.toHit(game, from.getId(), to, KickAttackAction.LEFT);        if (odds.getValue() != ToHitData.IMPOSSIBLE) {            damage = KickAttackAction.getDamageFor(from, KickAttackAction.LEFT);            dmg = Compute.oddsAbove(odds.getValue()) / 100.0 * damage;            if (dmg > bestDmg) {                bestType = PhysicalOption.KICK_LEFT;                bestDmg = dmg;            }        }        odds = KickAttackAction.toHit(game, from.getId(), to, KickAttackAction.RIGHT);        if (odds.getValue() != ToHitData.IMPOSSIBLE) {            damage = KickAttackAction.getDamageFor(from, KickAttackAction.RIGHT);            dmg = Compute.oddsAbove(odds.getValue()) / 100.0 * damage;            if (dmg > bestDmg) {                bestType = PhysicalOption.KICK_RIGHT;                bestDmg = dmg;            }        }        // Infantry in the open suffer double damage.        if (to instanceof Infantry) {            IHex e_hex = game.getBoard().getHex(to.getPosition());            if (!e_hex.containsTerrain(Terrains.WOODS) && !e_hex.containsTerrain(Terrains.BUILDING)) {                bestDmg *= 2;            }        }        if (bestDmg > 0) {            return new PhysicalOption(from, to, bestDmg, bestType);        }        return null;    }