1 package org
.sevenchan
.dongs
.enchantment
3 import org
.sevenchan
.dongs
.Creature
;
4 import flash
.utils
.getQualifiedClassName
;
5 import org
.sevenchan
.dongs
.Item
;
6 import org
.sevenchan
.dongs
.screens
.CombatScreen
;
12 public class Enchantment
15 * Cancel being added to new host.
17 public var cancelAddition
:Boolean = false;
19 public function Enchantment
()
25 * When first added to some poor sap's Enchantments
27 public function onInit
(newHost
:Creature
):String
33 * Unique name for every enchantment (so the enchantment can remove itself).
36 public function getID
():String
38 throw new Error("FATAL ERROR: " + getQualifiedClassName
(this) + " does not specify a custom getID()!");
43 * Do stuff after host wins/loses.
47 public function onCombatComplete
(hostWon
:Boolean, other
:Creature
):void
53 * Do stuff when combat begins
56 public function onCombatInit
(other
:Creature
):void
62 * Do stuff when it's my host's turn
66 public function onMyCombatTurn
(screen
:CombatScreen
,other
:Creature
):Boolean
72 * Can the player attack?
77 public function canAttack
(player
:Creature
, other
:Creature
):Boolean
88 public function canRun
(player
:Creature
, other
:Creature
):Boolean
94 * Do stuff after each screen update.
97 public function onScreenUpdate
():void
101 public static const INTERCEPT_ACTION_NONE
:int = -1;
102 public static const INTERCEPT_ACTION_USE
:int = 0;
103 public static const INTERCEPT_ACTION_TOSS
:int = 1;
107 * @return intercept action
109 public function onInventoryReceived
(item
:Item
):int { return INTERCEPT_ACTION_NONE
; }
113 * @return intercept action
115 public function onInventorySent
(item
:Item
):int { return INTERCEPT_ACTION_NONE
; }
117 public function getName
():String
119 trace
("ERROR: " + getQualifiedClassName
(this) + " does not specify a custom getName()!");
120 return getID
() + " [WIP?]";
123 public function getDescr
():String
125 trace
("ERROR: " + getQualifiedClassName
(this) + " does not specify a custom getDescr()!");
129 public static function isLockedOut
(subj
:Creature
):Boolean
131 return subj
.hasEnchantment
("paralyze") || subj
.hasEnchantment
("hunger");
133 public static function canAttack
(subj
:Creature
,combatant
:Creature
):Boolean
135 for each(var e
:Enchantment
in subj
.enchantments
)
137 if (!e
.canAttack
(subj
, combatant
))
142 public static function canRun
(subj
:Creature
,combatant
:Creature
):Boolean
144 for each(var e
:Enchantment
in subj
.enchantments
)
146 if (!e
.canRun
(subj
, combatant
))
152 public static function getLockoutEffectText
(subj
:Creature
):String
154 if (subj
.hasEnchantment
("paralyze"))
156 if (subj
.hasEnchantment
("hunger"))