Angel As Programmed In C++

back to filk list
by Gudanov

class Angel : public Human {
private:
CPersonality *m_personality;
CSoul *m_soul;
CDemon *m_demon;
public:
Angel() {
m_personality = new CPersonality(
CPersonality::Layabout |
CPersonality::Drunk );
m_soul = new CSoul();
m_demon = NULL;
}
void ProcessEvent(const CEvent& event) {
switch(event) {
case BecomeVampire:
::DepositSoul(this, m_soul);
delete m_soul;
m_demon = new CDemon();
delete m_personality;
m_personality = new CPersonality(
CPersonality::Funny |
CPersonality::Sadistic );
break;
case GypsyCurse:
m_soul = new CSoul(::GetSoulFromSoulBank(this));
delete m_personality;
m_personality = new CPersonality(
CPersonality::Brooding );
break;
default:
try {
if (event.Emotion == CEmotion::Happiness) {
int Happiness = event.Emotion.GetAmount();
int Factor = Happiness - 1;
int SumOfFactors = 0;
while (Factor > 0) {
if (Happiness % Factor == 0)
SumOfFactors += Factor;
Factor--;
}
if (Happiness == SumOfFactors) throw CurseHappinessException();
}
m_personality->ProcessEvent(event);
}
catch (CurseHappinessException) {
::DepositSoul(this, m_soul);
delete m_soul;
delete m_personality;
m_personality = new CPersonality(
CPersonality::Funny |
CPersonality::Sadistic );
}
break;
}
}
};

| back to top |

back to filk list