📄 physicaldisplay.java
字号:
return null; } /** * Club that target! */ private void club() { Mounted club = chooseClub(); if (null == club) return; ToHitData toHit = ClubAttackAction.toHit(client.game, cen, target, club); String title = Messages.getString("PhysicalDisplay.ClubDialog.title", new Object[]{target.getDisplayName()}); //$NON-NLS-1$ String message = Messages.getString("PhysicalDisplay.ClubDialog.message", new Object[]{//$NON-NLS-1$ toHit.getValueAsString(), new Double(Compute.oddsAbove(toHit.getValue())), toHit.getDesc(), ClubAttackAction.getDamageFor(ce(), club) + toHit.getTableDesc()}); if (clientgui.doYesNoDialog(title, message)) { disableButtons(); // declare searchlight, if possible if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) { doSearchlight(); } attacks.addElement(new ClubAttackAction(cen, target.getTargetType(), target.getTargetId(), club)); ready(); } } /** * Make a protomech physical attack on the target. */ private void proto() { ToHitData proto = ProtomechPhysicalAttackAction.toHit(client.game, cen, target); String title = Messages.getString("PhysicalDisplay.ProtoMechAttackDialog.title", new Object[]{target.getDisplayName()}); //$NON-NLS-1$ String message = Messages.getString("PhysicalDisplay.ProtoMechAttackDialog.message", new Object[]{//$NON-NLS-1$ proto.getValueAsString(), new Double(Compute.oddsAbove(proto.getValue())), proto.getDesc(), ProtomechPhysicalAttackAction.getDamageFor(ce()) + proto.getTableDesc()}); if (clientgui.doYesNoDialog(title, message)) { disableButtons(); // declare searchlight, if possible if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) { doSearchlight(); } attacks.addElement(new ProtomechPhysicalAttackAction(cen, target.getTargetType(), target.getTargetId())); ready(); } } private void explosives() { ToHitData explo = LayExplosivesAttackAction.toHit(client.game, cen, target); String title = Messages.getString("PhysicalDisplay.LayExplosivesAttackDialog.title", new Object[]{target.getDisplayName()}); //$NON-NLS-1$ String message = Messages.getString("PhysicalDisplay.LayExplosivesAttackDialog.message", new Object[]{//$NON-NLS-1$ explo.getValueAsString(), new Double(Compute.oddsAbove(explo.getValue())), explo.getDesc()}); if (clientgui.doYesNoDialog(title, message)) { disableButtons(); attacks.addElement(new LayExplosivesAttackAction(cen, target.getTargetType(), target.getTargetId())); ready(); } } /** * Sweep off the target with the arms that the player selects. */ private void brush() { ToHitData toHitLeft = BrushOffAttackAction.toHit (client.game, cen, target, BrushOffAttackAction.LEFT); ToHitData toHitRight = BrushOffAttackAction.toHit (client.game, cen, target, BrushOffAttackAction.RIGHT); boolean canHitLeft = (ToHitData.IMPOSSIBLE != toHitLeft.getValue()); boolean canHitRight = (ToHitData.IMPOSSIBLE != toHitRight.getValue()); int damageLeft = 0; int damageRight = 0; String title = null; StringBuffer warn = null; String left = null; String right = null; String both = null; String[] choices = null; SingleChoiceDialog dlg = null; // If the entity can't brush off, display an error message and abort. if (!canHitLeft && !canHitRight) { clientgui.doAlertDialog(Messages.getString("PhysicalDisplay.AlertDialog.title"), //$NON-NLS-1$ Messages.getString("PhysicalDisplay.AlertDialog.message")); //$NON-NLS-1$ return; } // If we can hit with both arms, the player will have to make a choice. // Otherwise, the player is just confirming the arm in the attack. if (canHitLeft && canHitRight) { both = Messages.getString("PhysicalDisplay.bothArms"); //$NON-NLS-1$ warn = new StringBuffer(Messages.getString("PhysicalDisplay.whichArm")); //$NON-NLS-1$ title = Messages.getString("PhysicalDisplay.chooseBrushOff"); //$NON-NLS-1$ } else { warn = new StringBuffer(Messages.getString("PhysicalDisplay.confirmArm")); //$NON-NLS-1$ title = Messages.getString("PhysicalDisplay.confirmBrushOff"); //$NON-NLS-1$ } // Build the rest of the warning string. // Use correct text when the target is an iNarc pod. if (Targetable.TYPE_INARC_POD == target.getTargetType()) { warn.append(Messages.getString("PhysicalDisplay.brushOff1",new Object[]{target})); //$NON-NLS-1$ } else { warn.append(Messages.getString("PhysicalDisplay.brushOff2")); //$NON-NLS-1$ } // If we can hit with the left arm, get // the damage and construct the string. if (canHitLeft) { damageLeft = BrushOffAttackAction.getDamageFor(ce(), BrushOffAttackAction.LEFT); left = Messages.getString("PhysicalDisplay.LAHit", new Object[]{//$NON-NLS-1$ toHitLeft.getValueAsString(), new Double(Compute.oddsAbove(toHitLeft.getValue())), new Integer(damageLeft)}); } // If we can hit with the right arm, get // the damage and construct the string. if (canHitRight) { damageRight = BrushOffAttackAction.getDamageFor(ce(), BrushOffAttackAction.RIGHT); right = Messages.getString("PhysicalDisplay.RAHit", new Object[]{//$NON-NLS-1$ toHitRight.getValueAsString(), new Double(Compute.oddsAbove(toHitRight.getValue())), new Integer(damageRight)}); } // Allow the player to cancel or choose which arm(s) to use. if (canHitLeft && canHitRight) { choices = new String[3]; choices[0] = left.toString(); choices[1] = right.toString(); choices[2] = both.toString(); dlg = new SingleChoiceDialog (clientgui.frame, title, warn.toString(), choices); dlg.setVisible(true); if (dlg.getAnswer()) { disableButtons(); switch (dlg.getChoice()) { case 0: attacks.addElement(new BrushOffAttackAction (cen, target.getTargetType(), target.getTargetId(), BrushOffAttackAction.LEFT)); break; case 1: attacks.addElement(new BrushOffAttackAction (cen, target.getTargetType(), target.getTargetId(), BrushOffAttackAction.RIGHT)); break; case 2: attacks.addElement(new BrushOffAttackAction (cen, target.getTargetType(), target.getTargetId(), BrushOffAttackAction.BOTH)); break; } ready(); } // End not-cancel } // End choose-attack(s) // If only the left arm is available, confirm that choice. else if (canHitLeft) { choices = new String[1]; choices[0] = left.toString(); dlg = new SingleChoiceDialog (clientgui.frame, title, warn.toString(), choices); dlg.setVisible(true); if (dlg.getAnswer()) { disableButtons(); attacks.addElement(new BrushOffAttackAction (cen, target.getTargetType(), target.getTargetId(), BrushOffAttackAction.LEFT)); ready(); } // End not-cancel } // End confirm-left // If only the right arm is available, confirm that choice. else if (canHitRight) { choices = new String[1]; choices[0] = right.toString(); dlg = new SingleChoiceDialog (clientgui.frame, title, warn.toString(), choices); dlg.setVisible(true); if (dlg.getAnswer()) { disableButtons(); attacks.addElement(new BrushOffAttackAction (cen, target.getTargetType(), target.getTargetId(), BrushOffAttackAction.RIGHT)); ready(); } // End not-cancel } // End confirm-right } // End private void brush() /** * Thrash at the target, unless the player cancels the action. */ private void thrash() { ThrashAttackAction act = new ThrashAttackAction(cen, target.getTargetType(), target.getTargetId()); ToHitData toHit = act.toHit(client.game); String title = Messages.getString("PhysicalDisplay.TrashDialog.title", new Object[]{target.getDisplayName()}); //$NON-NLS-1$ String message = Messages.getString("PhysicalDisplay.TrashDialog.message", new Object[]{//$NON-NLS-1$ toHit.getValueAsString(), new Double(Compute.oddsAbove(toHit.getValue())), toHit.getDesc(), ThrashAttackAction.getDamageFor(ce()) + toHit.getTableDesc()}); // Give the user to cancel the attack. if (clientgui.doYesNoDialog(title, message)) { disableButtons(); attacks.addElement(act); ready(); } } /** * Dodge like that guy in that movie that I won't name for copywrite reasons! */ private void dodge() { if (clientgui.doYesNoDialog(Messages.getString("PhysicalDisplay.DodgeDialog.title"), Messages.getString("PhysicalDisplay.DodgeDialog.message"))) { //$NON-NLS-1$ //$NON-NLS-2$ disableButtons(); Entity entity = client.game.getEntity(cen); entity.dodging = true; DodgeAction act = new DodgeAction(cen); attacks.addElement(act); ready(); } } /** * Targets something */ void target(Targetable t) { this.target = t; updateTarget(); } /** * Targets an entity */ private void updateTarget() { // dis/enable physical attach buttons if (cen != Entity.NONE && target != null) { if (target.getTargetType() != Targetable.TYPE_INARC_POD) { // punch? final ToHitData leftArm = PunchAttackAction.toHit (client.game, cen, target, PunchAttackAction.LEFT); final ToHitData rightArm = PunchAttackAction.toHit (client.game, cen, target, PunchAttackAction.RIGHT); boolean canPunch = leftArm.getValue() != ToHitData.IMPOSSIBLE || rightArm.getValue() != ToHitData.IMPOSSIBLE; setPunchEnabled(canPunch); // kick? ToHitData leftLeg = KickAttackAction.toHit (client.game, cen, target, KickAttackAction.LEFT); ToHitData rightLeg = KickAttackAction.toHit (client.game, cen, target, KickAttackAction.RIGHT); boolean canKick = leftLeg.getValue() != ToHitData.IMPOSSIBLE || rightLeg.getValue() != ToHitData.IMPOSSIBLE; if (client.game.getOptions().booleanOption("maxtech_mulekicks")) { ToHitData rightRearLeg = KickAttackAction.toHit (client.game, cen, target, KickAttackAction.RIGHTMULE); ToHitData leftRearLeg = KickAttackAction.toHit (client.game, cen, target, KickAttackAction.LEFTMULE); canKick |= (leftRearLeg.getValue() != ToHitData.IMPOSSIBLE) || (rightRearLeg.getValue() != ToHitData.IMPOSSIBLE); } setKickEnabled(canKick); // how about push? ToHitData push = PushAttackAction.toHit (client.game, cen, target); setPushEnabled(push.getValue() != ToHitData.IMPOSSIBLE); // how about trip? ToHitData trip = TripAttackAction.toHit (client.game, cen, target); setTripEnabled(trip.getValue() != ToHitData.IMPOSSIBLE); // how about grapple? ToHitData grap = GrappleAttackAction.toHit (client.game, cen, target); ToHitData bgrap = BreakGrappleAttackAction.toHit (client.game, cen, target); setGrappleEnabled(grap.getValue() != ToHitData.IMPOSSIBLE || bgrap.getValue() != ToHitData.IMPOSSIBLE); // how about JJ? ToHitData jjl = JumpJetAttackAction.toHit (client.game, cen, target, JumpJetAttackAction.LEFT); ToHitData jjr = JumpJetAttackAction.toHit (client.game, cen, target, JumpJetAttackAction.RIGHT); ToHitData jjb = JumpJetAttackAction.toHit (client.game, cen, target, JumpJetAttackAction.BOTH); setJumpJetEnabled(!(jjl.getValue() == ToHitData.IMPOSSIBLE && jjr.getValue() == ToHitData.IMPOSSIBLE && jjb.getValue() == ToHitData.IMPOSSIBLE)); // clubbing? boolean canClub = false; for (Iterator<Mounted> clubs = ce().getClubs().iterator(); clubs.hasNext();) { Mounted club = clubs.next(); if (club != null) { ToHitData clubToHit = ClubAttackAction.toHit (client.game, cen, target, club); canClub |= (clubToHit.getValue() != ToHitData.IMPOSSIBLE); } } setClubEnabled(canClub); // Thrash at infantry? ToHitData thrash = new ThrashAttackAction(cen, target).toHit (client.game); setThrashEnabled(thrash.getValue() != ToHitData.IMPOSSIBLE); // make a Protomech physical attack? ToHitData proto = ProtomechPhysicalAttackAction.toHit (client.game, cen, target); setProtoEnabled(proto.getValue() != ToHitData.IMPOSSIBLE); ToHitData explo = LayExplosivesAttackAction.toHit (client.game, cen, target); setExplosivesEnabled(explo.getValue() != ToHitData.IMPOSSIBLE); } // Brush off swarming infantry or iNarcPods? ToHitData brushRight = BrushOffAttackAction.toHit (client.game, cen, target, BrushOffAttackAction.RIGHT); ToHitData brushLeft = BrushOffAttackAction.toHit (client.game, cen, target, BrushOffAttackAction.LEFT); boolean canBrush = (brushRight.getValue() != ToHitData.IMPOSSIBLE || brushLeft.getValue() != ToHitData.IMPOSSIBLE); setBrushOffEnabled(canBrush); } else { setPunchEnabled(false); setPushEnabled(false); setTripEnabled(false); setGrappleEnabled(false); setJumpJetEnabled(false); setKickEnabled(false); setClubEnabled(false); setBrushOffEnabled(false); setThrashEnabled(false); setProtoEnabled(false); } setSearchlightEnabled(ce() != null && target != null && ce().isUsingSpotlight()); } /** * Returns the current entity. */ private Entity ce() { return client.game.getEntity(cen); } // // BoardListener // public void hexMoused(BoardViewEvent b) { // Are we ignoring events? if (this.isIgnoringEvents()) { return; } // control pressed means a line of sight check.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -