/* * Item's constructor * Arguments: * n: name of the Item * t: type of the Item * Item types (KATANA, SPEAR, BOW, NINJATO, WAKIZASHI) */ Item::Item(std::string n, int t) : GreenCard(n, ITEM), durability(0) { switch (t) { case KATANA: setCost(5); setAttackBonus(3); setDefenceBonus(3); setMinimumHonour(1); setEffectBonus(5); setEffectCost(6); durability = 4; break; case SPEAR: setCost(5); setAttackBonus(2); setDefenceBonus(2); setMinimumHonour(1); setEffectBonus(4); setEffectCost(6); durability = 4; break; case BOW: setCost(10); setAttackBonus(4); setDefenceBonus(4); setMinimumHonour(2); setEffectBonus(4); setEffectCost(10); durability = 6; break; case NINJATO: setCost(15); setAttackBonus(6); setDefenceBonus(6); setMinimumHonour(3); setEffectBonus(6); setEffectCost(10); durability = 8; break; case WAKIZASHI: setCost(20); setAttackBonus(8); setDefenceBonus(8); setMinimumHonour(6); setEffectBonus(8); setEffectCost(15); durability = 10; break; default: std::cerr << "shit"; } }
OperationItemDistribution::OperationItemDistribution( ItemDistribution* i, Buffer *src, Buffer* dest ) : itemdist(i) { if (!i || !src || !dest) throw LogicException( "An OperationItemDistribution always needs to point to " "a ItemDistribution, a source buffer and a destination buffer" ); stringstream o; o << "Ship " << dest->getItem()->getName() << " from " << src->getName() << " to " << dest->getName(); setName(o.str()); setDuration(i->getLeadTime()); setSizeMultiple(i->getSizeMultiple()); setSizeMinimum(i->getSizeMinimum()); setLocation(dest->getLocation()); setSource(i->getSource()); setCost(i->getCost()); setFence(i->getFence()); setHidden(true); new FlowEnd(this, dest, 1); new FlowStart(this, src, -1); initType(metadata); // Optionally, create a load if (i->getResource()) new LoadDefault(this, i->getResource(), i->getResourceQuantity()); // Insert in the list of ItemDistribution operations. // The list is not sorted (for performance reasons). nextOperation = i->firstOperation; i->firstOperation = this; }
Stock::Stock(int newItemNumber, int newQuantity, double newCost) { setItemNumber(newItemNumber); setQuantity(newQuantity); setCost(newCost); }
OperationItemSupplier::OperationItemSupplier( ItemSupplier* i, Buffer *b ) : supitem(i) { if (!i || !b || !i->getSupplier()) throw LogicException( "An OperationItemSupplier always needs to point to " "a itemsupplier and a buffer" ); stringstream o; o << "Purchase " << b->getName() << " from " << i->getSupplier()->getName(); setName(o.str()); setDuration(i->getLeadTime()); setSizeMultiple(i->getSizeMultiple()); setSizeMinimum(i->getSizeMinimum()); setLocation(b->getLocation()); setSource(i->getSource()); setCost(i->getCost()); setFence(i->getFence()); setHidden(true); new FlowEnd(this, b, 1); initType(metadata); // Optionally, create a load if (i->getResource()) new LoadDefault(this, i->getResource(), i->getResourceQuantity()); // Insert in the list of ItemSupplier operations. // The list is not sorted (for performance reasons). nextOperation = i->firstOperation; i->firstOperation = this; }
Truck::Truck(string man, int esize, int iyear, int bsz, bool tow):Vehicle(),bedsize(bsz),towPackage(tow) { //towPackage = bsz; //bedsize = tow; setYear(iyear); setEng(esize); setManu(man); Person p("nonae"); setOwner(p); setCost(BASE); }
DECLARE_EXPORT void SetupMatrix::Rule::endElement (XMLInput& pIn, const Attribute& pAttr, const DataElement& pElement) { if (pAttr.isA(Tags::tag_priority)) setPriority(pElement.getInt()); else if (pAttr.isA(Tags::tag_fromsetup)) setFromSetup(pElement.getString()); else if (pAttr.isA(Tags::tag_tosetup)) setToSetup(pElement.getString()); else if (pAttr.isA(Tags::tag_duration)) setDuration(pElement.getTimeperiod()); else if (pAttr.isA(Tags::tag_cost)) setCost(pElement.getDouble()); }
DECLARE_EXPORT OperationItemSupplier::OperationItemSupplier( ItemSupplier* i, Buffer *b ) : supitem(i) { if (!i || !b || !i->getSupplier()) throw LogicException( "An OperationItemSupplier always needs to point to " "a itemsupplier and a buffer" ); stringstream o; o << "Purchase " << b->getName() << " from " << i->getSupplier()->getName(); setName(o.str()); setDuration(i->getLeadTime()); setSizeMultiple(i->getSizeMultiple()); setSizeMinimum(i->getSizeMinimum()); setLocation(b->getLocation()); setSource(i->getSource()); setCost(i->getCost()); setFence(i->getFence()); setHidden(true); new FlowEnd(this, b, 1); initType(metadata); // Optionally, create a load if (i->getResource()) new LoadDefault(this, i->getResource(), i->getResourceQuantity()); // Insert in the list of ItemSupplier operations. // We keep the list sorted by the operation name. if (!i->firstOperation || getName() < i->firstOperation->getName()) { // New head of the list nextOperation = i->firstOperation; i->firstOperation = this; } else { // Insert in the middle or at the tail OperationItemSupplier* o = i->firstOperation; while (o->nextOperation) { if (b->getName() < o->nextOperation->getName()) break; o = o->nextOperation; } nextOperation = o->nextOperation; o->nextOperation = this; } }
DECLARE_EXPORT int SetupMatrix::Rule::setattro(const Attribute& attr, const PythonObject& field) { if (attr.isA(Tags::tag_priority)) setPriority(field.getInt()); else if (attr.isA(Tags::tag_fromsetup)) setFromSetup(field.getString()); else if (attr.isA(Tags::tag_tosetup)) setToSetup(field.getString()); else if (attr.isA(Tags::tag_duration)) setDuration(field.getTimeperiod()); else if (attr.isA(Tags::tag_cost)) setCost(field.getDouble()); else return -1; // Error return 0; // OK }
/** Read one edge from an input stream and add it to this Wflograph. * @param in is an open input stream * @return true on success, else false */ bool Wflograph::readEdge(istream& in) { vertex u, v; flow capp, ff; floCost fc; if (Util::readNext(in,'(') == 0 || !Util::readNode(in,u,N) || Util::readNext(in,',') == 0 || !Util::readNode(in,v,N) || Util::readNext(in,',') == 0 || !Util::readNum(in,capp) || Util::readNext(in,',') == 0 || !Util::readNum(in,fc) || Util::readNext(in,',') == 0 || !Util::readNum(in,ff) || Util::readNext(in,')') == 0) return false; if (u < 1 || u > n() || v < 1 || v > n()) return false; edge e = join(u,v); setCapacity(e,capp); setCost(e,fc); addFlow(u,e,ff); return true; }
DECLARE_EXPORT OperationItemDistribution::OperationItemDistribution( ItemDistribution* i, Buffer *src, Buffer* dest ) : itemdist(i) { if (!i || !src || !dest) throw LogicException( "An OperationItemDistribution always needs to point to " "a ItemDistribution, a source buffer and a destination buffer" ); stringstream o; o << "Ship " << dest->getItem()->getName() << " from " << src->getName() << " to " << dest->getName(); setName(o.str()); setDuration(i->getLeadTime()); setSizeMultiple(i->getSizeMultiple()); setSizeMinimum(i->getSizeMinimum()); setLocation(dest->getLocation()); setSource(i->getSource()); setCost(i->getCost()); setHidden(true); new FlowEnd(this, dest, 1); new FlowStart(this, src, -1); initType(metadata); // Insert in the list of ItemDistribution operations. // We keep the list sorted by the operation name. if (!i->firstOperation || getName() < i->firstOperation->getName()) { // New head of the list nextOperation = i->firstOperation; i->firstOperation = this; } else { // Insert in the middle or at the tail OperationItemDistribution* o = i->firstOperation; while (o->nextOperation) { if (getName() < o->nextOperation->getName()) break; o = o->nextOperation; } nextOperation = o->nextOperation; o->nextOperation = this; } }
void GridLayer::updateBounds(double origin_x, double origin_y, double origin_yaw, double* min_x, double* min_y, double* max_x, double* max_y) { if (!enabled_) return; double mark_x = origin_x + cos(origin_yaw), mark_y = origin_y + sin(origin_yaw); unsigned int mx; unsigned int my; if(worldToMap(mark_x, mark_y, mx, my)){ setCost(mx, my, LETHAL_OBSTACLE); } *min_x = std::min(*min_x, mark_x); *min_y = std::min(*min_y, mark_y); *max_x = std::max(*max_x, mark_x); *max_y = std::max(*max_y, mark_y); }
/** * Loads the research project from a YAML file. * @param node YAML node. */ void ResearchProject::load(const YAML::Node& node) { setAssigned(node["assigned"].as<int>(getAssigned())); setSpent(node["spent"].as<int>(getSpent())); setCost(node["cost"].as<int>(getCost())); }
EnergyUnit::EnergyUnit(AI *ai) : DefenseUnit(ai) { setRadius(1); setArmor(5); setCost(7); }
CrawlerUnit::CrawlerUnit(AI *ai) : DefenseUnit(ai) { setRadius(1); setArmor(3); setCost(7); }
TowerUnit::TowerUnit(AI *ai) : DefenseUnit(ai) { setRadius(1); setArmor(3); setCost(1); }
BridgeUnit::BridgeUnit(AI *ai) : DefenseUnit(ai) { setRadius(1); setArmor(3); setCost(1); }
ShieldUnit::ShieldUnit(AI *ai) : DefenseUnit(ai) { setRadius(170); setArmor(3); setCost(7); }
MineUnit::MineUnit(AI *ai) : DefenseUnit(ai) { setRadius(80); setArmor(1); setCost(3); }
AntiAirUnit::AntiAirUnit(AI *ai) : DefenseUnit(ai) { setRadius(190); setArmor(3); setCost(1); }
//Parameterized Constructor Garbage::Garbage(int quantity) { setCost(8); this->setColor("Yellow"); setQuantity(quantity); }
/** Generate random edge costs. * @param lo is the low end of the range of costs * @param hi is the high end of the range of costs * costs are generated uniformly in [lo,hi] */ void Wflograph::randCost(floCost lo, floCost hi) { for (edge e = first(); e != 0; e = next(e)) setCost(e,randint(lo,hi)); }
void AI01::think(const Status& my, const Status& enemy) { setCost(my.getNinjutsuCost()); ninjutsuPoint = Point(-1, -1); array<vector<MoveCommand>, 2> move; Status status(my); for (int i = 0; i < 2; i++) { try { move[i] = dogEscape.getCommand2(i, status); int ninryoku = my.getNinryoku() - defenceSort[3].first; if (ninryoku > 0) { if (ninryoku >= Status::getNinjutsuCost(NinjutsuCommand::RotatinCut)) { const auto ninjas = my.getNinjas(); const Stage stage(my.getStageDogStatus()); int dogCount[2] = { 0 }; for (int j = 0; j < 2; j++) { for (int y = -1; y < 2; y++) { for (int x = -1; x < 2; x++) { if (stage.getState(ninjas[j].point + Point(x, y)) == Stage::State::Dog) { dogCount[j]++; } } } } if (dogCount[i] >= dogCount[1 - i]) { if (dogCount[i] >= 3) { cerr << "回転斬!" << endl; ninjutsuFlag = true; ninjutsuString = "7 " + to_string(i); } } } else { useNinjutsuA(enemy, ninryoku); } } } catch (logic_error e) { if (!ninjutsuFlag) { try { move[i] = useNinjutsuD(my, status, e.what(), i); } catch (invalid_argument) { return; } } } if (move[i].empty()) { move[i] = soulFind.getCommand2(i, status); if (move[i].size() == 1) { Status nextStatus(status); auto soul = status.getSoulPoints(); auto stage = status.getStage(); const auto p = Stage::moveSimulation(status.getNinjas()[i].point, move[i][0], stage); for (auto it = soul.begin(); it != soul.end();) { if (p == *it) it = soul.erase(it); else ++it; } nextStatus.setSoulPoints(soul); auto m = soulFind.getCommand2(i, status); move[i].push_back(m[0]); } } Point p = status.getNinjas()[i].point; Stage stage = status.getStage(); auto soulPoints = status.getSoulPoints(); for (const auto& c : move[i]) { p = Stage::moveSimulation(p, status.getNinjas()[(i + 1) % 2].point, c, stage, status.getDogs()); for (auto it = soulPoints.begin(); it != soulPoints.end();) { if (p == *it) it = soulPoints.erase(it); else ++it; } } array<Character, 2> nextNinjas = status.getNinjas(); nextNinjas[i] = Character{ i, p }; if (ninjutsuFlag) { if (ninjutsuString[0] == '1')//落石 { auto arr = stage.getStage(); arr[ninjutsuPoint.x][ninjutsuPoint.y] = Stage::State::Rock; stage = Stage(arr); } else if (ninjutsuString[0] == '3')//雷撃 { auto arr = stage.getStage(); arr[ninjutsuPoint.x][ninjutsuPoint.y] = Stage::State::None; stage = Stage(arr); } else if (ninjutsuString[0] == '5')//自分身 { } else if (ninjutsuString[0] == '7')//回転斬 status.eraseDogs(status.getNinjas()[i].point); } status.setSoulPoints(soulPoints); status.setStage(stage); status.setNinjas(nextNinjas); } characterMove = move; }
//Default Constructor Garbage::Garbage() { setCost(0); this->setColor("Yellow"); //Defautl Color this->setQuantity(0); //Default amount }