megameknet-cvs Mailing List for MegaMekNET (Page 3)
Status: Inactive
Brought to you by:
mcwizard
You can subscribe to this list here.
2005 |
Jan
|
Feb
(203) |
Mar
(268) |
Apr
(41) |
May
(7) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: Helge R. <mcw...@us...> - 2005-03-29 20:10:59
|
Update of /cvsroot/megameknet/MegaMekNET/src/server/campaign In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11524/src/server/campaign Modified Files: CampaignMain.java Log Message: prevent a NPE Index: CampaignMain.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/CampaignMain.java,v retrieving revision 1.121 retrieving revision 1.122 diff -C2 -d -r1.121 -r1.122 *** CampaignMain.java 28 Mar 2005 17:23:51 -0000 1.121 --- CampaignMain.java 29 Mar 2005 20:10:38 -0000 1.122 *************** *** 494,498 **** // Start the xmlrpc server for the data-port (Main port + 1) ! rpcserver = new RPCServer(myServer.getMyCommunicator().getPort() + 1, data); } --- 494,498 ---- // Start the xmlrpc server for the data-port (Main port + 1) ! rpcserver = new RPCServer(Integer.parseInt(getConfig("RPCPORT")), data); } |
Update of /cvsroot/megameknet/MegaMekNET/client-dist/data/images In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12710 Added Files: absent.gif active.gif active_colored.gif ai.gif am.gif av.gif battle.gif cart.gif clock.gif conq.gif crtr1.gif fighting.gif fighting_colored.gif hi.gif hill0.gif hill1.gif hill2.gif hill3.gif hm.gif hv.gif li.gif lm.gif logout.gif logout_colored.gif lv.gif mi.gif miniticks.gif mm.gif mv.gif nothing.gif nothing.jpg reserve.gif reserve_colored.gif rivr1.gif road1.gif roug1.gif star.gif units.gif ware.gif watr1.gif watr2.gif wood1.gif wood2.gif wood3.gif wrench.gif Log Message: Adding some images missing from CVS --- NEW FILE: conq.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: am.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: hill3.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: ware.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: hv.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: hill0.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: hill1.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: nothing.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: road1.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: li.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: reserve_colored.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: watr2.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: rivr1.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: av.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: wood1.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: battle.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: active.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: mv.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: lv.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: mi.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: roug1.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: wood2.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: crtr1.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: logout.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: lm.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: cart.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: active_colored.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: absent.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: ai.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: reserve.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: clock.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: hill2.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: hi.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: star.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: hm.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: wrench.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: mm.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: logout_colored.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: units.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: wood3.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: fighting_colored.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: watr1.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: nothing.jpg --- (This appears to be a binary file; contents omitted.) --- NEW FILE: fighting.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: miniticks.gif --- (This appears to be a binary file; contents omitted.) |
From: Helge R. <mcw...@us...> - 2005-03-28 18:26:36
|
Update of /cvsroot/megameknet/MegaMekNET/src/server/campaign In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20708/src/server/campaign Modified Files: SPlanet.java Log Message: -> S Fix a problem with houses not getting the planets they conquered! Index: SPlanet.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/SPlanet.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** SPlanet.java 26 Mar 2005 12:22:13 -0000 1.33 --- SPlanet.java 28 Mar 2005 18:26:25 -0000 1.34 *************** *** 243,246 **** --- 243,247 ---- public int doGainInfluence(SHouse winner, SHouse looser, int amount) { + SHouse owner = getOwner(); if (!winner.canConquerPlanets()) return 0; int infgain = getInfluence().moveInfluence(winner, looser, amount); *************** *** 249,252 **** --- 250,270 ---- updated(); checkOwner(); + //Check the owner and assign the planet + if (getOwner() != null){ + //has a new owner + if (owner != null){ + if (!owner.equals(getOwner())){ + //The new owner is not the old owner + owner.removePlanet(this); + getOwner().addPlanet(this); + } + } else { + //The new owner now owns the planet + getOwner().addPlanet(this); + } + } else if (owner != null){ + //This planet has lost its owner! + owner.removePlanet(this); + } return infgain; } |
From: Helge R. <mcw...@us...> - 2005-03-28 18:26:33
|
Update of /cvsroot/megameknet/MegaMekNET In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20708 Modified Files: history.txt Log Message: -> S Fix a problem with houses not getting the planets they conquered! Index: history.txt =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/history.txt,v retrieving revision 1.202 retrieving revision 1.203 diff -C2 -d -r1.202 -r1.203 *** history.txt 28 Mar 2005 17:23:55 -0000 1.202 --- history.txt 28 Mar 2005 18:26:24 -0000 1.203 *************** *** 1,2 **** --- 1,3 ---- + -> S Fix a problem with houses not getting the planets they conquered! -> C/S DATAPORT is now Serverport + 1 fixed. No need for 2 paramters. McW 2005-03-28 |
From: Helge R. <mcw...@us...> - 2005-03-28 17:24:34
|
Update of /cvsroot/megameknet/MegaMekNET/src/server/campaign In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20913/src/server/campaign Modified Files: CampaignMain.java Log Message: -> C/S DATAPORT is now Serverport + 1 fixed. No need for 2 paramters. Index: CampaignMain.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/CampaignMain.java,v retrieving revision 1.120 retrieving revision 1.121 diff -C2 -d -r1.120 -r1.121 *** CampaignMain.java 27 Mar 2005 08:36:37 -0000 1.120 --- CampaignMain.java 28 Mar 2005 17:23:51 -0000 1.121 *************** *** 493,499 **** //Start a vote manager. ! // Start the xmlrpc server for the data-port ! rpcserver = new RPCServer(Integer.parseInt( ! myServer.getConfigParam("DATAPORT")), data); } --- 493,498 ---- //Start a vote manager. ! // Start the xmlrpc server for the data-port (Main port + 1) ! rpcserver = new RPCServer(myServer.getMyCommunicator().getPort() + 1, data); } |
From: Helge R. <mcw...@us...> - 2005-03-28 17:24:31
|
Update of /cvsroot/megameknet/MegaMekNET/src/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20913/src/client Modified Files: CConfig.java MMClient.java Log Message: -> C/S DATAPORT is now Serverport + 1 fixed. No need for 2 paramters. Index: CConfig.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/client/CConfig.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** CConfig.java 27 Feb 2005 09:33:14 -0000 1.27 --- CConfig.java 28 Mar 2005 17:23:49 -0000 1.28 *************** *** 82,86 **** defaults.setProperty("SERVERIP", "megamek.dyndns.org"); defaults.setProperty("SERVERPORT", "2347"); - defaults.setProperty("DATAPORT", "4867"); defaults.setProperty("AUTOCONNECT", "YES"); defaults.setProperty("TIMEOUT", "300"); --- 82,85 ---- *************** *** 298,305 **** ps.println("#The IP of a MegaMekNET Server. Default is: megamek.dyndns.org"); ps.println("SERVERIP: megamek.dyndns.org"); ! ps.println("#The Port used by the MegaMekNET Server. Default is: 2347"); ps.println("SERVERPORT: 2347"); - ps.println("#This is the port for server-client data transfer"); - ps.println("DATAPORT: 4867"); ps.println("# MegaMek host settings"); ps.println("#IF and only IF your ip isn't detected correctly, you may edit this setting (very unlikely that this happens)"); --- 297,302 ---- ps.println("#The IP of a MegaMekNET Server. Default is: megamek.dyndns.org"); ps.println("SERVERIP: megamek.dyndns.org"); ! ps.println("#The Port used by the MegaMekNET Server. Default is: 2347 You'll need to open this port and the port + 1"); ps.println("SERVERPORT: 2347"); ps.println("# MegaMek host settings"); ps.println("#IF and only IF your ip isn't detected correctly, you may edit this setting (very unlikely that this happens)"); *************** *** 668,679 **** } - public String getDataPort() { - return getParam("DATAPORT"); - } - - public void setdataPort(String dataport) { - config.setProperty("DATAPORT", dataport); - } - public String getImageName(String param) { return getParam(param); --- 665,668 ---- Index: MMClient.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/client/MMClient.java,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** MMClient.java 25 Mar 2005 13:53:16 -0000 1.67 --- MMClient.java 28 Mar 2005 17:23:50 -0000 1.68 *************** *** 209,213 **** createGUICommands(); dataFetcher = new DataFetchClient( ! Integer.parseInt(config.getDataPort()), config.getServerIP()); --- 209,213 ---- createGUICommands(); dataFetcher = new DataFetchClient( ! Integer.parseInt(config.getServerPort()) + 1, config.getServerIP()); |
From: Helge R. <mcw...@us...> - 2005-03-28 17:24:28
|
Update of /cvsroot/megameknet/MegaMekNET/src/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20913/src/server Modified Files: ServerWrapper.java Log Message: -> C/S DATAPORT is now Serverport + 1 fixed. No need for 2 paramters. Index: ServerWrapper.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/ServerWrapper.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ServerWrapper.java 20 Feb 2005 09:05:28 -0000 1.3 --- ServerWrapper.java 28 Mar 2005 17:23:47 -0000 1.4 *************** *** 84,88 **** return _distributedState.roomExists(roomname); } ! public java.net.InetAddress getIP(String username) { try { --- 84,88 ---- return _distributedState.roomExists(roomname); } ! public java.net.InetAddress getIP(String username) { try { |
From: Helge R. <mcw...@us...> - 2005-03-28 17:24:04
|
Update of /cvsroot/megameknet/MegaMekNET/client-dist/data/camo In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20913/client-dist/data/camo Added Files: 1stOldKentuckyRCT.jpg Log Message: -> C/S DATAPORT is now Serverport + 1 fixed. No need for 2 paramters. --- NEW FILE: 1stOldKentuckyRCT.jpg --- (This appears to be a binary file; contents omitted.) |
From: Helge R. <mcw...@us...> - 2005-03-28 17:24:04
|
Update of /cvsroot/megameknet/MegaMekNET In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20913 Modified Files: history.txt Log Message: -> C/S DATAPORT is now Serverport + 1 fixed. No need for 2 paramters. Index: history.txt =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/history.txt,v retrieving revision 1.201 retrieving revision 1.202 diff -C2 -d -r1.201 -r1.202 *** history.txt 27 Mar 2005 08:36:37 -0000 1.201 --- history.txt 28 Mar 2005 17:23:55 -0000 1.202 *************** *** 1,2 **** --- 1,4 ---- + -> C/S DATAPORT is now Serverport + 1 fixed. No need for 2 paramters. + McW 2005-03-28 -> S Renamed /c adminsave to /c savecampaign, make it a moderator command and removed /savecampaign. Imi 2005-03-27 |
From: Immanuel S. <im...@us...> - 2005-03-27 08:36:47
|
Update of /cvsroot/megameknet/MegaMekNET/src/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6840/src/server Modified Files: MMServ.java Log Message: built the xml saving at each tick into the server.. and renamed adminsave Index: MMServ.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/MMServ.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** MMServ.java 5 Mar 2005 21:26:49 -0000 1.35 --- MMServ.java 27 Mar 2005 08:36:37 -0000 1.36 *************** *** 463,467 **** //Ensure no links come from the players.. at least no harmful // ones) ! if (text.indexOf("href") != -1 && text.indexOf("MMNET") != -1 && !this.isAdmin(name)) { this.clientSend("CH|This message was deleted for security reasons", name); return; --- 463,467 ---- //Ensure no links come from the players.. at least no harmful // ones) ! if (text.indexOf("href") != -1 && text.indexOf("MMNET") != -1 && text.indexOf("mmnet://") != -1 && !this.isAdmin(name)) { this.clientSend("CH|This message was deleted for security reasons", name); return; *************** *** 475,487 **** StringTokenizer commandTokenizer = new StringTokenizer(text); String taskcommand = commandTokenizer.nextToken(); ! /* ! * if (text.startsWith("name") || text.startsWith("nick")) { ! * StringTokenizer in = new ! * StringTokenizer(text.substring(5),","); String newname = ! * ""; if (in.hasMoreElements()) newname = in.nextToken(); ! * String pw = ""; if (in.hasMoreElements()) pw = ! * in.nextToken(); if (newname != "") setName(newname, ! * false, name,pw); } RENAME COMMAND TEMPORARILY DISABLED ! */ //CODE TO KILL SERVER urgru 11/13/02 if (text.startsWith("shutdown")) { --- 475,479 ---- StringTokenizer commandTokenizer = new StringTokenizer(text); String taskcommand = commandTokenizer.nextToken(); ! //CODE TO KILL SERVER urgru 11/13/02 if (text.startsWith("shutdown")) { *************** *** 494,497 **** --- 486,490 ---- } } //end SHUTDOWN + if (text.startsWith("me ")) { sendChat(name + "|#me " + text.substring(3)); *************** *** 516,524 **** mmlog.infoLog("This line intentionally left blank."); if (text.startsWith("savecampaign")) { ! if (this.isModerator(name)) { ! campaign.toFile(); ! clientSend("CH|You saved the server. Have a nice day.", name); ! } else ! clientSend("CH|You need a higher userlevel to save the server. Nice try though.", name); }//end if(savecampaign) if (text.startsWith("config")) --- 509,513 ---- mmlog.infoLog("This line intentionally left blank."); if (text.startsWith("savecampaign")) { ! clientSend("CH|This command is deprecated. Use /c savecampaign instead. Nothing is saved.", name); }//end if(savecampaign) if (text.startsWith("config")) *************** *** 923,926 **** --- 912,916 ---- writeToLog(); campaign.toFile(); + campaign.saveData(); mmlog.infoLog("Server exiting... Bye bye..."); System.exit(0); |
From: Immanuel S. <im...@us...> - 2005-03-27 08:36:47
|
Update of /cvsroot/megameknet/MegaMekNET/src/server/campaign In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6840/src/server/campaign Modified Files: TickThread.java CampaignMain.java Log Message: built the xml saving at each tick into the server.. and renamed adminsave Index: TickThread.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/TickThread.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TickThread.java 16 Feb 2005 22:17:01 -0000 1.4 --- TickThread.java 27 Mar 2005 08:36:36 -0000 1.5 *************** *** 73,76 **** --- 73,77 ---- try { myCampaign.toFile(); + myCampaign.saveData(); myCampaign.toAllUsers("AutoSave succeeded!"); } Index: CampaignMain.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/CampaignMain.java,v retrieving revision 1.119 retrieving revision 1.120 diff -C2 -d -r1.119 -r1.120 *** CampaignMain.java 26 Mar 2005 18:37:53 -0000 1.119 --- CampaignMain.java 27 Mar 2005 08:36:37 -0000 1.120 *************** *** 41,44 **** --- 41,45 ---- import net.sf.hibernate.cfg.Configuration; import org.jdom.Element; + import org.jdom.JDOMException; import org.jdom.input.SAXBuilder; import server.BanList; *************** *** 72,79 **** --- 73,82 ---- import server.campaign.util.XMLTerrainDataParser; import server.campaign.visitor.SXMLLoadVisitor; + import server.campaign.visitor.SXMLSaveVisitor; import server.dataProvider.RPCServer; import common.BlackBoard; import common.BlackBoardMessage; import common.CampaignData; + import common.House; import common.Influences; import common.PlanetEnvironment; *************** *** 83,86 **** --- 86,91 ---- import common.constants.PlayerStatus; import common.util.MMNetXStream; + import common.visitor.Visitor; + import common.visitor.Visitorable; public class CampaignMain implements Serializable, StatusChangeListener { *************** *** 154,157 **** --- 159,270 ---- private RPCServer rpcserver; + + /** + * Load the campaign relevant data during initialisation. + */ + private void loadData() throws IOException, JDOMException { + SXMLLoadVisitor loader = new SXMLLoadVisitor(); + + // units (before houses or market) + for (Iterator it = loader.parseAll("campaign/unit.xml"); it.hasNext();) { + it.next(); + SUnit unit = (SUnit)new SUnit().visit(loader); + units.put(new Integer(unit.getId()), unit); + } + System.out.println("loaded "+units.size()+" units."); + + // Houses and player within the houses (must be before market) + List houses = new SAXBuilder().build("campaign/houses.xml").getRootElement().getChildren(); + for (Iterator it = houses.iterator(); it.hasNext();) { + Element e = (Element)it.next(); + SHouse house = null; + try { + house = (SHouse)Class.forName(e.getAttributeValue("class")).newInstance(); + } catch (InstantiationException e1) { + throw new RuntimeException(e1); + } catch (IllegalAccessException e1) { + throw new RuntimeException(e1); + } catch (ClassNotFoundException e1) { + throw new RuntimeException(e1); + } + loader.parse((e.getAttributeValue("file"))); + house.visit(loader); + data.addHouse(house); + house.addStatusListener(this); + System.out.println("loaded "+house.getName()+" with "+house.getMembers().size()+" players."); + } + + // planet environments (must be before planet's) + for (Iterator it = loader.parseAll("campaign/planetEnvironment.xml"); it.hasNext();) { + it.next(); + data.addTerrain((PlanetEnvironment)new PlanetEnvironment().visit(loader)); + } + System.out.println("loaded "+data.getAllTerrains().size()+" planet environments."); + + // planets + for (Iterator it = loader.parseAll("campaign/planet.xml"); it.hasNext();) { + it.next(); + SPlanet planet = (SPlanet)new SPlanet().visit(loader); + data.addPlanet(planet); + if (planet.getOwner() != null) + planet.getOwner().addPlanet(planet); + } + System.out.println("loaded "+data.getAllPlanets().size()+" planets."); + + // market + loader.parse("campaign/blackmarket.xml"); + market = (Market)new Market().visit(loader); + System.out.println("loaded "+market.getAllUnits().size()+" bids on market."); + + // blackboard + loader.parse("campaign/blackboard.xml"); + blackBoard.visit(loader); + System.out.println("loaded blackboard."); + + // ban list + MMNetXStream xml = new MMNetXStream(); + BanList.setInstance((BanList)xml.fromFile(BAN_FILENAME)); + + // freeing some ressources (cache lists) + loader = null; + System.gc(); + } + + /** + * Save the whole campaign state to xml + */ + public void saveData() { + SXMLSaveVisitor saver = new SXMLSaveVisitor(); + // Units + saver.toXml("campaign/unit.xml", "units", CampaignMain.cm.units.values()); + // Houses (one file for each house because memory concerns) + for (Iterator it = data.getAllHouses().iterator(); it.hasNext();) { + SHouse house = (SHouse)it.next(); + saver.toXml("campaign/"+house.getName()+".xml", house); + } + // Write all house names (on the fly). + saver.toXml("campaign/houses.xml", new Visitorable(){ + public Object visit(Visitor visitor) { + Element e = new Element("houses"); + for (Iterator it = data.getAllHouses().iterator(); it.hasNext();) { + House house = (House)it.next(); + Element h = new Element("house"); + h.setAttribute("class", house.getClass().getName()); + h.setAttribute("file", "campaign/"+house.getName()+".xml"); + e.addContent(h); + } + return e; + } + }); + // Blackboard + saver.toXml("campaign/blackboard.xml", CampaignMain.cm.getBlackBoard()); + // Market + saver.toXml("campaign/blackmarket.xml", CampaignMain.cm.getMarket()); + // Planet environment + saver.toXml("campaign/planetEnvironment.xml", "planetEnvironments", data.getAllTerrains()); + // Planets + saver.toXml("campaign/planet.xml", "planets", data.getAllPlanets()); + } + public CampaignMain(MMServ serv) { cm = this; *************** *** 180,250 **** // new .xml loading try { ! ! SXMLLoadVisitor loader = new SXMLLoadVisitor(); ! ! // units (before houses or market) ! for (Iterator it = loader.parseAll("campaign/unit.xml"); it.hasNext();) { ! it.next(); ! SUnit unit = (SUnit)new SUnit().visit(loader); ! units.put(new Integer(unit.getId()), unit); ! } ! System.out.println("loaded "+units.size()+" units."); ! ! // Houses and player within the houses (must be before market) ! List houses = new SAXBuilder().build("campaign/houses.xml").getRootElement().getChildren(); ! for (Iterator it = houses.iterator(); it.hasNext();) { ! Element e = (Element)it.next(); ! SHouse house = null; ! try { ! house = (SHouse)Class.forName(e.getAttributeValue("class")).newInstance(); ! } catch (InstantiationException e1) { ! throw new RuntimeException(e1); ! } catch (IllegalAccessException e1) { ! throw new RuntimeException(e1); ! } catch (ClassNotFoundException e1) { ! throw new RuntimeException(e1); ! } ! loader.parse((e.getAttributeValue("file"))); ! house.visit(loader); ! data.addHouse(house); ! house.addStatusListener(this); ! System.out.println("loaded "+house.getName()+" with "+house.getMembers().size()+" players."); ! } ! ! // planet environments (must be before planet's) ! for (Iterator it = loader.parseAll("campaign/planetEnvironment.xml"); it.hasNext();) { ! it.next(); ! data.addTerrain((PlanetEnvironment)new PlanetEnvironment().visit(loader)); ! } ! System.out.println("loaded "+data.getAllTerrains().size()+" planet environments."); ! ! // planets ! for (Iterator it = loader.parseAll("campaign/planet.xml"); it.hasNext();) { ! it.next(); ! SPlanet planet = (SPlanet)new SPlanet().visit(loader); ! data.addPlanet(planet); ! if (planet.getOwner() != null) ! planet.getOwner().addPlanet(planet); ! } ! System.out.println("loaded "+data.getAllPlanets().size()+" planets."); ! ! // market ! loader.parse("campaign/blackmarket.xml"); ! market = (Market)new Market().visit(loader); ! System.out.println("loaded "+market.getAllUnits().size()+" bids on market."); ! ! // blackboard ! loader.parse("campaign/blackboard.xml"); ! blackBoard.visit(loader); ! System.out.println("loaded blackboard."); ! ! // ban list ! MMNetXStream xml = new MMNetXStream(); ! BanList.setInstance((BanList)xml.fromFile(BAN_FILENAME)); ! ! // freeing some ressources (cache lists) ! loader = null; ! System.gc(); ! } catch (Throwable t) { t.printStackTrace(); --- 293,297 ---- // new .xml loading try { ! loadData(); } catch (Throwable t) { t.printStackTrace(); *************** *** 390,394 **** // yea, I know. Not the fine english way to do the save, but this // is temporary anyway. ! new AdminSaveCommand().process(new String[]{"xml"}, null); } catch (Exception e1) { } --- 437,441 ---- // yea, I know. Not the fine english way to do the save, but this // is temporary anyway. ! new SaveCampaignCommand().process(new String[]{"xml"}, null); } catch (Exception e1) { } *************** *** 463,467 **** /** ! * Saves the current campaign state to a file system. */ public void toFile() { --- 510,516 ---- /** ! * Saves the current campaign state to a file system. ! * This is the old .DAT saving and will be removed soon. Use saveData() ! * for the new .XML saving. */ public void toFile() { *************** *** 478,513 **** } - // saving xml stuff. Disabled until finished. - // try { - // SXMLSaveVisitor saver = new SXMLSaveVisitor(); - // // Houses (one file for each house because memory concerns) - // for (Iterator it = data.getAllHouses().iterator(); it.hasNext();) { - // SHouse house = (SHouse)it.next(); - // saver.toXml("campaign/"+house.getName()+".xml", house); - // } - // // Write all house names (on the fly). - // saver.toXml("campaign/houses.xml", new Visitorable(){ - // public Object visit(Visitor visitor) { - // Element e = new Element("houses"); - // String names = ""; - // for (Iterator it = data.getAllHouses().iterator(); it.hasNext();) - // names += ((House)it.next()).getName() + (it.hasNext()?",":""); - // e.setAttribute("names", names); - // return e; - // } - // }); - // // Blackboard - // saver.toXml("campaign/blackboard.xml", blackBoard); - // // Market - // saver.toXml("campaign/blackmarket.xml", market); - // // Planet environment - // saver.toXml("campaign/planetEnvironment.xml", "planetEnvironments", data.getAllTerrains()); - // // Planets - // saver.toXml("campaign/planet.xml", "planets", data.getAllPlanets()); - // } catch (RuntimeException e) { - // //XXX IMI: DEBUG - // e.printStackTrace(); - // } - // OLD way. Remove when no longer necessary! --- 527,530 ---- *************** *** 692,695 **** --- 709,716 ---- return; } + if (cmd.isModCommand() && !getServer().isModerator(userName)) { + toUser("The command '"+cmdName+"' needs moderator privilege. Ask someone with a * (star) in front of its name.", userName, true); + return; + } String[] param = new String[st.countTokens()]; if (cmd.getRequiredParameter() > param.length) { *************** *** 1236,1240 **** commands.put("ADMINRESETALLINFLUENCE", new AdminResetAllInfluenceCommand()); commands.put("adminrestart", new AdminRestartCommand()); ! commands.put("adminsave", new AdminSaveCommand()); commands.put("ADMINSAVEPLANETSTOXML", new AdminSavePlanetsToXMLCommand()); commands.put("ADMINSETCOMPONENTS", new AdminSetComponentsCommand()); --- 1257,1261 ---- commands.put("ADMINRESETALLINFLUENCE", new AdminResetAllInfluenceCommand()); commands.put("adminrestart", new AdminRestartCommand()); ! commands.put("savecampaign", new SaveCampaignCommand()); commands.put("ADMINSAVEPLANETSTOXML", new AdminSavePlanetsToXMLCommand()); commands.put("ADMINSETCOMPONENTS", new AdminSetComponentsCommand()); |
From: Immanuel S. <im...@us...> - 2005-03-27 08:36:46
|
Update of /cvsroot/megameknet/MegaMekNET/src/server/campaign/commands In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6840/src/server/campaign/commands Modified Files: Command.java Added Files: SaveCampaignCommand.java Removed Files: AdminSaveCommand.java Log Message: built the xml saving at each tick into the server.. and renamed adminsave --- AdminSaveCommand.java DELETED --- Index: Command.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/commands/Command.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Command.java 25 Mar 2005 13:53:14 -0000 1.8 --- Command.java 27 Mar 2005 08:36:36 -0000 1.9 *************** *** 115,118 **** --- 115,125 ---- return name[0].startsWith("admin"); } + /** + * You may overwrite this, if the command needs at least moderator privilege. + */ + public boolean isModCommand() { + return isAdminCommand(); + } + public final String getName() { return name[0]; --- NEW FILE: SaveCampaignCommand.java --- /** * MegaMekNET * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. */ package server.campaign.commands; import server.campaign.CampaignMain; /** * Various save actions. * * @author imi */ public class SaveCampaignCommand extends Command { public SaveCampaignCommand() { super("savecampaign", 0); } protected String usage() { return "[target]"; } public String help() { return "Saves some data within the server to disk. If target isn't " + "specified, assume 'xml'. Save target are:<br>" + "dat - save all data as old .dat format.<br>" + "xml - save all data into xml-files."; } public boolean isModCommand() { return true; } public void process(String[] param, String userName) throws IllegalUsageException { String target = param.length == 0 ? "xml" : param[0]; try { String saveString; if ("xml".equals(target.toLowerCase())) { CampaignMain.cm.saveData(); saveString = "XML"; } else if ("dat".equals(target.toLowerCase())) { CampaignMain.cm.toFile(); saveString = "DAT"; } else throw new IllegalUsageException(); send(saveString+" saved!",userName); } catch (RuntimeException e) { e.printStackTrace(); send("XML saving failed because: "+e, userName); } } } |
From: Immanuel S. <im...@us...> - 2005-03-27 08:36:46
|
Update of /cvsroot/megameknet/MegaMekNET In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6840 Modified Files: history.txt Log Message: built the xml saving at each tick into the server.. and renamed adminsave Index: history.txt =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/history.txt,v retrieving revision 1.200 retrieving revision 1.201 diff -C2 -d -r1.200 -r1.201 *** history.txt 26 Mar 2005 17:44:26 -0000 1.200 --- history.txt 27 Mar 2005 08:36:37 -0000 1.201 *************** *** 1,9 **** -> S XML saving finally finished. Now, the bug hunting saison is opened ;-) Imi 2005-03-26 ! -> S 1. Remove all task benefits from raiding SOL (Mechs, Comps) ! 2. Reduce EXP payout so that House players gain 1 RP for the game. ! 3. Make sure neither side suffers any losses from the game. Units on either side gain no EXP or kills. ! 4. Make it so SOL players can reset their hangar after a game. Coaches should be able to reset at any point ! (Yet untested...) McW 2005-03-26 -> S Added a help command. Query help on server commands with /c help#command. To get a list, use /c help#list --- 1,11 ---- + -> S Renamed /c adminsave to /c savecampaign, make it a moderator command and removed /savecampaign. + Imi 2005-03-27 -> S XML saving finally finished. Now, the bug hunting saison is opened ;-) Imi 2005-03-26 ! -> S 1. Remove all task benefits from raiding SOL (Mechs, Comps) ! 2. Reduce EXP payout so that House players gain 1 RP for the game. ! 3. Make sure neither side suffers any losses from the game. Units on either side gain no EXP or kills. ! 4. Make it so SOL players can reset their hangar after a game. Coaches should be able to reset at any point ! (Yet untested...) McW 2005-03-26 -> S Added a help command. Query help on server commands with /c help#command. To get a list, use /c help#list |
From: Immanuel S. <im...@us...> - 2005-03-26 18:38:05
|
Update of /cvsroot/megameknet/MegaMekNET/src/server/campaign In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17620/src/server/campaign Modified Files: SUnit.java SPlayer.java CampaignMain.java Log Message: modernized some commands (to new scheme) and fixed system unit list refresh Index: CampaignMain.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/CampaignMain.java,v retrieving revision 1.118 retrieving revision 1.119 diff -C2 -d -r1.118 -r1.119 *** CampaignMain.java 26 Mar 2005 17:44:26 -0000 1.118 --- CampaignMain.java 26 Mar 2005 18:37:53 -0000 1.119 *************** *** 1354,1358 **** commands.put("RETIREPILOT", new RetirePilotCommand()); //commands.put("SCAN", new ScanCommand()); ! commands.put("SCRAP", new ScrapCommand()); commands.put("sell", new SellCommand()); commands.put("SERVERVERSION", new ServerVersionCommand()); --- 1354,1358 ---- commands.put("RETIREPILOT", new RetirePilotCommand()); //commands.put("SCAN", new ScanCommand()); ! commands.put("scrap", new ScrapCommand()); commands.put("sell", new SellCommand()); commands.put("SERVERVERSION", new ServerVersionCommand()); *************** *** 1716,1719 **** --- 1716,1743 ---- } + // unit rebuild + units = new Hashtable(); + for (Iterator it = getData().getAllHouses().iterator();it.hasNext();) { + SHouse house = (SHouse)it.next(); + for (Iterator pl = house.getMembers().values().iterator(); pl.hasNext();) { + for (Iterator un = ((SPlayer)pl.next()).getUnits().iterator(); un.hasNext();) { + SUnit u = (SUnit)un.next(); + units.put(new Integer(u.getId()), u); + } + } + for (Iterator ha = house.getHangar().values().iterator(); ha.hasNext();) { + for (Iterator ha2 = ((Vector)ha.next()).iterator(); ha2.hasNext();) { + for (Iterator ha3 = ((Vector)ha2.next()).iterator(); ha3.hasNext();) { + SUnit u = (SUnit)ha3.next(); + units.put(new Integer(u.getId()), u); + } + } + } + } + for (Iterator it = market.getAllUnits().iterator(); it.hasNext();) { + SUnit u = (SUnit)((MarketUnit)it.next()).getCmech(); + units.put(new Integer(u.getId()), u); + } + //Purge inactive? - Every 100 ticks if (tickid % 100 == 0){ *************** *** 2058,2061 **** --- 2082,2086 ---- } + // Why synchronized? please comment. public synchronized int getAndUpdateCurrentUnitID(SUnit u){ if (useHibernate()) { *************** *** 2067,2074 **** UnitEntryKeeper.setUnitEntry(entry); return entry.getID().intValue(); ! } else { ! currentUnitID++; ! return currentUnitID - 1; ! } } --- 2092,2097 ---- UnitEntryKeeper.setUnitEntry(entry); return entry.getID().intValue(); ! } else ! return currentUnitID++; } Index: SPlayer.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/SPlayer.java,v retrieving revision 1.88 retrieving revision 1.89 diff -C2 -d -r1.88 -r1.89 *** SPlayer.java 26 Mar 2005 17:44:24 -0000 1.88 --- SPlayer.java 26 Mar 2005 18:37:53 -0000 1.89 *************** *** 811,816 **** int currId = currUnit.getId(); if (new Boolean(CampaignMain.cm.getConfig("ScrapUnmaintained")).booleanValue()) { ! CampaignMain.cm.toUser("Lack of maintainance has caused irreparable harm to vital systems on " + currUnit.getPilot().getName() + "'s " + currUnit.getModelname() + ". Your technicians" + " have stripped the unit down and set aside the remaining functional equipment.", this.getName(), true); this.removeUnit(currId); } else { CampaignMain.cm.toUser("Lack of maintainance on " + currUnit.getPilot().getName() + "'s " + currUnit.getModelname() + " has attracted your houses inspectors. " + " They have decided to remove the unit from your jurisdiction and bring it back to the house hangar for an overhaul", this.getName(), true); --- 811,821 ---- int currId = currUnit.getId(); if (new Boolean(CampaignMain.cm.getConfig("ScrapUnmaintained")).booleanValue()) { ! CampaignMain.cm.toUser( ! "Lack of maintainance has caused irreparable harm to vital systems on " + ! currUnit.getPilot().getName() + "'s " + currUnit.getModelname() + ". Your technicians" + ! " have stripped the unit down and set aside the remaining functional equipment.", ! this.getName(), true); this.removeUnit(currId); + CampaignMain.cm.units.remove(new Integer(currId)); } else { CampaignMain.cm.toUser("Lack of maintainance on " + currUnit.getPilot().getName() + "'s " + currUnit.getModelname() + " has attracted your houses inspectors. " + " They have decided to remove the unit from your jurisdiction and bring it back to the house hangar for an overhaul", this.getName(), true); Index: SUnit.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/SUnit.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** SUnit.java 26 Mar 2005 12:22:13 -0000 1.42 --- SUnit.java 26 Mar 2005 18:37:53 -0000 1.43 *************** *** 290,305 **** */ public SUnit(String producer, String filename, int weightclass) { ! setUnitFilename(filename); ! Entity m = getEntity(); ! setOriginalBV(m.calculateBattleValue()); ! if (m != null) { ! setProducer(producer); ! setPosId(-1); ! init(m); ! } ! if (weightclass == 0) ! weightclass = this.calulateWeightClass(); ! setWeightclass(weightclass); ! setId(CampaignMain.cm.getAndUpdateCurrentUnitID(this)); } --- 290,294 ---- */ public SUnit(String producer, String filename, int weightclass) { ! this(producer, filename, weightclass, -1); } *************** *** 323,327 **** weightclass = this.calulateWeightClass(); setWeightclass(weightclass); ! setId(replaceId); } --- 312,320 ---- weightclass = this.calulateWeightClass(); setWeightclass(weightclass); ! if (replaceId == -1) ! setId(CampaignMain.cm.getAndUpdateCurrentUnitID(this)); ! else ! setId(replaceId); ! CampaignMain.cm.units.put(new Integer(getId()), this); } *************** *** 350,357 **** else setModelname(m.getModel()); - /* - //Set Weight - this.weight = m.getWeight(); - */ } --- 343,346 ---- |
From: Immanuel S. <im...@us...> - 2005-03-26 18:38:05
|
Update of /cvsroot/megameknet/MegaMekNET/src/server/campaign/commands In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17620/src/server/campaign/commands Modified Files: AddToMuseumCommand.java DonateCommand.java AdminScrapCommand.java RepodCommand.java ScrapCommand.java Log Message: modernized some commands (to new scheme) and fixed system unit list refresh Index: DonateCommand.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/commands/DonateCommand.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** DonateCommand.java 5 Mar 2005 02:01:10 -0000 1.14 --- DonateCommand.java 26 Mar 2005 18:37:54 -0000 1.15 *************** *** 93,97 **** p.getName() + " has donated a " + m.getVerboseModelName() + ! " to the house bay!"); p.removeUnit(mechid); UnitHistoryKeeper.addDonateEntry(m.getId(), m.getPilot().getId(),p.getName(), p.getMyHouse().getName()); --- 93,97 ---- p.getName() + " has donated a " + m.getVerboseModelName() + ! " to the house bay!"); p.removeUnit(mechid); UnitHistoryKeeper.addDonateEntry(m.getId(), m.getPilot().getId(),p.getName(), p.getMyHouse().getName()); Index: AddToMuseumCommand.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/commands/AddToMuseumCommand.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** AddToMuseumCommand.java 20 Feb 2005 10:09:32 -0000 1.9 --- AddToMuseumCommand.java 26 Mar 2005 18:37:54 -0000 1.10 *************** *** 54,57 **** --- 54,58 ---- p.addMoney(-mechCbills); p.removeUnit(unitId); + CampaignMain.cm.units.remove(new Integer(unitId)); PilotEntryKeeper.kill(unit.getPilot().getId()); UnitEntryKeeper.kill(unitId); Index: ScrapCommand.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/commands/ScrapCommand.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ScrapCommand.java 5 Mar 2005 02:01:10 -0000 1.12 --- ScrapCommand.java 26 Mar 2005 18:37:54 -0000 1.13 *************** *** 12,48 **** * for more details. */ - package server.campaign.commands; ! import java.util.*; ! ! import server.campaign.*; import server.campaign.util.UnitHistoryKeeper; /** * @author Helge Richter * */ ! public class ScrapCommand extends Command ! { ! public void process(StringTokenizer command, String userName) ! { SPlayer p = CampaignMain.cm.getPlayer(userName); ! if (p.getMyHouse().isNewbieHouse()) ! { CampaignMain.cm.toUser("SOL players may not Sell, Scrap or Donate their units!", userName, true); return; } ! int mechid = Integer.parseInt(command.nextToken()); SUnit m = p.getUnit(mechid); - //If he has not scrapped this tick and Scrapping is allowed, OR if the entity has been salvaged recently ! if ((!p.isHasScrappedThisTick() && new Boolean(CampaignMain.cm.getConfig("ScrappingAllowed")).booleanValue()) ! || CampaignMain.cm.getCurrentTick() < m.getScrappableUntil()) ! { int mechscrapprize = 0; //If Scrapping costs bills, subtract the amount. ! if (new Boolean(CampaignMain.cm.getConfig("ScrappingCostsBills")).booleanValue() && CampaignMain.cm.getCurrentTick() >= m.getScrappableUntil()) ! { mechscrapprize = p.getMyHouse().getPriceForMech(m.getWeightclass(), m.getType(), null) / 3; int infToScrap = p.getMyHouse().getInfluenceForMech(m.getWeightclass(), m.getType(), null) / 3; --- 12,53 ---- * for more details. */ package server.campaign.commands; ! import server.campaign.CampaignMain; ! import server.campaign.SPlayer; ! import server.campaign.SUnit; import server.campaign.util.UnitHistoryKeeper; + /** * @author Helge Richter * */ ! public class ScrapCommand extends Command { ! public ScrapCommand() { ! super("scrap", 1); ! } ! ! protected String usage() { ! return "#unitid"; ! } ! ! public String help() { ! return "Scrap the unit (mech) with the id given as parameter."; ! } ! ! public void process(String[] param, String userName) throws IllegalUsageException { SPlayer p = CampaignMain.cm.getPlayer(userName); ! if (p.getMyHouse().isNewbieHouse()) { CampaignMain.cm.toUser("SOL players may not Sell, Scrap or Donate their units!", userName, true); return; } ! int mechid = Integer.parseInt(param[0]); SUnit m = p.getUnit(mechid); //If he has not scrapped this tick and Scrapping is allowed, OR if the entity has been salvaged recently ! if ((!p.isHasScrappedThisTick() && new Boolean(CampaignMain.cm.getConfig("ScrappingAllowed")).booleanValue()) || CampaignMain.cm.getCurrentTick() < m.getScrappableUntil()) { int mechscrapprize = 0; //If Scrapping costs bills, subtract the amount. ! if (new Boolean(CampaignMain.cm.getConfig("ScrappingCostsBills")).booleanValue() && CampaignMain.cm.getCurrentTick() >= m.getScrappableUntil()) { mechscrapprize = p.getMyHouse().getPriceForMech(m.getWeightclass(), m.getType(), null) / 3; int infToScrap = p.getMyHouse().getInfluenceForMech(m.getWeightclass(), m.getType(), null) / 3; *************** *** 51,60 **** p.addMoney(-mechscrapprize); //p.addInfluence(-infToScrap); ! } else ! { ! CampaignMain.cm.toUser( ! "You cannot afford to scrap this unit. You need " + mechscrapprize + " cbills and " + infToScrap + " influence.", ! userName, ! true); return; } --- 56,61 ---- p.addMoney(-mechscrapprize); //p.addInfluence(-infToScrap); ! } else { ! CampaignMain.cm.toUser("You cannot afford to scrap this unit. You need " + mechscrapprize + " cbills and " + infToScrap + " influence.", userName, true); return; } *************** *** 64,75 **** // m.getPilot().getPiloting()+")"); CampaignMain.cm.doSendHouseMail(p.getMyHouse(), "NOTE", p.getName() + " has scrapped a " + m.getVerboseModelName() + "!"); ! UnitHistoryKeeper.addScrapEntry(m.getId(),m.getPilot().getId(), p.getName(), p.getMyHouse().getName()); p.getMyHouse().addDispossessedPilot(m); p.removeUnit(mechid); CampaignMain.cm.addMechStat(m.getUnitFilename(), m.getWeightclass(), 0, 0, 1, false, m.getOriginalBV()); p.getMyHouse().addPP(m.getWeightclass(), m.getType(), mechscrapprize / 2); //give the house PP if (CampaignMain.cm.getCurrentTick() >= m.getScrappableUntil()) p.setHasScrappedThisTick(true); - //Is the mech recently salvaged? If so, grant some money for scrapping it int moneygain = 0; --- 65,76 ---- // m.getPilot().getPiloting()+")"); CampaignMain.cm.doSendHouseMail(p.getMyHouse(), "NOTE", p.getName() + " has scrapped a " + m.getVerboseModelName() + "!"); ! UnitHistoryKeeper.addScrapEntry(m.getId(), m.getPilot().getId(), p.getName(), p.getMyHouse().getName()); p.getMyHouse().addDispossessedPilot(m); p.removeUnit(mechid); + CampaignMain.cm.units.remove(new Integer(mechid)); CampaignMain.cm.addMechStat(m.getUnitFilename(), m.getWeightclass(), 0, 0, 1, false, m.getOriginalBV()); p.getMyHouse().addPP(m.getWeightclass(), m.getType(), mechscrapprize / 2); //give the house PP if (CampaignMain.cm.getCurrentTick() >= m.getScrappableUntil()) p.setHasScrappedThisTick(true); //Is the mech recently salvaged? If so, grant some money for scrapping it int moneygain = 0; *************** *** 78,83 **** if (moneygain == 0) CampaignMain.cm.toUser("The " + m.getModelname() + " has been scrapped. You pay " + mechscrapprize + " for recycling.", userName, true); ! else ! { CampaignMain.cm.toUser("The " + m.getModelname() + " has been scrapped. You get " + moneygain + " CBills for it!", userName, true); p.addMoney(moneygain); --- 79,83 ---- if (moneygain == 0) CampaignMain.cm.toUser("The " + m.getModelname() + " has been scrapped. You pay " + mechscrapprize + " for recycling.", userName, true); ! else { CampaignMain.cm.toUser("The " + m.getModelname() + " has been scrapped. You get " + moneygain + " CBills for it!", userName, true); p.addMoney(moneygain); *************** *** 88,91 **** CampaignMain.cm.toUser("Scrapping is not possible on this server!", userName, true); } - } --- 88,90 ---- Index: RepodCommand.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/commands/RepodCommand.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** RepodCommand.java 26 Mar 2005 12:22:15 -0000 1.17 --- RepodCommand.java 26 Mar 2005 18:37:54 -0000 1.18 *************** *** 108,129 **** while (dis.ready()) { String l = dis.readLine(); ! StringTokenizer ST = new StringTokenizer(l); ! if (ST.hasMoreElements()) { ! int from = Integer.parseInt(ST.nextToken()); if (new Boolean(CampaignMain.cm.getConfig("UseOldStyleBuildTables")).booleanValue()) { ! int to = Integer.parseInt(ST.nextToken()); } ! String Filename = ""; ! while (ST.hasMoreElements()) { ! Filename += ST.nextToken(); ! if (ST.hasMoreElements()) { ! Filename += " "; } } ! System.out.println("FileName: " + Filename); // compare this File name to the chassis type of our Omni ! if (Filename.startsWith(targetChassis)) { // now, check actual mech in this file, to see if it is Omni & same Chassis ! SUnit cm = new SUnit(m.getProducer(), Filename, m.getWeightclass(), mechid); Entity cme = cm.getEntity(); String chassis = cme.getChassis(); --- 108,129 ---- while (dis.ready()) { String l = dis.readLine(); ! StringTokenizer st = new StringTokenizer(l); ! if (st.hasMoreElements()) { ! int from = Integer.parseInt(st.nextToken()); if (new Boolean(CampaignMain.cm.getConfig("UseOldStyleBuildTables")).booleanValue()) { ! int to = Integer.parseInt(st.nextToken()); } ! String filename = ""; ! while (st.hasMoreElements()) { ! filename += st.nextToken(); ! if (st.hasMoreElements()) { ! filename += " "; } } ! System.out.println("FileName: " + filename); // compare this File name to the chassis type of our Omni ! if (filename.startsWith(targetChassis)) { // now, check actual mech in this file, to see if it is Omni & same Chassis ! SUnit cm = new SUnit(m.getProducer(), filename, m.getWeightclass(), mechid); Entity cme = cm.getEntity(); String chassis = cme.getChassis(); *************** *** 189,192 **** --- 189,193 ---- p.addUnit(cm, true); p.removeUnit(mechid); + CampaignMain.cm.units.remove(new Integer(mechid)); CampaignMain.cm.toUser("The " + m.getVerboseModelName() + " has been repodded to a " + cm.getVerboseModelName() + ".", userName, true); if (new Boolean(CampaignMain.cm.getConfig("RepodUsesComp")).booleanValue()) Index: AdminScrapCommand.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/commands/AdminScrapCommand.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** AdminScrapCommand.java 20 Feb 2005 10:09:32 -0000 1.8 --- AdminScrapCommand.java 26 Mar 2005 18:37:54 -0000 1.9 *************** *** 12,44 **** * for more details. */ - package server.campaign.commands; - import java.util.*; ! import server.campaign.*; import server.campaign.util.UnitHistoryKeeper; /** ! * @author Helge Richter ! * ! */ ! public class AdminScrapCommand extends Command ! { ! public void process(StringTokenizer command,String userName) ! { //Moderators may scrap always ! if (CampaignMain.cm.getServer().isModerator(userName)) ! { ! SPlayer p = CampaignMain.cm.getPlayer(command.nextToken()); ! int mechid= Integer.parseInt(command.nextToken()); SUnit m = p.getUnit(mechid); ! ! if (p != null) ! { p.removeUnit(mechid); ! UnitHistoryKeeper.addScrapEntry(m.getId(), m.getPilot().getId(),p.getName(), p.getMyHouse().getName()); ! CampaignMain.cm.toUser("The " + m.getModelname() + ! " has been scrapped. Your HQ bows before your godlike admin powers!", ! userName, true); server.MMServ.mmlog.modLog(userName + " has scrapped a " + m.getModelname() + " from " + p.getName()); } --- 12,40 ---- * for more details. */ package server.campaign.commands; ! import java.util.StringTokenizer; ! import server.campaign.CampaignMain; ! import server.campaign.SPlayer; ! import server.campaign.SUnit; import server.campaign.util.UnitHistoryKeeper; /** ! * @author Helge Richter ! */ ! public class AdminScrapCommand extends Command { ! public void process(StringTokenizer command, String userName) { //Moderators may scrap always ! if (CampaignMain.cm.getServer().isModerator(userName)) { ! SPlayer p = CampaignMain.cm.getPlayer(command.nextToken()); ! int mechid = Integer.parseInt(command.nextToken()); SUnit m = p.getUnit(mechid); ! if (p != null) { p.removeUnit(mechid); ! CampaignMain.cm.units.remove(new Integer(mechid)); ! UnitHistoryKeeper.addScrapEntry(m.getId(), m.getPilot().getId(), p.getName(), p.getMyHouse().getName()); ! CampaignMain.cm.toUser("The " + m.getModelname() + ! " has been scrapped. Your HQ bows before your godlike admin powers!", ! userName, true); server.MMServ.mmlog.modLog(userName + " has scrapped a " + m.getModelname() + " from " + p.getName()); } |
From: Immanuel S. <im...@us...> - 2005-03-26 17:45:05
|
Update of /cvsroot/megameknet/MegaMekNET/src/server/campaign/market In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20292/src/server/campaign/market Modified Files: Market.java MarketUnit.java MarketSeller.java Log Message: xml loading finished Index: MarketSeller.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/market/MarketSeller.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MarketSeller.java 26 Mar 2005 12:22:19 -0000 1.5 --- MarketSeller.java 26 Mar 2005 17:44:24 -0000 1.6 *************** *** 17,27 **** public interface MarketSeller { - void addUnit(SUnit m, boolean isNew); void addMoney(int amount); String getName(); String getHouseName(); - void increaseUnitsOnMarket(SUnit m); - void decreaseUnitsOnMarket(SUnit m); - boolean isHuman(); double getMarketShare(); } \ No newline at end of file --- 17,31 ---- public interface MarketSeller { void addMoney(int amount); String getName(); String getHouseName(); double getMarketShare(); + + void recallUnitFromMarket(SUnit unit); + void placeUnitOnMarket(SUnit unit); + + /** + * Send a message to the seller of the unit. + */ + void sendMessage(String message, boolean isChat); } \ No newline at end of file Index: Market.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/market/Market.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Market.java 26 Mar 2005 12:22:18 -0000 1.21 --- Market.java 26 Mar 2005 17:44:24 -0000 1.22 *************** *** 105,118 **** } public int getFreeID() { ! boolean found = false; ! int i = 0; ! while (!found) { ! if (units.get(new Integer(i)) == null) { ! found = true; ! } else ! i++; ! } ! return i; } --- 105,115 ---- } + /** + * Get the first unused id in the black market. + */ public int getFreeID() { ! for (int i = 0;;++i) ! if (!units.containsKey(new Integer(i))) ! return i; } *************** *** 147,153 **** * The Market's status has been changed, so NO ONE knows it. */ - // Make this synchronized? public void clearStatus() { ! this.statusKnown.clear(); } --- 144,149 ---- * The Market's status has been changed, so NO ONE knows it. */ public void clearStatus() { ! statusKnown.clear(); } *************** *** 179,190 **** */ public void addUnit(MarketUnit m) { ! if (m.getSeller() == null) ! return; ! if (m.getTimeLeft() > 50) ! m.setTimeLeft(50); ! int id = getFreeID(); ! m.setId(id); ! units.put(new Integer(id), m); ! m.getSeller().increaseUnitsOnMarket(m.toUnit()); newMechsSinceTick++; /* FIXME: That got broken by the XStream saving --- 175,185 ---- */ public void addUnit(MarketUnit m) { ! if (m.getId() < 0) { ! // no id given yet. do it now ! int id = getFreeID(); ! m.setId(id); ! } ! units.put(new Integer(m.getId()), m); ! m.getSeller().placeUnitOnMarket(m.getCmech()); newMechsSinceTick++; /* FIXME: That got broken by the XStream saving *************** *** 201,207 **** CampaignMain.cm.toUser("You've bid " + b.getAmount() + " for the " + m.getCmech().getModelname(), b.getBuyer().getName(), true); //R1 this.fireStatusEvent("bid added", new AddBidEvent(m, b.getAmount()), b.getBuyer().getName()); ! if (m.getSeller().isHuman()) { ! CampaignMain.cm.toUser(Market.getBMStatus(m.getSeller().getName()), m.getSeller().getName(), false); ! } } else { CampaignMain.cm.toUser("Your bid was not accepted", b.getBuyer().getName(), true); --- 196,200 ---- CampaignMain.cm.toUser("You've bid " + b.getAmount() + " for the " + m.getCmech().getModelname(), b.getBuyer().getName(), true); //R1 this.fireStatusEvent("bid added", new AddBidEvent(m, b.getAmount()), b.getBuyer().getName()); ! m.getSeller().sendMessage(Market.getBMStatus(m.getSeller().getName()), false); } else { CampaignMain.cm.toUser("Your bid was not accepted", b.getBuyer().getName(), true); *************** *** 228,245 **** } - public void clearMarketOfPlayers() { - Enumeration e = units.elements(); - while (e.hasMoreElements()) { - MarketUnit m = (MarketUnit)e.nextElement(); - //if (m.getSeller().getClass().isInstance(SPlayer)) - //TODO - if (true) { - m.getSeller().addUnit(m.toUnit(), false); - m.getSeller().decreaseUnitsOnMarket(m.toUnit()); - units.remove(new Integer(m.getId())); - } - } - } - public void recall(int id, SPlayer p) { MarketUnit m = (MarketUnit)units.get(new Integer(id)); --- 221,224 ---- *************** *** 250,259 **** return; } ! p.decreaseUnitsOnMarket(m.toUnit()); ! p.addUnit(m.toUnit(), false); Vector v = m.getBids(); for (int i = 0; i < v.size(); i++) { Bid b = (Bid)v.elementAt(i); ! CampaignMain.cm.toUser("The " + m.toUnit().getModelname() + " has been recalled from the market. MekBay (TM) is sorry for the inconvenience", b.getBuyer().getName(), true); } units.remove(new Integer(id)); --- 229,238 ---- return; } ! p.recallUnitFromMarket(m.getCmech()); ! p.addUnit(m.getCmech(), false); Vector v = m.getBids(); for (int i = 0; i < v.size(); i++) { Bid b = (Bid)v.elementAt(i); ! CampaignMain.cm.toUser("The " + m.getCmech().getModelname() + " has been recalled from the market. MekBay (TM) is sorry for the inconvenience", b.getBuyer().getName(), true); } units.remove(new Integer(id)); *************** *** 283,287 **** MarketUnit m = (MarketUnit)e.nextElement(); if (m.getTimeLeft() <= time || time == 0) { ! result += m.getInfo(marketStatistic.getAverageForMech(m.toUnit())); } } --- 262,266 ---- MarketUnit m = (MarketUnit)e.nextElement(); if (m.getTimeLeft() <= time || time == 0) { ! result += m.getInfo(marketStatistic.getAverageForMech(m.getCmech())); } } *************** *** 324,332 **** //Mech has been sold //Build a new Mech from the sold mech ! SUnit cm = m.toUnit(); //Update the Stats marketStatistic.addTransfer(b.getAmount(), cm); //Add History Entry ! UnitHistoryKeeper.addSoldOnBMEntry(cm.getId(), cm.getPilot().getId(), b.getBuyer().getName(), b.getBuyer().getHouseName(), m.getSeller().getName(), m.getSeller().getHouseName()); //Transfer the money b.getBuyer().setMoney(b.getBuyer().getMoney() - b.getAmount()); --- 303,314 ---- //Mech has been sold //Build a new Mech from the sold mech ! SUnit cm = m.getCmech(); //Update the Stats marketStatistic.addTransfer(b.getAmount(), cm); //Add History Entry ! UnitHistoryKeeper.addSoldOnBMEntry(cm.getId(), ! cm.getPilot().getId(), b.getBuyer().getName(), ! b.getBuyer().getHouseName(), m.getSeller().getName(), ! m.getSeller().getHouseName()); //Transfer the money b.getBuyer().setMoney(b.getBuyer().getMoney() - b.getAmount()); *************** *** 340,344 **** } m.getSeller().addMoney(b.getAmount() - market_share); ! m.getSeller().decreaseUnitsOnMarket(m.toUnit()); //Transfer the mech b.getBuyer().addUnit(cm, true); --- 322,326 ---- } m.getSeller().addMoney(b.getAmount() - market_share); ! m.getSeller().recallUnitFromMarket(m.getCmech()); //Transfer the mech b.getBuyer().addUnit(cm, true); *************** *** 356,362 **** //Noone wanted that mech CampaignMain.cm.toUser("Noone wanted to buy the " + m.getCmech().getModelname() + ". It has been returned to your hangar", m.getSeller().getName(), true); ! SUnit cm = m.toUnit(); ! m.getSeller().decreaseUnitsOnMarket(m.toUnit()); ! m.getSeller().addUnit(cm, false); //Let it be worth 1 for the stats, so overpriced AV gets down if (marketStatistic.getAverageForMech(m.getCmech()) > m.getMinBid()) --- 338,343 ---- //Noone wanted that mech CampaignMain.cm.toUser("Noone wanted to buy the " + m.getCmech().getModelname() + ". It has been returned to your hangar", m.getSeller().getName(), true); ! SUnit cm = m.getCmech(); ! m.getSeller().recallUnitFromMarket(m.getCmech()); //Let it be worth 1 for the stats, so overpriced AV gets down if (marketStatistic.getAverageForMech(m.getCmech()) > m.getMinBid()) *************** *** 387,395 **** String faction = "Rare"; SHouse seller = CampaignMain.getHouseFromPartialString("Solaris Training Company", null); ! String Filename = BuildTable.getUnitFilename(faction, Unit.getWeightClassDesc(size), SUnit.MEK, new TimeZoneData("3025", 100)); String[] reasons = {"Brewed by aliens and delivered to our planetoid", "Hidden in a cache for centuries", "From an unknown source", "Built by " + faction + " in a hidden facility"}; int pickReason = CampaignMain.cm.getR().nextInt(3) + 1; String reason = reasons[pickReason]; ! SUnit mech = new SUnit(reason, Filename, size); SPilot p = new SPilot("Ducan McLeod", 4, 5, CampaignMain.getHouseFromPartialString("Solaris", null)); mech.setPilot(p, true); --- 368,376 ---- String faction = "Rare"; SHouse seller = CampaignMain.getHouseFromPartialString("Solaris Training Company", null); ! String filename = BuildTable.getUnitFilename(faction, Unit.getWeightClassDesc(size), SUnit.MEK, new TimeZoneData("3025", 100)); String[] reasons = {"Brewed by aliens and delivered to our planetoid", "Hidden in a cache for centuries", "From an unknown source", "Built by " + faction + " in a hidden facility"}; int pickReason = CampaignMain.cm.getR().nextInt(3) + 1; String reason = reasons[pickReason]; ! SUnit mech = new SUnit(reason, filename, size); SPilot p = new SPilot("Ducan McLeod", 4, 5, CampaignMain.getHouseFromPartialString("Solaris", null)); mech.setPilot(p, true); Index: MarketUnit.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/market/MarketUnit.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** MarketUnit.java 6 Mar 2005 12:41:39 -0000 1.10 --- MarketUnit.java 26 Mar 2005 17:44:24 -0000 1.11 *************** *** 32,38 **** private SUnit cmech; ! public MarketUnit() { ! //for serialisability ! } public MarketUnit(MarketSeller seller, int timeleft, int minbid, String comment, SUnit cmech) { --- 32,39 ---- private SUnit cmech; ! /** ! * for serialisation ! */ ! public MarketUnit() {} public MarketUnit(MarketSeller seller, int timeleft, int minbid, String comment, SUnit cmech) { *************** *** 44,52 **** } ! public SUnit toUnit() { ! return cmech; ! } ! ! public String toString(String Playername) { String delimiter = "*"; String result = "MM"; --- 45,49 ---- } ! public String toString(String playername) { String delimiter = "*"; String result = "MM"; *************** *** 55,59 **** result += delimiter; //Send Client string to Clients, Server string to Server ! result += cmech.toString(!Playername.equals("")); result += delimiter; if (!comment.equals("")) --- 52,56 ---- result += delimiter; //Send Client string to Clients, Server string to Server ! result += cmech.toString(!playername.equals("")); result += delimiter; if (!comment.equals("")) *************** *** 67,76 **** result += delimiter; //Hide seller if it's not himself ! if (Playername.equals(seller.getName()) || Playername.equals("")) result += seller.getName(); else result += "unknown"; //It's a SAVE so no PLayername given ! if (Playername.equals("")) { result += delimiter; result += bids.size(); --- 64,73 ---- result += delimiter; //Hide seller if it's not himself ! if (playername.equals(seller.getName()) || playername.equals("")) result += seller.getName(); else result += "unknown"; //It's a SAVE so no PLayername given ! if (playername.equals("")) { result += delimiter; result += bids.size(); *************** *** 83,87 **** //Only send HIS bid to the player { ! Bid b = this.getBidFor(Playername); result += delimiter; if (b == null) --- 80,84 ---- //Only send HIS bid to the player { ! Bid b = this.getBidFor(playername); result += delimiter; if (b == null) *************** *** 102,113 **** public void fromString(String s, CampaignMain myC) { s = s.substring(3); ! StringTokenizer ST = new StringTokenizer(s, "*"); ! id = Integer.parseInt(ST.nextToken()); cmech = new SUnit(); ! cmech.fromString(ST.nextToken()); ! comment = ST.nextToken(); ! timeLeft = Integer.parseInt(ST.nextToken()); ! minBid = Integer.parseInt(ST.nextToken()); ! String sellername = ST.nextToken(); SHouse h = CampaignMain.getHouseFromPartialString(sellername, null); if (h != null) --- 99,110 ---- public void fromString(String s, CampaignMain myC) { s = s.substring(3); ! StringTokenizer st = new StringTokenizer(s, "*"); ! id = Integer.parseInt(st.nextToken()); cmech = new SUnit(); ! cmech.fromString(st.nextToken()); ! comment = st.nextToken(); ! timeLeft = Integer.parseInt(st.nextToken()); ! minBid = Integer.parseInt(st.nextToken()); ! String sellername = st.nextToken(); SHouse h = CampaignMain.getHouseFromPartialString(sellername, null); if (h != null) *************** *** 115,121 **** else this.seller = myC.getPlayer(sellername); ! int bidsamount = Integer.parseInt(ST.nextToken()); for (int i = 0; i < bidsamount; i++) { ! String bidstring = ST.nextToken(); Bid bid = new Bid(); bid.fromString(bidstring, myC); --- 112,118 ---- else this.seller = myC.getPlayer(sellername); ! int bidsamount = Integer.parseInt(st.nextToken()); for (int i = 0; i < bidsamount; i++) { ! String bidstring = st.nextToken(); Bid bid = new Bid(); bid.fromString(bidstring, myC); |
From: Immanuel S. <im...@us...> - 2005-03-26 17:44:37
|
Update of /cvsroot/megameknet/MegaMekNET/src/server/campaign/commands In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20292/src/server/campaign/commands Modified Files: AdminSaveCommand.java SellCommand.java UseRewardPointsCommand.java Log Message: xml loading finished Index: AdminSaveCommand.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/commands/AdminSaveCommand.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** AdminSaveCommand.java 26 Mar 2005 12:22:15 -0000 1.12 --- AdminSaveCommand.java 26 Mar 2005 17:44:26 -0000 1.13 *************** *** 65,68 **** --- 65,70 ---- try { SXMLSaveVisitor saver = new SXMLSaveVisitor(); + // Units + saver.toXml("campaign/unit.xml", "units", CampaignMain.cm.units.values()); // Houses (one file for each house because memory concerns) for (Iterator it = data.getAllHouses().iterator(); it.hasNext();) { Index: SellCommand.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/commands/SellCommand.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SellCommand.java 26 Feb 2005 13:58:47 -0000 1.10 --- SellCommand.java 26 Mar 2005 17:44:26 -0000 1.11 *************** *** 19,24 **** package server.campaign.commands; - import java.util.StringTokenizer; - import server.campaign.CampaignMain; import server.campaign.SPlayer; --- 19,22 ---- *************** *** 26,107 **** import server.campaign.market.MarketUnit; - /** * @author Helge Richter * */ ! public class SellCommand extends Command ! { ! public void process(StringTokenizer command, String userName) ! { ! SPlayer p= CampaignMain.cm.getPlayer(userName); ! if (p.getMyHouse().isNewbieHouse()) ! { CampaignMain.cm.toUser("SOL players may not Sell, Scrap or Donate their units!", userName, true); return; } ! int mechid= Integer.parseInt(command.nextToken()); ! SUnit m= p.getUnit(mechid); ! if (m != null) { ! int sellFluCost = Integer.parseInt(CampaignMain.cm.getConfig("BMSellFlu")); ! sellFluCost = sellFluCost + (m.getWeightclass()) * Integer.parseInt(CampaignMain.cm.getConfig("BMFluSizeCost")); ! if (p.getExperience() < Integer.parseInt(CampaignMain.cm.getConfig("MinEXPforBMSelling"))) { CampaignMain.cm.toUser("You are not allowed to sell mechs on the BM. You are too inexperienced to make contact, sorry", userName, true); return; ! } ! else if (!p.getMyHouse().isMayUseBM()) { CampaignMain.cm.toUser("Your house may not use the Black Market, sorry", userName, true); return; ! } ! else if(m.getStatus() == SUnit.STATUS_UNMAINTAINED) { CampaignMain.cm.toUser("You may not sell unmaintained mechs on the Black Market.", userName, true); return; ! } ! else if (!m.mayBeSoldOnMarket()) { CampaignMain.cm.toUser("This unit may not be sold on the Black Market.", userName, true); return; ! } ! else if (p.getAmountOfTimesUnitExistsInArmies(mechid) > 0 ) ! { ! CampaignMain.cm.toUser("Remove this unit from all armies before you try to sell it on the Black Market.", userName, true); return; } ! /*else if (p.getInfluence() < sellFluCost) { ! CampaignMain.cm.toUser("You need " + (sellFluCost - p.getInfluence()) + " more influence to sell this unit.", userName, true); ! return; ! }*/ ! else {//flu check passed, so take away flu. include expenditure in final message further down ! //p.addInfluence(-sellFluCost); ! } ! int time= 5; ! if (command.hasMoreElements()) ! time= Integer.parseInt(command.nextToken()); if (time == 0) ! time= 4; if (time > 100) ! time= 100; ! int minbid= 1; ! String comment= ""; ! if (command.hasMoreElements()) { ! minbid= Integer.parseInt(command.nextToken()); ! if (command.hasMoreElements()) ! comment= command.nextToken(); } ! MarketUnit mm= ! new MarketUnit( ! p, ! time, ! minbid, ! comment, ! m); ! CampaignMain.cm.getMarket().addUnit(mm); ! p.removeUnit(m.getId()); ! CampaignMain.cm.toUser("The " + m.getModelname() + " has been added to the Black Market.", userName, true); ! CampaignMain.cm.doSendHouseMail(p.getMyHouse(), "NOTE", p.getName() + " has put a " + m.getVerboseModelName() + " on the Black Market!"); ! server.MMServ.mmlog.bmLog(p.getName() + " is selling a " + m.getVerboseModelName() + " for " + minbid); } - } - } --- 24,96 ---- import server.campaign.market.MarketUnit; /** * @author Helge Richter * */ ! public class SellCommand extends Command { ! ! public SellCommand() { ! super("sell", 1); ! } ! ! protected String usage() { ! return "unitid[#ticks[#minbid[#comment]]]"; ! } ! ! public String help() { ! return "Places an unit on the black market. You have to specify the unit's" + ! "unique id and optional the number of ticks until the auction " + ! "finishes, the minimum bid and a comment for the auction."; ! } ! ! public void process(String[] param, String userName) throws IllegalUsageException { ! SPlayer player = CampaignMain.cm.getPlayer(userName); ! ! if (player.getMyHouse().isNewbieHouse()) { CampaignMain.cm.toUser("SOL players may not Sell, Scrap or Donate their units!", userName, true); return; } ! ! int mechid = Integer.parseInt(param[0]); ! SUnit unit = player.getUnit(mechid); ! if (unit != null) { ! if (player.getExperience() < Integer.parseInt(CampaignMain.cm.getConfig("MinEXPforBMSelling"))) { CampaignMain.cm.toUser("You are not allowed to sell mechs on the BM. You are too inexperienced to make contact, sorry", userName, true); return; ! } else if (!player.getMyHouse().isMayUseBM()) { CampaignMain.cm.toUser("Your house may not use the Black Market, sorry", userName, true); return; ! } else if (unit.getStatus() == SUnit.STATUS_UNMAINTAINED) { CampaignMain.cm.toUser("You may not sell unmaintained mechs on the Black Market.", userName, true); return; ! } else if (!unit.mayBeSoldOnMarket()) { CampaignMain.cm.toUser("This unit may not be sold on the Black Market.", userName, true); return; ! } else if (player.getAmountOfTimesUnitExistsInArmies(mechid) > 0) { ! CampaignMain.cm.toUser("Remove this unit from all armies before you try to sell it on the Black Market.", userName, true); return; } ! int time = 5; ! if (param.length > 1) ! time = Integer.parseInt(param[1]); if (time == 0) ! time = 4; if (time > 100) ! time = 100; ! int minbid = 1; ! String comment = ""; ! if (param.length > 2) { ! minbid = Integer.parseInt(param[2]); ! if (param.length > 3) ! comment = param[3]; } ! MarketUnit mm = new MarketUnit(player, time, minbid, comment, unit); ! CampaignMain.cm.getMarket().addUnit(mm); ! player.removeUnit(unit.getId()); ! CampaignMain.cm.toUser("The " + unit.getModelname() + " has been added to the Black Market.", userName, true); ! CampaignMain.cm.doSendHouseMail(player.getMyHouse(), "NOTE", player.getName() + " has put a " + unit.getVerboseModelName() + " on the Black Market!"); ! server.MMServ.mmlog.bmLog(player.getName() + " is selling a " + unit.getVerboseModelName() + " for " + minbid); } } } Index: UseRewardPointsCommand.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/commands/UseRewardPointsCommand.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** UseRewardPointsCommand.java 27 Feb 2005 09:28:26 -0000 1.22 --- UseRewardPointsCommand.java 26 Mar 2005 17:44:26 -0000 1.23 *************** *** 14,296 **** package server.campaign.commands; ! ! import java.util.*; ! ! import common.Unit; ! import server.campaign.SPlayer; import server.campaign.SUnit; - import server.campaign.SHouse; import server.campaign.SUnitFactory; - import server.campaign.CampaignMain; import server.campaign.pilot.SPilot; - import server.campaign.BuildTable; - - import server.campaign.util.UnitHistoryKeeper; import server.campaign.util.TimeZoneData; /** ! * ! * @author Torren Aug 28, 2004 ! * allows users to redeem award points. * they can redeem for techs, influence, or units ! * syntax for techs and influence: /c userewardpoints#typeofreward#amountofrewardpointstouse ! * syntax for units /c userewardpoints#typeofreward#unittype#unitweight#[house]/[rare] * items in brackets are optional. purchasing a rare unit will cost more rewardpoints * */ ! public class UseRewardPointsCommand extends Command ! { ! public void process(StringTokenizer command,String userName) ! { ! /* ! * rewardSelections: ! * 0 Techs ! * 1 Influence ! * 2 Units ! */ ! int rewardSelection = Integer.parseInt(command.nextToken()); ! int rewardPoints = 0; ! SPlayer player = CampaignMain.cm.getPlayer(userName); ! ! if (rewardSelection < 0 || rewardSelection > 2 ){ ! CampaignMain.cm.toUser("Invalid reward selection. 0 for techs, 1 for influence, 2 for units.",userName,true); ! return; ! } ! switch(rewardSelection){ ! case 0: //buying techs. ! rewardPoints = Integer.parseInt(command.nextToken()); ! if ( !(new Boolean(CampaignMain.cm.getConfig("AllowTechsForRewards")).booleanValue()) ){ ! CampaignMain.cm.toUser("Sorry but you are not allowed to buy techs with reward points.",userName,true); ! return; ! } ! if ( rewardPoints > player.getRewardPoints() ) ! { ! if ( player.getRewardPoints() == 1) ! CampaignMain.cm.toUser("You only have 1 reward point try again.",userName,true); ! else ! CampaignMain.cm.toUser("You only have " + player.getRewardPoints() + " reward points try again.",userName,true); ! return; ! } ! int numOfTechBought = (Integer.parseInt(CampaignMain.cm.getConfig("TechsForARewardPoint"))); ! numOfTechBought *= rewardPoints; ! String techs = ""; ! String rewards = ""; ! if ( numOfTechBought > 1 ) ! techs ="s"; ! if (rewardPoints > 1) ! rewards = "s"; ! CampaignMain.cm.toUser("You've bought " + numOfTechBought + " tech" + techs + " for " + rewardPoints + " reward point"+ rewards +".",userName,true); ! player.addReward(-rewardPoints); ! player.addTechnicians(numOfTechBought); ! break; ! case 1: //buying influence ! rewardPoints = Integer.parseInt(command.nextToken()); ! if ( !(new Boolean(CampaignMain.cm.getConfig("AllowInfluenceForRewards")).booleanValue())){ ! CampaignMain.cm.toUser("Sorry but you are not allowed to buy influence with reward points.",userName,true); ! return; ! } ! if ( rewardPoints > player.getRewardPoints() ) ! { ! if ( player.getRewardPoints() == 1) ! CampaignMain.cm.toUser("You only have 1 reward point try again.",userName,true); ! else ! CampaignMain.cm.toUser("You only have " + player.getRewardPoints() + " reward points try again.",userName,true); ! return; ! } ! int amountOfInfluenceBought = (Integer.parseInt(CampaignMain.cm.getConfig("InfluenceForARewardPoint"))); ! amountOfInfluenceBought *= rewardPoints; ! if ( rewardPoints > 1 ) ! rewards = "s"; ! else ! rewards = ""; ! CampaignMain.cm.toUser("You've bought " + amountOfInfluenceBought + " influence for " + rewardPoints + " reward point" + rewards + ".",userName,true); ! player.addReward(-rewardPoints); ! //player.addInfluence(amountOfInfluenceBought); ! break; ! case 2: //buying units ! if ( !(new Boolean(CampaignMain.cm.getConfig("AllowUnitsForRewards")).booleanValue())){ ! CampaignMain.cm.toUser("Sorry but you are not allowed to buy units with reward points.",userName,true); ! return; ! } ! int rewardPointsAvailable = player.getRewardPoints(); ! int unitTotalRewardPointCost = 0; ! String typestring = command.nextToken(); ! String weightstring = command.nextToken(); ! int unitType = Unit.MEK; ! int unitWeight = Unit.LIGHT; ! int typeCost = (Integer.parseInt(CampaignMain.cm.getConfig("RewardPointsForAMek"))); ! int weightCost = (Integer.parseInt(CampaignMain.cm.getConfig("RewardPointsForALight"))); ! SHouse house = player.getHouseFightingFor(); ! double rareCost = 1; ! double nonHouseCost = 1; ! boolean buyRareUnit = false; ! boolean buyNonHouseUnit = false; ! SUnit newUnit = null; ! SPilot newPilot = null; ! String housestring = "common"; ! ! if ( new Boolean(CampaignMain.cm.getConfig("AllowRareUnitsForRewards")).booleanValue()){ ! rareCost = (Double.parseDouble(CampaignMain.cm.getConfig("RewardPointMultiplierForRare"))); ! } ! nonHouseCost = (Double.parseDouble(CampaignMain.cm.getConfig("RewardPointMultiplierForNonHouse"))); ! try ! { ! unitType = Integer.parseInt(typestring); ! } ! catch (Exception ex) ! { ! unitType = Unit.getTypeIDForName(typestring); ! } ! ! try ! { ! unitWeight = Integer.parseInt(weightstring); ! } ! catch (Exception ex) ! { ! unitWeight = Unit.getWeightIDForName(((String)weightstring).toUpperCase()); ! } ! if ( command.hasMoreElements()) ! { ! housestring = command.nextToken(); ! ! if ( housestring.equalsIgnoreCase("rare") ) ! { ! if ( !(new Boolean(CampaignMain.cm.getConfig("AllowRareUnitsForRewards")).booleanValue()) ) ! { ! CampaignMain.cm.toUser("Sorry but you are not allowed to buy rare units with your reward points.",userName,true); ! return; ! } ! else ! { ! buyRareUnit = true; ! housestring = "Rare"; ! } ! } ! else { ! house = CampaignMain.cm.getHouseForName(housestring); ! if (house != null){ ! if (!house.equals(player.getHouseFightingFor())) ! buyNonHouseUnit = true; ! } ! } ! if ( house == null ) ! { ! house = player.getHouseFightingFor(); ! if ( house == null ) ! housestring = "Common"; ! } ! } ! ! ! switch (unitType) ! { ! case Unit.MEK: ! typeCost = (Integer.parseInt(CampaignMain.cm.getConfig("RewardPointsForAMek"))); ! break; ! case Unit.VEHICLE: ! typeCost = (Integer.parseInt(CampaignMain.cm.getConfig("RewardPointsForAVeh"))); ! break; ! case Unit.INFANTRY: ! typeCost = (Integer.parseInt(CampaignMain.cm.getConfig("RewardPointsForInf"))); ! unitWeight = Unit.LIGHT; ! break; ! } ! ! switch ( unitWeight) ! { ! case Unit.LIGHT: ! weightCost = (Integer.parseInt(CampaignMain.cm.getConfig("RewardPointsForALight"))); ! break; ! case Unit.MEDIUM: ! weightCost = (Integer.parseInt(CampaignMain.cm.getConfig("RewardPointsForAMed"))); ! break; ! case Unit.HEAVY: ! weightCost = (Integer.parseInt(CampaignMain.cm.getConfig("RewardPointsForAHeavy"))); ! break; ! case Unit.ASSAULT: ! weightCost = (Integer.parseInt(CampaignMain.cm.getConfig("RewardPointsForAnAssault"))); ! break; ! } ! ! unitTotalRewardPointCost = weightCost + typeCost; ! if (buyRareUnit) ! { ! unitTotalRewardPointCost *= rareCost; ! } else if (buyNonHouseUnit){ ! unitTotalRewardPointCost *= nonHouseCost; ! } ! if ( unitTotalRewardPointCost > rewardPointsAvailable ){ ! CampaignMain.cm.toUser("Sorry but you do not have enough reward points to buy that unit.",userName,true); ! return; ! } ! ! if ( !player.hasRoom(unitWeight) ) ! { ! CampaignMain.cm.toUser("Sorry but do not have enough room for that unit.",userName,true); ! return; ! } ! ! ! //Let get us a pilot and a unit hora ! newPilot = player.getHouseFightingFor().getNewPilot(unitType); ! ! newUnit = getUnitProduced(unitType,unitWeight,newPilot,housestring); ! player.addUnit(newUnit, true); ! UnitHistoryKeeper.addBoughtFromFactoryEntry(newUnit.getId(), newUnit.getPilot().getId(), "Reward Points", player.getMyHouse().getName()); ! CampaignMain.cm.toUser("You've bought a " + newUnit.getModelname() + " for " +unitTotalRewardPointCost + " reward points.",userName,true); ! player.addReward(-unitTotalRewardPointCost); ! ! } ! ! } ! ! /** ! * If a mek is produced (called when a new mech is requested) this is called. ! * It first determines which Timezone to use, then determines wether it's a Rare Mek ! * (Comstar or WD for now) and assembles appropriate fluff for the unit. ! * ONLY use this if you're going to use the mek it produces! ! * @return the Mek Produced ! */ ! private SUnit getUnitProduced(int type_id, int weightClass, SPilot pilot, String house) { ! ! SUnitFactory factory = new SUnitFactory(); ! String unitSize = Unit.getWeightClassDesc(weightClass); ! factory.setFounder(house); ! factory.setProductionTable(house); ! ! String MechConstructor = house;//the faction whose tables we read ! ! String Filename = ""; ! String timezone = CampaignMain.cm.getConfig("RewardPointUnitEra"); ! ! TimeZoneData TZUsed = new TimeZoneData(); ! TZUsed.setName(timezone); ! TZUsed.setPropability(100); ! ! //Build the fluff text for the mek ! String producer = "Built by reward points interstellar from spare parts stockpiles"; ! ! if (new Boolean(CampaignMain.cm.getConfig("UseOnlyOneVehicleSize")).booleanValue() && type_id == SUnit.VEHICLE) ! unitSize = Unit.getWeightClassDesc(CampaignMain.cm.getR().nextInt(4)); ! ! Filename = BuildTable.getUnitFilename(MechConstructor,unitSize,type_id,TZUsed); ! ! //log the creation ! System.out.println(unitSize + MechConstructor); ! //Build the Unit ! System.out.println("Producer: " + producer); ! System.out.println("Filename: " + Filename); ! SUnit cm = new SUnit(producer,Filename,weightClass); ! //Create History Entry ! producer = factory.getFounder(); ! UnitHistoryKeeper.addProductionEntry(cm.getId(), "Reward Points Factory", "ComStar", producer, cm.getUnitFilename()); ! ! cm.setPilot(pilot, true); ! return cm; ! } ! } \ No newline at end of file --- 14,263 ---- package server.campaign.commands; ! import server.campaign.BuildTable; ! import server.campaign.CampaignMain; ! import server.campaign.SHouse; import server.campaign.SPlayer; import server.campaign.SUnit; import server.campaign.SUnitFactory; import server.campaign.pilot.SPilot; import server.campaign.util.TimeZoneData; + import server.campaign.util.UnitHistoryKeeper; + import common.Unit; /** ! * Allows users to redeem award points. * they can redeem for techs, influence, or units ! * ! * syntax for techs and influence: ! * /c userewardpoints#typeofreward#amountofrewardpointstouse ! * ! * syntax for units ! * /c userewardpoints#typeofreward#unittype#unitweight#[house]/[rare] ! * * items in brackets are optional. purchasing a rare unit will cost more rewardpoints * + * @author Torren Aug 28, 2004 */ ! public class UseRewardPointsCommand extends Command { ! public UseRewardPointsCommand() { ! super("userewardpoints", 3); ! } ! ! protected String usage() { ! return "#type[#amount|unittype#weight[house|rare]]"; ! } ! public String help() { ! return "Use your rewardpoints by either hireing technicans (type=0) or " + ! "units (type=2).<br>example:<br> " + ! "/c userewardpoints#0#20 - spend 20 reward points on technicans.<br> " + ! "/c userewardpoints#2#mek#light#steiner - buy a light steiner mech."; ! } ! public void process(String[] param, String userName) throws IllegalUsageException { ! /* ! * rewardSelections: ! * 0 Techs ! * 1 Influence ! * 2 Units ! */ ! int rewardSelection = Integer.parseInt(param[0]); ! int rewardPoints = 0; ! SPlayer player = CampaignMain.cm.getPlayer(userName); ! if (rewardSelection < 0 || rewardSelection > 2) { ! CampaignMain.cm.toUser("Invalid reward selection. 0 for techs, 1 for influence, 2 for units.", userName, true); ! return; ! } ! switch (rewardSelection) { ! case 0: //buying techs. ! rewardPoints = Integer.parseInt(param[1]); ! if (!(new Boolean(CampaignMain.cm.getConfig("AllowTechsForRewards")).booleanValue())) { ! CampaignMain.cm.toUser("Sorry but you are not allowed to buy techs with reward points.", userName, true); ! return; ! } ! if (rewardPoints > player.getRewardPoints()) { ! if (player.getRewardPoints() == 1) ! CampaignMain.cm.toUser("You only have 1 reward point try again.", userName, true); ! else ! CampaignMain.cm.toUser("You only have " + player.getRewardPoints() + " reward points try again.", userName, true); ! return; ! } ! int numOfTechBought = (Integer.parseInt(CampaignMain.cm.getConfig("TechsForARewardPoint"))); ! numOfTechBought *= rewardPoints; ! String techs = ""; ! String rewards = ""; ! if (numOfTechBought > 1) ! techs = "s"; ! if (rewardPoints > 1) ! rewards = "s"; ! CampaignMain.cm.toUser("You've bought " + numOfTechBought + " tech" + techs + " for " + rewardPoints + " reward point" + rewards + ".", userName, true); ! player.addReward(-rewardPoints); ! player.addTechnicians(numOfTechBought); ! break; ! case 1: //buying influence ! rewardPoints = Integer.parseInt(param[1]); ! if (!(new Boolean(CampaignMain.cm.getConfig("AllowInfluenceForRewards")).booleanValue())) { ! CampaignMain.cm.toUser("Sorry but you are not allowed to buy influence with reward points.", userName, true); ! return; ! } ! if (rewardPoints > player.getRewardPoints()) { ! if (player.getRewardPoints() == 1) ! CampaignMain.cm.toUser("You only have 1 reward point try again.", userName, true); ! else ! CampaignMain.cm.toUser("You only have " + player.getRewardPoints() + " reward points try again.", userName, true); ! return; ! } ! int amountOfInfluenceBought = (Integer.parseInt(CampaignMain.cm.getConfig("InfluenceForARewardPoint"))); ! amountOfInfluenceBought *= rewardPoints; ! if (rewardPoints > 1) ! rewards = "s"; ! else ! rewards = ""; ! CampaignMain.cm.toUser("You've bought " + amountOfInfluenceBought + " influence for " + rewardPoints + " reward point" + rewards + ".", userName, true); ! player.addReward(-rewardPoints); ! //player.addInfluence(amountOfInfluenceBought); ! break; ! case 2: //buying units ! if (!(new Boolean(CampaignMain.cm.getConfig("AllowUnitsForRewards")).booleanValue())) { ! CampaignMain.cm.toUser("Sorry but you are not allowed to buy units with reward points.", userName, true); ! return; ! } ! int rewardPointsAvailable = player.getRewardPoints(); ! int unitTotalRewardPointCost = 0; ! String typestring = param[1]; ! String weightstring = param[2]; ! int unitType = Unit.MEK; ! int unitWeight = Unit.LIGHT; ! int typeCost = (Integer.parseInt(CampaignMain.cm.getConfig("RewardPointsForAMek"))); ! int weightCost = (Integer.parseInt(CampaignMain.cm.getConfig("RewardPointsForALight"))); ! SHouse house = player.getHouseFightingFor(); ! double rareCost = 1; ! double nonHouseCost = 1; ! boolean buyRareUnit = false; ! boolean buyNonHouseUnit = false; ! SUnit newUnit = null; ! SPilot newPilot = null; ! String housestring = "common"; ! if (new Boolean(CampaignMain.cm.getConfig("AllowRareUnitsForRewards")).booleanValue()) { ! rareCost = (Double.parseDouble(CampaignMain.cm.getConfig("RewardPointMultiplierForRare"))); ! } ! nonHouseCost = (Double.parseDouble(CampaignMain.cm.getConfig("RewardPointMultiplierForNonHouse"))); ! try { ! unitType = Integer.parseInt(typestring); ! } catch (Exception ex) { ! unitType = Unit.getTypeIDForName(typestring); ! } ! try { ! unitWeight = Integer.parseInt(weightstring); ! } catch (Exception ex) { ! unitWeight = Unit.getWeightIDForName(((String)weightstring).toUpperCase()); ! } ! if (param.length > 1) { ! housestring = param[1]; ! if (housestring.equalsIgnoreCase("rare")) { ! if (!(new Boolean(CampaignMain.cm.getConfig("AllowRareUnitsForRewards")).booleanValue())) { ! CampaignMain.cm.toUser("Sorry but you are not allowed to buy rare units with your reward points.", userName, true); ! return; ! } else { ! buyRareUnit = true; ! housestring = "Rare"; ! } ! } else { ! house = CampaignMain.cm.getHouseForName(housestring); ! if (house != null) { ! if (!house.equals(player.getHouseFightingFor())) ! buyNonHouseUnit = true; ! } ! } ! if (house == null) { ! house = player.getHouseFightingFor(); ! if (house == null) ! housestring = "Common"; ! } ! } ! switch (unitType) { ! case Unit.MEK: ! typeCost = (Integer.parseInt(CampaignMain.cm.getConfig("RewardPointsForAMek"))); ! break; ! case Unit.VEHICLE: ! typeCost = (Integer.parseInt(CampaignMain.cm.getConfig("RewardPointsForAVeh"))); ! break; ! case Unit.INFANTRY: ! typeCost = (Integer.parseInt(CampaignMain.cm.getConfig("RewardPointsForInf"))); ! unitWeight = Unit.LIGHT; ! break; ! } ! switch (unitWeight) { ! case Unit.LIGHT: ! weightCost = (Integer.parseInt(CampaignMain.cm.getConfig("RewardPointsForALight"))); ! break; ! case Unit.MEDIUM: ! weightCost = (Integer.parseInt(CampaignMain.cm.getConfig("RewardPointsForAMed"))); ! break; ! case Unit.HEAVY: ! weightCost = (Integer.parseInt(CampaignMain.cm.getConfig("RewardPointsForAHeavy"))); ! break; ! case Unit.ASSAULT: ! weightCost = (Integer.parseInt(CampaignMain.cm.getConfig("RewardPointsForAnAssault"))); ! break; ! } ! unitTotalRewardPointCost = weightCost + typeCost; ! if (buyRareUnit) { ! unitTotalRewardPointCost *= rareCost; ! } else if (buyNonHouseUnit) { ! unitTotalRewardPointCost *= nonHouseCost; ! } ! if (unitTotalRewardPointCost > rewardPointsAvailable) { ! CampaignMain.cm.toUser("Sorry but you do not have enough reward points to buy that unit.", userName, true); ! return; ! } ! if (!player.hasRoom(unitWeight)) { ! CampaignMain.cm.toUser("Sorry but do not have enough room for that unit.", userName, true); ! return; ! } ! //Let get us a pilot and a unit hora ! newPilot = player.getHouseFightingFor().getNewPilot(unitType); ! newUnit = getUnitProduced(unitType, unitWeight, newPilot, housestring); ! player.addUnit(newUnit, true); ! UnitHistoryKeeper.addBoughtFromFactoryEntry(newUnit.getId(), newUnit.getPilot().getId(), "Reward Points", player.getMyHouse().getName()); ! CampaignMain.cm.toUser("You've bought a " + newUnit.getModelname() + " for " + unitTotalRewardPointCost + " reward points.", userName, true); ! player.addReward(-unitTotalRewardPointCost); ! } ! } ! ! /** ! * If a mek is produced (called when a new mech is requested) this is called. ! * It first determines which Timezone to use, then determines wether it's a Rare Mek ! * (Comstar or WD for now) and assembles appropriate fluff for the unit. ! * ONLY use this if you're going to use the mek it produces! ! * @return the Mek Produced ! */ ! private SUnit getUnitProduced(int type_id, int weightClass, SPilot pilot, String house) { ! SUnitFactory factory = new SUnitFactory(); ! String unitSize = Unit.getWeightClassDesc(weightClass); ! factory.setFounder(house); ! factory.setProductionTable(house); ! String MechConstructor = house;//the faction whose tables we read ! String Filename = ""; ! String timezone = CampaignMain.cm.getConfig("RewardPointUnitEra"); ! TimeZoneData TZUsed = new TimeZoneData(); ! TZUsed.setName(timezone); ! TZUsed.setPropability(100); ! //Build the fluff text for the mek ! String producer = "Built by reward points interstellar from spare parts stockpiles"; ! if (new Boolean(CampaignMain.cm.getConfig("UseOnlyOneVehicleSize")).booleanValue() && type_id == SUnit.VEHICLE) ! unitSize = Unit.getWeightClassDesc(CampaignMain.cm.getR().nextInt(4)); ! Filename = BuildTable.getUnitFilename(MechConstructor, unitSize, type_id, TZUsed); ! //log the creation ! System.out.println(unitSize + MechConstructor); ! //Build the Unit ! System.out.println("Producer: " + producer); ! System.out.println("Filename: " + Filename); ! SUnit cm = new SUnit(producer, Filename, weightClass); ! //Create History Entry ! producer = factory.getFounder(); ! UnitHistoryKeeper.addProductionEntry(cm.getId(), "Reward Points Factory", "ComStar", producer, cm.getUnitFilename()); ! cm.setPilot(pilot, true); ! return cm; ! } } \ No newline at end of file |
From: Immanuel S. <im...@us...> - 2005-03-26 17:44:37
|
Update of /cvsroot/megameknet/MegaMekNET/src/common/visitor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20292/src/common/visitor Modified Files: XMLSaveVisitor.java XMLLoadVisitor.java Log Message: xml loading finished Index: XMLSaveVisitor.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/common/visitor/XMLSaveVisitor.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** XMLSaveVisitor.java 26 Mar 2005 12:22:17 -0000 1.9 --- XMLSaveVisitor.java 26 Mar 2005 17:44:27 -0000 1.10 *************** *** 20,23 **** --- 20,25 ---- import java.util.Date; import java.util.Iterator; + import java.util.LinkedList; + import java.util.List; import java.util.Map; import org.jdom.Document; *************** *** 91,99 **** /** ! * Helper to create a new element and add the "class" attribute. * * @param data The data to be saved. */ ! protected Element start(String elementName, Visitorable data) { Element element = start(elementName); element.setAttribute("class", data.getClass().getName()); --- 93,104 ---- /** ! * Helper to create a new element and add the "class" attribute if ! * necessary. * * @param data The data to be saved. + * @param defaultClass The assuming default class for data. If this does + * not match, save the class as "class" attribute */ ! protected Element start(String elementName, Visitorable data, Class defaultClass) { Element element = start(elementName); element.setAttribute("class", data.getClass().getName()); *************** *** 182,186 **** public Object visitCampaignData(CampaignData data) { ! Element e = start("campaignData", data); attr(e, "timestamp", data.getTimestamp().getTime()); --- 187,191 ---- public Object visitCampaignData(CampaignData data) { ! Element e = start("campaignData", data, CampaignData.class); attr(e, "timestamp", data.getTimestamp().getTime()); *************** *** 201,205 **** public Object visitContinent(Continent data) { ! Element e = start("continent", data); attr(e, "size", data.getSize()); // saving only the id --- 206,210 ---- public Object visitContinent(Continent data) { ! Element e = start("continent", data, Continent.class); attr(e, "size", data.getSize()); // saving only the id *************** *** 209,213 **** public Object visitHouse(House data) { ! Element e = start("house", data); attr(e, "id", data.getId()); attr(e, "name", data.getName()); --- 214,218 ---- public Object visitHouse(House data) { ! Element e = start("house", data, House.class); attr(e, "id", data.getId()); attr(e, "name", data.getName()); *************** *** 233,237 **** public Object visitInfluences(Influences data) { ! Element e = start("influences", data); for (Iterator it = data.getHouseIds().iterator(); it.hasNext();) { Integer i = (Integer)it.next(); --- 238,242 ---- public Object visitInfluences(Influences data) { ! Element e = start("influences", data, Influences.class); for (Iterator it = data.getHouseIds().iterator(); it.hasNext();) { Integer i = (Integer)it.next(); *************** *** 242,246 **** public Object visitPlanet(Planet data) { ! Element e = start("planet", data); attr(e, "id", data.getId()); attr(e, "name", data.getName()); --- 247,251 ---- public Object visitPlanet(Planet data) { ! Element e = start("planet", data, Planet.class); attr(e, "id", data.getId()); attr(e, "name", data.getName()); *************** *** 258,262 **** public Object visitPlanetEnvironment(PlanetEnvironment data) { ! Element e = start("planetEnvironment", data); attr(e, "id", data.getId()); attr(e, "name", data.getName()); --- 263,267 ---- public Object visitPlanetEnvironment(PlanetEnvironment data) { ! Element e = start("planetEnvironment", data, PlanetEnvironment.class); attr(e, "id", data.getId()); attr(e, "name", data.getName()); *************** *** 290,294 **** public Object visitTerrain(Terrain data) { ! Element e = start("terrain", data); for (Iterator it = data.iterator(); it.hasNext();) addChild(e, ((Visitorable)it.next()).visit(this)); --- 295,299 ---- public Object visitTerrain(Terrain data) { ! Element e = start("terrain", data, Terrain.class); for (Iterator it = data.iterator(); it.hasNext();) addChild(e, ((Visitorable)it.next()).visit(this)); *************** *** 297,301 **** public Object visitUnitFactories(UnitFactories data) { ! Element e = start("unitFactories", data); for (Iterator it = data.iterator(); it.hasNext();) addChild(e, ((Visitorable)it.next()).visit(this)); --- 302,306 ---- public Object visitUnitFactories(UnitFactories data) { ! Element e = start("unitFactories", data, UnitFactories.class); for (Iterator it = data.iterator(); it.hasNext();) addChild(e, ((Visitorable)it.next()).visit(this)); *************** *** 304,308 **** public Object visitUnitFactory(UnitFactory data) { ! Element e = start("unitFactory", data); attr(e, "name", data.getName()); attr(e, "size", data.getSize()); --- 309,313 ---- public Object visitUnitFactory(UnitFactory data) { ! Element e = start("unitFactory", data, UnitFactory.class); attr(e, "name", data.getName()); attr(e, "size", data.getSize()); *************** *** 316,320 **** public Object visitPlayer(Player data) { ! Element e = start("player", data); attr(e, "id", data.getId()); attr(e, "name", data.getName()); --- 321,325 ---- public Object visitPlayer(Player data) { ! Element e = start("player", data, Player.class); attr(e, "id", data.getId()); attr(e, "name", data.getName()); *************** *** 325,331 **** attr(e, "pricePenalty", data.getPricePenalty()); attr(e, "currentReward", data.getCurrentReward()); ! addAllVisitorables(e, "units", data.getUnits()); ! addAllVisitorables(e, "unitsOnMarket", data.getUnitsOnMarket()); addAllVisitorables(e, "armies", data.getArmies()); addAllVisitorables(e, "gameOptions", data.getGameoptions().values()); --- 330,343 ---- attr(e, "pricePenalty", data.getPricePenalty()); attr(e, "currentReward", data.getCurrentReward()); + Collection unitIds = new LinkedList(); + for (Iterator it = data.getUnitsOnMarket().iterator(); it.hasNext();) + unitIds.add(new Integer(((Unit)it.next()).getId())); + attr(e, "unitsOnMarket", createIdList(unitIds)); ! List ids = new LinkedList(); ! for (Iterator it = data.getUnits().iterator(); it.hasNext();) ! ids.add(new Integer(((Unit)it.next()).getId())); ! attr(e, "unitIds", createIdList(ids)); ! addAllVisitorables(e, "armies", data.getArmies()); addAllVisitorables(e, "gameOptions", data.getGameoptions().values()); *************** *** 335,339 **** public Object visitArmy(Army data) { ! Element e = start("army", data); attr(e, "id", data.getId()); attr(e, "bv", data.getBv()); --- 347,351 ---- public Object visitArmy(Army data) { ! Element e = start("army", data, Army.class); attr(e, "id", data.getId()); attr(e, "bv", data.getBv()); *************** *** 351,355 **** public Object visitUnit(Unit data) { ! Element e = start("unit", data); attr(e, "id", data.getId()); attr(e, "type", data.getType()); --- 363,367 ---- public Object visitUnit(Unit data) { ! Element e = start("unit", data, Unit.class); attr(e, "id", data.getId()); attr(e, "type", data.getType()); *************** *** 368,372 **** public Object visitPilot(Pilot data) { ! Element e = start("pilot", data); attr(e, "id", data.getId()); attr(e, "gunnery", data.getGunnery()); --- 380,384 ---- public Object visitPilot(Pilot data) { ! Element e = start("pilot", data, Pilot.class); attr(e, "id", data.getId()); attr(e, "gunnery", data.getGunnery()); *************** *** 388,392 **** public Object visitMegaMekPilotOption(MegaMekPilotOption data) { ! Element e = start("megaMekPilotOption", data); attr(e, "mmname", data.getMmname()); attr(e, "value", data.isValue()); --- 400,404 ---- public Object visitMegaMekPilotOption(MegaMekPilotOption data) { ! Element e = start("megaMekPilotOption", data, MegaMekPilotOption.class); attr(e, "mmname", data.getMmname()); attr(e, "value", data.isValue()); *************** *** 395,399 **** public Object visitPilotSkill(PilotSkill data) { ! Element e = start("pilotSkill", data); attr(e,"id", data.getId()); attr(e,"name", data.getName()); --- 407,411 ---- public Object visitPilotSkill(PilotSkill data) { ! Element e = start("pilotSkill", data, PilotSkill.class); attr(e,"id", data.getId()); attr(e,"name", data.getName()); *************** *** 404,408 **** public Object visitPilotSkills(PilotSkills data) { ! Element e = start("pilotSkills", data); attr(e, "id", data.getId()); addAllVisitorables(e, null, data.getSkills()); --- 416,420 ---- public Object visitPilotSkills(PilotSkills data) { ! Element e = start("pilotSkills", data, PilotSkills.class); attr(e, "id", data.getId()); addAllVisitorables(e, null, data.getSkills()); *************** *** 411,415 **** public Object visitPlayerOption(PlayerOption data) { ! Element e = start("playerOption", data); attr(e, "description", data.getDescription()); attr(e, "setting", data.getSetting()); --- 423,427 ---- public Object visitPlayerOption(PlayerOption data) { ! Element e = start("playerOption", data, PlayerOption.class); attr(e, "description", data.getDescription()); attr(e, "setting", data.getSetting()); *************** *** 418,422 **** public Object visitTaskInfo(TaskInfo data) { ! Element e = start("taskInfo", data); attr(e, "name", data.getName()); attr(e, "info", data.getInfo()); --- 430,434 ---- public Object visitTaskInfo(TaskInfo data) { ! Element e = start("taskInfo", data, TaskInfo.class); attr(e, "name", data.getName()); attr(e, "info", data.getInfo()); *************** *** 441,445 **** public Object visitBlackBoardMessage(BlackBoardMessage data) { ! Element e = start("blackBoardMessage", data); attr(e, "title", data.getTitle()); attr(e, "htmlMsg", data.getHtmlMsg()); --- 453,457 ---- public Object visitBlackBoardMessage(BlackBoardMessage data) { ! Element e = start("blackBoardMessage", data, BlackBoardMessage.class); attr(e, "title", data.getTitle()); attr(e, "htmlMsg", data.getHtmlMsg()); *************** *** 456,460 **** public Object visitBlackBoard(BlackBoard data) { ! Element e = start("blackBoard", data); addAllVisitorables(e, null, data.allMessages()); return e; --- 468,472 ---- public Object visitBlackBoard(BlackBoard data) { ! Element e = start("blackBoard", data, BlackBoard.class); addAllVisitorables(e, null, data.allMessages()); return e; Index: XMLLoadVisitor.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/common/visitor/XMLLoadVisitor.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** XMLLoadVisitor.java 26 Mar 2005 12:22:16 -0000 1.6 --- XMLLoadVisitor.java 26 Mar 2005 17:44:27 -0000 1.7 *************** *** 26,29 **** --- 26,30 ---- import java.util.Map; import java.util.StringTokenizer; + import megamek.common.options.GameOption; import org.jdom.Attribute; import org.jdom.Element; *************** *** 75,79 **** * Key: Integer (id), value: Unit */ ! protected Hashtable units = new Hashtable(); /** --- 76,80 ---- * Key: Integer (id), value: Unit */ ! public Hashtable units = new Hashtable(); /** *************** *** 193,202 **** * <code>childName == null</code> and return a collection of the fully * constructed Visitorables. */ ! protected final List toVisitorable(String childName, Element h) { List c = new LinkedList(); List l = childName == null ? h.getChildren() : h.getChildren(childName); for (Iterator it = l.iterator(); it.hasNext();) ! c.add(create((Element)it.next())); return c; } --- 194,206 ---- * <code>childName == null</code> and return a collection of the fully * constructed Visitorables. + * + * @param defaultClass Assume that the elements are of either this default + * class or that the element's "class" attribute is set. */ ! protected final List toVisitorable(String childName, Element h, Class defaultClass) { List c = new LinkedList(); List l = childName == null ? h.getChildren() : h.getChildren(childName); for (Iterator it = l.iterator(); it.hasNext();) ! c.add(create((Element)it.next(), defaultClass)); return c; } *************** *** 221,236 **** * This also calls visit on the created object with a copy of this on the * given parameter element, so it returns a fully operable object. */ ! protected final Object create(Element element) { try { ! Class cl = Class.forName(element.getAttributeValue("class")); Visitorable v = (Visitorable)cl.newInstance(); return v.visit(copy(element)); } catch (ClassNotFoundException e) { ! throw new RuntimeException("class="+element.getAttributeValue("class")+" attribute unknown.", e); } catch (InstantiationException e) { ! throw new RuntimeException("class="+element.getAttributeValue("class")+" attribute illegal.", e); } catch (IllegalAccessException e) { ! throw new RuntimeException("class="+element.getAttributeValue("class")+" attribute illegal.", e); } } --- 225,246 ---- * This also calls visit on the created object with a copy of this on the * given parameter element, so it returns a fully operable object. + * + * @param defaultClass Use an instance of this class, if the "class" + * attribute is missing. */ ! protected final Object create(Element element, Class defaultClass) { ! String classAttr = element.getAttributeValue("class"); ! if (classAttr == null) ! classAttr = defaultClass.getName(); try { ! Class cl = Class.forName(classAttr); Visitorable v = (Visitorable)cl.newInstance(); return v.visit(copy(element)); } catch (ClassNotFoundException e) { ! throw new RuntimeException("class="+classAttr+" attribute unknown.", e); } catch (InstantiationException e) { ! throw new RuntimeException("class="+classAttr+" attribute illegal.", e); } catch (IllegalAccessException e) { ! throw new RuntimeException("class="+classAttr+" attribute illegal.", e); } } *************** *** 240,250 **** data.setServerConfig(toMap("serverConfig", e)); ! for (Iterator it = toVisitorable("terrains", e).iterator(); it.hasNext();) data.addTerrain((PlanetEnvironment)it.next()); ! for (Iterator it = toVisitorable("houses", e).iterator(); it.hasNext();) data.addHouse((House)it.next()); ! for (Iterator it = toVisitorable("planets", e).iterator(); it.hasNext();) data.addPlanet((Planet)it.next()); --- 250,260 ---- data.setServerConfig(toMap("serverConfig", e)); ! for (Iterator it = toVisitorable("terrains", e, Terrain.class).iterator(); it.hasNext();) data.addTerrain((PlanetEnvironment)it.next()); ! for (Iterator it = toVisitorable("houses", e, House.class).iterator(); it.hasNext();) data.addHouse((House)it.next()); ! for (Iterator it = toVisitorable("planets", e, Planet.class).iterator(); it.hasNext();) data.addPlanet((Planet)it.next()); *************** *** 304,314 **** data.setPosition(pos); ! data.setInfluence((Influences)create(e.getChild("influences"))); data.setBaysProvided(toInt("baysProvided", e)); data.setCompProduction(toInt("compProduction", e)); data.setConquerable(toBoolean("isConquerable", e)); data.setDescription(toString("description", e)); ! data.setUnitFactories((UnitFactories)create(e.getChild("unitFactories"))); ! data.setTerrain((Terrain)create(e.getChild("terrain"))); return data; --- 314,324 ---- data.setPosition(pos); ! data.setInfluence((Influences)create(e.getChild("influences"), Influences.class)); data.setBaysProvided(toInt("baysProvided", e)); data.setCompProduction(toInt("compProduction", e)); data.setConquerable(toBoolean("isConquerable", e)); data.setDescription(toString("description", e)); ! data.setUnitFactories((UnitFactories)create(e.getChild("unitFactories"), UnitFactories.class)); ! data.setTerrain((Terrain)create(e.getChild("terrain"), Terrain.class)); return data; *************** *** 351,355 **** public Object visitTerrain(Terrain data) { ! for (Iterator it = toVisitorable("continent", e).iterator(); it.hasNext();) data.add((Continent)it.next()); return data; --- 361,365 ---- public Object visitTerrain(Terrain data) { ! for (Iterator it = toVisitorable("continent", e, Continent.class).iterator(); it.hasNext();) data.add((Continent)it.next()); return data; *************** *** 357,361 **** public Object visitUnitFactories(UnitFactories data) { ! for (Iterator it = toVisitorable("unitFactory", e).iterator(); it.hasNext();) data.add((UnitFactory)it.next()); return data; --- 367,371 ---- public Object visitUnitFactories(UnitFactories data) { ! for (Iterator it = toVisitorable("unitFactory", e, UnitFactory.class).iterator(); it.hasNext();) data.add((UnitFactory)it.next()); return data; *************** *** 383,404 **** data.setCurrentReward(toInt("currentReward", e)); ! List l = toVisitorable("unit", e.getChild("units")); ! for (Iterator it = l.iterator(); it.hasNext();) { ! Unit u = (Unit)it.next(); ! units.put(new Integer(u.getId()), u); ! } ! data.setUnits(l); ! l = toVisitorable("unit", e.getChild("unitsOnMarket")); ! for (Iterator it = l.iterator(); it.hasNext();) { ! Unit u = (Unit)it.next(); ! units.put(new Integer(u.getId()), u); ! } ! data.setUnitsOnMarket(l); ! ! data.setArmies(toVisitorable("army", e.getChild("armies"))); Map options = new HashMap(); ! for (Iterator it = toVisitorable("gameOption", e).iterator(); it.hasNext();) { PlayerOption po = (PlayerOption)it.next(); options.put(po.getDescription(), po); --- 393,410 ---- data.setCurrentReward(toInt("currentReward", e)); ! List unitsInHangar = new LinkedList(); ! for (Iterator it = toIdList(toString("unitIds", e)).iterator(); it.hasNext();) ! unitsInHangar.add((Unit)units.get(new Integer((String)it.next()))); ! data.setUnits(unitsInHangar); ! List unitsOnMarket = new LinkedList(); ! for (Iterator it = toIdList(toString("unitsOnMarket", e)).iterator(); it.hasNext();) ! unitsOnMarket.add((Unit)units.get(new Integer((String)it.next()))); ! data.setUnitsOnMarket(unitsOnMarket); ! ! data.setArmies(toVisitorable("army", e.getChild("armies"), Army.class)); Map options = new HashMap(); ! for (Iterator it = toVisitorable("gameOption", e, GameOption.class).iterator(); it.hasNext();) { PlayerOption po = (PlayerOption)it.next(); options.put(po.getDescription(), po); *************** *** 440,444 **** data.setModelname(toString("modelname", e)); data.setMaintainanceLevel(toInt("maintenanceLevel", e)); ! data.setPilot((Pilot)create(e.getChild("pilot"))); return data; } --- 446,453 ---- data.setModelname(toString("modelname", e)); data.setMaintainanceLevel(toInt("maintenanceLevel", e)); ! data.setPilot((Pilot)create(e.getChild("pilot"), Pilot.class)); ! ! units.put(new Integer(data.getId()), data); ! return data; } *************** *** 455,463 **** data.setBayModifier(toInt("bayModifier", e)); ! data.setMegamekOptions(toVisitorable("megaMekPilotOption", e)); Element skills = e.getChild("pilotSkills"); if (skills != null) ! data.setSkills((PilotSkills)create(skills)); return data; --- 464,472 ---- data.setBayModifier(toInt("bayModifier", e)); ! data.setMegamekOptions(toVisitorable("megaMekPilotOption", e, MegaMekPilotOption.class)); Element skills = e.getChild("pilotSkills"); if (skills != null) ! data.setSkills((PilotSkills)create(skills, PilotSkills.class)); return data; *************** *** 480,484 **** public Object visitPilotSkills(PilotSkills data) { data.setId(toInt("id", e)); ! data.setSkills(toVisitorable("pilotSkill", e)); return data; } --- 489,493 ---- public Object visitPilotSkills(PilotSkills data) { data.setId(toInt("id", e)); ! data.setSkills(toVisitorable("pilotSkill", e, PilotSkill.class)); return data; } *************** *** 522,526 **** public Object visitBlackBoard(BlackBoard data) { ! for (Iterator it = toVisitorable("blackBoardMessage", e).iterator(); it.hasNext();) data.addMessage((BlackBoardMessage)it.next()); return data; --- 531,535 ---- public Object visitBlackBoard(BlackBoard data) { ! for (Iterator it = toVisitorable("blackBoardMessage", e, BlackBoardMessage.class).iterator(); it.hasNext();) data.addMessage((BlackBoardMessage)it.next()); return data; |
From: Immanuel S. <im...@us...> - 2005-03-26 17:44:37
|
Update of /cvsroot/megameknet/MegaMekNET/src/server/campaign In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20292/src/server/campaign Modified Files: SPlayer.java SHouse.java CampaignMain.java Log Message: xml loading finished Index: SHouse.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/SHouse.java,v retrieving revision 1.94 retrieving revision 1.95 diff -C2 -d -r1.94 -r1.95 *** SHouse.java 26 Mar 2005 12:22:13 -0000 1.94 --- SHouse.java 26 Mar 2005 17:44:25 -0000 1.95 *************** *** 2140,2150 **** } ! public void increaseUnitsOnMarket(SUnit m) { ! ++unitsOnMarket; ! } ! ! public void decreaseUnitsOnMarket(SUnit m) { --unitsOnMarket; } //Comparable --- 2140,2149 ---- } ! public void recallUnitFromMarket(SUnit unit) { --unitsOnMarket; } + public void placeUnitOnMarket(SUnit unit) { + ++unitsOnMarket; + } //Comparable *************** *** 2268,2270 **** --- 2267,2274 ---- return null; } + + /** + * Houses do not receive messages, so do nothing here. + */ + public void sendMessage(String message, boolean isChat) {} } \ No newline at end of file Index: CampaignMain.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/CampaignMain.java,v retrieving revision 1.117 retrieving revision 1.118 diff -C2 -d -r1.117 -r1.118 *** CampaignMain.java 26 Mar 2005 12:22:13 -0000 1.117 --- CampaignMain.java 26 Mar 2005 17:44:26 -0000 1.118 *************** *** 31,34 **** --- 31,35 ---- import java.util.LinkedList; import java.util.List; + import java.util.Map; import java.util.Properties; import java.util.Random; *************** *** 107,110 **** --- 108,117 ---- CampaignData data = new CampaignData(); + /** + * Map of all units in the campaign. + * key: Integer (id), value: SUnit + */ + public Map units = new Hashtable(); + Hashtable activePlayers = new Hashtable(); *************** *** 175,179 **** SXMLLoadVisitor loader = new SXMLLoadVisitor(); ! // Houses and player within the houses (must be before market) List houses = new SAXBuilder().build("campaign/houses.xml").getRootElement().getChildren(); --- 182,194 ---- SXMLLoadVisitor loader = new SXMLLoadVisitor(); ! ! // units (before houses or market) ! for (Iterator it = loader.parseAll("campaign/unit.xml"); it.hasNext();) { ! it.next(); ! SUnit unit = (SUnit)new SUnit().visit(loader); ! units.put(new Integer(unit.getId()), unit); ! } ! System.out.println("loaded "+units.size()+" units."); ! // Houses and player within the houses (must be before market) List houses = new SAXBuilder().build("campaign/houses.xml").getRootElement().getChildren(); *************** *** 196,200 **** System.out.println("loaded "+house.getName()+" with "+house.getMembers().size()+" players."); } ! // planet environments (must be before planet's) for (Iterator it = loader.parseAll("campaign/planetEnvironment.xml"); it.hasNext();) { --- 211,215 ---- System.out.println("loaded "+house.getName()+" with "+house.getMembers().size()+" players."); } ! // planet environments (must be before planet's) for (Iterator it = loader.parseAll("campaign/planetEnvironment.xml"); it.hasNext();) { *************** *** 203,207 **** } System.out.println("loaded "+data.getAllTerrains().size()+" planet environments."); ! // planets for (Iterator it = loader.parseAll("campaign/planet.xml"); it.hasNext();) { --- 218,222 ---- } System.out.println("loaded "+data.getAllTerrains().size()+" planet environments."); ! // planets for (Iterator it = loader.parseAll("campaign/planet.xml"); it.hasNext();) { *************** *** 214,222 **** System.out.println("loaded "+data.getAllPlanets().size()+" planets."); - // blackboard - loader.parse("campaign/blackboard.xml"); - blackBoard.visit(loader); - System.out.println("loaded blackboard."); - // market loader.parse("campaign/blackmarket.xml"); --- 229,232 ---- *************** *** 224,231 **** System.out.println("loaded "+market.getAllUnits().size()+" bids on market."); // ban list MMNetXStream xml = new MMNetXStream(); BanList.setInstance((BanList)xml.fromFile(BAN_FILENAME)); ! // freeing some ressources (cache lists) loader = null; --- 234,246 ---- System.out.println("loaded "+market.getAllUnits().size()+" bids on market."); + // blackboard + loader.parse("campaign/blackboard.xml"); + blackBoard.visit(loader); + System.out.println("loaded blackboard."); + // ban list MMNetXStream xml = new MMNetXStream(); BanList.setInstance((BanList)xml.fromFile(BAN_FILENAME)); ! // freeing some ressources (cache lists) loader = null; *************** *** 348,351 **** --- 363,389 ---- } + // generate a list of all units in the system. + for (Iterator it = getData().getAllHouses().iterator();it.hasNext();) { + SHouse house = (SHouse)it.next(); + for (Iterator pl = house.getMembers().values().iterator(); pl.hasNext();) { + for (Iterator un = ((SPlayer)pl.next()).getUnits().iterator(); un.hasNext();) { + SUnit u = (SUnit)un.next(); + units.put(new Integer(u.getId()), u); + } + } + for (Iterator ha = house.getHangar().values().iterator(); ha.hasNext();) { + for (Iterator ha2 = ((Vector)ha.next()).iterator(); ha2.hasNext();) { + for (Iterator ha3 = ((Vector)ha2.next()).iterator(); ha3.hasNext();) { + SUnit u = (SUnit)ha3.next(); + units.put(new Integer(u.getId()), u); + } + } + } + } + for (Iterator it = market.getAllUnits().iterator(); it.hasNext();) { + SUnit u = (SUnit)((MarketUnit)it.next()).getCmech(); + units.put(new Integer(u.getId()), u); + } + try { // saving in fresh xml format for the next run to make it better :) *************** *** 1317,1321 **** //commands.put("SCAN", new ScanCommand()); commands.put("SCRAP", new ScrapCommand()); ! commands.put("SELL", new SellCommand()); commands.put("SERVERVERSION", new ServerVersionCommand()); commands.put("SETARMYMAPSIZE", new SetArmyMapSizeCommand()); --- 1355,1359 ---- //commands.put("SCAN", new ScanCommand()); commands.put("SCRAP", new ScrapCommand()); ! commands.put("sell", new SellCommand()); commands.put("SERVERVERSION", new ServerVersionCommand()); commands.put("SETARMYMAPSIZE", new SetArmyMapSizeCommand()); *************** *** 1343,1347 **** commands.put("UNLOCKLANCES", new UnlockLancesCommand()); commands.put("unvote", new UnVoteCommand()); ! commands.put("USEREWARDPOINTS", new UseRewardPointsCommand()); commands.put("vote", new VoteCommand()); --- 1381,1385 ---- commands.put("UNLOCKLANCES", new UnlockLancesCommand()); commands.put("unvote", new UnVoteCommand()); ! commands.put("userewardpoints", new UseRewardPointsCommand()); commands.put("vote", new VoteCommand()); Index: SPlayer.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/SPlayer.java,v retrieving revision 1.87 retrieving revision 1.88 diff -C2 -d -r1.87 -r1.88 *** SPlayer.java 26 Mar 2005 16:05:17 -0000 1.87 --- SPlayer.java 26 Mar 2005 17:44:24 -0000 1.88 *************** *** 45,48 **** --- 45,49 ---- import common.Player; import common.PlayerOption; + import common.Unit; import common.constants.PlayerStatus; import common.visitor.Visitor; *************** *** 428,433 **** */ public void addUnit(SUnit m, boolean isNew) { ! if (new Boolean(CampaignMain.cm.getConfig("UseOnlyOneVehicleSize")).booleanValue() && m.getType() == SUnit.VEHICLE) ! m.setWeightclass(SUnit.LIGHT); if (isNew) UnitHistoryKeeper.addAcquireEntry(m.getId(), m.getPilot().getId(), getName(), getMyHouse().getName()); --- 429,434 ---- */ public void addUnit(SUnit m, boolean isNew) { ! if (new Boolean(CampaignMain.cm.getConfig("UseOnlyOneVehicleSize")).booleanValue() && m.getType() == Unit.VEHICLE) ! m.setWeightclass(Unit.LIGHT); if (isNew) UnitHistoryKeeper.addAcquireEntry(m.getId(), m.getPilot().getId(), getName(), getMyHouse().getName()); *************** *** 1339,1358 **** } ! public void increaseUnitsOnMarket(SUnit m) { ! List unitsOnMarket = getUnitsOnMarket(); ! unitsOnMarket.add(m); ! setUnitsOnMarket(unitsOnMarket); } ! ! public void decreaseUnitsOnMarket(SUnit m) { ! List unitsOnMarket = getUnitsOnMarket(); ! for (int i = 0; i < unitsOnMarket.size(); i++) { ! SUnit mech = (SUnit) unitsOnMarket.get(i); ! if (m.equals(mech)) { ! unitsOnMarket.remove(i); ! setUnitsOnMarket(unitsOnMarket); ! return; ! } ! } } --- 1340,1348 ---- } ! public void recallUnitFromMarket(SUnit unit) { ! getUnitsOnMarket().remove(unit); } ! public void placeUnitOnMarket(SUnit unit) { ! getUnitsOnMarket().add(unit); } *************** *** 1776,1779 **** --- 1766,1779 ---- return visitor instanceof ServerVisitor ? ((ServerVisitor) visitor).visitSPlayer(this) : super.visit(visitor); } + + /** + * Send a message to the user. + * @param message the message text + * @param isChat if <code>true</code>, the message is sent as chat message. + * <code>false</code> means, a raw message. + */ + public void sendMessage(String message, boolean isChat) { + CampaignMain.cm.toUser(message, getName(), isChat); + } /** |
From: Immanuel S. <im...@us...> - 2005-03-26 17:44:36
|
Update of /cvsroot/megameknet/MegaMekNET/server-dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20292/server-dist Modified Files: campaignconfig.txt Log Message: xml loading finished Index: campaignconfig.txt =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/server-dist/campaignconfig.txt,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -d -r1.82 -r1.83 *** campaignconfig.txt 26 Mar 2005 16:05:18 -0000 1.82 --- campaignconfig.txt 26 Mar 2005 17:44:27 -0000 1.83 *************** *** 493,495 **** # values: 'XML' for the new XML loading or 'DAT' for the old DAT file loading ! FILE_LOADING_SYSTEM=DAT \ No newline at end of file --- 493,495 ---- # values: 'XML' for the new XML loading or 'DAT' for the old DAT file loading ! FILE_LOADING_SYSTEM=XML \ No newline at end of file |
From: Immanuel S. <im...@us...> - 2005-03-26 17:44:36
|
Update of /cvsroot/megameknet/MegaMekNET In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20292 Modified Files: history.txt Log Message: xml loading finished Index: history.txt =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/history.txt,v retrieving revision 1.199 retrieving revision 1.200 diff -C2 -d -r1.199 -r1.200 *** history.txt 26 Mar 2005 16:05:19 -0000 1.199 --- history.txt 26 Mar 2005 17:44:26 -0000 1.200 *************** *** 1,2 **** --- 1,4 ---- + -> S XML saving finally finished. Now, the bug hunting saison is opened ;-) + Imi 2005-03-26 -> S 1. Remove all task benefits from raiding SOL (Mechs, Comps) 2. Reduce EXP payout so that House players gain 1 RP for the game. |
From: Immanuel S. <im...@us...> - 2005-03-26 17:44:35
|
Update of /cvsroot/megameknet/MegaMekNET/src/server/campaign/visitor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20292/src/server/campaign/visitor Modified Files: SXMLSaveVisitor.java SXMLLoadVisitor.java Log Message: xml loading finished Index: SXMLLoadVisitor.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/visitor/SXMLLoadVisitor.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SXMLLoadVisitor.java 26 Mar 2005 12:22:15 -0000 1.4 --- SXMLLoadVisitor.java 26 Mar 2005 17:44:26 -0000 1.5 *************** *** 101,105 **** for (int weight = 0; weight < Unit.WEIGHT_STR.length; ++weight) { Element weightElem = typeElem.getChild(Unit.WEIGHT_STR[weight]); ! Vector units = new Vector(toVisitorable(null, weightElem)); weights.add(units); } --- 101,113 ---- for (int weight = 0; weight < Unit.WEIGHT_STR.length; ++weight) { Element weightElem = typeElem.getChild(Unit.WEIGHT_STR[weight]); ! String idstr = toString("unitIds", weightElem); ! Vector units = new Vector(); ! for (Iterator it = toIdList(idstr).iterator(); it.hasNext();) { ! Integer id = new Integer((String)it.next()); ! SUnit unit = (SUnit)this.units.get(id); ! if (unit == null) ! throw new RuntimeException("Hangar unit "+id+" in house "+data.getName()+" not found."); ! units.add(unit); ! } weights.add(units); } *************** *** 109,121 **** // components Element components = e.getChild("components"); for (int type = 0; type < Unit.TYPE_STR.length; ++type) { Element typeElem = components.getChild(Unit.TYPE_STR[type].toLowerCase()); for (int weight = 0; weight < Unit.WEIGHT_STR.length; ++weight) ! data.setPP(weight, toInt(Unit.WEIGHT_STR[weight], typeElem), type); } // members Hashtable members = new Hashtable(); ! for (Iterator it = toVisitorable(null, e.getChild("members")).iterator(); it.hasNext();) { SPlayer p = (SPlayer)it.next(); members.put(p.getName().toLowerCase(), p); --- 117,134 ---- // components Element components = e.getChild("components"); + Hashtable comps = new Hashtable(); for (int type = 0; type < Unit.TYPE_STR.length; ++type) { Element typeElem = components.getChild(Unit.TYPE_STR[type].toLowerCase()); + Vector weights = new Vector(); for (int weight = 0; weight < Unit.WEIGHT_STR.length; ++weight) ! weights.add(new Integer(toInt(Unit.WEIGHT_STR[weight], typeElem))); ! comps.put(new Integer(type), weights); } + data.setComponents(comps); + data.addPP(0,0,0); // members Hashtable members = new Hashtable(); ! for (Iterator it = toVisitorable(null, e.getChild("members"), SPlayer.class).iterator(); it.hasNext();) { SPlayer p = (SPlayer)it.next(); members.put(p.getName().toLowerCase(), p); *************** *** 150,154 **** data.setExternalRank(toInt("externalRank", e)); ! data.setCounterBag((CounterBag)create(e.getChild("counterBag"))); data.setMyHouse(house); --- 163,167 ---- data.setExternalRank(toInt("externalRank", e)); ! data.setCounterBag((CounterBag)create(e.getChild("counterBag"), CounterBag.class)); data.setMyHouse(house); *************** *** 180,184 **** public Object visitMarket(Market data) { ! for (Iterator it = toVisitorable("marketunit", e).iterator(); it.hasNext();) data.addUnit((MarketUnit)it.next()); return data; --- 193,197 ---- public Object visitMarket(Market data) { ! for (Iterator it = toVisitorable("marketUnit", e, MarketUnit.class).iterator(); it.hasNext();) data.addUnit((MarketUnit)it.next()); return data; *************** *** 187,191 **** public Object visitMarketUnit(MarketUnit data) { data.setId(toInt("id", e)); - data.setCmech((SUnit)units.get(new Integer(toInt("unitId", e)))); data.setComment(toString("comment", e)); data.setTimeLeft(toInt("timeLeft", e)); --- 200,203 ---- *************** *** 197,203 **** data.setSeller(ms); ! for (Iterator it = toVisitorable("bid", e).iterator(); it.hasNext();) data.addBid((Bid)it.next()); return data; } --- 209,220 ---- data.setSeller(ms); ! for (Iterator it = toVisitorable("bid", e, Bid.class).iterator(); it.hasNext();) data.addBid((Bid)it.next()); + SUnit cmech = (SUnit)units.get(new Integer(toInt("unitId", e))); + if (cmech == null) + throw new RuntimeException("Black Market unit "+toInt("unitId", e)+" not found."); + data.setCmech(cmech); + return data; } Index: SXMLSaveVisitor.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/visitor/SXMLSaveVisitor.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** SXMLSaveVisitor.java 26 Mar 2005 12:22:14 -0000 1.11 --- SXMLSaveVisitor.java 26 Mar 2005 17:44:26 -0000 1.12 *************** *** 15,18 **** --- 15,19 ---- import java.util.Iterator; + import java.util.LinkedList; import java.util.List; import java.util.Map; *************** *** 70,74 **** public Object visitCounterBag(CounterBag data) { ! Element e = start("counterBag", data); Map contents = data.getContents(); for (Iterator it = contents.keySet().iterator(); it.hasNext();) { --- 71,75 ---- public Object visitCounterBag(CounterBag data) { ! Element e = start("counterBag", data, CounterBag.class); Map contents = data.getContents(); for (Iterator it = contents.keySet().iterator(); it.hasNext();) { *************** *** 81,85 **** public Object visitMarket(Market data) { ! Element e = start("market", data); addAllVisitorables(e, null, data.getAllUnits()); return e; --- 82,86 ---- public Object visitMarket(Market data) { ! Element e = start("market", data, Market.class); addAllVisitorables(e, null, data.getAllUnits()); return e; *************** *** 87,93 **** public Object visitMarketUnit(MarketUnit data) { ! Element e = start("marketunit", data); attr(e, "id", data.getId()); - attr(e, "unitId", data.getCmech().getId()); attr(e, "comment", data.getComment()); attr(e, "timeLeft", data.getTimeLeft()); --- 88,93 ---- public Object visitMarketUnit(MarketUnit data) { ! Element e = start("marketUnit", data, MarketUnit.class); attr(e, "id", data.getId()); attr(e, "comment", data.getComment()); attr(e, "timeLeft", data.getTimeLeft()); *************** *** 95,98 **** --- 95,99 ---- attr(e, "seller", data.getSeller().getName()); attr(e, "sellerClass", data.getSeller().getClass().getName()); + attr(e, "unitId", data.getCmech().getId()); addAllVisitorables(e, null, data.getBids()); return e; *************** *** 100,104 **** public Object visitBid(Bid data) { ! Element e = start("bid", data); attr(e, "buyer", data.getBuyer().getName()); attr(e, "amount", data.getAmount()); --- 101,105 ---- public Object visitBid(Bid data) { ! Element e = start("bid", data, Bid.class); attr(e, "buyer", data.getBuyer().getName()); attr(e, "amount", data.getAmount()); *************** *** 158,162 **** Element weightElem = start(Unit.WEIGHT_STR[weight]); List units = data.getHangar(type, weight); ! addAllVisitorables(weightElem, null, units); addChild(typeElem, weightElem); } --- 159,166 ---- Element weightElem = start(Unit.WEIGHT_STR[weight]); List units = data.getHangar(type, weight); ! List unitids = new LinkedList(); ! for (Iterator it = units.iterator(); it.hasNext();) ! unitids.add(new Integer(((Unit)it.next()).getId())); ! attr(weightElem, "unitIds", createIdList(unitids)); addChild(typeElem, weightElem); } *************** *** 197,201 **** public Object visitContractInfo(ContractInfo data) { ! Element e = start("contractInfo", data); attr(e, "contractDuration", data.getContractDuration()); attr(e, "startingExperience", data.getStartingExperience()); --- 201,205 ---- public Object visitContractInfo(ContractInfo data) { ! Element e = start("contractInfo", data, ContractInfo.class); attr(e, "contractDuration", data.getContractDuration()); attr(e, "startingExperience", data.getStartingExperience()); |
From: Helge R. <mcw...@us...> - 2005-03-26 16:41:06
|
Update of /cvsroot/megameknet/MegaMekNET/src/server/campaign/tasks In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18212/src/server/campaign/tasks Modified Files: Task.java TrainingTask.java Log Message: Index: Task.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/tasks/Task.java,v retrieving revision 1.92 retrieving revision 1.93 diff -C2 -d -r1.92 -r1.93 *** Task.java 26 Mar 2005 16:05:19 -0000 1.92 --- Task.java 26 Mar 2005 16:40:58 -0000 1.93 *************** *** 1976,1983 **** }//end else if (Should give Triad Disabled message) else if (task.equalsIgnoreCase("Training")) { ! //t = new ! // TrainingTask(ActorHouse.getMember(Actor),targetPlanet,task,army,TaskID,this); ! CampaignMain.cm.toUser("Training missions are disabled at the moment! Check back later!", Actor, true); ! return; }//end else if(Should give Training Disabled message) else if (task.equalsIgnoreCase("ComponentRaid")) --- 1976,1980 ---- }//end else if (Should give Triad Disabled message) else if (task.equalsIgnoreCase("Training")) { ! t = new TrainingTask(ActorHouse.getMember(Actor.toLowerCase()), targetPlanet, task, actorArmy); }//end else if(Should give Training Disabled message) else if (task.equalsIgnoreCase("ComponentRaid")) Index: TrainingTask.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/tasks/TrainingTask.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TrainingTask.java 26 Mar 2005 16:05:19 -0000 1.1 --- TrainingTask.java 26 Mar 2005 16:40:58 -0000 1.2 *************** *** 17,21 **** --- 17,23 ---- import server.campaign.CampaignMain; + import server.campaign.SArmy; import server.campaign.SHouse; + import server.campaign.SPlanet; import server.campaign.SPlayer; *************** *** 26,29 **** --- 28,35 ---- public class TrainingTask extends Task { + public TrainingTask(SPlayer actor, SPlanet target, String task, SArmy army) { + super(actor,target,"Training task",army); + } + /* (non-Javadoc) * @see server.campaign.tasks.Task#doTickGain(server.campaign.SPlayer, int) |
From: Helge R. <mcw...@us...> - 2005-03-26 16:05:28
|
Update of /cvsroot/megameknet/MegaMekNET/src/server/campaign/tasks In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28650/src/server/campaign/tasks Modified Files: Task.java Added Files: TrainingTask.java Log Message: -> S 1. Remove all task benefits from raiding SOL (Mechs, Comps) 2. Reduce EXP payout so that House players gain 1 RP for the game. 3. Make sure neither side suffers any losses from the game. Units on either side gain no EXP or kills. 4. Make it so SOL players can reset their hangar after a game. Coaches should be able to reset at any point (Yet untested...) McW 2005-03-26 Index: Task.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/tasks/Task.java,v retrieving revision 1.91 retrieving revision 1.92 diff -C2 -d -r1.91 -r1.92 *** Task.java 6 Mar 2005 17:53:28 -0000 1.91 --- Task.java 26 Mar 2005 16:05:19 -0000 1.92 *************** *** 129,132 **** --- 129,134 ---- public static final int TASK_DELAYRAID = 4; public static final int TASK_ARENA = 5; + public static final int TASK_TRAINING = 6; + public Task() { //Only used for special purposes *************** *** 160,172 **** public abstract int getNumberOfPlayers(); public abstract String getClosedTaskInfo(boolean accureate); ! public abstract String getRunningTaskInfo(boolean accureate); public abstract int getTaskTickTime(); public abstract int getMaxDistance(); public abstract String getName(); - public boolean grantsInfluence() { - return true; - } - public int getMinEXPNeeded() { return 0; --- 162,175 ---- public abstract int getNumberOfPlayers(); public abstract String getClosedTaskInfo(boolean accureate); ! public String getRunningTaskInfo(boolean accurate){ ! if (accurate) ! return "#" + this.getID() + " <b>" + getActor().getColoredName() + " (" + getActor().getPlayer().getHouseFightingFor().getName() + ")</b>" + " performing a " + getName() + " on " + getTarget().getName() + " with " + getAttacker().getArmy().getDescription(true) + ". Defender is: <b>" + getDefender(0).getPlayer().getColoredName() + " (" + getDefender(0).getPlayer().getMyHouse().getHouseFightingFor(getDefender(0).getPlayer()).getName() + ")</b>" + " with " + getDefender(0).getArmy().getDescription(true) + "<br>"; ! else ! return "#" + this.getID() + " <b>" + getActor().getColoredName() + " (" + getActor().getPlayer().getHouseFightingFor().getName() + ")</b>" + " performing a " + getName() + " on " + getTarget().getName() + " with " + getAttacker().getArmy().getInaccurateDescription() + ". Defender is: <b>" + getDefender(0).getPlayer().getColoredName() + " (" + getDefender(0).getPlayer().getMyHouse().getHouseFightingFor(getDefender(0).getPlayer()).getName() + ")</b>" + " with " + getDefender(0).getArmy().getInaccurateDescription() + "<br>"; ! } public abstract int getTaskTickTime(); public abstract int getMaxDistance(); public abstract String getName(); public int getMinEXPNeeded() { return 0; *************** *** 254,305 **** return; } Vector possibleSalvage = new Vector(); Hashtable pilots = new Hashtable(); ! //Go through all living mechs and handle pilot damage ! for (int i = 0; i < Meks.size(); i++) { ! if (((String) Meks.elementAt(i)).startsWith("mw")) { ! StringTokenizer ST = new StringTokenizer((String) Meks.elementAt(i), "*"); ! //Read ID ! ST.nextElement(); ! //Mechwarrior ! MechWarrior mw = MechWarrior.getMechWarrior(Integer.parseInt(ST.nextToken()), Integer.parseInt(ST.nextToken()), new Boolean(ST.nextToken()).booleanValue()); ! pilots.put(new Integer(mw.getOriginalID()), mw); ! } else { ! //Unit ! TaskEntity t = new TaskEntity((String) Meks.elementAt(i), this, CampaignMain.cm); ! ! //Remove Meks which were not really involved into the fight ! // (2vs2) ! if (!this.isInvolved(t.getPlayer().getName())) { ! Meks.removeElementAt(i); ! i--; } else { ! TaskEntities.add(t); } } ! } ! for (int i = 0; i < TaskEntities.size(); i++) { ! TaskEntity t = (TaskEntity) TaskEntities.elementAt(i); ! SUnit m = this.getMechForID(t.getID()); ! TaskPlayer player = (TaskPlayer) this.getPlayer(t.getPlayer().getName()); ! ! //Tell him the kills and add to the log ! if (t.getKills().size() > 0) { ! ((SPilot) m.getPilot()).addKills(t.getKills().size(), m, player.getPlayer()); ! if (t.getKills().size() == 1) ! ! CampaignMain.cm.toUser("Your " + m.getModelname() + " has been awarded 1 kill!", player.getPlayer().getName(), true); ! else ! CampaignMain.cm.toUser("Your " + m.getModelname() + " has been awarded " + t.getKills().size() + " kills!", player.getPlayer().getName(), true); ! //Add History Entry ! for (int j = 0; j < t.getKills().size(); j++) { ! //Try to find the correct Taskplayer for that unit ! int unitId = ((Integer) t.getKills().elementAt(j)).intValue(); ! TaskPlayer pl = getPlayerForUnitID(unitId); ! if (pl != null) { ! SUnit unit = pl.getPlayer().getUnit(unitId); ! if (unit != null) { ! UnitHistoryKeeper.addUnitKilledUnitEntry(t.getID(), m.getPilot().getId(), unit.getId(), pl.getName(), pl.getPlayer().getMyHouse().getName()); ! KillboardKeeper.addEntry(m, unit); } } --- 257,311 ---- return; } + Vector possibleSalvage = new Vector(); Hashtable pilots = new Hashtable(); ! if (!isSimulated()){ ! //Go through all living mechs and handle pilot damage ! for (int i = 0; i < Meks.size(); i++) { ! if (((String) Meks.elementAt(i)).startsWith("mw")) { ! StringTokenizer ST = new StringTokenizer((String) Meks.elementAt(i), "*"); ! //Read ID ! ST.nextElement(); ! //Mechwarrior ! MechWarrior mw = MechWarrior.getMechWarrior(Integer.parseInt(ST.nextToken()), Integer.parseInt(ST.nextToken()), new Boolean(ST.nextToken()).booleanValue()); ! pilots.put(new Integer(mw.getOriginalID()), mw); } else { ! //Unit ! TaskEntity t = new TaskEntity((String) Meks.elementAt(i), this, CampaignMain.cm); ! ! //Remove Meks which were not really involved into the fight ! // (2vs2) ! if (!this.isInvolved(t.getPlayer().getName())) { ! Meks.removeElementAt(i); ! i--; ! } else { ! TaskEntities.add(t); ! } } } ! for (int i = 0; i < TaskEntities.size(); i++) { ! TaskEntity t = (TaskEntity) TaskEntities.elementAt(i); ! SUnit m = this.getMechForID(t.getID()); ! TaskPlayer player = (TaskPlayer) this.getPlayer(t.getPlayer().getName()); ! ! //Tell him the kills and add to the log ! if (t.getKills().size() > 0) { ! ((SPilot) m.getPilot()).addKills(t.getKills().size(), m, player.getPlayer()); ! if (t.getKills().size() == 1) ! ! CampaignMain.cm.toUser("Your " + m.getModelname() + " has been awarded 1 kill!", player.getPlayer().getName(), true); ! else ! CampaignMain.cm.toUser("Your " + m.getModelname() + " has been awarded " + t.getKills().size() + " kills!", player.getPlayer().getName(), true); ! //Add History Entry ! for (int j = 0; j < t.getKills().size(); j++) { ! //Try to find the correct Taskplayer for that unit ! int unitId = ((Integer) t.getKills().elementAt(j)).intValue(); ! TaskPlayer pl = getPlayerForUnitID(unitId); ! if (pl != null) { ! SUnit unit = pl.getPlayer().getUnit(unitId); ! if (unit != null) { ! UnitHistoryKeeper.addUnitKilledUnitEntry(t.getID(), m.getPilot().getId(), unit.getId(), pl.getName(), pl.getPlayer().getMyHouse().getName()); ! KillboardKeeper.addEntry(m, unit); ! } } } *************** *** 307,311 **** } } - //Mechstats Vector Winners = (this.getPlayersWhich("win")); --- 313,316 ---- *************** *** 355,359 **** } ! if (!t.isLiving()) { boolean pilotdied = true; String pilotmsg = ""; --- 360,364 ---- } ! if (!t.isLiving() && !isSimulated()) { boolean pilotdied = true; String pilotmsg = ""; *************** *** 1008,1011 **** --- 1013,1017 ---- //Just in case he lost a LandLord Pilot, check if somethng has to be unmaintained p.getPlayer().setRandomUnmaintained(); + p.getPlayer().setMayReset(true); //Was it a real task or just a try? If it was a real task,put all // players on reserve *************** *** 1322,1344 **** //Calculate Experience ! for (int i = 0; i < Winners.size(); i++) { ! TaskPlayer p = (TaskPlayer) Winners.elementAt(i); if (p.getInitialBV() > 0) { ! Vector losers = (getPlayersWhich("loss")); //get all players ! // listed as losing ! double loserRating = getTaskElo(((TaskPlayer) losers.elementAt(0)).getPlayer()); ! double winnerRating = getTaskElo(p.getPlayer()); ! //Modifier: the ratio of the loser's Rating to the current ! // winner's Rating. ! double modifier = (loserRating / winnerRating); ! // Factor: a number based on the type of task. ! double EXPtaskModifier = this.getEXPFactor(); ! double MoneyTaskModifier = this.getMoneyFactor(); ! int expworth = this.getBaseEXPWorth(p); ! int expgain = (int) Math.round(modifier * EXPtaskModifier * expworth); p.getPlayer().addExperience(expgain); ! int moneyworth = this.getBaseMoneyWorth(p); ! int moneygain = (int) Math.round(modifier * MoneyTaskModifier * moneyworth); //Add PP to the house double PPGain = (double) expgain / 50; --- 1328,1347 ---- //Calculate Experience ! for (int i = 0; i < AllPlayers.size(); i++) { ! TaskPlayer p = (TaskPlayer) AllPlayers.elementAt(i); if (p.getInitialBV() > 0) { ! double eloModifier = 1.0; ! if (p.isWinner()){ ! eloModifier = getTaskElo(p.getPlayer()) / getTaskElo(getFirstLooser().getPlayer()); ! } else { ! eloModifier = getTaskElo(getFirstWinner().getPlayer()) / getTaskElo(p.getPlayer()); ! } ! //Calulate and grant EXP ! int expgain = getEXPWorth(p, eloModifier); p.getPlayer().addExperience(expgain); ! //Calculate MoneyGain ! int moneygain = this.getMoneyWorth(p, eloModifier); ! //Add PP to the house double PPGain = (double) expgain / 50; *************** *** 1368,1393 **** moneygain = 0; } ! if (p.getPlayer().equals(getDefender().getPlayer())) {//if // winner is defender - double influenceToAdd = 0; - if (this.grantsInfluence()) { - int slicesToPay = p.getPlayer().getBusySlices() + 1; - int maxSlicesToPay = Integer.parseInt(CampaignMain.cm.getConfig("MaxBusySlicesToPay")); - if (slicesToPay > maxSlicesToPay) {//pay no more than - // config'ed # slices worth of flu - slicesToPay = maxSlicesToPay; - } - /* - * for (i = 0; i < slicesToPay; i++) { influenceToAdd += - * p.getPlayer().getMyHouse().doPayInfluenceMath(p.getPlayer()); } - */ - influenceToAdd = influenceToAdd * (1.15);//now, give a - // small winner bonus (15% boost to gain) - }//end if (task grants influence) CampaignMain.cm.toUser("You've gained " + expgain + " EXP and " + moneygain + " CBills.", p.getPlayer().getName(), true); String techPay = p.getPlayer().doPayTechnicians(1); CampaignMain.cm.toUser(techPay, p.getPlayer().getName(), true); - //p.getPlayer().addInfluence((int)influenceToAdd);//actually - // give the flu p.getPlayer().setBusySlices(0); } else {//winner was attacker --- 1371,1379 ---- moneygain = 0; } ! if (!p.isAttacker()) {//if // winner is defender CampaignMain.cm.toUser("You've gained " + expgain + " EXP and " + moneygain + " CBills.", p.getPlayer().getName(), true); String techPay = p.getPlayer().doPayTechnicians(1); CampaignMain.cm.toUser(techPay, p.getPlayer().getName(), true); p.getPlayer().setBusySlices(0); } else {//winner was attacker *************** *** 1401,1480 **** } } - - for (int i = 0; i < Losers.size(); i++) { - TaskPlayer p = (TaskPlayer) Losers.elementAt(i); - if (p.getInitialBV() > 0) { - TaskPlayer Winner = (TaskPlayer) (getPlayersWhich("win").elementAt(0)); - - //Modifier: The ratio of the Winner's BV to the loser's V. - //double modifier = (((double)Winner.getArmy().getBV() / - // (double)p.getArmy().getBV())); - double modifier = getTaskElo(Winner.getPlayer()) / getTaskElo(p.getPlayer()); - // Factor: a number based on the type of task. - double EXPtaskModifier = this.getEXPFactor(); - double MoneyTaskModifier = this.getMoneyFactor(); - int expworth = this.getBaseEXPWorth(p); - int expgain = (int) Math.round(modifier * EXPtaskModifier * expworth); - p.getPlayer().addExperience(expgain); - int moneyworth = this.getBaseMoneyWorth(p); - int moneygain = (int) Math.round(modifier * MoneyTaskModifier * moneyworth); - //Add PP to the house - double PPGain = (double) expgain / 50; - p.getPlayer().getMyHouse().addGeneralPP(PPGain, PPGain, PPGain); - if (!p.getPlayer().getMyHouse().isMercHouse()) {//if not a - // merc, pay - // player - p.getPlayer().addMoney(moneygain); - p.getPlayer().getMyHouse().addMoney(-moneygain); - } else {//is a merc, so set moneygain to 0 - SPlayer merc = p.getPlayer(); - MercHouse house = (MercHouse) merc.getMyHouse(); - ContractInfo contract = house.getContractInfo(merc); - //Inform his contract partner - CampaignMain.cm.toUser(this.getTaskInfo(true), contract.getOfferingPlayer().getName(), true); - int currentXP = merc.getExperience(); - int duration = contract.getContractDuration(); - int startXP = contract.getStartingExperience(); - if (currentXP >= startXP + duration) { - //if contract requirements completed - CampaignMain.cm.toUser("You have completed your contract with " + contract.getEmployingHouse().getName() + " and received the " + (contract.getPayment()) / 2 + " c-bills which Comstar held in escrow. <br>", merc.getName(), true); - CampaignMain.cm.toUser("You are now avaliable for hire.", merc.getName(), true); - merc.addMoney((contract.getPayment()) / 2); - house.endContract(merc); - } - moneygain = 0; - } - - if (p.getPlayer().equals(getDefender().getPlayer())) {//if - // winner is defender - double influenceToAdd = 0; - if (this.grantsInfluence()) { - int slicesToPay = p.getPlayer().getBusySlices() + 1; - int maxSlicesToPay = Integer.parseInt(CampaignMain.cm.getConfig("MaxBusySlicesToPay")); - if (slicesToPay > maxSlicesToPay) {//pay no more than - // config'ed # slices worth of flu - slicesToPay = maxSlicesToPay; - } - /* - * for (i = 0; i < slicesToPay; i++) { influenceToAdd += - * p.getPlayer().getMyHouse().doPayInfluenceMath(p.getPlayer()); } - */ - }//end if(task grants influence) - CampaignMain.cm.toUser("You've gained " + expgain + " EXP and " + moneygain + " CBills.", p.getPlayer().getName(), true); - String techPay = p.getPlayer().doPayTechnicians(1); - CampaignMain.cm.toUser(techPay, p.getPlayer().getName(), true); - //p.getPlayer().addInfluence((int)influenceToAdd);//actually - // give the flu - p.getPlayer().setBusySlices(0);//reset busySlilces - } else {//winner was attacker - CampaignMain.cm.toUser("You've gained " + expgain + " EXP, and " + moneygain + " CBills.", p.getPlayer().getName(), true); - if (!getDefender().getPlayer().getMyHouse().isNewbieHouse()){ - String techPay = p.getPlayer().doPayTechnicians(1); - CampaignMain.cm.toUser(techPay, p.getPlayer().getName(), true); - } - p.getPlayer().setBusySlices(0); - } - } - } } //Counters - if it counts for elo, it counts for counter --- 1387,1390 ---- *************** *** 1509,1513 **** } ! public int getBaseEXPWorth(TaskPlayer p) { int factor = 3; if (p.isWinner()) --- 1419,1423 ---- } ! public int getEXPWorth(TaskPlayer p, double eloMod) { int factor = 3; if (p.isWinner()) *************** *** 1516,1523 **** if (p.getLostMechs().size() == 0 && !p.isWinner()) expgain = expgain / 2; //Less EXP for losers which didn't lose anything ! return expgain; } ! public int getBaseMoneyWorth(TaskPlayer p) { int moneygain; if (p.isWinner()) --- 1426,1434 ---- if (p.getLostMechs().size() == 0 && !p.isWinner()) expgain = expgain / 2; //Less EXP for losers which didn't lose anything ! double EXPtaskModifier = this.getEXPFactor(); ! return (int)Math.round(expgain * eloMod * EXPtaskModifier); } ! public int getMoneyWorth(TaskPlayer p, double eloMod) { int moneygain; if (p.isWinner()) *************** *** 1527,1531 **** if (p.getLostMechs().size() == 0 && !p.isWinner() && getOpponent(p).getLostMechs().size() == 0) moneygain = 0; //Nothing lost = no money ! return moneygain; } --- 1438,1444 ---- if (p.getLostMechs().size() == 0 && !p.isWinner() && getOpponent(p).getLostMechs().size() == 0) moneygain = 0; //Nothing lost = no money ! // Factor: a number based on the type of task. ! double MoneyTaskModifier = this.getMoneyFactor(); ! return (int)Math.round(moneygain * eloMod * MoneyTaskModifier); } *************** *** 1944,1947 **** --- 1857,1867 ---- return false; } + + public boolean isAllowedToParticipate(SHouse h){ + if (h.isNewbieHouse()){ + return false; + } + return true; + } public String getTaskInfo(boolean accurate) { *************** *** 1965,1998 **** return true; } - public int getInfluencecost() { - if (Influencecost != 0) - return Influencecost; - //INFLUENCE CHECK @urgru 2/08/03 - int influenceCost = 0; - int heaviestClass = 0; - int numberOfLances = 1; - SArmy army = this.getActorArmy(); - heaviestClass = army.getHeaviesUnitClass(); - - String taskConfigToLoad = getName() + "BaseInfluenceCost"; - String weightConfigToLoad = "WeightInfluencePenalty" + Unit.getWeightClassDesc(heaviestClass); - - influenceCost = Integer.parseInt(CampaignMain.cm.getConfig(taskConfigToLoad)); //get - // task - // inf - influenceCost += Integer.parseInt(CampaignMain.cm.getConfig(weightConfigToLoad)); //add - // weight - if (numberOfLances > 1) //if more than one lance add penalty - influenceCost += Integer.parseInt(CampaignMain.cm.getConfig("MultiLanceInfluencePenalty")); - - //if the cost if over the maximum possible, make it max - if (influenceCost > Integer.parseInt(CampaignMain.cm.getConfig("InfluenceCeiling"))) - influenceCost = Integer.parseInt(CampaignMain.cm.getConfig("InfluenceCeiling")); - - if (getTarget() instanceof NewbiePlanet) - influenceCost = 0; - this.Influencecost = influenceCost; - return influenceCost; - } public double getJumpToRescueDifference() { --- 1885,1888 ---- *************** *** 2250,2253 **** --- 2140,2152 ---- p.setRaidElo(elo); } + + /** + * Simulated tasks should not have real casualties + * @return + */ + protected boolean isSimulated(){ + return false; + } + } --- NEW FILE: TrainingTask.java --- /** * MegaMekNET * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. */ package server.campaign.tasks; import java.util.Vector; import server.campaign.CampaignMain; import server.campaign.SHouse; import server.campaign.SPlayer; /** * @author HRi * */ public class TrainingTask extends Task { /* (non-Javadoc) * @see server.campaign.tasks.Task#doTickGain(server.campaign.SPlayer, int) */ public void doTickGain(SPlayer p, int leechNumber) { //Zilch no leeching } /* (non-Javadoc) * @see server.campaign.tasks.Task#processTaskResult() */ public void processTaskResult() { //Zilch, No result } /* (non-Javadoc) * @see server.campaign.tasks.Task#getFactor() */ public double getFactor() { return Double.parseDouble(CampaignMain.cm.getConfig("TrainingFactor")); } /* (non-Javadoc) * @see server.campaign.tasks.Task#getEXPFactor() */ public double getEXPFactor() { return 0; } /* (non-Javadoc) * @see server.campaign.tasks.Task#getNumberOfPlayers() */ public int getNumberOfPlayers() { return 2; } /* (non-Javadoc) * @see server.campaign.tasks.Task#getClosedTaskInfo(boolean) */ public String getClosedTaskInfo(boolean accureate) { Vector Winners = this.getPlayersWhich("win"); if (Winners == null) return ""; if (Winners.size() == 0) return ""; SPlayer Winner = ((TaskPlayer)Winners.elementAt(0)).getPlayer(); //This doesn't work since the lance is destroyed after the battle if (false) return "#" + this.getID() + " <b>" + getActor().getColoredName() + " (" + getActor().getPlayer().getHouseFightingFor().getName() + ")</b>" + " performed a training task on " + getTarget().getName() + ". Defender was: " + getDefender(0).getPlayer().getColoredName() + " (" + getDefender(0).getPlayer().getMyHouse().getHouseFightingFor(getDefender(0).getPlayer()).getName() + ")" + ". Winner: " + Winner.getName() + ".<br>"; else return "#" + this.getID() + " <b>" + getActor().getColoredName() + " (" + getActor().getPlayer().getHouseFightingFor().getName() + ")</b>" + " performed a training task on " + getTarget().getName() + ". Defender was: " + getDefender(0).getPlayer().getColoredName() + " (" + getDefender(0).getPlayer().getMyHouse().getHouseFightingFor(getDefender(0).getPlayer()).getName() + ")" + ". Winner: " + Winner.getName() + ".<br>"; } /* (non-Javadoc) * @see server.campaign.tasks.Task#getTaskTickTime() */ public int getTaskTickTime() { return Integer.MAX_VALUE; } /* (non-Javadoc) * @see server.campaign.tasks.Task#getMaxDistance() */ public int getMaxDistance() { return Integer.MAX_VALUE; } /* (non-Javadoc) * @see server.campaign.tasks.Task#getName() */ public String getName() { return "Training task"; } /* (non-Javadoc) * @see server.campaign.tasks.Task#getTypeID() */ public int getTypeID() { return TASK_TRAINING; } protected boolean isSimulated(){ return true; } public int getEXPWorth(TaskPlayer p, double eloMod) { return (Integer.parseInt(CampaignMain.cm.getConfig("XPRollOverCap"))); } public boolean isAllowedToParticipate(SHouse h){ return true; } } |
From: Helge R. <mcw...@us...> - 2005-03-26 16:05:27
|
Update of /cvsroot/megameknet/MegaMekNET/src/server/campaign In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28650/src/server/campaign Modified Files: SPlayer.java NewbieHouse.java Log Message: -> S 1. Remove all task benefits from raiding SOL (Mechs, Comps) 2. Reduce EXP payout so that House players gain 1 RP for the game. 3. Make sure neither side suffers any losses from the game. Units on either side gain no EXP or kills. 4. Make it so SOL players can reset their hangar after a game. Coaches should be able to reset at any point (Yet untested...) McW 2005-03-26 Index: NewbieHouse.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/NewbieHouse.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** NewbieHouse.java 26 Mar 2005 12:22:13 -0000 1.26 --- NewbieHouse.java 26 Mar 2005 16:05:18 -0000 1.27 *************** *** 146,151 **** String result; if (!(p.getActivityStatus() == PlayerStatus.FIGHTING)) { ! if (p.getAllUnits().size() < 5) { p.stripOfAllUnits(false); addLanceToPlayer(1, p); SUnit c = this.getRandomMech(SUnit.LIGHT); --- 146,152 ---- String result; if (!(p.getActivityStatus() == PlayerStatus.FIGHTING)) { ! if (p.getAllUnits().size() < 5 || p.isMayReset()) { p.stripOfAllUnits(false); + p.setMayReset(false); addLanceToPlayer(1, p); SUnit c = this.getRandomMech(SUnit.LIGHT); Index: SPlayer.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/SPlayer.java,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -d -r1.86 -r1.87 *** SPlayer.java 26 Mar 2005 12:22:13 -0000 1.86 --- SPlayer.java 26 Mar 2005 16:05:17 -0000 1.87 *************** *** 67,70 **** --- 67,71 ---- private boolean retasking = false; private int externalRank = 0; + private boolean mayReset = true; // cache fields. *************** *** 950,953 **** --- 951,958 ---- if (this.getAverageRating() < t.getMinRatingNeeded()) return res; + //Check if the house is allowed to participate + if (!t.isAllowedToParticipate(getMyHouse())){ + return res; + } //Immune players don't count as well. if (this.getImmunetill() > System.currentTimeMillis()) *************** *** 1771,1773 **** --- 1776,1792 ---- return visitor instanceof ServerVisitor ? ((ServerVisitor) visitor).visitSPlayer(this) : super.visit(visitor); } + + /** + * @param mayReset The mayReset to set. + */ + public void setMayReset(boolean mayReset) { + this.mayReset = mayReset; + } + + /** + * @return Returns the mayReset. + */ + public boolean isMayReset() { + return mayReset; + } } \ No newline at end of file |