📄 physicaldisplay.java
字号:
/** * Does turn start stuff */ private void beginMyTurn() { // There's special processing for countering break grapple. if ( client.game.getTurn() instanceof GameTurn.CounterGrappleTurn) { disableButtons(); selectEntity(((GameTurn.CounterGrappleTurn)client.game.getTurn()).getEntityNum()); grapple(true); ready(); } else { target(null); selectEntity(client.getFirstEntityNum()); setNextEnabled(true); butDone.setEnabled(true); butMore.setEnabled(true); } clientgui.setDisplayVisible(true); clientgui.getBoardView().select(null); } /** * Does end turn stuff. */ private void endMyTurn() { // end my turn, then. Entity next = client.game.getNextEntity(client.game.getTurnIndex()); if (IGame.PHASE_PHYSICAL == client.game.getPhase() && null != next && null != ce() && next.getOwnerId() != ce().getOwnerId()) { clientgui.setDisplayVisible(false); } cen = Entity.NONE; target(null); clientgui.getBoardView().select(null); clientgui.getBoardView().highlight(null); clientgui.getBoardView().cursor(null); clientgui.bv.clearMovementData(); disableButtons(); } /** * Disables all buttons in the interface */ private void disableButtons() { setKickEnabled(false); setPunchEnabled(false); setPushEnabled(false); setTripEnabled(false); setGrappleEnabled(false); setJumpJetEnabled(false); setClubEnabled(false); setBrushOffEnabled(false); setThrashEnabled(false); setDodgeEnabled(false); setProtoEnabled(false); setExplosivesEnabled(false); butDone.setEnabled(false); setNextEnabled(false); } /** * Called when the current entity is done with physical attacks. */ private void ready() { if (attacks.isEmpty() && GUIPreferences.getInstance().getNagForNoAction()) { // comfirm this action ConfirmDialog response = clientgui.doYesNoBotherDialog(Messages.getString("PhysicalDisplay.DontPhysicalAttackDialog.title") //$NON-NLS-1$ , Messages.getString("PhysicalDisplay.DontPhysicalAttackDialog.message")); //$NON-NLS-1$ if (!response.getShowAgain()) { GUIPreferences.getInstance().setNagForNoAction(false); } if (!response.getAnswer()) { return; } } disableButtons(); client.sendAttackData(cen, attacks); attacks.removeAllElements(); } /** * Clears all current actions */ private void clearattacks() { if (attacks.size() > 0) { attacks.removeAllElements(); } clientgui.mechD.wPan.displayMech(ce()); updateTarget(); Entity entity = client.game.getEntity(cen); entity.dodging = true; } /** * Punch the target! */ private void punch() { final ToHitData leftArm = PunchAttackAction.toHit(client.game, cen, target, PunchAttackAction.LEFT); final ToHitData rightArm = PunchAttackAction.toHit(client.game, cen, target, PunchAttackAction.RIGHT); String title = Messages.getString("PhysicalDisplay.PunchDialog.title", new Object[]{target.getDisplayName()}); //$NON-NLS-1$ String message = Messages.getString("PhysicalDisplay.PunchDialog.message", new Object[]{//$NON-NLS-1$ rightArm.getValueAsString(), new Double(Compute.oddsAbove(rightArm.getValue())), rightArm.getDesc(), new Integer(PunchAttackAction.getDamageFor(ce(), PunchAttackAction.RIGHT)), rightArm.getTableDesc(), leftArm.getValueAsString(), new Double(Compute.oddsAbove(leftArm.getValue())), leftArm.getDesc(), new Integer(PunchAttackAction.getDamageFor(ce(), PunchAttackAction.LEFT)), leftArm.getTableDesc()}); if (clientgui.doYesNoDialog(title, message)) { disableButtons(); // declare searchlight, if possible if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) { doSearchlight(); } if (leftArm.getValue() != ToHitData.IMPOSSIBLE && rightArm.getValue() != ToHitData.IMPOSSIBLE) { attacks.addElement(new PunchAttackAction(cen, target.getTargetType(), target.getTargetId(), PunchAttackAction.BOTH)); } else if (leftArm.getValue() < rightArm.getValue()) { attacks.addElement(new PunchAttackAction(cen, target.getTargetType(), target.getTargetId(), PunchAttackAction.LEFT)); } else { attacks.addElement(new PunchAttackAction(cen, target.getTargetType(), target.getTargetId(), PunchAttackAction.RIGHT)); } ready(); } } private void doSearchlight() { // validate if (ce() == null || target == null) { throw new IllegalArgumentException("current searchlight parameters are invalid"); //$NON-NLS-1$ } if (!SearchlightAttackAction.isPossible(client.game, cen, target, null)) return; //create and queue a searchlight action SearchlightAttackAction saa = new SearchlightAttackAction(cen, target.getTargetType(), target.getTargetId()); attacks.addElement(saa); // and add it into the game, temporarily client.game.addAction(saa); clientgui.bv.addAttack(saa); clientgui.bv.repaint(100); clientgui.minimap.drawMap(); //and prevent duplicates setSearchlightEnabled(false); //refresh weapon panel, as bth will have changed updateTarget(); } /** * Kick the target! */ private void kick() { ToHitData leftLeg = KickAttackAction.toHit(client.game, cen, target, KickAttackAction.LEFT); ToHitData rightLeg = KickAttackAction.toHit(client.game, cen, target, KickAttackAction.RIGHT); ToHitData rightRearLeg = null; ToHitData leftRearLeg = null; if (client.game.getEntity(cen) instanceof QuadMech && client.game.getOptions().booleanOption("maxtech_mulekicks")) { rightRearLeg = KickAttackAction.toHit(client.game, cen, target, KickAttackAction.RIGHTMULE); leftRearLeg = KickAttackAction.toHit(client.game, cen, target, KickAttackAction.LEFTMULE); } ToHitData attackLeg; int attackSide = KickAttackAction.LEFT; int value = leftLeg.getValue(); attackLeg = leftLeg; if (value > rightLeg.getValue()) { value = rightLeg.getValue(); attackSide = KickAttackAction.RIGHT; attackLeg = rightLeg; } if (client.game.getEntity(cen) instanceof QuadMech && client.game.getOptions().booleanOption("maxtech_mulekicks")) { if (value > rightRearLeg.getValue()) { value = rightRearLeg.getValue(); attackSide = KickAttackAction.RIGHTMULE; attackLeg = rightRearLeg; } if (value > leftRearLeg.getValue()) { value = leftRearLeg.getValue(); attackSide = KickAttackAction.LEFTMULE; attackLeg = leftRearLeg; } } String title = Messages.getString("PhysicalDisplay.KickDialog.title", new Object[]{target.getDisplayName()}); //$NON-NLS-1$ String message = Messages.getString("PhysicalDisplay.KickDialog.message", new Object[]{//$NON-NLS-1$ attackLeg.getValueAsString(), new Double(Compute.oddsAbove(attackLeg.getValue())), attackLeg.getDesc() , KickAttackAction.getDamageFor(ce(), attackSide) + attackLeg.getTableDesc()}); if (clientgui.doYesNoDialog(title, message)) { disableButtons(); // declare searchlight, if possible if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) { doSearchlight(); } attacks.addElement(new KickAttackAction(cen, target.getTargetType(), target.getTargetId(), attackSide)); ready(); } } /** * Push that target! */ private void push() { ToHitData toHit = PushAttackAction.toHit(client.game, cen, target); String title = Messages.getString("PhysicalDisplay.PushDialog.title", new Object[]{target.getDisplayName()}); //$NON-NLS-1$ String message = Messages.getString("PhysicalDisplay.PushDialog.message", new Object[]{//$NON-NLS-1$ toHit.getValueAsString(), new Double(Compute.oddsAbove(toHit.getValue())), toHit.getDesc()}); if (clientgui.doYesNoDialog(title, message)) { disableButtons(); // declare searchlight, if possible if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) { doSearchlight(); } attacks.addElement(new PushAttackAction(cen, target.getTargetType(), target.getTargetId(), target.getPosition())); ready(); } } /** * Trip that target! */ private void trip() { ToHitData toHit = TripAttackAction.toHit(client.game, cen, target); String title = Messages.getString("PhysicalDisplay.TripDialog.title", new Object[]{target.getDisplayName()}); //$NON-NLS-1$ String message = Messages.getString("PhysicalDisplay.TripDialog.message", new Object[]{ //$NON-NLS-1$ toHit.getValueAsString(), new Double(Compute.oddsAbove(toHit.getValue())),toHit.getDesc()}); if (clientgui.doYesNoDialog( title, message)){ disableButtons(); // declare searchlight, if possible if(GUIPreferences.getInstance().getAutoDeclareSearchlight()) { doSearchlight(); } attacks.addElement(new TripAttackAction(cen, target.getTargetType(), target.getTargetId())); ready(); } } /** * Grapple that target! */ private void doGrapple() { if(((Mech)ce()).getGrappled() == Entity.NONE) grapple(false); else breakGrapple(); } private void grapple(boolean counter) { ToHitData toHit = GrappleAttackAction.toHit(client.game, cen, target); String title = Messages.getString("PhysicalDisplay.GrappleDialog.title", new Object[]{target.getDisplayName()}); //$NON-NLS-1$ String message = Messages.getString("PhysicalDisplay.GrappleDialog.message", new Object[]{ //$NON-NLS-1$ toHit.getValueAsString(), new Double(Compute.oddsAbove(toHit.getValue())),toHit.getDesc()}); if(counter) { message = Messages.getString("PhysicalDisplay.CounterGrappleDialog.message", new Object[]{ //$NON-NLS-1$ target.getDisplayName(), toHit.getValueAsString(), new Double(Compute.oddsAbove(toHit.getValue())), toHit.getDesc()}); } if (clientgui.doYesNoDialog( title, message)){ disableButtons(); // declare searchlight, if possible if(GUIPreferences.getInstance().getAutoDeclareSearchlight()) { doSearchlight(); } attacks.addElement(new GrappleAttackAction(cen, target.getTargetType(), target.getTargetId())); ready(); } } private void breakGrapple() { ToHitData toHit = BreakGrappleAttackAction.toHit(client.game, cen, target); String title = Messages.getString("PhysicalDisplay.BreakGrappleDialog.title", new Object[]{target.getDisplayName()}); //$NON-NLS-1$ String message = Messages.getString("PhysicalDisplay.BreakGrappleDialog.message", new Object[]{ //$NON-NLS-1$ toHit.getValueAsString(), new Double(Compute.oddsAbove(toHit.getValue())),toHit.getDesc()}); if (clientgui.doYesNoDialog( title, message)){ disableButtons(); // declare searchlight, if possible if(GUIPreferences.getInstance().getAutoDeclareSearchlight()) { doSearchlight(); } attacks.addElement(new BreakGrappleAttackAction(cen, target.getTargetType(), target.getTargetId())); ready(); } } private void jumpjetatt() { ToHitData toHit; int leg; int damage; if(ce().isProne()) { toHit = JumpJetAttackAction.toHit(client.game, cen, target, JumpJetAttackAction.BOTH); leg = JumpJetAttackAction.BOTH; damage = JumpJetAttackAction.getDamageFor(ce(), JumpJetAttackAction.BOTH); } else { ToHitData left = JumpJetAttackAction.toHit(client.game, cen, target, JumpJetAttackAction.LEFT); ToHitData right = JumpJetAttackAction.toHit(client.game, cen, target, JumpJetAttackAction.RIGHT); int d_left = JumpJetAttackAction.getDamageFor(ce(), JumpJetAttackAction.LEFT); int d_right = JumpJetAttackAction.getDamageFor(ce(), JumpJetAttackAction.RIGHT); if(d_left * Compute.oddsAbove(left.getValue()) > d_right * Compute.oddsAbove(right.getValue())) { toHit = left; leg = JumpJetAttackAction.LEFT; damage = d_left; } else { toHit = right; leg = JumpJetAttackAction.RIGHT; damage = d_right; } } String title = Messages.getString("PhysicalDisplay.JumpJetDialog.title", new Object[]{target.getDisplayName()}); //$NON-NLS-1$ String message = Messages.getString("PhysicalDisplay.JumpJetDialog.message", new Object[]{ //$NON-NLS-1$ toHit.getValueAsString(), new Double(Compute.oddsAbove(toHit.getValue())),toHit.getDesc(),damage}); if (clientgui.doYesNoDialog( title, message)){ disableButtons(); // declare searchlight, if possible if(GUIPreferences.getInstance().getAutoDeclareSearchlight()) { doSearchlight(); } attacks.addElement(new JumpJetAttackAction(cen, target.getTargetType(), target.getTargetId(), leg)); ready(); } } private Mounted chooseClub() { java.util.List<Mounted> clubs = ce().getClubs(); if (clubs.size() == 1) return clubs.get(0); else if (clubs.size() > 1) { String[] names = new String[clubs.size()]; for (int loop = 0; loop < names.length; loop++) { Mounted club = clubs.get(loop); names[loop] = Messages.getString("PhysicalDisplay.ChooseClubDialog.line", new Object[]{ club.getName(), ClubAttackAction.toHit(client.game, cen, target, club).getValueAsString(), ClubAttackAction.getDamageFor(ce(), club) }); } SingleChoiceDialog choiceDialog = new SingleChoiceDialog(clientgui.frame, Messages.getString("PhysicalDisplay.ChooseClubDialog.title"), //$NON-NLS-1$ Messages.getString("PhysicalDisplay.ChooseClubDialog.message"), //$NON-NLS-1$ names); choiceDialog.setVisible(true); if (choiceDialog.getAnswer() == true) { return clubs.get(choiceDialog.getChoice()); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -