本文整理汇总了C++中Damage类的典型用法代码示例。如果您正苦于以下问题:C++ Damage类的具体用法?C++ Damage怎么用?C++ Damage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Damage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: end
void TableShape::handleDamages(const QList<Damage*>& damages)
{
QList<Damage*>::ConstIterator end(damages.end());
for (QList<Damage*>::ConstIterator it = damages.begin(); it != end; ++it) {
Damage* damage = *it;
if (!damage) continue;
if (damage->type() == Damage::Cell) {
CellDamage* cellDamage = static_cast<CellDamage*>(damage);
const Region region = cellDamage->region();
if (cellDamage->changes() & CellDamage::Appearance)
d->sheetView->invalidateRegion(region);
continue;
}
if (damage->type() == Damage::Sheet) {
SheetDamage* sheetDamage = static_cast<SheetDamage*>(damage);
if (sheetDamage->changes() & SheetDamage::PropertiesChanged)
d->sheetView->invalidate();
continue;
}
}
update();
}
示例2: looseLiveFromDamage
void Attributs::looseLiveFromDamage(const Damage &damage)
{
for(int i=0 ; i<damage.getMaxIndex() ; i++)
{
live -= damage.getValue(i).getValue();
}
}
示例3: GameObserver
/* Damage Stack resolve process:
1 - apply damages to targets. For each of them, send an event to the GameObserver (for Damage triggers)
2 - Once this is done, send a "Damage Stakc Resolved" event to the GameObserver
3 - Once that message is received on the DamageStack's side, do the "afterDamage" effects (send to graveyard, etc...)
Using events in 2 and 3 guarantees that the "send to graveyard" effect will only apply AFTER Damaged triggers are applied
*/
int DamageStack::resolve()
{
for (int i = (int)(mObjects.size()) - 1; i >= 0; i--)
{
Damage * damage = (Damage*) mObjects[i];
if (damage->state == NOT_RESOLVED)
damage->resolve();
}
((Interruptible*)this)->getObserver()->receiveEvent(NEW WEventDamageStackResolved());
return 1;
}
示例4: loadAttackData
void Attack::loadAttackData(GameObjectData* dataObj)
{
for(GameObjectData* damageData : dataObj->getObjectList("damages"))
{
Damage dam;
dam.load(damageData);
_damages.push_back(dam);
}
if(dataObj->hasFloat("duration"))
_duration = dataObj->getFloat("duration");
}
示例5: applyAttackRelativeBonnus
void Attributs::applyAttackRelativeBonnus(Damage &damage) const
{
for(unsigned i=0; i<damage.getValues().size() ; i++)
{
for(unsigned a=0 ; a<relativeFightBonus.size() ; a++)
{
if(damage.getValues().at(i).getType() == relativeFightBonus.at(a).getType() )
{
int newDamage = damage.getValues().at(i).getValue();
newDamage += (newDamage * relativeFightBonus.at(a).getValue()) / 100; //one value point -> add 1% damage
damage.getValues().at(i).setValue(newDamage);
}
}
}
}
示例6: Render
void DamageStack::Render()
{
float currenty = y;
for (size_t i = 0; i < mObjects.size(); i++)
{
Damage * damage = (Damage*) mObjects[i];
if (damage->state == NOT_RESOLVED)
{
damage->x = x;
damage->y = currenty;
currenty += damage->mHeight;
damage->Render();
}
}
}
示例7: totalGSGraphic
void ViewerGraphic::Update () {
GraphicComp* parent = (GraphicComp*) _view->GetGraphicComp()->GetParent();
if (parent != nil) {
FullGraphic gs;
totalGSGraphic(parent->GetGraphic(), gs);
if (Different(this, &gs)) {
Damage* damage = _view->GetViewer()->GetDamage();
damage->Incur(this);
*(Graphic*)this = *(Graphic*)(&gs);
damage->Incur(this);
}
}
}
示例8: victim
void Attack::Act(IGame& game) const
{
State attacker = game.Get(actor);
auto& targetActor = dynamic_cast<const Identity&>(target);
State victim(game.Get(targetActor));
if (!part)
{
Engage(attacker);
game.Adjust(actor, attacker, skill.name);
game.Adjust(targetActor, victim, L"Miss " + skill.name);
return;
}
auto skillLevel = attacker.SkillLevel(skill, &victim);
if (skillLevel.Value() == 0)
{
Engage(attacker);
game.Adjust(actor, attacker, skill.name);
game.Adjust(targetActor, victim, L"Resist " + skill.name + L":" + skillLevel.Description());
return;
}
auto damage = attacker.AttackDamage(skill, skillLevel);
Damage pain = damage - victim.Mitigation(*part);
if (!victim.Hurt(*part, pain, actor.Description()+L"'"+skill.description))
{
Engage(attacker);
game.Adjust(actor, attacker, skill.name);
game.Adjust(targetActor, victim, L"Mitigate " + skill.name + L"@" + part->Name() + L":" + pain.ActionDescription());
return;
}
Engage(attacker);
game.Adjust(actor, attacker, skill.name);
game.Adjust(targetActor, victim, L"Hit " + skill.name + L"@" + part->Name() + L":" + pain.ActionDescription());
}
示例9: takeDamage
int Character::takeDamage(Damage dmg)
{
//TODO: handle damage resists
int roll = dmg.roll();
modifyHitPoints(-1 * roll);
return roll;
}
示例10: applyAttackFixBonnus
void Attributs::applyAttackFixBonnus(Damage &damage) const
{
for(unsigned i=0; i<damage.getValues().size() ; i++)
{
int newDamage = damage.getValues().at(i).getValue();
newDamage += fixDamageBonnus;
for(unsigned a=0 ; a<fixFightBonus.size() ; a++)
{
if(damage.getValues().at(i).getType() == fixFightBonus.at(a).getType() )
{
newDamage += fixFightBonus.at(a).getValue(); //add fix attack bonnus
//exit for loop: (there are only one couple)
a = values.size();
}
}
damage.getValues().at(i).setValue(newDamage);
}
}
示例11: applyDefenseRelativeResistances
void Attributs::applyDefenseRelativeResistances(Damage &damage) const
{
for(unsigned i=0; i<damage.getValues().size() ; i++)
{
for(unsigned a=0 ; a<relativeResistances.size() ; a++)
{
if(damage.getValues().at(i).getType() == relativeResistances.at(a).getType() )
{
int newDamage = damage.getValues().at(i).getValue();
newDamage -= (newDamage * relativeResistances.at(a).getValue()) / 100; //one value point -> add 1% resistances
if(newDamage<0)
{
newDamage = 0;
}
damage.getValues().at(i).setValue(newDamage);
}
}
}
}
示例12: applyDefenseFixResistances
void Attributs::applyDefenseFixResistances(Damage &damage) const
{
for(unsigned i=0; i<damage.getValues().size() ; i++)
{
for(unsigned a=0 ; a<fixResistances.size() ; a++)
{
if(damage.getValues().at(i).getType() == fixResistances.at(a).getType() )
{
int newDamage = damage.getValues().at(i).getValue();
newDamage -= fixResistances.at(a).getValue(); //add fix attack bonnus
if(newDamage<0)
{
newDamage = 0;
}
damage.getValues().at(i).setValue(newDamage);
}
}
}
}
示例13: applyAttackValues
void Attributs::applyAttackValues(Damage &damage) const
{
for(unsigned i=0; i<damage.getValues().size() ; i++)
{
int newDamage = damage.getValues().at(i).getValue();
int damageBonnus = powerBonnus;
for(unsigned a=0 ; a<values.size() ; a++)
{
if(damage.getValues().at(i).getType() == values.at(a).getType() )
{
damageBonnus += values.at(a).getValue(); //one value point -> add 1% damage
//exit for loop: (there are only one couple)
a = values.size();
}
}
newDamage += newDamage*damageBonnus/100;
damage.getValues().at(i).setValue(newDamage);
}
}
示例14: return
bool Creature::doReflectionDamage(Damage damage, Creature* target, ReflectedDamageType printZero) {
int dmg = damage.getReflected() ? damage.getReflected() : damage.getPhysicalReflected();
// don't quit if we want to print 0
if(!dmg && printZero == REFLECTED_NONE)
return(false);
if(damage.getReflected() || printZero == REFLECTED_MAGIC) {
target->printColor("Your shield of magic reflects %s%d^x damage.\n", target->customColorize("*CC:DAMAGE*").c_str(), dmg);
printColor("%M's shield of magic flares up and hits you for %s%d^x damage.\n", target, customColorize("*CC:DAMAGE*").c_str(), dmg);
broadcastGroup(false, this, "%M's shield of magic flares up and hits %N for *CC:DAMAGE*%d^x damage.\n",
target, this, dmg);
} else {
switch(damage.getPhysicalReflectedType()) {
case REFLECTED_FIRE_SHIELD:
default:
target->printColor("Your shield of fire reflects %s%d^x damage.\n", target->customColorize("*CC:DAMAGE*").c_str(), dmg);
printColor("%M's shield of fire flares up and hits you for %s%d^x damage.\n", target, customColorize("*CC:DAMAGE*").c_str(), dmg);
broadcastGroup(false, this, "%M's shield of fire flares up and hits %N for *CC:DAMAGE*%d^x damage.\n",
target, this, dmg);
break;
}
}
if(damage.getDoubleReflected()) {
Damage reflectedDamage;
reflectedDamage.setReflected(damage.getDoubleReflected());
target->doReflectionDamage(reflectedDamage, this);
}
// we may have gotten this far for printing reasons (even on zero), but really, go no further
if(!dmg)
return(false);
if(target->isPlayer() && isMonster())
getAsMonster()->adjustThreat(target, dmg);
hp.decrease(dmg);
if(hp.getCur() <= 0)
return(true);
return(false);
}
示例15: end
void SheetAccessModel::handleDamages(const QList<Damage*>& damages)
{
QList<Damage*>::ConstIterator end(damages.end());
for (QList<Damage*>::ConstIterator it = damages.begin(); it != end; ++it) {
Damage* damage = *it;
if (!damage) {
continue;
}
if (damage->type() == Damage::Sheet) {
SheetDamage* sheetDamage = static_cast<SheetDamage*>(damage);
kDebug(36007) << "Processing\t" << *sheetDamage;
if (sheetDamage->changes() & SheetDamage::Name) {
Sheet *sheet = sheetDamage->sheet();
// We should never receive signals from sheets that are not in our model
Q_ASSERT(d->cols.contains(sheet));
const int sheetIndex = d->cols[sheet];
setHeaderData(sheetIndex, Qt::Horizontal, sheet->sheetName());
}
continue;
}
}
}