1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 22:45:34 +00:00

Refactorization

This commit is contained in:
Miroslav Puda 2013-05-27 20:23:04 +02:00
parent 4e17bc1499
commit b40e24c50c
4 changed files with 33 additions and 33 deletions

View file

@ -61,7 +61,7 @@ namespace MWGui
void EnchantingDialog::updateLabels() void EnchantingDialog::updateLabels()
{ {
std::stringstream enchantCost; std::stringstream enchantCost;
enchantCost << std::setprecision(1) << std::fixed << mEnchanting.getEnchantCost(); enchantCost << std::setprecision(1) << std::fixed << mEnchanting.getEnchantPoints();
mEnchantmentPoints->setCaption(enchantCost.str() + " / " + boost::lexical_cast<std::string>(mEnchanting.getMaxEnchantValue())); mEnchantmentPoints->setCaption(enchantCost.str() + " / " + boost::lexical_cast<std::string>(mEnchanting.getMaxEnchantValue()));
mCharge->setCaption(boost::lexical_cast<std::string>(mEnchanting.getGemCharge())); mCharge->setCaption(boost::lexical_cast<std::string>(mEnchanting.getGemCharge()));
@ -74,19 +74,19 @@ namespace MWGui
switch(mEnchanting.getCastStyle()) switch(mEnchanting.getCastStyle())
{ {
case ESM::CS_CastOnce: case ESM::CastingStyle_CastOnce:
mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastOnce","Cast Once")); mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastOnce","Cast Once"));
mAddEffectDialog.constantEffect=false; mAddEffectDialog.constantEffect=false;
break; break;
case ESM::CS_WhenStrikes: case ESM::CastingStyle_WhenStrikes:
mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastWhenStrikes", "When Strikes")); mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastWhenStrikes", "When Strikes"));
mAddEffectDialog.constantEffect=false; mAddEffectDialog.constantEffect=false;
break; break;
case ESM::CS_WhenUsed: case ESM::CastingStyle_WhenUsed:
mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastWhenUsed", "When Used")); mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastWhenUsed", "When Used"));
mAddEffectDialog.constantEffect=false; mAddEffectDialog.constantEffect=false;
break; break;
case ESM::CS_ConstantEffect: case ESM::CastingStyle_ConstantEffect:
mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastConstant", "Cast Constant")); mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastConstant", "Cast Constant"));
mAddEffectDialog.constantEffect=true; mAddEffectDialog.constantEffect=true;
break; break;
@ -280,7 +280,7 @@ namespace MWGui
return; return;
} }
if (mEnchanting.getEnchantCost() > mEnchanting.getMaxEnchantValue()) if (mEnchanting.getEnchantPoints() > mEnchanting.getMaxEnchantValue())
{ {
MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage29}"); MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage29}");
return; return;

View file

@ -12,7 +12,7 @@
namespace MWMechanics namespace MWMechanics
{ {
Enchanting::Enchanting(): Enchanting::Enchanting():
mCastStyle(ESM::CS_CastOnce) mCastStyle(ESM::CastingStyle_CastOnce)
{} {}
void Enchanting::setOldItem(MWWorld::Ptr oldItem) void Enchanting::setOldItem(MWWorld::Ptr oldItem)
@ -74,12 +74,12 @@ namespace MWMechanics
MWWorld::Class::get (mEnchanter).skillUsageSucceeded (mEnchanter, ESM::Skill::Enchant, 1); MWWorld::Class::get (mEnchanter).skillUsageSucceeded (mEnchanter, ESM::Skill::Enchant, 1);
} }
if(mCastStyle==ESM::CS_ConstantEffect) if(mCastStyle==ESM::CastingStyle_ConstantEffect)
{ {
enchantment.mData.mCharge=0; enchantment.mData.mCharge=0;
} }
enchantment.mData.mType = mCastStyle; enchantment.mData.mType = mCastStyle;
enchantment.mData.mCost = getEnchantCost(); enchantment.mData.mCost = getEnchantPoints();
enchantment.mEffects = mEffectList; enchantment.mEffects = mEffectList;
const ESM::Enchantment *enchantmentPtr = MWBase::Environment::get().getWorld()->createRecord (enchantment); const ESM::Enchantment *enchantmentPtr = MWBase::Environment::get().getWorld()->createRecord (enchantment);
@ -102,7 +102,7 @@ namespace MWMechanics
{ {
if (itemEmpty()) if (itemEmpty())
{ {
mCastStyle = ESM::CS_WhenUsed; mCastStyle = ESM::CastingStyle_WhenUsed;
return; return;
} }
@ -112,12 +112,12 @@ namespace MWMechanics
{ // Armor or Clothing { // Armor or Clothing
switch(mCastStyle) switch(mCastStyle)
{ {
case ESM::CS_WhenUsed: case ESM::CastingStyle_WhenUsed:
if (powerfulSoul) if (powerfulSoul)
mCastStyle = ESM::CS_ConstantEffect; mCastStyle = ESM::CastingStyle_ConstantEffect;
return; return;
default: // takes care of Constant effect too default: // takes care of Constant effect too
mCastStyle = ESM::CS_WhenUsed; mCastStyle = ESM::CastingStyle_WhenUsed;
return; return;
} }
} }
@ -125,28 +125,28 @@ namespace MWMechanics
{ // Weapon { // Weapon
switch(mCastStyle) switch(mCastStyle)
{ {
case ESM::CS_WhenStrikes: case ESM::CastingStyle_WhenStrikes:
mCastStyle = ESM::CS_WhenUsed; mCastStyle = ESM::CastingStyle_WhenUsed;
return; return;
case ESM::CS_WhenUsed: case ESM::CastingStyle_WhenUsed:
if (powerfulSoul) if (powerfulSoul)
mCastStyle = ESM::CS_ConstantEffect; mCastStyle = ESM::CastingStyle_ConstantEffect;
else else
mCastStyle = ESM::CS_WhenStrikes; mCastStyle = ESM::CastingStyle_WhenStrikes;
return; return;
default: // takes care of Constant effect too default: // takes care of Constant effect too
mCastStyle = ESM::CS_WhenStrikes; mCastStyle = ESM::CastingStyle_WhenStrikes;
return; return;
} }
} }
else if(mObjectType == typeid(ESM::Book).name()) else if(mObjectType == typeid(ESM::Book).name())
{ // Scroll or Book { // Scroll or Book
mCastStyle = ESM::CS_CastOnce; mCastStyle = ESM::CastingStyle_CastOnce;
return; return;
} }
// Fail case // Fail case
mCastStyle = ESM::CS_CastOnce; mCastStyle = ESM::CastingStyle_CastOnce;
} }
/* /*
@ -163,7 +163,7 @@ namespace MWMechanics
* *
* Formula on UESPWiki is not entirely correct. * Formula on UESPWiki is not entirely correct.
*/ */
float Enchanting::getEnchantCost() const float Enchanting::getEnchantPoints() const
{ {
if (mEffectList.mList.empty()) if (mEffectList.mList.empty())
// No effects added, cost = 0 // No effects added, cost = 0
@ -184,7 +184,7 @@ namespace MWMechanics
magMax = (it->mMagnMax == 0) ? 1 : it->mMagnMax; magMax = (it->mMagnMax == 0) ? 1 : it->mMagnMax;
area = (it->mArea == 0) ? 1 : it->mArea; area = (it->mArea == 0) ? 1 : it->mArea;
if (mCastStyle == ESM::CS_ConstantEffect) if (mCastStyle == ESM::CastingStyle_ConstantEffect)
{ {
magnitudeCost = (magMin + magMax) * baseCost * 2.5; magnitudeCost = (magMin + magMax) * baseCost * 2.5;
} }
@ -209,10 +209,10 @@ namespace MWMechanics
float Enchanting::getCastCost() const float Enchanting::getCastCost() const
{ {
if (mCastStyle == ESM::CS_ConstantEffect) if (mCastStyle == ESM::CastingStyle_ConstantEffect)
return 0; return 0;
const float enchantCost = getEnchantCost(); const float enchantCost = getEnchantPoints();
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
MWMechanics::NpcStats &stats = MWWorld::Class::get(player).getNpcStats(player); MWMechanics::NpcStats &stats = MWWorld::Class::get(player).getNpcStats(player);
int eSkill = stats.getSkill(ESM::Skill::Enchant).getModified(); int eSkill = stats.getSkill(ESM::Skill::Enchant).getModified();
@ -233,7 +233,7 @@ namespace MWMechanics
return 0; return 0;
float priceMultipler = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("fEnchantmentValueMult")->getFloat(); float priceMultipler = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("fEnchantmentValueMult")->getFloat();
int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mEnchanter, (getEnchantCost() * priceMultipler), true); int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mEnchanter, (getEnchantPoints() * priceMultipler), true);
return price; return price;
} }
@ -290,8 +290,8 @@ namespace MWMechanics
(0.25 * creatureStats.getAttribute (ESM::Attribute::Intelligence).getModified()) (0.25 * creatureStats.getAttribute (ESM::Attribute::Intelligence).getModified())
+ (0.125 * creatureStats.getAttribute (ESM::Attribute::Luck).getModified())); + (0.125 * creatureStats.getAttribute (ESM::Attribute::Luck).getModified()));
float chance2 = 2.5 * getEnchantCost(); float chance2 = 2.5 * getEnchantPoints();
if(mCastStyle==ESM::CS_ConstantEffect) if(mCastStyle==ESM::CastingStyle_ConstantEffect)
{ {
float constantChance = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("fEnchantmentConstantChanceMult")->getFloat(); float constantChance = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("fEnchantmentConstantChanceMult")->getFloat();
chance2 /= constantChance; chance2 /= constantChance;

View file

@ -36,7 +36,7 @@ namespace MWMechanics
bool create(); //Return true if created, false if failed. bool create(); //Return true if created, false if failed.
void nextCastStyle(); //Set enchant type to next possible type (for mOldItemPtr object) void nextCastStyle(); //Set enchant type to next possible type (for mOldItemPtr object)
int getCastStyle() const; int getCastStyle() const;
float getEnchantCost() const; float getEnchantPoints() const;
float getCastCost() const; float getCastCost() const;
int getEnchantPrice() const; int getEnchantPrice() const;
float getMaxEnchantValue() const; float getMaxEnchantValue() const;

View file

@ -26,10 +26,10 @@ enum RangeType
// Casting style (in enchanting) // Casting style (in enchanting)
enum CastingStyle enum CastingStyle
{ {
CS_CastOnce = 0, CastingStyle_CastOnce = 0,
CS_WhenStrikes = 1, CastingStyle_WhenStrikes = 1,
CS_WhenUsed = 2, CastingStyle_WhenUsed = 2,
CS_ConstantEffect = 3 CastingStyle_ConstantEffect = 3
}; };
#pragma pack(push) #pragma pack(push)