void NeighborCoverage::CreateAllInters(std::set<std::set<int> > &inters) const { inters.clear(); int upper_bound=getParaNum()-getStrength(); for(int i=0;i<=upper_bound;i++) { std::set<int> temp; for(int j=0;j<getStrength();j++) temp.insert(i+j); inters.insert(temp); } }
// Checks if the person is healthy // returns true if yes, and false if no bool Person::checkForHealth() { int tmpStrength = getStrength(); setStrength(tmpStrength--); // if not dead if (!isDead()) { bool isSuccessful = isTruePctMarker(getImmunity()); if (isSuccessful) { successHealth++; } if (3 == successHealth) { successHealth = 0; return true; } else { successHealth = 0; } } return false; }
int Robot::getDamage() { int damage = getStrength() + bonus_damage; bonus_damage = 0; return damage; }
void Monster::getMonsterStats() { cout << "[[ " << monsterName << " - level: " << getLevel() << " || " << "Health: " << getHealth() << " HP || " << "Attack: " << getAttack() << " || " << "Strength: " << getStrength() << " || " << "Defence: " << getDefence() << " ]] \n"; }
int characterShell::getStrength(lua_State* pLua) { auto pCharacter = worldShell::CWorldSingleton::instance()->getPlayer()->getCharacter(); if(pCharacter != nullptr) lua_pushinteger(pLua, pCharacter->getStrength()); return 1; }
// TODO function needs some proper testing void Human::strengthHelp( bool isLimitBet, double& odds ) { // Excel sheet for the odds double oddsBeginner [ 9 ] = { 41, 26.5, 19.4, 15.4, 12.7, 10.7, 9.7, 8.4, 7.6 }; double oddsIntermediate [ 9 ] = { 49, 31, 23.3, 18.7, 16, 13.7, 12, 11, 9.9 }; double oddsExpert [ 9 ] = { 55, 37, 28.0, 22.5, 19, 16.5, 14.5, 13, 12 }; // For Players for( unsigned int p = 2; p < 10; p++ ) { // numplayer = 2 if( p == mPlayersLeft ) { // odds (-1) Because 9 players starting (minimum) 2 players int oddsIndex = p - 2; // Skill Levels (0) Beginner, (1) Intermediate, (2) Expert if( getStrength( ) == BEGINNER ) { if( odds >= oddsBeginner[ oddsIndex ] ) betAction( isLimitBet ); else foldAction( ); } if( getStrength( ) == INTERMEDIATE ) { if( odds >= oddsIntermediate[ oddsIndex ] ) betAction( isLimitBet ); else foldAction( ); } if( getStrength( ) == EXPERT ) { if( odds >= oddsExpert[ oddsIndex ] ) betAction( isLimitBet ); else foldAction( ); } } } }
bool Robot::useAbility() { bool used_ability = false; if (current_energy >= ROBOT_ABILITY_COST) { bonus_damage = (getStrength() * ( pow((current_energy/(max_energy * 1.0)), 4.0 ))); current_energy -= ROBOT_ABILITY_COST; used_ability = true; } return used_ability; }
std::string Player::getSaveText() const { std::ostringstream oss; std::string objectName = "thePlayer"; oss << "-- General status attributes" << std::endl; oss << "local " << objectName << " = DawnInterface.getPlayer();" << std::endl; oss << objectName << ":setStrength( " << getStrength() << " );" << std::endl; oss << objectName << ":setDexterity( " << getDexterity() << " );" << std::endl; oss << objectName << ":setVitality( " << getVitality() << " );" << std::endl; oss << objectName << ":setIntellect( " << getIntellect() << " );" << std::endl; oss << objectName << ":setWisdom( " << getWisdom() << " );" << std::endl; oss << objectName << ":setMaxHealth( " << getMaxHealth() << " );" << std::endl; oss << objectName << ":setMaxMana( " << getMaxMana() << " );" << std::endl; oss << objectName << ":setMaxFatigue( " << getMaxFatigue() << " );" << std::endl; oss << objectName << ":setMinDamage( " << getMinDamage() << " );" << std::endl; oss << objectName << ":setMaxDamage( " << getMaxDamage() << " );" << std::endl; // don't set activity textures here. That is determined by class of Player / NPC oss << objectName << ":setDamageModifierPoints( " << getDamageModifierPoints() << " );" << std::endl; oss << objectName << ":setHitModifierPoints( " << getHitModifierPoints() << " );" << std::endl; oss << objectName << ":setEvadeModifierPoints( " << getEvadeModifierPoints() << " );" << std::endl; oss << objectName << ":setParryModifierPoints( " << getParryModifierPoints() << " );" << std::endl; oss << objectName << ":setBlockModifierPoints( " << getBlockModifierPoints() << " );" << std::endl; oss << objectName << ":setMeleeCriticalModifierPoints( " << getMeleeCriticalModifierPoints() << " );" << std::endl; oss << objectName << ":setResistAllModifierPoints( " << getResistAllModifierPoints() << " );" << std::endl; oss << objectName << ":setSpellEffectAllModifierPoints( " << getSpellEffectAllModifierPoints() << " );" << std::endl; for( size_t curElement=0; curElement<static_cast<size_t>(ElementType::Count); ++curElement ) { ElementType::ElementType curElementType = static_cast<ElementType::ElementType>(curElement); oss << objectName << ":setResistElementModifierPoints( " << curElementType << ", " << getResistElementModifierPoints( curElementType ) << " );" << std::endl; oss << objectName << ":setSpellEffectElementModifierPoints( " << curElementType << ", " << getSpellEffectElementModifierPoints( curElementType ) << " );" << std::endl; } oss << objectName << ":setSpellCriticalModifierPoints( " << getSpellCriticalModifierPoints() << " );" << std::endl; oss << objectName << ":setName( \"" << getName() << "\" );" << std::endl; // string stream doesn't seem to have a proper overload for uint8_t and makes it the 0-character, so cast to size_t oss << objectName << ":setLevel( " << static_cast<size_t>(getLevel()) << " );" << std::endl; oss << objectName << ":setExperience( " << getExperience() << " );" << std::endl; oss << objectName << ":setClass( CharacterClass." << getClassName() << " );" << std::endl; oss << "-- coins" << std::endl; oss << objectName << ":setCoins( " << getCoins() << " );" << std::endl; oss << "-- position" << std::endl; oss << objectName << ":setPosition( " << getXPos() << ", " << getYPos() << " );" << std::endl; // no current attributes are set here because after reloading the player is completely refreshed again return oss.str(); }
void NeighborPlusCoverage::CreateAllInters(std::set<std::set<int> > &inters) const { inters.clear(); std::set<std::set<int> > big_inters; for(NeighborPlusCoverage::const_iterator it_1=begin(); it_1!=end();++it_1) { std::set<int>::const_iterator it_begin=it_1->first.begin(); std::set<int>::const_iterator it_end=it_1->first.begin(); for(int i=0;i<it_1->second;i++) ++it_end; for(;it_end!=it_1->first.end();++it_begin,++it_end) big_inters.insert(std::set<int>(it_begin,it_end)); } int upper_bound=getParaNum()-getStrength(); for(int i=0;i<=upper_bound;i++) { std::set<int> temp; for(int j=0;j<getStrength();j++) temp.insert(i+j); std::set<std::set<int> >::const_iterator it_2=big_inters.begin(); for(;it_2!=big_inters.end();++it_2) { if(includes(it_2->begin(),it_2->end(),temp.begin(),temp.end())) break; } if(big_inters.end()==it_2) inters.insert(temp); } inters.insert(big_inters.begin(),big_inters.end()); }
void PolyhedraSplitter::action() { const shared_ptr<Scene> _rb=shared_ptr<Scene>(); shared_ptr<Scene> rb=(_rb?_rb:Omega::instance().getScene()); vector<PSplitT> splitsV; vector<Matrix3r> bStresses (scene->bodies->size(), Matrix3r::Zero()); getStressForEachBody(bStresses); FOREACH(const shared_ptr<Body>& b, *rb->bodies){ if(!b || !b->material || !b->shape) continue; shared_ptr<Polyhedra> p=YADE_PTR_DYN_CAST<Polyhedra>(b->shape); shared_ptr<PolyhedraMat> m=YADE_PTR_DYN_CAST<PolyhedraMat>(b->material); if(p && m->IsSplitable){ //not real strees, to get real one, it has to be divided by body volume Matrix3r stress = bStresses[b->id]; //get eigenstresses Symmetrize(stress); Matrix3r I_vect(Matrix3r::Zero()), I_valu(Matrix3r::Zero()); matrixEigenDecomposition(stress,I_vect,I_valu); Eigen::Matrix3f::Index min_i, max_i; I_valu.diagonal().minCoeff(&min_i); I_valu.diagonal().maxCoeff(&max_i); //division of stress by volume const Vector3r dirC = I_vect.col(max_i); const Vector3r dirT = I_vect.col(min_i); const Vector3r dir1 = dirC.normalized() + dirT.normalized(); const Vector3r dir2 = dirC.normalized() - dirT.normalized(); //double sigma_t = -comp_stress/2.+ tens_stress; const Real sigma_t = pow(( pow(I_valu(0,0)-I_valu(1,1),2)+ pow(I_valu(0,0)-I_valu(2,2),2)+ pow(I_valu(1,1)-I_valu(2,2),2)) /2.,0.5)/p->GetVolume(); if (sigma_t > getStrength(p->GetVolume(),m->GetStrength())) { splitsV.push_back(std::make_tuple(b, dir1.normalized(), dir2.normalized())); } } } std::for_each(splitsV.begin(), splitsV.end(), &SplitPolyhedraDouble); }
character* golem::attack(character* enemy,const short& plusDP) throw(Error) try {//metodo ereditato short hp; if(enemy->getHP() && isAlive()) { if(enemy!=this)//se è un attacco offensivo non è possibile autoinfliggerselo hp=enemy->getHP()-(getDP()+plusDP+getStrength()); else//enemy==this;non esistono attacchi curativi per i tipi demon { throw Error(); return NULL; } enemy->setHP(hp); } return enemy; } catch(Error e){ cout<<"Invalid target "<<endl; }
float Recipe::calcWaterContainer(enum PROD_TYPE aType,enum STRENGTH strength,enum CUPSIZE size){ float canvol; float ratio=getStrength(aType,strength); switch (aType){ case LEFT_BIB: canvol=getTotVol(size)*left_bib_percent; return ratio*canvol/(ratio+1); break; case RIGHT_BIB: canvol=getTotVol(size)*right_bib_percent; return ratio*canvol/(ratio+1); break; case CANISTER: return getTotVol(size)*instant_percent-ingr_ml_per_gram*ratio*(getTotVol(size)*instant_ingredient_rtd_standard); break; } return 0; }
/** * @brief Calculates the strength of the territory against attack, including * neighboring territories owned by the same player, but not including any ally support. * @return The strength of the territory against attack, not including ally support. */ int Territory::getDefensiveStrength() { if(ownedBy == NullPlayer::getNullPlayer()) { // hack, fix later. return 1; } int strength = getStrength(); if(boatPresent) strength += strengths::boat; if(wallPresent) strength += strengths::wall; std::list<Territory*>::iterator i; Territory* currentTerritory; for(i=adjacentTerritories->begin();i != adjacentTerritories->end(); ++i) { currentTerritory = (*i); if(currentTerritory->ownedBy == ownedBy) { strength += currentTerritory->getStrength(); } } return strength; }
float Archer::getTotalStrength() { float base = (float)getHealth() * (float)getStrength() / 100; return (dynamic_cast<Hills*>(getField()) != nullptr) ? base * HILL_STR_FACTOR : base; }
void PetDetailInfoLayer::resetUI() { auto pet = getCurrBag()->getPetByID(getUserID());//-----得到用户点击的宠物 _islock = pet->isLocked(); if (_islock) { _imglock->loadTexture("pet_look_b.png", Widget::TextureResType::PLIST); } else { _imglock->loadTexture("pet_look_a.png", Widget::TextureResType::PLIST); } auto stTimer = StrengthTimerManager::getInstance()->getTaskByPetID(pet->getUserId()); stTimer->onTimerUpdate(); //-----------------------------------宠物图表信息-------------------------------------// _icon->loadTexture(_X(pet->getBigFrontIcon(), _icon)); //------获取宠物的头像 UIHelper::setStars(_stars[0]->getParent(), pet->getStarNum(), pet->getStarMax()); _evaluate->loadTexture(pet->getUintIcon(), Widget::TextureResType::PLIST); //------品种(S, SS, A, 等待) //-----------------------------宠物数据信息--------------------------------------------// _petName->setString(StringUtils::format("Bahamu")); //----宠物名字 _attr->loadTexture(StringUtils::format("base_property%d.png", pet->getKeyPet()->attr), Widget::TextureResType::PLIST); //----宠物的属性(火、水.....) _lv->setString(StringUtils::format("%s.%d", "Lv", pet->getLevel())); //----等级显示 auto monster = MonsterExpConfig::getMonsterExpBy(pet->getLevel()); _lv_Text->setString(StringUtils::format("%d/%d", pet->getExp(), monster->expLvup)); //升级经验数值 _lv_LoadingBar->setPercent(pet->getExp() * 100.0 / monster->expLvup); //经验条 _hp_Text->setString(StringUtils::format("%d/%d", pet->getHP(), pet->getHpMax())); //hp数值 _hp_LoadingBar->setPercent(pet->getHP() * 100.0 / pet->getHpMax()); _energy_Text->setString(_T("%d/100", pet->getStrength())); //------能量值 _energy_Text->runAction(UserPetTimer::create(_uid)); _energy_LoadingBar->setPercent(pet->getStrength()); //------能量条显示为0 _energy_LoadingBar->runAction(UserPetTimer::create(_uid)); _hp_Value->setString(StringUtils::format("%d", pet->getBaseHp())); //-------血量 _hp_add->setString(StringUtils::format("+%d", pet->getAddedHp())); //-------额外增加的 _atk_Value->setString(StringUtils::format("%d", pet->getBaseAttack())); //-------攻击 _atk_add->setString(StringUtils::format("+%d", pet->getAddedAttack())); //-------额外增加的 _def_Value->setString(StringUtils::format("%d", pet->getBaseDefense())); //-------防御力 _def_add->setString(StringUtils::format("+%d", pet->getAddedDefense())); _atc_Value->setString(StringUtils::format("%d", pet->getBaseMAttack())); //------魔攻 _atc_add->setString(StringUtils::format("+%d", pet->getAddedMAttack())); _dec_Value->setString(StringUtils::format("%d", pet->getBaseMDefense())); //------魔防 _dec_add->setString(StringUtils::format("+%d", pet->getAddedMDefense())); _spe_Value->setString(StringUtils::format("%d", pet->getBaseSpeed())); //------速度 _spe_add->setString(StringUtils::format("+%d", pet->getAddedSpeed())); }
uint32 DamageOverTimeList::addDot(CreatureObject* victim, CreatureObject* attacker, uint64 objectID, uint32 duration, uint64 dotType, uint8 pool, uint32 strength, float potency, uint32 defense, int secondaryStrength) { Locker locker(&guard); if (strength == 0 || duration == 0) return 0; // determine chance to hit, if no hit, just return 0. potency of less than 0 can't be resisted if (potency > 0 && System::random(100) >= MAX(5.f, MIN(potency * (80.f / (100.f + defense)), 95.f))) return 0; if (pool == CreatureAttribute::UNKNOWN) { pool = getRandomPool(dotType); } int oldStrength = getStrength(pool, dotType); int durationMod = 0; switch (dotType) { case CreatureState::POISONED: durationMod = victim->getSkillMod("dissipation_poison"); break; case CreatureState::DISEASED: durationMod = victim->getSkillMod("dissipation_disease"); break; case CreatureState::ONFIRE: durationMod = victim->getSkillMod("dissipation_fire"); break; case CreatureState::BLEEDING: durationMod = victim->getSkillMod("dissipation_bleeding"); break; default: break; } if (durationMod > 0) { if (durationMod > 90) durationMod = 90; duration = MAX(1, (int)(duration * (1.f - (durationMod / 100.f)))); } //only 1 disease per bar allowed if(dotType == CreatureState::DISEASED) { objectID = Long::hashCode(CreatureState::DISEASED); } else if (dotType == CommandEffect::FORCECHOKE) { objectID = 0; } DamageOverTime newDot(attacker, dotType, pool, strength, duration, secondaryStrength); int dotPower = newDot.initDot(victim, attacker); uint64 key = generateKey(dotType, pool, objectID); if (contains(key)) { Vector<DamageOverTime>* vector = &get(key); Vector<DamageOverTime> newVec; // This seems to only ever put one value in the DOT vector. This needs to remain a vector to // maintain the integrity of the db. for (int i = 0; i < vector->size(); ++i) { DamageOverTime dot = vector->get(i); // Curing the dot can cause the dot to expire but not get // removed from the list, so if the dot is expired make sure // to not reset it if (dot.isPast()) { newVec.add(newDot); } else if (newDot.getStrength() >= dot.getStrength()) { // but we only want to reuse the tick if the old dot has not // expired yet but is being replaced due to strength newDot.setNextTick(dot.getNextTick()); newVec.add(newDot); } else // the new dot has less strength and the old dot hasn't expired newVec.add(dot); drop(key); put(key, newVec); } } else { Vector<DamageOverTime> newVector; newVector.add(newDot); put(key, newVector); } Time nTime = newDot.getNextTick(); if (isEmpty() || nextTick.isPast() || nTime.compareTo(nextTick) > 0) nextTick = nTime; if(oldStrength == 0) sendStartMessage(victim, dotType); else sendIncreaseMessage(victim, dotType); dot = true; locker.release(); if (dotType != CommandEffect::FORCECHOKE) victim->setState(dotType); return dotPower; }
const EXPECTED_VALUE AI::evaluate(const Board &b) { EXPECTED_VALUE teams[2];// = new EXPECTED_VALUE [b.getSides()]; if(b.won() != NULL) { if(b.won()->getSide() == side) return 100000.0; else return -100000.0; } for(SIDE_t s = 0; s < b.getSides(); s++) { vector<Piece> &pieces = b.getPieceList(s); for(auto i = pieces.begin(); i != pieces.end(); i++) { Uint8 pVal = i->getValue(); auto validLocations = b.getValid(&*i); for(auto c = validLocations.begin(); c != validLocations.end(); c++) { Point loc = b.getPoint(i->getCell()); if(i->getCell() == NULL) { loc = (s == 0? Point(-1, 0):Point(10, 9)); } Point dest = b.getPoint(*c); EXPECTED_VALUE multiplier = 1.0; multiplier *= (i->hasFlag() >= 0? 5.0:1.0) * ((i->getStrength()+5.0)/2.0); if((i->hasFlag() >= 0) + s == 1) { multiplier *= (Y_t(s? 10:20) - dest.y())/((3.0-pVal < 0.0? pVal-3.0:3.0-pVal)+1.0); } else { multiplier *= (dest.y()+Y_t(s? 10:1))/((3.0-pVal < 0.0? pVal-3.0:3.0-pVal)+1.0); } if((*c)->getSide() != i->getSide() && (*c)->getType() == Cell::CAP_ZONE) { multiplier *= 2; } teams[s] += multiplier/3; } } } EXPECTED_VALUE ourSide; EXPECTED_VALUE sum_a_ther_side = 0.0; for(Uint8 t = 0; t < b.getSides(); t++) { if(t == side) { ourSide = teams[t]; } else { sum_a_ther_side += teams[t]; } } return ourSide - sum_a_ther_side/(b.getSides()-1); }
uint16_t Player::getModifiedStrength() const { return getModifiedAttribute( inventory, this, getStrength(), &getItemStrengthHelper, &getSpellStrengthHelper, NON_NULLABLE_ATTRIBUTE_MIN ); }