public COrder(CEncodedObjectInputBufferI bin) { bin.nextTag(TAG); Dictionary <string, string> A = bin.getAttributes(); ordType_ = A[ORDTYPE]; value_ = EncodeUtil.parseInt(A[VALUE]); if (A.ContainsKey(UTYPE)) { utype_ = A[UTYPE]; } flag_ = EncodeUtil.fromBoolString(A[FLAG]); ugid_ = EncodeUtil.parseUInt(A[UGID]); useEmbark_ = EncodeUtil.fromBoolString(A[UGID]); bin.firstChild(); bin.nextTag(LOCS); if (bin.hasChildren()) { bin.firstChild(); locs_ = new List <CLoc>(); while (!bin.reachedEndTag(LOCS)) { CLoc l = CLoc.fromKey(bin.getObjectText(LOC)); locs_.Add(l); } } bin.endTag(LOCS); bin.endTag(TAG); }
public CPlayer(CEncodedObjectInputBufferI bin) { bin.nextTag(TAG); Dictionary <string, string> A = bin.getAttributes(); originalPosition_ = EncodeUtil.parseInt(A[ORIGINAL_POSITION]); position_ = EncodeUtil.parseInt(A[POSITION]); buypoints_ = EncodeUtil.parseInt(A[BUYPOINTS]); buypointsSpent_ = EncodeUtil.parseInt(A[BUYPOINTSSPENT]); score_ = EncodeUtil.parseInt(A[SCORE]); pcap_ = EncodeUtil.parseInt(A[PCAP]); ccap_ = EncodeUtil.parseInt(A[CCAP]); ncap_ = EncodeUtil.parseInt(A[NCAP]); living_ = EncodeUtil.fromBoolString(A[LIVING]); type_ = bin.getObjectText(TYPE_TAG); if (bin.thisTag() == PNAME_TAG) { pname_ = bin.getObjectText(PNAME_TAG); } else { pname_ = null; } if (bin.thisTag() == DEAD_REASON_TAG) { deadReason_ = bin.getObjectText(DEAD_REASON_TAG); } else { deadReason_ = null; } bin.endTag(TAG); }
public VlasovPlayer( int position, Dictionary <string, string> caMap, CEncodedObjectInputBufferI bin, string logpath, string logname, AIEventInterfaceI aiEvent, AICommandInterfaceI command, AIQueryI query, AICheatI cheat, int logLevel) : base( position, logpath, logname, caMap, bin, aiEvent, command, query, cheat, logLevel) { elogger_ = new CSubLog("ExamplePlayer:" + Convert.ToString(position), realLog_); elogger_.info("D Logger Log Open: " + logpath + " " + logname); elogger_.info("Position " + Convert.ToSingle(position) + " waking up."); testAttribute_ = EncodeUtil.parseInt(caMap[TEST_ATTR]); hints_ = new CDLLHints(bin); }
public CDLLNumericRangeValueHintInfo(Dictionary <string, string> attr, CEncodedObjectInputBufferI bin) : base(NUMERIC_RANGE_VALUE_TYPE, attr, bin) { def_ = EncodeUtil.parseInt(attr[DEF_ATTR]); value_ = EncodeUtil.parseInt(attr[VALUE_ATTR]); min_ = EncodeUtil.parseInt(attr[MIN_ATTR]); max_ = EncodeUtil.parseInt(attr[MAX_ATTR]); }
public static CLoc fromKey(string k) { int si = k.IndexOf("_", StringComparison.Ordinal); string sx = k.Substring(0, si); string sy = k.Substring(si + 1); return(new CLoc(EncodeUtil.parseInt(sx), EncodeUtil.parseInt(sy))); }
public CVictoryConditions(CEncodedObjectInputBufferI bin) { bin.nextTag(TAG); Dictionary <string, string> A = bin.getAttributes(); annihilationVictory_ = EncodeUtil.fromBoolString(A[ANNIHILATION]); percentageCitiesV_ = EncodeUtil.parseInt(A[PERCITIESVALUE]); percentageCitiesVDuration_ = EncodeUtil.parseInt(A[PERCITIESDUR]); numImportantV_ = EncodeUtil.parseInt(A[NUMIMPVALUE]); numImportantVDuration_ = EncodeUtil.parseInt(A[NUMIMPDUR]); capitalKill_ = EncodeUtil.fromBoolString(A[CAPKILL]); regicideV_ = EncodeUtil.parseInt(A[REGICIDE]); bin.endTag(TAG); }
public CDLLNumericValueHintInfo(Dictionary <string, string> attr, CEncodedObjectInputBufferI bin) : base(NUMERIC_VALUE_TYPE, attr, bin) { def_ = EncodeUtil.parseInt(attr[DEF_ATTR]); value_ = EncodeUtil.parseInt(attr[VALUE_ATTR]); if (attr.ContainsKey(POS_ATTR)) { positiveOnly_ = EncodeUtil.fromBoolString(attr[POS_ATTR]); } else { positiveOnly_ = false; } }
public CProposal(CEncodedObjectInputBufferI bin) { bin.nextTag(TAG); Dictionary <string, string> A = bin.getAttributes(); type_ = A[TYPE]; fromP_ = EncodeUtil.parseInt(A[FROM]); toP_ = EncodeUtil.parseInt(A[TO]); gid_ = EncodeUtil.parseUInt(A[GID]); id_ = EncodeUtil.parseUInt(A[ID]); status_ = A[STATUS]; name_ = bin.getObjectText(NAME); bin.endTag(TAG); }
public CMTRandom(string tag, CEncodedObjectInputBufferI bin) { bin.nextTag(tag); Dictionary <string, string> attr = bin.getAttributes(); //with seeded constructor, run use count up to appropriate total int useCount = EncodeUtil.parseInt(attr[USE_COUNT_ATTR]); seedUsed_ = ulong.Parse(bin.getObjectText(SEED_TAG)); twister_ = new CMersenneTwister(seedUsed_); for (int i = 0; i < useCount; i++) { random(2); } bin.endTag(tag); }
public CProductionReportData(CEncodedObjectInputBufferI bin) { bin.nextTag(TAG); Dictionary <string, string> A = bin.getAttributes(); value_ = EncodeUtil.parseInt(A[VALUE]); pkey_ = EncodeUtil.parseUInt(A[PKEY]); ckey_ = EncodeUtil.parseUInt(A[CKEY]); rtype_ = bin.getObjectText(RTYPE); if (bin.thisTag() == REPORT) { report_ = bin.getObjectText(REPORT); } else { report_ = null; } if (bin.thisTag() == PTYPE) { ptype_ = bin.getObjectText(PTYPE); } else { ptype_ = null; } if (bin.thisTag() == CTYPE) { ctype_ = bin.getObjectText(CTYPE); } else { ctype_ = null; } if (bin.thisTag() == LOC) { loc_ = CLoc.fromKey(bin.getObjectText(LOC)); } else { loc_ = null; } bin.endTag(TAG); }
private CProducerUnit(Dictionary <string, string> A, CEncodedObjectInputBufferI bin, AIQueryI query) : base(A, bin, query) { producing_ = A[PRODUCING]; specialty_ = A[SPECIALTY]; turnsToCompletion_ = EncodeUtil.parseInt(A[TURNSTOCOMPLETE]); efficiency_ = EncodeUtil.parseInt(A[EFFICIENCY]); supplyStore_ = EncodeUtil.parseUInt(A[SUPPLYSTORE]); minStore_ = EncodeUtil.parseUInt(A[MINSTORE]); scrapVal_ = EncodeUtil.parseUInt(A[SCRAPVAL]); consumeSupplyForDrain_ = EncodeUtil.fromBoolString(A[CONSUMESUPPFORDRAIN]); consumePriority_ = EncodeUtil.parseInt(A[CONSUMEPRIORITY]); autoDrainSupply_ = EncodeUtil.fromBoolString(A[AUTODRAIN]); isCapital_ = EncodeUtil.fromBoolString(A[CAPITAL]); isImportant_ = EncodeUtil.fromBoolString(A[IMPORTANT]); }
public AIMap(CEncodedObjectInputBufferI bin) { bin.nextTag(TAG); Dictionary <string, string> A = bin.getAttributes(); int width = EncodeUtil.parseInt(A[GAME_MAP_WIDTH_ATTR]); int height = EncodeUtil.parseInt(A[GAME_MAP_HEIGHT_ATTR]); bool vwrap = EncodeUtil.fromBoolString(A[GAME_MAP_VWRAP_ATTR]); bool hwrap = EncodeUtil.fromBoolString(A[GAME_MAP_HWRAP_ATTR]); mapUtil_ = new CMapUtil(width, hwrap, height, vwrap); stackCount_ = EncodeUtil.parseUInt(A[STACKCOUNT]); string mb = bin.getObjectText(TMAP_TAG); mapBytes_ = mb.ToCharArray(); var tmp = new List <string>(); EncodeUtil.decodeStringList(WASTELAND, tmp, bin); foreach (string s in tmp) { wasteland_.Add(s, true); } tmp.Clear(); EncodeUtil.decodeStringList(MINES, tmp, bin); foreach (string s in tmp) { mines_.Add(s, true); } tmp.Clear(); EncodeUtil.decodeStringList(ROAD, tmp, bin); foreach (string s in tmp) { roads_.Add(s, true); } tmp.Clear(); EncodeUtil.decodeDSI(RESOURCES, resources_, bin); bin.endTag(TAG); }
protected CUnit(Dictionary <string, string> A, CEncodedObjectInputBufferI bin, AIQueryI query) { utype_ = A[UTYPE]; loc_ = CLoc.fromKey(A[LOC]); gid_ = EncodeUtil.parseUInt(A[GID]); owner_ = EncodeUtil.parseInt(A[OWNER]); stackLayer_ = EncodeUtil.parseUInt(A[STACKLAYER]); level_ = A[LEVEL]; landed_ = EncodeUtil.fromBoolString(A[LANDED]); inReentry_ = EncodeUtil.fromBoolString(A[INREENTRY]); host_ = EncodeUtil.parseUInt(A[HOST]); turn_ = EncodeUtil.parseInt(A[TURN]); rmvr_ = EncodeUtil.parseInt(A[RMVR]); rmvs_ = EncodeUtil.parseInt(A[RMVS]); fired_ = EncodeUtil.fromBoolString(A[FIRED]); armed_ = EncodeUtil.fromBoolString(A[ARMED]); dmg_ = EncodeUtil.parseInt(A[DMG]); shortFuel_ = EncodeUtil.fromBoolString(A[SHORTFUEL]); sawEnemy_ = EncodeUtil.fromBoolString(A[SAWENEMY]); dugIn_ = EncodeUtil.fromBoolString(A[DUGIN]); experience_ = EncodeUtil.parseUInt(A[EXPERIENCE]); readiness_ = A[READINESS]; expType_ = A[EXPTYPE]; name_ = bin.getObjectText(NAME); bin.nextTag(CUNITS); if (bin.hasChildren()) { bin.firstChild(); while (!bin.reachedEndTag(CUNITS)) { bin.nextTag(CUNIT); Dictionary <string, string> D = bin.getAttributes(); uint u = EncodeUtil.parseUInt(D[CUNITID]); cunits_.Add(u); bin.endTag(CUNIT); } } bin.endTag(CUNITS); ord_ = new COrder(bin); entry_ = query.unitQuery(utype_); }
public CGameMapParameters(CEncodedObjectInputBufferI bin) { bin.nextTag(TAG); Dictionary <string, string> attr = bin.getAttributes(); numPositions_ = EncodeUtil.parseInt(attr[NUM_POSITION_ATTR]); needCapitals_ = EncodeUtil.fromBoolString(attr[NEEDCAP_ATTR]); needImportant_ = EncodeUtil.fromBoolString(attr[NEEDIMPORT_ATTR]); numImportant_ = EncodeUtil.parseInt(attr[NUMIMPORT_ATTR]); numStartingCities_ = null; var plist = new List <KeyValuePair <int, int> >(); bin.nextTag(NUMSTARTCI_TAGS); if (bin.hasChildren()) { bin.firstChild(); while (!bin.reachedEndTag(NUMSTARTCI_TAGS)) { Dictionary <string, string> attrc = bin.getAttributes(); int index = EncodeUtil.parseInt(attrc[POS_ATTR]); int v = EncodeUtil.parseInt(attrc[VALUE_ATTR]); plist.Add(new KeyValuePair <int, int>(index, v)); bin.endTag(NUMSTARTCI_TAG); } } if (plist.Count > 0) { numStartingCities_ = new int[plist.Count]; foreach (KeyValuePair <int, int> kp in plist) { numStartingCities_[kp.Key] = kp.Value; } } bin.endTag(NUMSTARTCI_TAGS); bin.endTag(TAG); }
//////////////////////////////////////////////////////////////////// //Reloading protected AIPlayerData( int position, string path, string logname, Dictionary <string, string> caMap, CEncodedObjectInputBufferI bin, AIEventInterfaceI aiEvent, AICommandInterfaceI command, AIQueryI query, AICheatI cheat, int logLevel) : base(position, path, logname, caMap, bin, aiEvent, command, query, cheat, logLevel) { dlogger_ = new CSubLog("PlayerData:" + Convert.ToString(position), realLog_); curturn_ = EncodeUtil.parseInt(caMap[CUR_TURN]); numPlayers_ = EncodeUtil.parseInt(caMap[NUM_PLAYERS]); rdWeight_ = EncodeUtil.parseInt(caMap[RD_WEIGHT]); unitsBeforeDrain_ = EncodeUtil.parseInt(caMap[UNITS_BEFORE_DRAIN]); bin.nextTag(CPlayer.TAGS); if (bin.hasChildren()) { bin.firstChild(); while (!bin.reachedEndTag(CPlayer.TAGS)) { players_.Add(new CPlayer(bin)); } } bin.endTag(CPlayer.TAGS); bin.nextTag(SPOTU); if (bin.hasChildren()) { bin.firstChild(); while (!bin.reachedEndTag(SPOTU)) { CUnit u = CUnit.decodeCUnit(bin, query_); masterObjects_.Add(u.gid_, u); spotMap_.Add(u.gid_, u); spots_.Add(u); } } bin.endTag(SPOTU); bin.nextTag(SPOTC); if (bin.hasChildren()) { bin.firstChild(); while (!bin.reachedEndTag(SPOTC)) { CProducerUnit c = CProducerUnit.decodeCProducerUnit(bin, query_); masterObjects_.Add(c.gid_, c); knownCitiesVec_.Add(c); spotMap_.Add(c.gid_, c); spots_.Add(c); } } bin.endTag(SPOTC); bin.nextTag(SPOTP); if (bin.hasChildren()) { bin.firstChild(); while (!bin.reachedEndTag(SPOTP)) { CProducerUnit p = CProducerUnit.decodeCProducerUnit(bin, query); masterObjects_.Add(p.gid_, p); spotMap_.Add(p.gid_, p); spots_.Add(p); } } bin.endTag(SPOTP); bin.nextTag(CITIES); if (bin.hasChildren()) { bin.firstChild(); while (!bin.reachedEndTag(CITIES)) { CProducerUnit c = CProducerUnit.decodeCProducerUnit(bin, query_); masterObjects_.Add(c.gid_, c); knownCitiesVec_.Add(c); cities_.Add(c); cityMap_.Add(c.gid_, c); } } bin.endTag(CITIES); bin.nextTag(UNITS); if (bin.hasChildren()) { bin.firstChild(); while (!bin.reachedEndTag(UNITS)) { CUnit u = CUnit.decodeCUnit(bin, query_); masterObjects_.Add(u.gid_, u); unitMap_.Add(u.gid_, u); units_.Add(u); } } bin.endTag(UNITS); bin.nextTag(PRODUCERS); if (bin.hasChildren()) { bin.firstChild(); while (!bin.reachedEndTag(PRODUCERS)) { CProducerUnit p = CProducerUnit.decodeCProducerUnit(bin, query_); masterObjects_.Add(p.gid_, p); producers_.Add(p); producerMap_.Add(p.gid_, p); unitMap_.Add(p.gid_, p); units_.Add(p); } } bin.endTag(PRODUCERS); bin.nextTag(CSupplyRoute.TAGS); if (bin.hasChildren()) { bin.firstChild(); while (!bin.reachedEndTag(CSupplyRoute.TAGS)) { var csr = new CSupplyRoute(bin); supplySources_.Add(csr.rid_, csr); } } bin.endTag(CSupplyRoute.TAGS); map_ = new AIMap(bin); mapUtil_ = map_.mapUtil_; gameRules_ = new CGameRules(bin); vc_ = new CVictoryConditions(bin); bin.nextTag(CProposal.TAGS); if (bin.hasChildren()) { bin.firstChild(); while (!bin.reachedEndTag(CProposal.TAGS)) { var p = new CProposal(bin); proposals_.Add(p); } } bin.endTag(CProposal.TAGS); bin.nextTag(CProductionReportData.TAGS); if (bin.hasChildren()) { bin.firstChild(); while (!bin.reachedEndTag(CProductionReportData.TAGS)) { var prd = new CProductionReportData(bin); prodReport_.Add(prd); } } bin.endTag(CProductionReportData.TAGS); random_ = new CMTRandom(AI_RANDOM_TAG, bin); //retrieve flyover foUnit_ = null; if (caMap.ContainsKey(FOUNIT_ID)) { uint fid = EncodeUtil.parseUInt(caMap[FOUNIT_ID]); foUnit_ = masterObjects_[fid]; } }
public override bool update(string attr, string value, CSubLog logger) { if (base.update(attr, value, logger)) { return(true); } switch (attr) { case CUnitConstants.PRODUCING: producing_ = value; return(true); case CUnitConstants.SPECIALTY: { specialty_ = value; return(true); } case CUnitConstants.EFFICIENCY: { efficiency_ = EncodeUtil.parseInt(value); return(true); } case CUnitConstants.TTC: { turnsToCompletion_ = EncodeUtil.parseInt(value); return(true); } case CUnitConstants.SUPPLY_STORE: { supplyStore_ = EncodeUtil.parseUInt(value); return(true); } case CUnitConstants.MIN_STORE: { minStore_ = EncodeUtil.parseUInt(value); return(true); } case CUnitConstants.SCRAPVAL: { scrapVal_ = EncodeUtil.parseUInt(value); return(true); } case CUnitConstants.AUTOSUPPLYDRAIN: { autoDrainSupply_ = EncodeUtil.fromBoolString(value); return(true); } case CUnitConstants.CONS_FOR_DRAIN: { consumeSupplyForDrain_ = EncodeUtil.fromBoolString(value); return(true); } case CUnitConstants.CONS_PRIORITY: { consumePriority_ = EncodeUtil.parseInt(value); return(true); } } return(false); }
public CDLLRadioContainerHintInfo(Dictionary <string, string> attr, CEncodedObjectInputBufferI bin) : base(RADIO_CONTAINER_TYPE, attr, bin) { sig_ = EncodeUtil.parseUInt(attr[SIG_ATTR]); currentOption_ = EncodeUtil.parseInt(attr[CURRENT_ATTR]); minfos_ = new List <List <CDLLHintInfo> >(); bin.nextTag(LIST_TAGS + Convert.ToString(sig_)); if (bin.hasChildren()) { bin.firstChild(); while (!bin.reachedEndTag(LIST_TAGS + Convert.ToString(sig_))) { var infos = new List <CDLLHintInfo>(); minfos_.Add(infos); bin.nextTag(LIST_TAG + Convert.ToString(sig_)); if (bin.hasChildren()) { bin.firstChild(); while (!bin.reachedEndTag(LIST_TAG + Convert.ToString(sig_))) { CDLLHintInfo hi = decode(bin); infos.Add(hi); } } bin.endTag(LIST_TAG + Convert.ToString(sig_)); } } bin.endTag(LIST_TAGS + Convert.ToString(sig_)); catkeys_ = new List <string>(); bin.nextTag(KEY_TAGS); if (bin.hasChildren()) { bin.firstChild(); while (!bin.reachedEndTag(KEY_TAGS)) { catkeys_.Add(bin.getObjectText(KEY_TAG)); } } bin.endTag(KEY_TAGS); catnames_ = new List <string>(); bin.nextTag(CATNAME_TAGS); if (bin.hasChildren()) { bin.firstChild(); while (!bin.reachedEndTag(CATNAME_TAGS)) { catnames_.Add(bin.getObjectText(CATNAME_TAG)); } } bin.endTag(CATNAME_TAGS); rbnames_ = new List <string>(); bin.nextTag(RBNAME_TAGS); if (bin.hasChildren()) { bin.firstChild(); while (!bin.reachedEndTag(RBNAME_TAGS)) { rbnames_.Add(bin.getObjectText(RBNAME_TAG)); } } bin.endTag(RBNAME_TAGS); }
public virtual bool update(string attr, string value, CSubLog logger) { switch (attr) { case CUnitConstants.NAME: { name_ = value; return(true); } case CUnitConstants.TURN: { turn_ = EncodeUtil.parseInt(value); return(true); } case CUnitConstants.HOST: { host_ = EncodeUtil.parseUInt(value); logger.info(this + " now has host value [" + Convert.ToString(host_) + "]"); return(true); } case CUnitConstants.RMVR: { rmvr_ = EncodeUtil.parseInt(value); return(true); } case CUnitConstants.RMVS: { rmvs_ = EncodeUtil.parseInt(value); return(true); } case CUnitConstants.FIRED: { fired_ = EncodeUtil.fromBoolString(value); return(true); } case CUnitConstants.ARMED: { armed_ = EncodeUtil.fromBoolString(value); return(true); } case CUnitConstants.DUGIN: { dugIn_ = EncodeUtil.fromBoolString(value); return(true); } case CUnitConstants.DMG: { dmg_ = EncodeUtil.parseInt(value); return(true); } case CUnitConstants.SHORT_FUEL: { shortFuel_ = EncodeUtil.fromBoolString(value); return(true); } case CUnitConstants.READINESS: { readiness_ = value; return(true); } case CUnitConstants.EXPERIENCE: { experience_ = EncodeUtil.parseUInt(value); return(true); } case CUnitConstants.EXP_LEVEL: { expType_ = value; return(true); } case CUnitConstants.CHILD_ADD: { uint cgid = EncodeUtil.parseUInt(value); cunits_.Add(cgid); logger.info("Unit " + Convert.ToString(gid_) + " adds child " + Convert.ToString(cgid)); return(true); } case CUnitConstants.CHILD_REM: { uint cgid = EncodeUtil.parseUInt(value); for (int j = 0; j < cunits_.Count; j++) { if (cunits_[j] == cgid) { cunits_.RemoveAt(j); break; } } logger.info("Unit " + Convert.ToString(gid_) + " removes child " + Convert.ToString(cgid)); return(true); } case CUnitConstants.LX: setLoc(new CLoc(EncodeUtil.parseInt(value), loc_.y)); return(true); case CUnitConstants.LY: setLoc(new CLoc(loc_.x, EncodeUtil.parseInt(value))); return(true); case CUnitConstants.OWNER: //will need to do more here if interested in gifts or giveaways { owner_ = EncodeUtil.parseInt(value); return(true); } case CUnitConstants.LANDED: { landed_ = EncodeUtil.fromBoolString(value); return(true); } case CUnitConstants.REENTRY: { inReentry_ = EncodeUtil.fromBoolString(value); return(true); } case CUnitConstants.LEVEL: { level_ = value; return(true); } case CUnitConstants.SLAYER: { stackLayer_ = EncodeUtil.parseUInt(value); return(true); } } return(false); }