Thread: [Megameknet-cvs] MegaMekNET/src/server/cyclops CyclopsVisitor.java,1.2,1.3 Cyclops.java,1.2,1.3
Status: Inactive
Brought to you by:
mcwizard
From: Immanuel S. <im...@us...> - 2005-04-09 09:47:59
|
Update of /cvsroot/megameknet/MegaMekNET/src/server/cyclops In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5552/src/server/cyclops Modified Files: CyclopsVisitor.java Cyclops.java Log Message: Cyclops changes and some minor corrections to the xml loading Index: CyclopsVisitor.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/cyclops/CyclopsVisitor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CyclopsVisitor.java 25 Mar 2005 19:52:54 -0000 1.2 --- CyclopsVisitor.java 9 Apr 2005 09:47:44 -0000 1.3 *************** *** 19,27 **** --- 19,33 ---- import java.util.Iterator; import java.util.LinkedList; + import java.util.List; + import java.util.Map; + import server.campaign.CampaignMain; import server.campaign.SPlanet; + import server.campaign.SPlayer; + import server.campaign.ranks.RankClassifier; import common.Continent; import common.House; import common.Planet; import common.PlanetEnvironment; + import common.Player; import common.UnitFactory; import common.visitor.AbstractVisitor; *************** *** 90,93 **** --- 96,100 ---- * - continents (an array of continent structs) * - enhancements (an array of enhancement struct) + * - influences (an array of influences struct) * * continent struct is : *************** *** 100,104 **** * - desc (str) * - type (char3) ! * - rank (char3) */ public Object visitPlanet(Planet dataPlanet) { --- 107,126 ---- * - desc (str) * - type (char3) ! * WH - Warehouse ! * LM - light mech ! * MM - medium mech ! * HM - heavy mech ! * AM - assault mech ! * LV - light vehicle ! * MV - medium vehicle ! * HV - heavy vehicle ! * AV - assault vehicle ! * LI - light infantry ! * AI - assault infantry ("battlearmor" on lvl2 servers) ! * - rank (char3) ! * ! * influence struct is: ! * - house (id of the house) ! * - influence (integer with influence on the planet) */ public Object visitPlanet(Planet dataPlanet) { *************** *** 146,157 **** wh.put("type", "WH"); wh.put("rank", new Integer(data.getBaysProvided())); } for (Iterator it = data.getUnitFactories().iterator(); it.hasNext();) { UnitFactory uf = (UnitFactory)it.next(); ! HashMap h = new HashMap(); ! h.put("id", "id"+data.getId()); ! //TODO: continue here. } return e; } --- 168,210 ---- wh.put("type", "WH"); wh.put("rank", new Integer(data.getBaysProvided())); + enhancements.add(wh); + } + // sum up all factory types for this planet + class CyclopsFab { + String id; + String desc; + String planet; + String type; + int rank; } + Map sumFabs = new HashMap(); for (Iterator it = data.getUnitFactories().iterator(); it.hasNext();) { UnitFactory uf = (UnitFactory)it.next(); ! String type = uf.getSize().substring(0,1) + uf.getTypeString(); ! HashMap c = (HashMap)sumFabs.get(type); ! if (c == null) { ! c = new HashMap(); ! c.put("planet", "id"+data.getId()); ! c.put("id", "id"+data.getId()+type); ! c.put("type", type); ! c.put("desc", uf.getName()); ! c.put("rank", new Integer(0)); ! } ! c.put("rank", new Integer(((Integer)c.get("rank")).intValue()+1)); ! sumFabs.put(type, c); } + enhancements.addAll(sumFabs.values()); + e.put("enhancements", enhancements); + // Influences + List influences = new LinkedList(); + for (Iterator it = data.getInfluence().getHouseIds().iterator();it.hasNext();) { + HashMap h = new HashMap(); + Integer id = (Integer)it.next(); + h.put("house", "id"+id); + h.put("influence", new Integer(data.getInfluence().getInfluence(id.intValue()))); + influences.add(h); + } + e.put("influences", influences); return e; } *************** *** 207,209 **** --- 260,288 ---- return new BigInteger(bin, 2).intValue(); } + + /** + * id, + * username, + * desc, (not used in MMnet i guess), + * house, (houseid) + * logo, (url) + * camo, + * passwd, (leave it empty) + * access, (that the user level in MMnet, let's define a encoding) + * level (that's the rank of the player) + */ + public Object visitPlayer(Player data) { + SPlayer p = (SPlayer)data; + HashMap e = new HashMap(); + e.put("id", "id"+p.getName().toLowerCase()); + e.put("username", p.getName()); + // e.put("desc", ""); + e.put("house", "id"+p.getMyHouse().getId()); + e.put("logo", p.getLogo()); + // e.put("passwd", ""); + // e.put("camo", ""); + e.put("access", new Integer(CampaignMain.cm.getServer().getUserAccessLevel(p.getName()))); + e.put("level", RankClassifier.getRankDescription(p)); + return e; + } } Index: Cyclops.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/cyclops/Cyclops.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Cyclops.java 25 Mar 2005 19:52:54 -0000 1.2 --- Cyclops.java 9 Apr 2005 09:47:44 -0000 1.3 *************** *** 20,23 **** --- 20,24 ---- import common.House; import common.Planet; + import common.Player; import common.util.CommunicationException; import common.util.MMNetXmlRpcClient; *************** *** 41,44 **** --- 42,59 ---- /** + * Send the players given at parameter to the cyclops server. + */ + public static String player_writeFromList(Collection players) { + return invoke1("player.writeFromList", players); + } + + /** + * Send the player given at parameter to the cyclops server. + */ + public static String player_write(Player player) { + return invoke1("player.write", player); + } + + /** * Send the houses given at parameter to the cyclops server. */ |