/** * Method that repaces a CBMUnit. Called after a player bids on a unit in order to change colors * and show amount. */ public void changeBMUnit(String command) { CBMUnit bmUnit = new CBMUnit( command, this, Boolean.parseBoolean(mwclient.getserverConfigs("HiddenBMUnits"))); BlackMarket.remove(bmUnit.getAuctionID()); BlackMarket.put(bmUnit.getAuctionID(), bmUnit); }
/** * Method that reads data generated by Market2.getAutoMarketStatus() on the server. All data for * all BM units sent at once. "|" used to seperate units, * used to seperate fields inside each * unit. */ public void setBMData(String command) { // create tokenizer StringTokenizer mainTokenizer = new StringTokenizer(command, "$"); // clear all current BM data BlackMarket.clear(); while (mainTokenizer.hasMoreTokens()) { boolean hidden = Boolean.parseBoolean(mwclient.getserverConfigs("HiddenBMUnits")); CBMUnit currBMUnit = new CBMUnit(TokenReader.readString(mainTokenizer), this, hidden); BlackMarket.put(currBMUnit.getAuctionID(), currBMUnit); } }
public void setComponentConverter(String converterData) { try { StringTokenizer st = new StringTokenizer(converterData, "#"); ComponentConverter.clear(); while (st.hasMoreTokens()) { ComponentToCritsConverter converter = new ComponentToCritsConverter(); converter.setCritName(TokenReader.readString(st)); converter.setMinCritLevel(TokenReader.readInt(st)); converter.setComponentUsedType(TokenReader.readInt(st)); converter.setComponentUsedWeight(TokenReader.readInt(st)); ComponentConverter.put(converter.getCritName(), converter); } mwclient.setWaiting(false); } catch (Exception ex) { CampaignData.mwlog.errLog(ex); } }
public TechnicianPanel(MWClient mwclient) { super(); /* * TECH PANEL CONSTRUCTION Technician (and bays from XP) options. */ JPanel techsBox = new JPanel(); techsBox.setLayout(new BoxLayout(techsBox, BoxLayout.Y_AXIS)); JPanel techsCBoxFlow = new JPanel(); JPanel techsSendRecPayFlow = new JPanel(); JPanel techSpring = new JPanel(new SpringLayout()); techsBox.add(techsCBoxFlow); techsBox.add(techsSendRecPayFlow); techsBox.add(techSpring); // the basic CBox flow BaseCheckBox = new JCheckBox("Use Techs"); BaseCheckBox.setToolTipText("Unchecking disables technicians. Not advised."); BaseCheckBox.setName("UseTechnicians"); techsCBoxFlow.add(BaseCheckBox); BaseCheckBox = new JCheckBox("Use XP"); BaseCheckBox.setToolTipText("Check grants additional technicians w/ XP."); BaseCheckBox.setName("UseExperience"); techsCBoxFlow.add(BaseCheckBox); BaseCheckBox = new JCheckBox("Decreasing Cost"); BaseCheckBox.setToolTipText("Checking lowers tech hiring costs w/ XP."); BaseCheckBox.setName("DecreasingTechCost"); techsCBoxFlow.add(BaseCheckBox); BaseCheckBox = new JCheckBox("Disable Tech Advancement"); BaseCheckBox.setToolTipText("Checking disables tech advancement and retiring"); BaseCheckBox.setName("DisableTechAdvancement"); techsCBoxFlow.add(BaseCheckBox); // the sendRecPay flow. BaseCheckBox = new JCheckBox("Sender Pays"); BaseCheckBox.setToolTipText("If checked, a player sending a unit will pay techs."); BaseCheckBox.setName("SenderPaysOnTransfer"); techsSendRecPayFlow.add(BaseCheckBox); BaseCheckBox = new JCheckBox("Recipient Pays"); BaseCheckBox.setToolTipText("If checked, a player receiving a unit will pay techs."); BaseCheckBox.setName("ReceiverPaysOnTransfer"); techsSendRecPayFlow.add(BaseCheckBox); // set up the spring baseTextField = new JTextField(5); techSpring.add(new JLabel("Base Tech Cost:", SwingConstants.TRAILING)); baseTextField.setToolTipText("Starting cost to hire a technician"); baseTextField.setName("BaseTechCost"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("XP for Decrease:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "Amount of XP required to reduce hiring cost by 1 " + mwclient.moneyOrFluMessage(true, true, -1)); baseTextField.setName("XPForDecrease"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Minimum Tech Cost:", SwingConstants.TRAILING)); baseTextField.setToolTipText("Lowest hiring price. XP cannot reduce below this level."); baseTextField.setName("MinimumTechCost"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Additive Per Tech:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "<HTML>" + "Use additive costs -- each tech costs as much as the last one, plus the additive. EG -<br>" + "with .05 set, the first tech would cost .05, the second .10, the third .15, the fourth .20,<br>" + "such that your first 4 techs cost haf a Cbill (total) to maintain, while the 10th tech costs<br>" + "half a " + mwclient.moneyOrFluMessage(true, true, -1) + " all by himself. A cap on this price can be set, after which there is no further<br>" + "increase. The ceiling ABSOLUTELY MUST be a multiple of the additive.</HTML>"); baseTextField.setName("AdditivePerTech"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Additive Ceiling:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "Additive ceiling. Post-game per-tech costs don't increase past this level."); baseTextField.setName("AdditiveCostCeiling"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Transfer Payment:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "Percentage of usual post-game cost charged if transfer fees are enabled."); baseTextField.setName("TransferPayment"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Maint Increase:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "Amount maintainance level is increased each slice a unit is maintained"); baseTextField.setName("MaintainanceIncrease"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Maint Decrease:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "Amount maintainance level is lowered each slice a unit is unmaintained"); baseTextField.setName("MaintainanceDecrease"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Base Unmaint Level:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "Mainatainance level set when a unit is first unmaintained. Set to 100 to disable."); baseTextField.setName("BaseUnmaintainedLevel"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Unmaintain Penalty:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "" + "<HTML>Maintainance reduction for units which are already below 100. If the BaseLevel is lower than current<br>" + "level minus penalty, it is used instead. Example1: A unit has a maintainance level of 90 and is set to<br>" + "unmaintained status. The unmaint penalty is 10 and base elvel is 75. 90-10 = 80, so the base level of 75 is<br>" + "set. Example2: A unit has an mlevel of 80 and is set to unmaintained. 80 - 10 = 70. 70 is set and the base<br>" + "level (75) is ignored.</HTML>"); baseTextField.setName("UnmaintainedPenalty"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Transfer Scrap Level:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "<HTML>Units @ or under this maint. level must survive a scrap check<br>to be transfered. Set to 0 to disable</HTML>"); baseTextField.setName("TransferScrapLevel"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Techs To Proto Point Ratio:", SwingConstants.TRAILING)); baseTextField.setToolTipText("<HTML>Ratio of Techs to 5 Protos Default 1 tech</HTML>"); baseTextField.setName("TechsToProtoPointRatio"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Techs per Light Mek:", SwingConstants.TRAILING)); baseTextField.setToolTipText("<HTML>Number of Techs it takes to maintain a light Mek</HTML>"); baseTextField.setName("TechsForLightMek"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Techs per Medium Mek:", SwingConstants.TRAILING)); baseTextField.setToolTipText("<HTML>Number of Techs it takes to maintain a medium Mek</HTML>"); baseTextField.setName("TechsForMediumMek"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Techs per Heavy Mek:", SwingConstants.TRAILING)); baseTextField.setToolTipText("<HTML>Number of Techs it takes to maintain a heavy Mek</HTML>"); baseTextField.setName("TechsForHeavyMek"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Techs per Assault Mek:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "<HTML>Number of Techs it takes to maintain an assault Mek</HTML>"); baseTextField.setName("TechsForAssaultMek"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Techs per Light Vehicle:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "<HTML>Number of Techs it takes to maintain a light Vehicle</HTML>"); baseTextField.setName("TechsForLightVehicle"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Techs per Medium Vehicle:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "<HTML>Number of Techs it takes to maintain a medium Vehicle</HTML>"); baseTextField.setName("TechsForMediumVehicle"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Techs per Heavy Vehicle:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "<HTML>Number of Techs it takes to maintain a heavy Vehicle</HTML>"); baseTextField.setName("TechsForHeavyVehicle"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Techs per Assault Vehicle:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "<HTML>Number of Techs it takes to maintain an assault Vehicle</HTML>"); baseTextField.setName("TechsForAssaultVehicle"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Techs per Light Infantry:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "<HTML>Number of Techs it takes to maintain a light Infantry</HTML>"); baseTextField.setName("TechsForLightInfantry"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Techs per Medium Infantry:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "<HTML>Number of Techs it takes to maintain a medium Infantry</HTML>"); baseTextField.setName("TechsForMediumInfantry"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Techs per Heavy Infantry:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "<HTML>Number of Techs it takes to maintain a heavy Infantry</HTML>"); baseTextField.setName("TechsForHeavyInfantry"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Techs per Assault Infantry:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "<HTML>Number of Techs it takes to maintain an assault Infantry</HTML>"); baseTextField.setName("TechsForAssaultInfantry"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Techs per Light BattleArmor:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "<HTML>Number of Techs it takes to maintain a light BattleArmor</HTML>"); baseTextField.setName("TechsForLightBattleArmor"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Techs per Medium BattleArmor:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "<HTML>Number of Techs it takes to maintain a medium BattleArmor</HTML>"); baseTextField.setName("TechsForMediumBattleArmor"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Techs per Heavy BattleArmor:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "<HTML>Number of Techs it takes to maintain a heavy BattleArmor</HTML>"); baseTextField.setName("TechsForHeavyBattleArmor"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Techs per Assault BattleArmor:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "<HTML>Number of Techs it takes to maintain an assault BattleArmor</HTML>"); baseTextField.setName("TechsForAssaultBattleArmor"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Techs per Light Aero:", SwingConstants.TRAILING)); baseTextField.setToolTipText("<HTML>Number of Techs it takes to maintain a light Aero</HTML>"); baseTextField.setName("TechsForLightAero"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Techs per Medium Aero:", SwingConstants.TRAILING)); baseTextField.setToolTipText("<HTML>Number of Techs it takes to maintain a medium Aero</HTML>"); baseTextField.setName("TechsForMediumAero"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Techs per Heavy Aero:", SwingConstants.TRAILING)); baseTextField.setToolTipText("<HTML>Number of Techs it takes to maintain a heavy Aero</HTML>"); baseTextField.setName("TechsForHeavyAero"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Techs per Assault Aero:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "<HTML>Number of Techs it takes to maintain an assault Aero</HTML>"); baseTextField.setName("TechsForAssaultAero"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Non-House Unit Increased Techs:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "Float field. Multiplier to tech cost of non-house units. Only used with Tech Repair."); baseTextField.setName("NonFactionUnitsIncreasedTechs"); techSpring.add(baseTextField); baseTextField = new JTextField(5); techSpring.add(new JLabel("Max Techs to Hire:", SwingConstants.TRAILING)); baseTextField.setToolTipText( "Integer field. Max number of techs that can be hired. Set to -1 for unlimited. Users with more than this number of techs will lose them at next login."); baseTextField.setName("MaxTechsToHire"); techSpring.add(baseTextField); SpringLayoutHelper.setupSpringGrid(techSpring, 4); // finalize the layout add(techsBox); }
public boolean decodeCommand(String command) { StringTokenizer ST; String element; ST = new StringTokenizer(command, "|"); element = TokenReader.readString(ST); /* if (!element.equals("CC")) {return(false);} element = TokenReader.readString(ST);*/ command = command.substring(3); if (element.equals("PS")) { if (!Player.setData(command)) { mwclient.addToChat("Player data load failed!<br>"); return (false); } return (true); } if (element.equals("CC")) // Campaign Command { String commandid = TokenReader.readString(ST); if (commandid.equals("AT")) { // incoming attack if (mwclient.getConfig().isParam("ENABLEATTACKSOUND")) { mwclient.doPlaySound(mwclient.getConfigParam("SOUNDONATTACK")); } mwclient.addToChat( "<font color=\"red\"><b>Your forces are under attack!</b></font>", CCommPanel.CHANNEL_HMAIL); mwclient.addToChat( "<font color=\"red\"><b>Your forces are under attack!</b></font>", CCommPanel.CHANNEL_PMAIL, "Server"); if (mwclient.getConfig().isParam("POPUPONATTACK")) { int opID = TokenReader.readInt(ST); int teams = TokenReader.readInt(ST); // mwclient.showInfoWindow("Your forces are under attack!"); new ArmyViewerDialog( mwclient, null, ST, ArmyViewerDialog.AVD_DEFEND, null, null, opID, teams); } } if (commandid.equals("NT")) { // next tick int time = TokenReader.readInt(ST); boolean decrement = TokenReader.readBoolean(ST); mwclient.processTick(time); /* * Decrements tick counters for units without explicit auction * length being sent from the server to save a bit of bandwidth. */ if (decrement) { for (CBMUnit currUnit : BlackMarket.values()) { currUnit.decrementSalesTicks(); } mwclient.refreshGUI(MWClient.REFRESH_BMPANEL); } } return (true); } if (element.equals("CA")) { if (!setData(command)) { mwclient.addToChat("<b>Error: Campaign data load failed.</b><br>"); return (false); } return (true); } if (element.equals("PL")) { if (!Player.decodeCommand(command)) { mwclient.addToChat("<b>Error: Player data load failed.</b><br>"); return (false); } return (true); } if (element.equals("MS")) { if (!showMsg(command)) { mwclient.addToChat("<b>Error: Message show failed.</b><br>"); return (false); } return (true); } if (element.equals("ST")) { if (!showStatus(command)) { mwclient.addToChat("<b>Error: Status show failed.</b><br>"); return (false); } return (true); } mwclient.addToChat("<b>Error: Wrong campaign command from server.</b><br>"); return (false); }
protected boolean showStatus(String command) { mwclient.addToChat(command); return (true); }