void econ_change_items(dbref d, int id, int brand, int num) { char *t, *u; int base = 0, i1, i2, i3; if(!Good_obj(d)) return; if(brand) if(get_parts_short_name(id, brand) == get_parts_short_name(id, 0)) brand = 0; t = silly_atr_get(d, A_ECONPARTS); if((u = find_entry(t, id, brand))) { if(sscanf(u, "[%d,%d,%d]", &i1, &i2, &i3) == 3) base += i3; remove_entry(t, u); } base += num; if(base <= 0) { if(u) silly_atr_set(d, A_ECONPARTS, t); return; } if(!(IsActuator(id))) add_entry(t, tprintf("%d,%d,%d", id, brand, base)); silly_atr_set(d, A_ECONPARTS, t); if(IsActuator(id)) econ_change_items(d, Cargo(S_ACTUATOR), brand, base); /* Successfully changed */ }
World::World() { this->rules = Rules(); this->charon = Charon(Charon::EAST); this->goat = Cargo(Cargo::GOAT, Charon::EAST); this->wolf = Cargo(Cargo::WOLF, Charon::EAST); this->cabbage = Cargo(Cargo::CABBAGE, Charon::EAST); cpositions.push_back(goat); cpositions.push_back(wolf); cpositions.push_back(cabbage); gameStatus = 0; }
bool Range::next(string & chrom, Interval & intv){ if(!on_chromosome) return false; chrom = chr; while(!recurse.empty()){ Cargo c = recurse.top(); Interval i = cvector.at(c.root); if(d.getStart() >= i.getSubMax()){ recurse.pop(); }else{ if(!c.goLeft){ //check this one, pop, then put right on top if it exists and start is less than i stop recurse.pop(); if(d.getStop() > i.getStart()){ Capacity root; if(getMidpoint(c.root+1, c.high, root)){ recurse.push(Cargo(c.root+1, c.high, root)); } if(i.overlaps(d)){ intv = i; return true; } }//else this node and right children do not overlap d }else{ recurse.top().goLeft = false; //go left Capacity root; if(getMidpoint(c.low, c.root, root)){ recurse.push(Cargo(c.low, c.root, root)); } } } } return false; }
void Range::setChr(string chrom){ recurse = stack<Cargo>(); Capacity start; Capacity stop; if(getRanges(chrom, chrmap, start, stop)){ on_chromosome = true; chr = chrom; cvector.setRange(offset, start, stop); Capacity root; if(getMidpoint(0, cvector.size(), root)){ recurse.push(Cargo(0, cvector.size(), root)); } }else{ on_chromosome = false; } }
int FindAmmoType(MECH * mech, int loc, int part) { int t = GetPartType(mech, loc, part); int m = GetPartAmmoMode(mech, loc, part); int base = -1; if(!IsAmmo(t)) return t; t = Ammo2I(t); if(strstr(MechWeapons[t].name, "StreakSRM")) base = SSRM_AMMO; else if(strstr(MechWeapons[t].name, "StreakLRM")) base = SLRM_AMMO; else if(strstr(MechWeapons[t].name, "ELRM")) base = ELRM_AMMO; else if(strstr(MechWeapons[t].name, "LR_DFM")) base = LR_DFM_AMMO; else if(strstr(MechWeapons[t].name, "SR_DFM")) base = SR_DFM_AMMO; else if(strstr(MechWeapons[t].name, "LRM")) base = LRM_AMMO; else if(strstr(MechWeapons[t].name, "SRM")) base = SRM_AMMO; else if(strstr(MechWeapons[t].name, "MRM")) base = MRM_AMMO; if(!(m & AMMO_MODES)) { if(base < 0) return I2Ammo(t); else return Cargo(base); } if(m & LBX_MODE) { if(strstr(MechWeapons[t].name, "LB20")) base = LBX20_AMMO; else if(strstr(MechWeapons[t].name, "LB10")) base = LBX10_AMMO; else if(strstr(MechWeapons[t].name, "LB5")) base = LBX5_AMMO; else if(strstr(MechWeapons[t].name, "LB2")) base = LBX2_AMMO; if(base < 0) return I2Ammo(t); return Cargo(base); } if(m & AC_MODES) { if(m & AC_AP_MODE) { if(strstr(MechWeapons[t].name, "AC/2")) base = AC2_AP_AMMO; if(strstr(MechWeapons[t].name, "AC/5")) base = AC5_AP_AMMO; if(strstr(MechWeapons[t].name, "AC/10")) base = AC10_AP_AMMO; if(strstr(MechWeapons[t].name, "AC/20")) base = AC20_AP_AMMO; if(strstr(MechWeapons[t].name, "LightAC/2")) base = LAC2_AP_AMMO; if(strstr(MechWeapons[t].name, "LightAC/5")) base = LAC5_AP_AMMO; } if(m & AC_FLECHETTE_MODE) { if(strstr(MechWeapons[t].name, "AC/2")) base = AC2_FLECHETTE_AMMO; if(strstr(MechWeapons[t].name, "AC/5")) base = AC5_FLECHETTE_AMMO; if(strstr(MechWeapons[t].name, "AC/10")) base = AC10_FLECHETTE_AMMO; if(strstr(MechWeapons[t].name, "AC/20")) base = AC20_FLECHETTE_AMMO; if(strstr(MechWeapons[t].name, "LightAC/2")) base = LAC2_FLECHETTE_AMMO; if(strstr(MechWeapons[t].name, "LightAC/5")) base = LAC5_FLECHETTE_AMMO; } if(m & AC_INCENDIARY_MODE) { if(strstr(MechWeapons[t].name, "AC/2")) base = AC2_INCENDIARY_AMMO; if(strstr(MechWeapons[t].name, "AC/5")) base = AC5_INCENDIARY_AMMO; if(strstr(MechWeapons[t].name, "AC/10")) base = AC10_INCENDIARY_AMMO; if(strstr(MechWeapons[t].name, "AC/20")) base = AC20_INCENDIARY_AMMO; if(strstr(MechWeapons[t].name, "LightAC/2")) base = LAC2_INCENDIARY_AMMO; if(strstr(MechWeapons[t].name, "LightAC/5")) base = LAC5_INCENDIARY_AMMO; } if(m & AC_PRECISION_MODE) { if(strstr(MechWeapons[t].name, "AC/2")) base = AC2_PRECISION_AMMO; if(strstr(MechWeapons[t].name, "AC/5")) base = AC5_PRECISION_AMMO; if(strstr(MechWeapons[t].name, "AC/10")) base = AC10_PRECISION_AMMO; if(strstr(MechWeapons[t].name, "AC/20")) base = AC20_PRECISION_AMMO; if(strstr(MechWeapons[t].name, "LightAC/2")) base = LAC2_PRECISION_AMMO; if(strstr(MechWeapons[t].name, "LightAC/5")) base = LAC5_PRECISION_AMMO; } if(m & AC_CASELESS_MODE) { if(strstr(MechWeapons[t].name, "AC/2")) base = AC2_CASELESS_AMMO; if(strstr(MechWeapons[t].name, "AC/5")) base = AC5_CASELESS_AMMO; if(strstr(MechWeapons[t].name, "AC/10")) base = AC10_CASELESS_AMMO; if(strstr(MechWeapons[t].name, "AC/20")) base = AC20_CASELESS_AMMO; if(strstr(MechWeapons[t].name, "LightAC/2")) base = LAC2_CASELESS_AMMO; if(strstr(MechWeapons[t].name, "LightAC/5")) base = LAC5_CASELESS_AMMO; } if(base < 0) return I2Ammo(t); return Cargo(base); } if(m & INARC_EXPLO_MODE) return Cargo(INARC_EXPLO_AMMO); else if(m & INARC_HAYWIRE_MODE) return Cargo(INARC_HAYWIRE_AMMO); else if(m & INARC_ECM_MODE) return Cargo(INARC_ECM_AMMO); else if(m & INARC_NEMESIS_MODE) return Cargo(INARC_NEMESIS_AMMO); if(base < 0) return I2Ammo(t); if(m & NARC_MODE) return Cargo(base) + NARC_LRM_AMMO - LRM_AMMO; if(m & ARTEMIS_MODE) return Cargo(base) + ARTEMIS_LRM_AMMO - LRM_AMMO; if(m & SWARM_MODE) return Cargo(base) + SWARM_LRM_AMMO - LRM_AMMO; if(m & SWARM1_MODE) return Cargo(base) + SWARM1_LRM_AMMO - LRM_AMMO; if(m & INFERNO_MODE) return Cargo(base) + INFERNO_SRM_AMMO - SRM_AMMO; if(m & STINGER_MODE) return Cargo(base) + AMMO_LRM_STINGER - LRM_AMMO; if(m & SGUIDED_MODE) return Cargo(base) + AMMO_LRM_SGUIDED - LRM_AMMO; return Cargo(base); }