Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function reactToCalculateCharacterStatEvent($event) {
- // The event listener only reacts if the talk skill is calculated
- if($event->getStat() == "talk") {
- // Increase the item bonus depending on the Character's intelligence
- if($event->sender->intelligence < 6) {
- $event->increaseBonusAbsolute(1);
- } else {
- $event->increaseBonusAbsolute(2);
- }
- }
- }
- getSkillTalking() {
- $event = new CalculateCharacterStatEvent($this, "talking");
- $this->raiseEvent($event);
- $base = 5; // or some logic to determine the base stats
- return $base * $event->getBonusPercentage + $event->getBonusAbsolute();
- }
- // in Character class
- getSkillMelee($battle) {
- $event = new CalculateCharacterBattleStatEvent($this, $battle->enemy, "melee");
- $this->raiseEvent($event);
- $base = 5; // or some logic to determine the base stats
- return $base * $event->getBonusPercentage + $event->getBonusAbsolute();
- }
- // in Item class
- public function reactToCalculateCharacterBattleStatEvent($event) {
- if($event->getStat() == "melee") {
- // Increase the item bonus depending on the Character's enemy's intelligence
- if($event->enemy->intelligence < 6) {
- $event->increaseBonusAbsolute(1);
- } else {
- $event->increaseBonusAbsolute(2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement